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

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

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