| 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..62e6c250f77ffc9803c6da1775da756207a46fbe 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() {
|
| - return g_native_display;
|
| +#if defined(USE_WAYLAND)
|
| + static EGLNativeDisplayType native_display = NULL;
|
| + if (!native_display)
|
| + native_display = ui::WaylandDisplay::Connect(NULL)->display();
|
| + return native_display;
|
| +#elif defined(USE_X11)
|
| + return ui::GetXDisplay();
|
| +#else
|
| + return EGL_DEFAULT_DISPLAY;
|
| +#endif
|
| }
|
|
|
| NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software,
|
|
|