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> |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 const unsigned int MULTISWAP_FRAME_VSYNC_THRESHOLD = 60; | 119 const unsigned int MULTISWAP_FRAME_VSYNC_THRESHOLD = 60; |
120 #endif | 120 #endif |
121 | 121 |
122 namespace { | 122 namespace { |
123 | 123 |
124 EGLDisplay g_display = EGL_NO_DISPLAY; | 124 EGLDisplay g_display = EGL_NO_DISPLAY; |
125 EGLNativeDisplayType g_native_display = EGL_DEFAULT_DISPLAY; | 125 EGLNativeDisplayType g_native_display = EGL_DEFAULT_DISPLAY; |
126 | 126 |
127 const char* g_egl_extensions = nullptr; | 127 const char* g_egl_extensions = nullptr; |
128 bool g_egl_create_context_robustness_supported = false; | 128 bool g_egl_create_context_robustness_supported = false; |
129 bool g_egl_create_context_bind_generates_resource_supported = false; | |
130 bool g_egl_create_context_webgl_compatability_supported = false; | |
131 bool g_egl_sync_control_supported = false; | 129 bool g_egl_sync_control_supported = false; |
132 bool g_egl_window_fixed_size_supported = false; | 130 bool g_egl_window_fixed_size_supported = false; |
133 bool g_egl_surfaceless_context_supported = false; | 131 bool g_egl_surfaceless_context_supported = false; |
134 bool g_egl_surface_orientation_supported = false; | 132 bool g_egl_surface_orientation_supported = false; |
135 bool g_use_direct_composition = false; | 133 bool g_use_direct_composition = false; |
136 | 134 |
137 EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display, | 135 EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display, |
138 EGLenum platform_type, | 136 EGLenum platform_type, |
139 bool warpDevice) { | 137 bool warpDevice) { |
140 std::vector<EGLint> display_attribs; | 138 std::vector<EGLint> display_attribs; |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 InitializeDisplay(native_display); | 471 InitializeDisplay(native_display); |
474 if (g_display == EGL_NO_DISPLAY) | 472 if (g_display == EGL_NO_DISPLAY) |
475 return false; | 473 return false; |
476 | 474 |
477 // Must be called after InitializeDisplay(). | 475 // Must be called after InitializeDisplay(). |
478 g_driver_egl.InitializeExtensionBindings(); | 476 g_driver_egl.InitializeExtensionBindings(); |
479 | 477 |
480 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); | 478 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); |
481 g_egl_create_context_robustness_supported = | 479 g_egl_create_context_robustness_supported = |
482 HasEGLExtension("EGL_EXT_create_context_robustness"); | 480 HasEGLExtension("EGL_EXT_create_context_robustness"); |
483 g_egl_create_context_bind_generates_resource_supported = | |
484 HasEGLExtension("EGL_CHROMIUM_create_context_bind_generates_resource"); | |
485 g_egl_create_context_webgl_compatability_supported = | |
486 HasEGLExtension("EGL_ANGLE_create_context_webgl_compatibility"); | |
487 g_egl_sync_control_supported = | 481 g_egl_sync_control_supported = |
488 HasEGLExtension("EGL_CHROMIUM_sync_control"); | 482 HasEGLExtension("EGL_CHROMIUM_sync_control"); |
489 g_egl_window_fixed_size_supported = | 483 g_egl_window_fixed_size_supported = |
490 HasEGLExtension("EGL_ANGLE_window_fixed_size"); | 484 HasEGLExtension("EGL_ANGLE_window_fixed_size"); |
491 g_egl_surface_orientation_supported = | 485 g_egl_surface_orientation_supported = |
492 HasEGLExtension("EGL_ANGLE_surface_orientation"); | 486 HasEGLExtension("EGL_ANGLE_surface_orientation"); |
493 | 487 |
494 // Need EGL_ANGLE_flexible_surface_compatibility to allow surfaces with and | 488 // Need EGL_ANGLE_flexible_surface_compatibility to allow surfaces with and |
495 // without alpha to be bound to the same context. | 489 // without alpha to be bound to the same context. |
496 g_use_direct_composition = | 490 g_use_direct_composition = |
(...skipping 11 matching lines...) Expand all Loading... |
508 #else | 502 #else |
509 // Check if SurfacelessEGL is supported. | 503 // Check if SurfacelessEGL is supported. |
510 g_egl_surfaceless_context_supported = | 504 g_egl_surfaceless_context_supported = |
511 HasEGLExtension("EGL_KHR_surfaceless_context"); | 505 HasEGLExtension("EGL_KHR_surfaceless_context"); |
512 if (g_egl_surfaceless_context_supported) { | 506 if (g_egl_surfaceless_context_supported) { |
513 // EGL_KHR_surfaceless_context is supported but ensure | 507 // EGL_KHR_surfaceless_context is supported but ensure |
514 // GL_OES_surfaceless_context is also supported. We need a current context | 508 // GL_OES_surfaceless_context is also supported. We need a current context |
515 // to query for supported GL extensions. | 509 // to query for supported GL extensions. |
516 scoped_refptr<GLSurface> surface = new SurfacelessEGL(gfx::Size(1, 1)); | 510 scoped_refptr<GLSurface> surface = new SurfacelessEGL(gfx::Size(1, 1)); |
517 scoped_refptr<GLContext> context = InitializeGLContext( | 511 scoped_refptr<GLContext> context = InitializeGLContext( |
518 new GLContextEGL(nullptr), surface.get(), GLContextAttribs()); | 512 new GLContextEGL(nullptr), surface.get(), PreferIntegratedGpu); |
519 if (!context->MakeCurrent(surface.get())) | 513 if (!context->MakeCurrent(surface.get())) |
520 g_egl_surfaceless_context_supported = false; | 514 g_egl_surfaceless_context_supported = false; |
521 | 515 |
522 // Ensure context supports GL_OES_surfaceless_context. | 516 // Ensure context supports GL_OES_surfaceless_context. |
523 if (g_egl_surfaceless_context_supported) { | 517 if (g_egl_surfaceless_context_supported) { |
524 g_egl_surfaceless_context_supported = context->HasExtension( | 518 g_egl_surfaceless_context_supported = context->HasExtension( |
525 "GL_OES_surfaceless_context"); | 519 "GL_OES_surfaceless_context"); |
526 context->ReleaseCurrent(surface.get()); | 520 context->ReleaseCurrent(surface.get()); |
527 } | 521 } |
528 } | 522 } |
529 #endif | 523 #endif |
530 initialized_ = true; | 524 initialized_ = true; |
531 | 525 |
532 return true; | 526 return true; |
533 } | 527 } |
534 | 528 |
535 // static | 529 // static |
536 void GLSurfaceEGL::ResetForTesting() { | 530 void GLSurfaceEGL::ResetForTesting() { |
537 if (g_display != EGL_NO_DISPLAY) | 531 if (g_display != EGL_NO_DISPLAY) |
538 eglTerminate(g_display); | 532 eglTerminate(g_display); |
539 g_display = EGL_NO_DISPLAY; | 533 g_display = EGL_NO_DISPLAY; |
540 | 534 |
541 g_egl_extensions = nullptr; | 535 g_egl_extensions = nullptr; |
542 g_egl_create_context_robustness_supported = false; | 536 g_egl_create_context_robustness_supported = false; |
543 g_egl_create_context_bind_generates_resource_supported = false; | |
544 g_egl_create_context_webgl_compatability_supported = false; | |
545 g_egl_sync_control_supported = false; | 537 g_egl_sync_control_supported = false; |
546 g_egl_window_fixed_size_supported = false; | 538 g_egl_window_fixed_size_supported = false; |
547 g_egl_surface_orientation_supported = false; | 539 g_egl_surface_orientation_supported = false; |
548 g_use_direct_composition = false; | 540 g_use_direct_composition = false; |
549 g_egl_surfaceless_context_supported = false; | 541 g_egl_surfaceless_context_supported = false; |
550 | 542 |
551 initialized_ = false; | 543 initialized_ = false; |
552 } | 544 } |
553 | 545 |
554 // static | 546 // static |
(...skipping 14 matching lines...) Expand all Loading... |
569 // static | 561 // static |
570 bool GLSurfaceEGL::HasEGLExtension(const char* name) { | 562 bool GLSurfaceEGL::HasEGLExtension(const char* name) { |
571 return ExtensionsContain(GetEGLExtensions(), name); | 563 return ExtensionsContain(GetEGLExtensions(), name); |
572 } | 564 } |
573 | 565 |
574 // static | 566 // static |
575 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { | 567 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { |
576 return g_egl_create_context_robustness_supported; | 568 return g_egl_create_context_robustness_supported; |
577 } | 569 } |
578 | 570 |
579 bool GLSurfaceEGL::IsCreateContextBindGeneratesResourceSupported() { | |
580 return g_egl_create_context_bind_generates_resource_supported; | |
581 } | |
582 | |
583 bool GLSurfaceEGL::IsCreateContextWebGLCompatabilitySupported() { | |
584 return g_egl_create_context_webgl_compatability_supported; | |
585 } | |
586 | |
587 // static | 571 // static |
588 bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() { | 572 bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() { |
589 return g_egl_surfaceless_context_supported; | 573 return g_egl_surfaceless_context_supported; |
590 } | 574 } |
591 | 575 |
592 // static | 576 // static |
593 bool GLSurfaceEGL::IsDirectCompositionSupported() { | 577 bool GLSurfaceEGL::IsDirectCompositionSupported() { |
594 return g_use_direct_composition; | 578 return g_use_direct_composition; |
595 } | 579 } |
596 | 580 |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 } | 1200 } |
1217 | 1201 |
1218 void* SurfacelessEGL::GetShareHandle() { | 1202 void* SurfacelessEGL::GetShareHandle() { |
1219 return NULL; | 1203 return NULL; |
1220 } | 1204 } |
1221 | 1205 |
1222 SurfacelessEGL::~SurfacelessEGL() { | 1206 SurfacelessEGL::~SurfacelessEGL() { |
1223 } | 1207 } |
1224 | 1208 |
1225 } // namespace gl | 1209 } // namespace gl |
OLD | NEW |