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

Unified Diff: app/gfx/gl/gl_context_linux.cc

Issue 6041002: Implicitly detect the use of --in-process-webgl by the absence of a... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/gfx/gl/gl_context_linux.cc
===================================================================
--- app/gfx/gl/gl_context_linux.cc (revision 69765)
+++ app/gfx/gl/gl_context_linux.cc (working copy)
@@ -6,6 +6,10 @@
#include "app/gfx/gl/gl_context.h"
+extern "C" {
+#include <X11/Xlib.h>
+}
+
#include <GL/osmesa.h>
#include "app/gfx/gl/gl_bindings.h"
@@ -18,6 +22,23 @@
#include "base/logging.h"
#include "base/scoped_ptr.h"
+namespace {
+
+Display* GetXDisplayHelper() {
+ static Display* display = NULL;
greggman 2010/12/21 22:47:01 I'll assume this works with multiple display, as i
Ken Russell (switch to Gerrit) 2010/12/21 22:49:59 Not sure. It'll work as well as x11_util::GetXDisp
+
+ if (!display) {
+ if (x11_util::XDisplayExists()) {
+ display = x11_util::GetXDisplay();
+ } else {
+ display = XOpenDisplay(NULL);
+ }
+ }
+ return display;
+}
+
+}
+
namespace gfx {
typedef GLXContext GLContextHandle;
@@ -183,7 +204,7 @@
case kGLImplementationDesktopGL: {
// Only check the GLX version if we are in fact using GLX. We might
// actually be using the mock GL implementation.
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
int major, minor;
if (!glXQueryVersion(display, &major, &minor)) {
LOG(ERROR) << "glxQueryVersion failed";
@@ -211,7 +232,7 @@
}
std::string BaseLinuxGLContext::GetExtensions() {
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
const char* extensions = glXQueryExtensionsString(display, 0);
if (extensions) {
return GLContext::GetExtensions() + " " + extensions;
@@ -225,7 +246,7 @@
LOG(WARNING) << "Multisampling not implemented.";
}
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
XWindowAttributes attributes;
XGetWindowAttributes(display, window_, &attributes);
XVisualInfo visual_info_template;
@@ -264,7 +285,7 @@
}
void ViewGLContext::Destroy() {
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
bool result = glXMakeCurrent(display, 0, 0);
// glXMakeCurrent isn't supposed to fail when unsetting the context, unless
@@ -282,7 +303,7 @@
return true;
}
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
if (glXMakeCurrent(display, window_, context_) != True) {
glXDestroyContext(display, context_);
context_ = 0;
@@ -303,14 +324,14 @@
}
bool ViewGLContext::SwapBuffers() {
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
glXSwapBuffers(display, window_);
return true;
}
gfx::Size ViewGLContext::GetSize() {
XWindowAttributes attributes;
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
XGetWindowAttributes(display, window_, &attributes);
return gfx::Size(attributes.width, attributes.height);
}
@@ -322,7 +343,7 @@
void ViewGLContext::SetSwapInterval(int interval) {
DCHECK(IsCurrent());
if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) {
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
glXSwapIntervalEXT(display, window_, interval);
}
}
@@ -334,7 +355,7 @@
return false;
}
- window_graphics_context_ = XCreateGC(x11_util::GetXDisplay(),
+ window_graphics_context_ = XCreateGC(GetXDisplayHelper(),
window_,
0,
NULL);
@@ -352,7 +373,7 @@
void OSMesaViewGLContext::Destroy() {
osmesa_context_.Destroy();
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
if (pixmap_graphics_context_) {
XFreeGC(display, pixmap_graphics_context_);
@@ -396,7 +417,7 @@
gfx::Size size = osmesa_context_.GetSize();
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
// Copy the frame into the pixmap.
XWindowAttributes attributes;
@@ -439,7 +460,7 @@
bool OSMesaViewGLContext::UpdateSize() {
// Get the window size.
XWindowAttributes attributes;
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
XGetWindowAttributes(display, window_, &attributes);
gfx::Size window_size = gfx::Size(std::max(1, attributes.width),
std::max(1, attributes.height));
@@ -529,7 +550,7 @@
0
};
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
int nelements = 0;
// TODO(kbr): figure out whether hardcoding screen to 0 is sufficient.
@@ -588,7 +609,7 @@
}
void PbufferGLContext::Destroy() {
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
bool result = glXMakeCurrent(display, 0, 0);
// glXMakeCurrent isn't supposed to fail when unsetting the context, unless
// we have pending draws on an invalid window - which shouldn't be the case
@@ -609,7 +630,7 @@
if (IsCurrent()) {
return true;
}
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
if (glXMakeCurrent(display, pbuffer_, context_) != True) {
glXDestroyContext(display, context_);
context_ = NULL;
@@ -656,7 +677,7 @@
0
};
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
int screen = DefaultScreen(display);
scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> visual_info(
@@ -706,7 +727,7 @@
}
void PixmapGLContext::Destroy() {
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
bool result = glXMakeCurrent(display, 0, 0);
// glXMakeCurrent isn't supposed to fail when unsetting the context, unless
// we have pending draws on an invalid window - which shouldn't be the case
@@ -732,7 +753,7 @@
if (IsCurrent()) {
return true;
}
- Display* display = x11_util::GetXDisplay();
+ Display* display = GetXDisplayHelper();
if (glXMakeCurrent(display, glx_pixmap_, context_) != True) {
glXDestroyContext(display, context_);
context_ = NULL;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698