| 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 "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 EGLConfig g_config; | 109 EGLConfig g_config; |
| 110 EGLDisplay g_display; | 110 EGLDisplay g_display; |
| 111 EGLNativeDisplayType g_native_display; | 111 EGLNativeDisplayType g_native_display; |
| 112 | 112 |
| 113 const char* g_egl_extensions = NULL; | 113 const char* g_egl_extensions = NULL; |
| 114 bool g_egl_create_context_robustness_supported = false; | 114 bool g_egl_create_context_robustness_supported = false; |
| 115 bool g_egl_sync_control_supported = false; | 115 bool g_egl_sync_control_supported = false; |
| 116 bool g_egl_window_fixed_size_supported = false; | 116 bool g_egl_window_fixed_size_supported = false; |
| 117 bool g_egl_surfaceless_context_supported = false; | 117 bool g_egl_surfaceless_context_supported = false; |
| 118 bool g_egl_surface_orientation_supported = false; | 118 bool g_egl_surface_orientation_supported = false; |
| 119 bool g_use_direct_composition = false; |
| 119 | 120 |
| 120 class EGLSyncControlVSyncProvider | 121 class EGLSyncControlVSyncProvider |
| 121 : public gfx::SyncControlVSyncProvider { | 122 : public gfx::SyncControlVSyncProvider { |
| 122 public: | 123 public: |
| 123 explicit EGLSyncControlVSyncProvider(EGLSurface surface) | 124 explicit EGLSyncControlVSyncProvider(EGLSurface surface) |
| 124 : SyncControlVSyncProvider(), | 125 : SyncControlVSyncProvider(), |
| 125 surface_(surface) { | 126 surface_(surface) { |
| 126 } | 127 } |
| 127 | 128 |
| 128 ~EGLSyncControlVSyncProvider() override {} | 129 ~EGLSyncControlVSyncProvider() override {} |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); | 370 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); |
| 370 g_egl_create_context_robustness_supported = | 371 g_egl_create_context_robustness_supported = |
| 371 HasEGLExtension("EGL_EXT_create_context_robustness"); | 372 HasEGLExtension("EGL_EXT_create_context_robustness"); |
| 372 g_egl_sync_control_supported = | 373 g_egl_sync_control_supported = |
| 373 HasEGLExtension("EGL_CHROMIUM_sync_control"); | 374 HasEGLExtension("EGL_CHROMIUM_sync_control"); |
| 374 g_egl_window_fixed_size_supported = | 375 g_egl_window_fixed_size_supported = |
| 375 HasEGLExtension("EGL_ANGLE_window_fixed_size"); | 376 HasEGLExtension("EGL_ANGLE_window_fixed_size"); |
| 376 g_egl_surface_orientation_supported = | 377 g_egl_surface_orientation_supported = |
| 377 HasEGLExtension("EGL_ANGLE_surface_orientation"); | 378 HasEGLExtension("EGL_ANGLE_surface_orientation"); |
| 378 | 379 |
| 380 g_use_direct_composition = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 381 switches::kUseDirectComposition); |
| 382 |
| 379 // TODO(oetuaho@nvidia.com): Surfaceless is disabled on Android as a temporary | 383 // TODO(oetuaho@nvidia.com): Surfaceless is disabled on Android as a temporary |
| 380 // workaround, since code written for Android WebView takes different paths | 384 // workaround, since code written for Android WebView takes different paths |
| 381 // based on whether GL surface objects have underlying EGL surface handles, | 385 // based on whether GL surface objects have underlying EGL surface handles, |
| 382 // conflicting with the use of surfaceless. See https://crbug.com/382349 | 386 // conflicting with the use of surfaceless. See https://crbug.com/382349 |
| 383 #if defined(OS_ANDROID) | 387 #if defined(OS_ANDROID) |
| 384 DCHECK(!g_egl_surfaceless_context_supported); | 388 DCHECK(!g_egl_surfaceless_context_supported); |
| 385 #else | 389 #else |
| 386 // Check if SurfacelessEGL is supported. | 390 // Check if SurfacelessEGL is supported. |
| 387 g_egl_surfaceless_context_supported = | 391 g_egl_surfaceless_context_supported = |
| 388 HasEGLExtension("EGL_KHR_surfaceless_context"); | 392 HasEGLExtension("EGL_KHR_surfaceless_context"); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 } | 435 } |
| 432 | 436 |
| 433 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { | 437 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { |
| 434 return g_egl_create_context_robustness_supported; | 438 return g_egl_create_context_robustness_supported; |
| 435 } | 439 } |
| 436 | 440 |
| 437 bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() { | 441 bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() { |
| 438 return g_egl_surfaceless_context_supported; | 442 return g_egl_surfaceless_context_supported; |
| 439 } | 443 } |
| 440 | 444 |
| 445 bool GLSurfaceEGL::IsDirectCompositionSupported() { |
| 446 return g_use_direct_composition; |
| 447 } |
| 448 |
| 441 GLSurfaceEGL::~GLSurfaceEGL() {} | 449 GLSurfaceEGL::~GLSurfaceEGL() {} |
| 442 | 450 |
| 443 // InitializeDisplay is necessary because the static binding code | 451 // InitializeDisplay is necessary because the static binding code |
| 444 // needs a full Display init before it can query the Display extensions. | 452 // needs a full Display init before it can query the Display extensions. |
| 445 // static | 453 // static |
| 446 EGLDisplay GLSurfaceEGL::InitializeDisplay() { | 454 EGLDisplay GLSurfaceEGL::InitializeDisplay() { |
| 447 if (g_display != EGL_NO_DISPLAY) { | 455 if (g_display != EGL_NO_DISPLAY) { |
| 448 return g_display; | 456 return g_display; |
| 449 } | 457 } |
| 450 | 458 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 } | 501 } |
| 494 } | 502 } |
| 495 | 503 |
| 496 return g_display; | 504 return g_display; |
| 497 } | 505 } |
| 498 | 506 |
| 499 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window) | 507 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window) |
| 500 : window_(window), | 508 : window_(window), |
| 501 config_(NULL), | 509 config_(NULL), |
| 502 size_(1, 1), | 510 size_(1, 1), |
| 511 alpha_(true), |
| 512 enable_fixed_size_angle_(false), |
| 503 surface_(NULL), | 513 surface_(NULL), |
| 504 supports_post_sub_buffer_(false), | 514 supports_post_sub_buffer_(false), |
| 505 alpha_(true), | |
| 506 flips_vertically_(false), | 515 flips_vertically_(false), |
| 507 swap_interval_(1) { | 516 swap_interval_(1) { |
| 508 #if defined(OS_ANDROID) | 517 #if defined(OS_ANDROID) |
| 509 if (window) | 518 if (window) |
| 510 ANativeWindow_acquire(window); | 519 ANativeWindow_acquire(window); |
| 511 #endif | 520 #endif |
| 512 | 521 |
| 513 #if defined(OS_WIN) | 522 #if defined(OS_WIN) |
| 514 vsync_override_ = false; | 523 vsync_override_ = false; |
| 515 swap_generation_ = 0; | 524 swap_generation_ = 0; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 534 | 543 |
| 535 // We need to make sure that window_ is correctly initialized with all | 544 // We need to make sure that window_ is correctly initialized with all |
| 536 // the platform-dependant quirks, if any, before creating the surface. | 545 // the platform-dependant quirks, if any, before creating the surface. |
| 537 if (!InitializeNativeWindow()) { | 546 if (!InitializeNativeWindow()) { |
| 538 LOG(ERROR) << "Error trying to initialize the native window."; | 547 LOG(ERROR) << "Error trying to initialize the native window."; |
| 539 return false; | 548 return false; |
| 540 } | 549 } |
| 541 | 550 |
| 542 std::vector<EGLint> egl_window_attributes; | 551 std::vector<EGLint> egl_window_attributes; |
| 543 | 552 |
| 544 if (g_egl_window_fixed_size_supported) { | 553 if (g_egl_window_fixed_size_supported && enable_fixed_size_angle_) { |
| 545 egl_window_attributes.push_back(EGL_FIXED_SIZE_ANGLE); | 554 egl_window_attributes.push_back(EGL_FIXED_SIZE_ANGLE); |
| 546 egl_window_attributes.push_back(EGL_TRUE); | 555 egl_window_attributes.push_back(EGL_TRUE); |
| 547 egl_window_attributes.push_back(EGL_WIDTH); | 556 egl_window_attributes.push_back(EGL_WIDTH); |
| 548 egl_window_attributes.push_back(size_.width()); | 557 egl_window_attributes.push_back(size_.width()); |
| 549 egl_window_attributes.push_back(EGL_HEIGHT); | 558 egl_window_attributes.push_back(EGL_HEIGHT); |
| 550 egl_window_attributes.push_back(size_.height()); | 559 egl_window_attributes.push_back(size_.height()); |
| 551 } | 560 } |
| 552 | 561 |
| 553 if (gfx::g_driver_egl.ext.b_EGL_NV_post_sub_buffer) { | 562 if (gfx::g_driver_egl.ext.b_EGL_NV_post_sub_buffer) { |
| 554 egl_window_attributes.push_back(EGL_POST_SUB_BUFFER_SUPPORTED_NV); | 563 egl_window_attributes.push_back(EGL_POST_SUB_BUFFER_SUPPORTED_NV); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 } | 994 } |
| 986 | 995 |
| 987 void* SurfacelessEGL::GetShareHandle() { | 996 void* SurfacelessEGL::GetShareHandle() { |
| 988 return NULL; | 997 return NULL; |
| 989 } | 998 } |
| 990 | 999 |
| 991 SurfacelessEGL::~SurfacelessEGL() { | 1000 SurfacelessEGL::~SurfacelessEGL() { |
| 992 } | 1001 } |
| 993 | 1002 |
| 994 } // namespace gfx | 1003 } // namespace gfx |
| OLD | NEW |