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