Index: ui/gl/gl_surface_egl.cc |
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc |
index 2e193a5d5dc2e2fcff8043065594bee13300930c..f85258ff8b876e276aed88706849a1a179131e0a 100644 |
--- a/ui/gl/gl_surface_egl.cc |
+++ b/ui/gl/gl_surface_egl.cc |
@@ -85,16 +85,7 @@ namespace { |
EGLConfig g_config; |
EGLDisplay g_display; |
-EGLNativeDisplayType g_native_display_type; |
- |
-// In the Cast environment, we need to destroy the EGLNativeDisplayType and |
-// EGLDisplay returned by the GPU platform when we switch to an external app |
-// which will temporarily own all screen and GPU resources. |
-// Even though Chromium is still in the background. |
-// As such, it must be reinitialized each time we come back to the foreground. |
-bool g_initialized = false; |
-int g_num_surfaces = 0; |
-bool g_terminate_pending = false; |
+EGLNativeDisplayType g_native_display; |
const char* g_egl_extensions = NULL; |
bool g_egl_create_context_robustness_supported = false; |
@@ -138,13 +129,6 @@ class EGLSyncControlVSyncProvider |
DISALLOW_COPY_AND_ASSIGN(EGLSyncControlVSyncProvider); |
}; |
-void DeinitializeEgl() { |
- if (g_initialized) { |
- g_initialized = false; |
- eglTerminate(g_display); |
- } |
-} |
- |
EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display, |
EGLenum platform_type, |
bool warpDevice) { |
@@ -270,17 +254,11 @@ void GetEGLInitDisplays(bool supports_angle_d3d, |
} |
} |
-GLSurfaceEGL::GLSurfaceEGL() { |
- ++g_num_surfaces; |
- if (!g_initialized) { |
- bool result = GLSurfaceEGL::InitializeOneOff(); |
- DCHECK(result); |
- DCHECK(g_initialized); |
- } |
-} |
+GLSurfaceEGL::GLSurfaceEGL() {} |
bool GLSurfaceEGL::InitializeOneOff() { |
- if (g_initialized) |
+ static bool initialized = false; |
+ if (initialized) |
return true; |
InitializeDisplay(); |
@@ -347,12 +325,6 @@ bool GLSurfaceEGL::InitializeOneOff() { |
g_egl_window_fixed_size_supported = |
HasEGLExtension("EGL_ANGLE_window_fixed_size"); |
- // We always succeed beyond this point so set g_initialized here to avoid |
- // infinite recursion through CreateGLContext and GetDisplay |
- // if g_egl_surfaceless_context_supported. |
- g_initialized = true; |
- g_terminate_pending = false; |
- |
// TODO(oetuaho@nvidia.com): Surfaceless is disabled on Android as a temporary |
// workaround, since code written for Android WebView takes different paths |
// based on whether GL surface objects have underlying EGL surface handles, |
@@ -382,35 +354,24 @@ bool GLSurfaceEGL::InitializeOneOff() { |
} |
#endif |
+ initialized = true; |
+ |
return true; |
} |
EGLDisplay GLSurfaceEGL::GetDisplay() { |
- DCHECK(g_initialized); |
return g_display; |
} |
-// static |
EGLDisplay GLSurfaceEGL::GetHardwareDisplay() { |
- if (!g_initialized) { |
- bool result = GLSurfaceEGL::InitializeOneOff(); |
- DCHECK(result); |
- } |
return g_display; |
} |
-// static |
EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { |
- if (!g_initialized) { |
- bool result = GLSurfaceEGL::InitializeOneOff(); |
- DCHECK(result); |
- } |
- return g_native_display_type; |
+ return g_native_display; |
} |
const char* GLSurfaceEGL::GetEGLExtensions() { |
- // No need for InitializeOneOff. Assume that extensions will not change |
- // after the first initialization. |
return g_egl_extensions; |
} |
@@ -426,20 +387,7 @@ bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() { |
return g_egl_surfaceless_context_supported; |
} |
-void GLSurfaceEGL::DestroyAndTerminateDisplay() { |
- DCHECK(g_initialized); |
- DCHECK_EQ(g_num_surfaces, 1); |
- Destroy(); |
- g_terminate_pending = true; |
-} |
- |
-GLSurfaceEGL::~GLSurfaceEGL() { |
- DCHECK_GT(g_num_surfaces, 0) << "Bad surface count"; |
- if (--g_num_surfaces == 0 && g_terminate_pending) { |
- DeinitializeEgl(); |
- g_terminate_pending = false; |
- } |
-} |
+GLSurfaceEGL::~GLSurfaceEGL() {} |
// InitializeDisplay is necessary because the static binding code |
// needs a full Display init before it can query the Display extensions. |
@@ -449,7 +397,7 @@ EGLDisplay GLSurfaceEGL::InitializeDisplay() { |
return g_display; |
} |
- g_native_display_type = GetPlatformDefaultEGLNativeDisplay(); |
+ g_native_display = GetPlatformDefaultEGLNativeDisplay(); |
// If EGL_EXT_client_extensions not supported this call to eglQueryString |
// will return NULL. |
@@ -474,7 +422,7 @@ EGLDisplay GLSurfaceEGL::InitializeDisplay() { |
for (size_t disp_index = 0; disp_index < init_displays.size(); ++disp_index) { |
DisplayType display_type = init_displays[disp_index]; |
EGLDisplay display = |
- GetDisplayFromType(display_type, g_native_display_type); |
+ GetDisplayFromType(display_type, g_native_display); |
if (display == EGL_NO_DISPLAY) { |
LOG(ERROR) << "EGL display query failed with error " |
<< GetLastEGLErrorString(); |