| OLD | NEW |
| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 EGLNativeDisplayType g_native_display = EGL_DEFAULT_DISPLAY; | 127 EGLNativeDisplayType g_native_display = EGL_DEFAULT_DISPLAY; |
| 126 | 128 |
| 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_sync_control_supported = false; | 131 bool g_egl_sync_control_supported = false; |
| 130 bool g_egl_window_fixed_size_supported = false; | 132 bool g_egl_window_fixed_size_supported = false; |
| 131 bool g_egl_surfaceless_context_supported = false; | 133 bool g_egl_surfaceless_context_supported = false; |
| 132 bool g_egl_surface_orientation_supported = false; | 134 bool g_egl_surface_orientation_supported = false; |
| 133 bool g_use_direct_composition = false; | 135 bool g_use_direct_composition = false; |
| 134 | 136 |
| 137 base::LazyInstance<ANGLEPlatformImpl> g_angle_platform_impl = |
| 138 LAZY_INSTANCE_INITIALIZER; |
| 139 ANGLEPlatformShutdownFunc g_angle_platform_shutdown = nullptr; |
| 140 |
| 135 EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display, | 141 EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display, |
| 136 EGLenum platform_type, | 142 EGLenum platform_type, |
| 137 bool warpDevice) { | 143 bool warpDevice) { |
| 138 std::vector<EGLint> display_attribs; | 144 std::vector<EGLint> display_attribs; |
| 139 | 145 |
| 140 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); | 146 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); |
| 141 display_attribs.push_back(platform_type); | 147 display_attribs.push_back(platform_type); |
| 142 | 148 |
| 143 if (warpDevice) { | 149 if (warpDevice) { |
| 144 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); | 150 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 context->ReleaseCurrent(surface.get()); | 526 context->ReleaseCurrent(surface.get()); |
| 521 } | 527 } |
| 522 } | 528 } |
| 523 #endif | 529 #endif |
| 524 initialized_ = true; | 530 initialized_ = true; |
| 525 | 531 |
| 526 return true; | 532 return true; |
| 527 } | 533 } |
| 528 | 534 |
| 529 // static | 535 // static |
| 530 void GLSurfaceEGL::ResetForTesting() { | 536 void GLSurfaceEGL::ShutdownOneOff() { |
| 537 if (g_angle_platform_shutdown) { |
| 538 g_angle_platform_shutdown(); |
| 539 } |
| 540 |
| 531 if (g_display != EGL_NO_DISPLAY) | 541 if (g_display != EGL_NO_DISPLAY) |
| 532 eglTerminate(g_display); | 542 eglTerminate(g_display); |
| 533 g_display = EGL_NO_DISPLAY; | 543 g_display = EGL_NO_DISPLAY; |
| 534 | 544 |
| 535 g_egl_extensions = nullptr; | 545 g_egl_extensions = nullptr; |
| 536 g_egl_create_context_robustness_supported = false; | 546 g_egl_create_context_robustness_supported = false; |
| 537 g_egl_sync_control_supported = false; | 547 g_egl_sync_control_supported = false; |
| 538 g_egl_window_fixed_size_supported = false; | 548 g_egl_window_fixed_size_supported = false; |
| 539 g_egl_surface_orientation_supported = false; | 549 g_egl_surface_orientation_supported = false; |
| 540 g_use_direct_composition = false; | 550 g_use_direct_composition = false; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 // needs a full Display init before it can query the Display extensions. | 594 // needs a full Display init before it can query the Display extensions. |
| 585 // static | 595 // static |
| 586 EGLDisplay GLSurfaceEGL::InitializeDisplay( | 596 EGLDisplay GLSurfaceEGL::InitializeDisplay( |
| 587 EGLNativeDisplayType native_display) { | 597 EGLNativeDisplayType native_display) { |
| 588 if (g_display != EGL_NO_DISPLAY) { | 598 if (g_display != EGL_NO_DISPLAY) { |
| 589 return g_display; | 599 return g_display; |
| 590 } | 600 } |
| 591 | 601 |
| 592 g_native_display = native_display; | 602 g_native_display = native_display; |
| 593 | 603 |
| 604 // Init ANGLE platform here, before we call GetPlatformDisplay(). |
| 605 ANGLEPlatformInitializeFunc angle_platform_init = |
| 606 reinterpret_cast<ANGLEPlatformInitializeFunc>( |
| 607 eglGetProcAddress("ANGLEPlatformInitialize")); |
| 608 if (angle_platform_init) { |
| 609 angle_platform_init(&g_angle_platform_impl.Get()); |
| 610 |
| 611 g_angle_platform_shutdown = reinterpret_cast<ANGLEPlatformShutdownFunc>( |
| 612 eglGetProcAddress("ANGLEPlatformShutdown")); |
| 613 } |
| 614 |
| 594 // If EGL_EXT_client_extensions not supported this call to eglQueryString | 615 // If EGL_EXT_client_extensions not supported this call to eglQueryString |
| 595 // will return NULL. | 616 // will return NULL. |
| 596 const char* client_extensions = | 617 const char* client_extensions = |
| 597 eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); | 618 eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); |
| 598 | 619 |
| 599 bool supports_angle_d3d = false; | 620 bool supports_angle_d3d = false; |
| 600 bool supports_angle_opengl = false; | 621 bool supports_angle_opengl = false; |
| 601 bool supports_angle_null = false; | 622 bool supports_angle_null = false; |
| 602 // Check for availability of ANGLE extensions. | 623 // Check for availability of ANGLE extensions. |
| 603 if (client_extensions && | 624 if (client_extensions && |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 } | 1221 } |
| 1201 | 1222 |
| 1202 void* SurfacelessEGL::GetShareHandle() { | 1223 void* SurfacelessEGL::GetShareHandle() { |
| 1203 return NULL; | 1224 return NULL; |
| 1204 } | 1225 } |
| 1205 | 1226 |
| 1206 SurfacelessEGL::~SurfacelessEGL() { | 1227 SurfacelessEGL::~SurfacelessEGL() { |
| 1207 } | 1228 } |
| 1208 | 1229 |
| 1209 } // namespace gl | 1230 } // namespace gl |
| OLD | NEW |