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

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

Issue 8873018: Less X connections. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments. 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 | « ui/gfx/gl/gl_surface_egl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « ui/gfx/gl/gl_surface_egl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698