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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 440 |
441 // If no displays are available due to missing angle extensions or invalid | 441 // If no displays are available due to missing angle extensions or invalid |
442 // flags, request the default display. | 442 // flags, request the default display. |
443 if (init_displays->empty()) { | 443 if (init_displays->empty()) { |
444 init_displays->push_back(DEFAULT); | 444 init_displays->push_back(DEFAULT); |
445 } | 445 } |
446 } | 446 } |
447 | 447 |
448 GLSurfaceEGL::GLSurfaceEGL() {} | 448 GLSurfaceEGL::GLSurfaceEGL() {} |
449 | 449 |
| 450 GLSurface::Format GLSurfaceEGL::GetFormat() { |
| 451 return format_; |
| 452 } |
| 453 |
| 454 EGLDisplay GLSurfaceEGL::GetDisplay() { |
| 455 return g_display; |
| 456 } |
| 457 |
| 458 EGLConfig GLSurfaceEGL::GetConfig() { |
| 459 if (!config_) { |
| 460 config_ = ChooseConfig(format_); |
| 461 } |
| 462 return config_; |
| 463 } |
| 464 |
| 465 // static |
| 466 void GLSurfaceEGL::SetNativeDisplay(EGLNativeDisplayType native_display) { |
| 467 g_native_display = native_display; |
| 468 } |
| 469 |
| 470 // static |
450 bool GLSurfaceEGL::InitializeOneOff() { | 471 bool GLSurfaceEGL::InitializeOneOff() { |
451 static bool initialized = false; | 472 static bool initialized = false; |
452 if (initialized) | 473 if (initialized) |
453 return true; | 474 return true; |
454 | 475 |
455 InitializeDisplay(); | 476 InitializeDisplay(); |
456 if (g_display == EGL_NO_DISPLAY) | 477 if (g_display == EGL_NO_DISPLAY) |
457 return false; | 478 return false; |
458 | 479 |
459 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); | 480 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 context->ReleaseCurrent(surface.get()); | 522 context->ReleaseCurrent(surface.get()); |
502 } | 523 } |
503 } | 524 } |
504 #endif | 525 #endif |
505 | 526 |
506 initialized = true; | 527 initialized = true; |
507 | 528 |
508 return true; | 529 return true; |
509 } | 530 } |
510 | 531 |
511 GLSurface::Format GLSurfaceEGL::GetFormat() { | 532 // static |
512 return format_; | |
513 } | |
514 | |
515 EGLDisplay GLSurfaceEGL::GetDisplay() { | |
516 return g_display; | |
517 } | |
518 | |
519 EGLConfig GLSurfaceEGL::GetConfig() { | |
520 if (!config_) { | |
521 config_ = ChooseConfig(format_); | |
522 } | |
523 return config_; | |
524 } | |
525 | |
526 EGLDisplay GLSurfaceEGL::GetHardwareDisplay() { | 533 EGLDisplay GLSurfaceEGL::GetHardwareDisplay() { |
527 return g_display; | 534 return g_display; |
528 } | 535 } |
529 | 536 |
| 537 // static |
530 EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { | 538 EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { |
531 return g_native_display; | 539 return g_native_display; |
532 } | 540 } |
533 | 541 |
| 542 // static |
534 const char* GLSurfaceEGL::GetEGLExtensions() { | 543 const char* GLSurfaceEGL::GetEGLExtensions() { |
535 return g_egl_extensions; | 544 return g_egl_extensions; |
536 } | 545 } |
537 | 546 |
| 547 // static |
538 bool GLSurfaceEGL::HasEGLExtension(const char* name) { | 548 bool GLSurfaceEGL::HasEGLExtension(const char* name) { |
539 return ExtensionsContain(GetEGLExtensions(), name); | 549 return ExtensionsContain(GetEGLExtensions(), name); |
540 } | 550 } |
541 | 551 |
| 552 // static |
542 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { | 553 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { |
543 return g_egl_create_context_robustness_supported; | 554 return g_egl_create_context_robustness_supported; |
544 } | 555 } |
545 | 556 |
| 557 // static |
546 bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() { | 558 bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() { |
547 return g_egl_surfaceless_context_supported; | 559 return g_egl_surfaceless_context_supported; |
548 } | 560 } |
549 | 561 |
| 562 // static |
550 bool GLSurfaceEGL::IsDirectCompositionSupported() { | 563 bool GLSurfaceEGL::IsDirectCompositionSupported() { |
551 return g_use_direct_composition; | 564 return g_use_direct_composition; |
552 } | 565 } |
553 | 566 |
554 GLSurfaceEGL::~GLSurfaceEGL() {} | 567 GLSurfaceEGL::~GLSurfaceEGL() {} |
555 | 568 |
556 // InitializeDisplay is necessary because the static binding code | 569 // InitializeDisplay is necessary because the static binding code |
557 // needs a full Display init before it can query the Display extensions. | 570 // needs a full Display init before it can query the Display extensions. |
558 // static | 571 // static |
559 EGLDisplay GLSurfaceEGL::InitializeDisplay() { | 572 EGLDisplay GLSurfaceEGL::InitializeDisplay() { |
560 if (g_display != EGL_NO_DISPLAY) { | 573 if (g_display != EGL_NO_DISPLAY) { |
561 return g_display; | 574 return g_display; |
562 } | 575 } |
563 | 576 |
564 g_native_display = GetPlatformDefaultEGLNativeDisplay(); | |
565 | |
566 // If EGL_EXT_client_extensions not supported this call to eglQueryString | 577 // If EGL_EXT_client_extensions not supported this call to eglQueryString |
567 // will return NULL. | 578 // will return NULL. |
568 const char* client_extensions = | 579 const char* client_extensions = |
569 eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); | 580 eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); |
570 | 581 |
571 bool supports_angle_d3d = false; | 582 bool supports_angle_d3d = false; |
572 bool supports_angle_opengl = false; | 583 bool supports_angle_opengl = false; |
573 // Check for availability of ANGLE extensions. | 584 // Check for availability of ANGLE extensions. |
574 if (client_extensions && | 585 if (client_extensions && |
575 ExtensionsContain(client_extensions, "EGL_ANGLE_platform_angle")) { | 586 ExtensionsContain(client_extensions, "EGL_ANGLE_platform_angle")) { |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 } | 1136 } |
1126 | 1137 |
1127 void* SurfacelessEGL::GetShareHandle() { | 1138 void* SurfacelessEGL::GetShareHandle() { |
1128 return NULL; | 1139 return NULL; |
1129 } | 1140 } |
1130 | 1141 |
1131 SurfacelessEGL::~SurfacelessEGL() { | 1142 SurfacelessEGL::~SurfacelessEGL() { |
1132 } | 1143 } |
1133 | 1144 |
1134 } // namespace gl | 1145 } // namespace gl |
OLD | NEW |