Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ui/gl/gl_surface_egl.cc

Issue 2415663008: Expose Null ANGLE backend (Closed)
Patch Set: Fix/Add test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/gl/gl_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_surface_egl.h" 5 #include "ui/gl/gl_surface_egl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B 70 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B
71 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_REFERENCE_ANGLE 0x320C 71 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_REFERENCE_ANGLE 0x320C
72 #endif /* EGL_ANGLE_platform_angle_d3d */ 72 #endif /* EGL_ANGLE_platform_angle_d3d */
73 73
74 #ifndef EGL_ANGLE_platform_angle_opengl 74 #ifndef EGL_ANGLE_platform_angle_opengl
75 #define EGL_ANGLE_platform_angle_opengl 1 75 #define EGL_ANGLE_platform_angle_opengl 1
76 #define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D 76 #define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D
77 #define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320E 77 #define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320E
78 #endif /* EGL_ANGLE_platform_angle_opengl */ 78 #endif /* EGL_ANGLE_platform_angle_opengl */
79 79
80 #ifndef EGL_ANGLE_platform_angle_null
81 #define EGL_ANGLE_platform_angle_null 1
82 #define EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE 0x33AE
83 #endif /* EGL_ANGLE_platform_angle_null */
84
80 #ifndef EGL_ANGLE_x11_visual 85 #ifndef EGL_ANGLE_x11_visual
81 #define EGL_ANGLE_x11_visual 1 86 #define EGL_ANGLE_x11_visual 1
82 #define EGL_X11_VISUAL_ID_ANGLE 0x33A3 87 #define EGL_X11_VISUAL_ID_ANGLE 0x33A3
83 #endif /* EGL_ANGLE_x11_visual */ 88 #endif /* EGL_ANGLE_x11_visual */
84 89
85 #ifndef EGL_ANGLE_surface_orientation 90 #ifndef EGL_ANGLE_surface_orientation
86 #define EGL_ANGLE_surface_orientation 91 #define EGL_ANGLE_surface_orientation
87 #define EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE 0x33A7 92 #define EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE 0x33A7
88 #define EGL_SURFACE_ORIENTATION_ANGLE 0x33A8 93 #define EGL_SURFACE_ORIENTATION_ANGLE 0x33A8
89 #define EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE 0x0001 94 #define EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE 0x0001
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, false); 171 EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, false);
167 case ANGLE_D3D11: 172 case ANGLE_D3D11:
168 return GetPlatformANGLEDisplay( 173 return GetPlatformANGLEDisplay(
169 native_display, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, false); 174 native_display, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, false);
170 case ANGLE_OPENGL: 175 case ANGLE_OPENGL:
171 return GetPlatformANGLEDisplay( 176 return GetPlatformANGLEDisplay(
172 native_display, EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE, false); 177 native_display, EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE, false);
173 case ANGLE_OPENGLES: 178 case ANGLE_OPENGLES:
174 return GetPlatformANGLEDisplay( 179 return GetPlatformANGLEDisplay(
175 native_display, EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE, false); 180 native_display, EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE, false);
181 case ANGLE_NULL:
182 return GetPlatformANGLEDisplay(native_display,
183 EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE, false);
176 default: 184 default:
177 NOTREACHED(); 185 NOTREACHED();
178 return EGL_NO_DISPLAY; 186 return EGL_NO_DISPLAY;
179 } 187 }
180 } 188 }
181 189
182 const char* DisplayTypeString(DisplayType display_type) { 190 const char* DisplayTypeString(DisplayType display_type) {
183 switch (display_type) { 191 switch (display_type) {
184 case DEFAULT: 192 case DEFAULT:
185 return "Default"; 193 return "Default";
186 case SWIFT_SHADER: 194 case SWIFT_SHADER:
187 return "SwiftShader"; 195 return "SwiftShader";
188 case ANGLE_D3D9: 196 case ANGLE_D3D9:
189 return "D3D9"; 197 return "D3D9";
190 case ANGLE_D3D11: 198 case ANGLE_D3D11:
191 return "D3D11"; 199 return "D3D11";
192 case ANGLE_OPENGL: 200 case ANGLE_OPENGL:
193 return "OpenGL"; 201 return "OpenGL";
194 case ANGLE_OPENGLES: 202 case ANGLE_OPENGLES:
195 return "OpenGLES"; 203 return "OpenGLES";
204 case ANGLE_NULL:
205 return "Null";
196 default: 206 default:
197 NOTREACHED(); 207 NOTREACHED();
198 return "Err"; 208 return "Err";
199 } 209 }
200 } 210 }
201 211
202 bool ValidateEglConfig(EGLDisplay display, 212 bool ValidateEglConfig(EGLDisplay display,
203 const EGLint* config_attribs, 213 const EGLint* config_attribs,
204 EGLint* num_configs) { 214 EGLint* num_configs) {
205 if (!eglChooseConfig(display, 215 if (!eglChooseConfig(display,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 350 }
341 351
342 LOG(ERROR) << "No suitable EGL configs found."; 352 LOG(ERROR) << "No suitable EGL configs found.";
343 return nullptr; 353 return nullptr;
344 } 354 }
345 355
346 } // namespace 356 } // namespace
347 357
348 void GetEGLInitDisplays(bool supports_angle_d3d, 358 void GetEGLInitDisplays(bool supports_angle_d3d,
349 bool supports_angle_opengl, 359 bool supports_angle_opengl,
360 bool supports_angle_null,
350 const base::CommandLine* command_line, 361 const base::CommandLine* command_line,
351 std::vector<DisplayType>* init_displays) { 362 std::vector<DisplayType>* init_displays) {
352 // SwiftShader does not use the platform extensions 363 // SwiftShader does not use the platform extensions
353 if (command_line->GetSwitchValueASCII(switches::kUseGL) == 364 if (command_line->GetSwitchValueASCII(switches::kUseGL) ==
354 kGLImplementationSwiftShaderName) { 365 kGLImplementationSwiftShaderName) {
355 init_displays->push_back(SWIFT_SHADER); 366 init_displays->push_back(SWIFT_SHADER);
356 return; 367 return;
357 } 368 }
358 369
359 std::string requested_renderer = 370 std::string requested_renderer =
360 command_line->GetSwitchValueASCII(switches::kUseANGLE); 371 command_line->GetSwitchValueASCII(switches::kUseANGLE);
361 372
362 bool use_angle_default = 373 bool use_angle_default =
363 !command_line->HasSwitch(switches::kUseANGLE) || 374 !command_line->HasSwitch(switches::kUseANGLE) ||
364 requested_renderer == kANGLEImplementationDefaultName; 375 requested_renderer == kANGLEImplementationDefaultName;
365 376
377 if (supports_angle_null &&
378 requested_renderer == kANGLEImplementationNullName) {
379 init_displays->push_back(ANGLE_NULL);
380 return;
381 }
382
366 if (supports_angle_d3d) { 383 if (supports_angle_d3d) {
367 if (use_angle_default) { 384 if (use_angle_default) {
368 // Default mode for ANGLE - try D3D11, else try D3D9 385 // Default mode for ANGLE - try D3D11, else try D3D9
369 if (!command_line->HasSwitch(switches::kDisableD3D11)) { 386 if (!command_line->HasSwitch(switches::kDisableD3D11)) {
370 init_displays->push_back(ANGLE_D3D11); 387 init_displays->push_back(ANGLE_D3D11);
371 } 388 }
372 init_displays->push_back(ANGLE_D3D9); 389 init_displays->push_back(ANGLE_D3D9);
373 } else { 390 } else {
374 if (requested_renderer == kANGLEImplementationD3D11Name) { 391 if (requested_renderer == kANGLEImplementationD3D11Name) {
375 init_displays->push_back(ANGLE_D3D11); 392 init_displays->push_back(ANGLE_D3D11);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 591
575 g_native_display = native_display; 592 g_native_display = native_display;
576 593
577 // If EGL_EXT_client_extensions not supported this call to eglQueryString 594 // If EGL_EXT_client_extensions not supported this call to eglQueryString
578 // will return NULL. 595 // will return NULL.
579 const char* client_extensions = 596 const char* client_extensions =
580 eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); 597 eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
581 598
582 bool supports_angle_d3d = false; 599 bool supports_angle_d3d = false;
583 bool supports_angle_opengl = false; 600 bool supports_angle_opengl = false;
601 bool supports_angle_null = false;
584 // Check for availability of ANGLE extensions. 602 // Check for availability of ANGLE extensions.
585 if (client_extensions && 603 if (client_extensions &&
586 ExtensionsContain(client_extensions, "EGL_ANGLE_platform_angle")) { 604 ExtensionsContain(client_extensions, "EGL_ANGLE_platform_angle")) {
587 supports_angle_d3d = 605 supports_angle_d3d =
588 ExtensionsContain(client_extensions, "EGL_ANGLE_platform_angle_d3d"); 606 ExtensionsContain(client_extensions, "EGL_ANGLE_platform_angle_d3d");
589 supports_angle_opengl = 607 supports_angle_opengl =
590 ExtensionsContain(client_extensions, "EGL_ANGLE_platform_angle_opengl"); 608 ExtensionsContain(client_extensions, "EGL_ANGLE_platform_angle_opengl");
609 supports_angle_null =
610 ExtensionsContain(client_extensions, "EGL_ANGLE_platform_angle_null");
591 } 611 }
592 612
593 std::vector<DisplayType> init_displays; 613 std::vector<DisplayType> init_displays;
594 GetEGLInitDisplays(supports_angle_d3d, supports_angle_opengl, 614 GetEGLInitDisplays(supports_angle_d3d, supports_angle_opengl,
615 supports_angle_null,
595 base::CommandLine::ForCurrentProcess(), &init_displays); 616 base::CommandLine::ForCurrentProcess(), &init_displays);
596 617
597 for (size_t disp_index = 0; disp_index < init_displays.size(); ++disp_index) { 618 for (size_t disp_index = 0; disp_index < init_displays.size(); ++disp_index) {
598 DisplayType display_type = init_displays[disp_index]; 619 DisplayType display_type = init_displays[disp_index];
599 EGLDisplay display = 620 EGLDisplay display =
600 GetDisplayFromType(display_type, g_native_display); 621 GetDisplayFromType(display_type, g_native_display);
601 if (display == EGL_NO_DISPLAY) { 622 if (display == EGL_NO_DISPLAY) {
602 LOG(ERROR) << "EGL display query failed with error " 623 LOG(ERROR) << "EGL display query failed with error "
603 << GetLastEGLErrorString(); 624 << GetLastEGLErrorString();
604 } 625 }
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 } 1200 }
1180 1201
1181 void* SurfacelessEGL::GetShareHandle() { 1202 void* SurfacelessEGL::GetShareHandle() {
1182 return NULL; 1203 return NULL;
1183 } 1204 }
1184 1205
1185 SurfacelessEGL::~SurfacelessEGL() { 1206 SurfacelessEGL::~SurfacelessEGL() {
1186 } 1207 }
1187 1208
1188 } // namespace gl 1209 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/gl/gl_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698