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

Unified Diff: ui/gfx/gl/gl_surface_egl.cc

Issue 8873018: Less X connections. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Two less statics. Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/gl/gl_surface_glx.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | ui/gfx/gl/gl_surface_glx.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698