Chromium Code Reviews| Index: ui/gfx/gl/gl_surface_egl.cc |
| diff --git a/ui/gfx/gl/gl_surface_egl.cc b/ui/gfx/gl/gl_surface_egl.cc |
| index f1d075048a45d2c5f97cb92cea7d668af3fd2b78..d6aec38a2a4787dd3b2c30190226b0c10723a5a0 100644 |
| --- a/ui/gfx/gl/gl_surface_egl.cc |
| +++ b/ui/gfx/gl/gl_surface_egl.cc |
| @@ -25,6 +25,7 @@ |
| extern "C" { |
| #include <X11/Xlib.h> |
| } |
| +#include "ui/base/x/x11_util.h" |
| #endif |
| #if defined(USE_WAYLAND) |
| @@ -36,7 +37,6 @@ namespace gfx { |
| namespace { |
| EGLConfig g_config; |
| EGLDisplay g_display; |
| -EGLNativeDisplayType g_native_display; |
| EGLConfig g_software_config; |
| EGLDisplay g_software_display; |
| EGLNativeDisplayType g_software_native_display; |
| @@ -48,19 +48,13 @@ GLSurfaceEGL::GLSurfaceEGL() : software_(false) { |
| GLSurfaceEGL::~GLSurfaceEGL() { |
| } |
| +// static |
| bool GLSurfaceEGL::InitializeOneOff() { |
| static bool initialized = false; |
| if (initialized) |
| return true; |
| -#if defined(USE_WAYLAND) |
| - g_native_display = ui::WaylandDisplay::Connect(NULL)->display(); |
| -#elif defined(USE_X11) |
| - g_native_display = XOpenDisplay(NULL); |
| -#else |
| - g_native_display = EGL_DEFAULT_DISPLAY; |
| -#endif |
| - g_display = eglGetDisplay(g_native_display); |
| + g_display = eglGetDisplay(GetNativeDisplay()); |
| if (!g_display) { |
| LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); |
| return false; |
| @@ -164,16 +158,28 @@ EGLConfig GLSurfaceEGL::GetConfig() { |
| return software_ ? g_software_config : g_config; |
| } |
| +// static |
| EGLDisplay GLSurfaceEGL::GetHardwareDisplay() { |
| return g_display; |
| } |
| +// static |
| EGLDisplay GLSurfaceEGL::GetSoftwareDisplay() { |
| return g_software_display; |
| } |
| +// static |
| EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { |
| +#if defined(USE_WAYLAND) |
| + static EGLNativeDisplayType g_native_display = NULL; |
|
apatrick_chromium
2011/12/08 20:16:24
nit: drop the g_ for a local variable.
|
| + if (!g_native_display) |
| + g_native_display = ui::WaylandDisplay::Connect(NULL)->display(); |
| return g_native_display; |
| +#elif defined(USE_X11) |
| + return ui::GetXDisplay(); |
| +#else |
| + return EGL_DEFAULT_DISPLAY; |
| +#endif |
| } |
| NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, |