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

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

Issue 2491993002: ui/gl: Initialize the ANGLE Platform on all configurations (Closed)
Patch Set: Rebase on top of the renaming of ClearGLBindings Created 4 years 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/init/gl_initializer_android.cc » ('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>
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/lazy_instance.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
18 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
19 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
20 #include "base/sys_info.h" 21 #include "base/sys_info.h"
21 #include "base/trace_event/trace_event.h" 22 #include "base/trace_event/trace_event.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
25 #include "ui/gl/angle_platform_impl.h"
24 #include "ui/gl/egl_util.h" 26 #include "ui/gl/egl_util.h"
25 #include "ui/gl/gl_context.h" 27 #include "ui/gl/gl_context.h"
26 #include "ui/gl/gl_context_egl.h" 28 #include "ui/gl/gl_context_egl.h"
27 #include "ui/gl/gl_image.h" 29 #include "ui/gl/gl_image.h"
28 #include "ui/gl/gl_implementation.h" 30 #include "ui/gl/gl_implementation.h"
29 #include "ui/gl/gl_surface_stub.h" 31 #include "ui/gl/gl_surface_stub.h"
30 #include "ui/gl/gl_switches.h" 32 #include "ui/gl/gl_switches.h"
31 #include "ui/gl/scoped_make_current.h" 33 #include "ui/gl/scoped_make_current.h"
32 34
33 #if defined(USE_X11) && !defined(OS_CHROMEOS) 35 #if defined(USE_X11) && !defined(OS_CHROMEOS)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const char* g_egl_extensions = nullptr; 129 const char* g_egl_extensions = nullptr;
128 bool g_egl_create_context_robustness_supported = false; 130 bool g_egl_create_context_robustness_supported = false;
129 bool g_egl_create_context_bind_generates_resource_supported = false; 131 bool g_egl_create_context_bind_generates_resource_supported = false;
130 bool g_egl_create_context_webgl_compatability_supported = false; 132 bool g_egl_create_context_webgl_compatability_supported = false;
131 bool g_egl_sync_control_supported = false; 133 bool g_egl_sync_control_supported = false;
132 bool g_egl_window_fixed_size_supported = false; 134 bool g_egl_window_fixed_size_supported = false;
133 bool g_egl_surfaceless_context_supported = false; 135 bool g_egl_surfaceless_context_supported = false;
134 bool g_egl_surface_orientation_supported = false; 136 bool g_egl_surface_orientation_supported = false;
135 bool g_use_direct_composition = false; 137 bool g_use_direct_composition = false;
136 138
139 base::LazyInstance<ANGLEPlatformImpl> g_angle_platform_impl =
140 LAZY_INSTANCE_INITIALIZER;
141 ANGLEPlatformShutdownFunc g_angle_platform_shutdown = nullptr;
142
137 EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display, 143 EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display,
138 EGLenum platform_type, 144 EGLenum platform_type,
139 bool warpDevice) { 145 bool warpDevice) {
140 std::vector<EGLint> display_attribs; 146 std::vector<EGLint> display_attribs;
141 147
142 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); 148 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
143 display_attribs.push_back(platform_type); 149 display_attribs.push_back(platform_type);
144 150
145 if (warpDevice) { 151 if (warpDevice) {
146 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); 152 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 context->ReleaseCurrent(surface.get()); 532 context->ReleaseCurrent(surface.get());
527 } 533 }
528 } 534 }
529 #endif 535 #endif
530 initialized_ = true; 536 initialized_ = true;
531 537
532 return true; 538 return true;
533 } 539 }
534 540
535 // static 541 // static
536 void GLSurfaceEGL::ResetForTesting() { 542 void GLSurfaceEGL::ShutdownOneOff() {
543 if (g_angle_platform_shutdown) {
544 g_angle_platform_shutdown();
545 }
546
537 if (g_display != EGL_NO_DISPLAY) 547 if (g_display != EGL_NO_DISPLAY)
538 eglTerminate(g_display); 548 eglTerminate(g_display);
539 g_display = EGL_NO_DISPLAY; 549 g_display = EGL_NO_DISPLAY;
540 550
541 g_egl_extensions = nullptr; 551 g_egl_extensions = nullptr;
542 g_egl_create_context_robustness_supported = false; 552 g_egl_create_context_robustness_supported = false;
543 g_egl_create_context_bind_generates_resource_supported = false; 553 g_egl_create_context_bind_generates_resource_supported = false;
544 g_egl_create_context_webgl_compatability_supported = false; 554 g_egl_create_context_webgl_compatability_supported = false;
545 g_egl_sync_control_supported = false; 555 g_egl_sync_control_supported = false;
546 g_egl_window_fixed_size_supported = false; 556 g_egl_window_fixed_size_supported = false;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // needs a full Display init before it can query the Display extensions. 610 // needs a full Display init before it can query the Display extensions.
601 // static 611 // static
602 EGLDisplay GLSurfaceEGL::InitializeDisplay( 612 EGLDisplay GLSurfaceEGL::InitializeDisplay(
603 EGLNativeDisplayType native_display) { 613 EGLNativeDisplayType native_display) {
604 if (g_display != EGL_NO_DISPLAY) { 614 if (g_display != EGL_NO_DISPLAY) {
605 return g_display; 615 return g_display;
606 } 616 }
607 617
608 g_native_display = native_display; 618 g_native_display = native_display;
609 619
620 // Init ANGLE platform here, before we call GetPlatformDisplay().
621 ANGLEPlatformInitializeFunc angle_platform_init =
622 reinterpret_cast<ANGLEPlatformInitializeFunc>(
623 eglGetProcAddress("ANGLEPlatformInitialize"));
624 if (angle_platform_init) {
625 angle_platform_init(&g_angle_platform_impl.Get());
626
627 g_angle_platform_shutdown = reinterpret_cast<ANGLEPlatformShutdownFunc>(
628 eglGetProcAddress("ANGLEPlatformShutdown"));
629 }
630
610 // If EGL_EXT_client_extensions not supported this call to eglQueryString 631 // If EGL_EXT_client_extensions not supported this call to eglQueryString
611 // will return NULL. 632 // will return NULL.
612 const char* client_extensions = 633 const char* client_extensions =
613 eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); 634 eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
614 635
615 bool supports_angle_d3d = false; 636 bool supports_angle_d3d = false;
616 bool supports_angle_opengl = false; 637 bool supports_angle_opengl = false;
617 bool supports_angle_null = false; 638 bool supports_angle_null = false;
618 // Check for availability of ANGLE extensions. 639 // Check for availability of ANGLE extensions.
619 if (client_extensions && 640 if (client_extensions &&
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 } 1237 }
1217 1238
1218 void* SurfacelessEGL::GetShareHandle() { 1239 void* SurfacelessEGL::GetShareHandle() {
1219 return NULL; 1240 return NULL;
1220 } 1241 }
1221 1242
1222 SurfacelessEGL::~SurfacelessEGL() { 1243 SurfacelessEGL::~SurfacelessEGL() {
1223 } 1244 }
1224 1245
1225 } // namespace gl 1246 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/gl/init/gl_initializer_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698