Index: ui/gfx/gl/gl_surface_glx.cc |
diff --git a/ui/gfx/gl/gl_surface_glx.cc b/ui/gfx/gl/gl_surface_glx.cc |
index 3b8cbe9a789d1071ce9886171c4eedd9c0f7531d..89fd8a36452ea06fe86957ca63a08ff7d96ec703 100644 |
--- a/ui/gfx/gl/gl_surface_glx.cc |
+++ b/ui/gfx/gl/gl_surface_glx.cc |
@@ -31,7 +31,6 @@ class ScopedPtrXFree { |
} |
}; |
-Display* g_display; |
const char* g_glx_extensions = NULL; |
bool g_glx_create_context_robustness_supported = false; |
@@ -48,14 +47,13 @@ bool GLSurfaceGLX::InitializeOneOff() { |
if (initialized) |
return true; |
- g_display = XOpenDisplay(NULL); |
- if (!g_display) { |
+ if (!ui::GetXDisplay()) { |
LOG(ERROR) << "XOpenDisplay failed."; |
return false; |
} |
int major, minor; |
- if (!glXQueryVersion(g_display, &major, &minor)) { |
+ if (!glXQueryVersion(ui::GetXDisplay(), &major, &minor)) { |
LOG(ERROR) << "glxQueryVersion failed"; |
return false; |
} |
@@ -65,7 +63,7 @@ bool GLSurfaceGLX::InitializeOneOff() { |
return false; |
} |
- g_glx_extensions = glXQueryExtensionsString(g_display, 0); |
+ g_glx_extensions = glXQueryExtensionsString(ui::GetXDisplay(), 0); |
g_glx_create_context_robustness_supported = |
HasGLXExtension("GLX_ARB_create_context_robustness"); |
@@ -99,7 +97,7 @@ bool GLSurfaceGLX::IsCreateContextRobustnessSupported() { |
} |
void* GLSurfaceGLX::GetDisplay() { |
- return g_display; |
+ return ui::GetXDisplay(); |
} |
NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX(gfx::PluginWindowHandle window) |
@@ -128,13 +126,13 @@ bool NativeViewGLSurfaceGLX::IsOffscreen() { |
} |
bool NativeViewGLSurfaceGLX::SwapBuffers() { |
- glXSwapBuffers(g_display, window_); |
+ glXSwapBuffers(ui::GetXDisplay(), window_); |
return true; |
} |
gfx::Size NativeViewGLSurfaceGLX::GetSize() { |
XWindowAttributes attributes; |
- if (!XGetWindowAttributes(g_display, window_, &attributes)) { |
+ if (!XGetWindowAttributes(ui::GetXDisplay(), window_, &attributes)) { |
LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; |
return gfx::Size(); |
} |
@@ -170,7 +168,7 @@ void* NativeViewGLSurfaceGLX::GetConfig() { |
XWindowAttributes attributes; |
if (!XGetWindowAttributes( |
- g_display, |
+ ui::GetXDisplay(), |
reinterpret_cast<GLXDrawable>(GetHandle()), |
&attributes)) { |
LOG(ERROR) << "XGetWindowAttributes failed for window " << |
@@ -182,8 +180,8 @@ void* NativeViewGLSurfaceGLX::GetConfig() { |
int num_elements = 0; |
scoped_ptr_malloc<GLXFBConfig, ScopedPtrXFree> configs( |
- glXGetFBConfigs(g_display, |
- DefaultScreen(g_display), |
+ glXGetFBConfigs(ui::GetXDisplay(), |
+ DefaultScreen(ui::GetXDisplay()), |
&num_elements)); |
if (!configs.get()) { |
LOG(ERROR) << "glXGetFBConfigs failed."; |
@@ -198,7 +196,7 @@ void* NativeViewGLSurfaceGLX::GetConfig() { |
for (i = 0; i < num_elements; ++i) { |
int value; |
if (glXGetFBConfigAttrib( |
- g_display, configs.get()[i], GLX_VISUAL_ID, &value)) { |
+ ui::GetXDisplay(), configs.get()[i], GLX_VISUAL_ID, &value)) { |
LOG(ERROR) << "glXGetFBConfigAttrib failed."; |
return NULL; |
} |
@@ -218,7 +216,7 @@ void* NativeViewGLSurfaceGLX::GetConfig() { |
bool NativeViewGLSurfaceGLX::PostSubBuffer( |
int x, int y, int width, int height) { |
DCHECK(g_GLX_MESA_copy_sub_buffer); |
- glXCopySubBufferMESA(g_display, window_, x, y, width, height); |
+ glXCopySubBufferMESA(ui::GetXDisplay(), window_, x, y, width, height); |
return true; |
} |
@@ -249,8 +247,8 @@ bool PbufferGLSurfaceGLX::Initialize() { |
int num_elements = 0; |
scoped_ptr_malloc<GLXFBConfig, ScopedPtrXFree> configs( |
- glXChooseFBConfig(g_display, |
- DefaultScreen(g_display), |
+ glXChooseFBConfig(ui::GetXDisplay(), |
+ DefaultScreen(ui::GetXDisplay()), |
config_attributes, |
&num_elements)); |
if (!configs.get()) { |
@@ -269,7 +267,7 @@ bool PbufferGLSurfaceGLX::Initialize() { |
GLX_PBUFFER_HEIGHT, size_.height(), |
0 |
}; |
- pbuffer_ = glXCreatePbuffer(g_display, |
+ pbuffer_ = glXCreatePbuffer(ui::GetXDisplay(), |
static_cast<GLXFBConfig>(config_), |
pbuffer_attributes); |
if (!pbuffer_) { |
@@ -283,7 +281,7 @@ bool PbufferGLSurfaceGLX::Initialize() { |
void PbufferGLSurfaceGLX::Destroy() { |
if (pbuffer_) { |
- glXDestroyPbuffer(g_display, pbuffer_); |
+ glXDestroyPbuffer(ui::GetXDisplay(), pbuffer_); |
pbuffer_ = 0; |
} |