Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: ui/gl/gl_surface_egl.cc

Issue 2697463003: gpu: Update ANGLE Platform integration. (Closed)
Patch Set: Fix crash in Reset Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/angle_platform_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const char* g_egl_extensions = nullptr; 129 const char* g_egl_extensions = nullptr;
130 bool g_egl_create_context_robustness_supported = false; 130 bool g_egl_create_context_robustness_supported = false;
131 bool g_egl_create_context_bind_generates_resource_supported = false; 131 bool g_egl_create_context_bind_generates_resource_supported = false;
132 bool g_egl_create_context_webgl_compatability_supported = false; 132 bool g_egl_create_context_webgl_compatability_supported = false;
133 bool g_egl_sync_control_supported = false; 133 bool g_egl_sync_control_supported = false;
134 bool g_egl_window_fixed_size_supported = false; 134 bool g_egl_window_fixed_size_supported = false;
135 bool g_egl_surfaceless_context_supported = false; 135 bool g_egl_surfaceless_context_supported = false;
136 bool g_egl_surface_orientation_supported = false; 136 bool g_egl_surface_orientation_supported = false;
137 bool g_use_direct_composition = false; 137 bool g_use_direct_composition = false;
138 138
139 base::LazyInstance<ANGLEPlatformImpl> g_angle_platform_impl =
140 LAZY_INSTANCE_INITIALIZER;
141 ANGLEPlatformShutdownFunc g_angle_platform_shutdown = nullptr;
142
143 EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display, 139 EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display,
144 EGLenum platform_type, 140 EGLenum platform_type,
145 bool warpDevice) { 141 bool warpDevice) {
146 std::vector<EGLint> display_attribs; 142 std::vector<EGLint> display_attribs;
147 143
148 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); 144 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
149 display_attribs.push_back(platform_type); 145 display_attribs.push_back(platform_type);
150 146
151 if (warpDevice) { 147 if (warpDevice) {
152 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); 148 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE);
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 538 }
543 } 539 }
544 #endif 540 #endif
545 initialized_ = true; 541 initialized_ = true;
546 542
547 return true; 543 return true;
548 } 544 }
549 545
550 // static 546 // static
551 void GLSurfaceEGL::ShutdownOneOff() { 547 void GLSurfaceEGL::ShutdownOneOff() {
552 if (g_angle_platform_shutdown) { 548 ResetANGLEPlatform(g_display);
553 g_angle_platform_shutdown();
554 }
555 549
556 if (g_display != EGL_NO_DISPLAY) 550 if (g_display != EGL_NO_DISPLAY)
557 eglTerminate(g_display); 551 eglTerminate(g_display);
558 g_display = EGL_NO_DISPLAY; 552 g_display = EGL_NO_DISPLAY;
559 553
560 g_egl_extensions = nullptr; 554 g_egl_extensions = nullptr;
561 g_egl_create_context_robustness_supported = false; 555 g_egl_create_context_robustness_supported = false;
562 g_egl_create_context_bind_generates_resource_supported = false; 556 g_egl_create_context_bind_generates_resource_supported = false;
563 g_egl_create_context_webgl_compatability_supported = false; 557 g_egl_create_context_webgl_compatability_supported = false;
564 g_egl_sync_control_supported = false; 558 g_egl_sync_control_supported = false;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 // needs a full Display init before it can query the Display extensions. 613 // needs a full Display init before it can query the Display extensions.
620 // static 614 // static
621 EGLDisplay GLSurfaceEGL::InitializeDisplay( 615 EGLDisplay GLSurfaceEGL::InitializeDisplay(
622 EGLNativeDisplayType native_display) { 616 EGLNativeDisplayType native_display) {
623 if (g_display != EGL_NO_DISPLAY) { 617 if (g_display != EGL_NO_DISPLAY) {
624 return g_display; 618 return g_display;
625 } 619 }
626 620
627 g_native_display = native_display; 621 g_native_display = native_display;
628 622
629 // Init ANGLE platform here, before we call GetPlatformDisplay().
630 ANGLEPlatformInitializeFunc angle_platform_init =
631 reinterpret_cast<ANGLEPlatformInitializeFunc>(
632 eglGetProcAddress("ANGLEPlatformInitialize"));
633 if (angle_platform_init) {
634 angle_platform_init(&g_angle_platform_impl.Get());
635
636 g_angle_platform_shutdown = reinterpret_cast<ANGLEPlatformShutdownFunc>(
637 eglGetProcAddress("ANGLEPlatformShutdown"));
638 }
639
640 // If EGL_EXT_client_extensions not supported this call to eglQueryString 623 // If EGL_EXT_client_extensions not supported this call to eglQueryString
641 // will return NULL. 624 // will return NULL.
642 const char* client_extensions = 625 const char* client_extensions =
643 eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); 626 eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
644 627
645 bool supports_angle_d3d = false; 628 bool supports_angle_d3d = false;
646 bool supports_angle_opengl = false; 629 bool supports_angle_opengl = false;
647 bool supports_angle_null = false; 630 bool supports_angle_null = false;
648 // Check for availability of ANGLE extensions. 631 // Check for availability of ANGLE extensions.
649 if (client_extensions && 632 if (client_extensions &&
(...skipping 13 matching lines...) Expand all
663 646
664 for (size_t disp_index = 0; disp_index < init_displays.size(); ++disp_index) { 647 for (size_t disp_index = 0; disp_index < init_displays.size(); ++disp_index) {
665 DisplayType display_type = init_displays[disp_index]; 648 DisplayType display_type = init_displays[disp_index];
666 EGLDisplay display = 649 EGLDisplay display =
667 GetDisplayFromType(display_type, g_native_display); 650 GetDisplayFromType(display_type, g_native_display);
668 if (display == EGL_NO_DISPLAY) { 651 if (display == EGL_NO_DISPLAY) {
669 LOG(ERROR) << "EGL display query failed with error " 652 LOG(ERROR) << "EGL display query failed with error "
670 << GetLastEGLErrorString(); 653 << GetLastEGLErrorString();
671 } 654 }
672 655
656 // Init ANGLE platform now that we have the global display.
657 if (!InitializeANGLEPlatform(display)) {
658 LOG(ERROR) << "ANGLE Platform initialization failed.";
659 }
660
673 if (!eglInitialize(display, nullptr, nullptr)) { 661 if (!eglInitialize(display, nullptr, nullptr)) {
674 bool is_last = disp_index == init_displays.size() - 1; 662 bool is_last = disp_index == init_displays.size() - 1;
675 663
676 LOG(ERROR) << "eglInitialize " << DisplayTypeString(display_type) 664 LOG(ERROR) << "eglInitialize " << DisplayTypeString(display_type)
677 << " failed with error " << GetLastEGLErrorString() 665 << " failed with error " << GetLastEGLErrorString()
678 << (is_last ? "" : ", trying next display type"); 666 << (is_last ? "" : ", trying next display type");
679 } else { 667 } else {
680 UMA_HISTOGRAM_ENUMERATION("GPU.EGLDisplayType", display_type, 668 UMA_HISTOGRAM_ENUMERATION("GPU.EGLDisplayType", display_type,
681 DISPLAY_TYPE_MAX); 669 DISPLAY_TYPE_MAX);
682 g_display = display; 670 g_display = display;
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 } 1216 }
1229 1217
1230 void* SurfacelessEGL::GetShareHandle() { 1218 void* SurfacelessEGL::GetShareHandle() {
1231 return NULL; 1219 return NULL;
1232 } 1220 }
1233 1221
1234 SurfacelessEGL::~SurfacelessEGL() { 1222 SurfacelessEGL::~SurfacelessEGL() {
1235 } 1223 }
1236 1224
1237 } // namespace gl 1225 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/angle_platform_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698