summaryrefslogtreecommitdiffstats
path: root/app/gfx/gl/gl_context_linux.cc
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 23:19:16 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 23:19:16 +0000
commit1c0585d585bc9f88ee177553b66e0025d7fe3aa0 (patch)
treedcce9c6dcbe4634483104b236a87e42d694bbeb1 /app/gfx/gl/gl_context_linux.cc
parentfd3a7df6c4caaeceb8402daa2c1b357c7f78331f (diff)
downloadchromium_src-1c0585d585bc9f88ee177553b66e0025d7fe3aa0.zip
chromium_src-1c0585d585bc9f88ee177553b66e0025d7fe3aa0.tar.gz
chromium_src-1c0585d585bc9f88ee177553b66e0025d7fe3aa0.tar.bz2
Added switch to disable GPU vsync.
This is useful for GPU performance testing because the vsync caps the frame rate. TEST=try BUG=none Review URL: http://codereview.chromium.org/3380011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61877 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx/gl/gl_context_linux.cc')
-rw-r--r--app/gfx/gl/gl_context_linux.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/app/gfx/gl/gl_context_linux.cc b/app/gfx/gl/gl_context_linux.cc
index 48f0368..2301e9e 100644
--- a/app/gfx/gl/gl_context_linux.cc
+++ b/app/gfx/gl/gl_context_linux.cc
@@ -23,6 +23,11 @@ namespace gfx {
typedef GLXContext GLContextHandle;
typedef GLXPbuffer PbufferHandle;
+class BaseLinuxGLContext : public GLContext {
+ public:
+ virtual std::string GetExtensions();
+};
+
// This class is a wrapper around a GL context that renders directly to a
// window.
class ViewGLContext : public GLContext {
@@ -43,6 +48,7 @@ class ViewGLContext : public GLContext {
virtual bool SwapBuffers();
virtual gfx::Size GetSize();
virtual void* GetHandle();
+ virtual void SetSwapInterval(int interval);
private:
gfx::PluginWindowHandle window_;
@@ -73,6 +79,7 @@ class OSMesaViewGLContext : public GLContext {
virtual bool SwapBuffers();
virtual gfx::Size GetSize();
virtual void* GetHandle();
+ virtual void SetSwapInterval(int interval);
private:
bool UpdateSize();
@@ -106,6 +113,7 @@ class PbufferGLContext : public GLContext {
virtual bool SwapBuffers();
virtual gfx::Size GetSize();
virtual void* GetHandle();
+ virtual void SetSwapInterval(int interval);
private:
GLContextHandle context_;
@@ -133,6 +141,7 @@ class PixmapGLContext : public GLContext {
virtual bool SwapBuffers();
virtual gfx::Size GetSize();
virtual void* GetHandle();
+ virtual void SetSwapInterval(int interval);
private:
GLContextHandle context_;
@@ -201,6 +210,16 @@ bool GLContext::InitializeOneOff() {
return true;
}
+std::string BaseLinuxGLContext::GetExtensions() {
+ Display* display = x11_util::GetXDisplay();
+ const char* extensions = glXQueryExtensionsString(display, 0);
+ if (extensions) {
+ return GLContext::GetExtensions() + " " + extensions;
+ }
+
+ return GLContext::GetExtensions();
+}
+
bool ViewGLContext::Initialize(bool multisampled) {
if (multisampled) {
LOG(WARNING) << "Multisampling not implemented.";
@@ -300,6 +319,14 @@ void* ViewGLContext::GetHandle() {
return context_;
}
+void ViewGLContext::SetSwapInterval(int interval) {
+ DCHECK(IsCurrent());
+ if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) {
+ Display* display = x11_util::GetXDisplay();
+ glXSwapIntervalEXT(display, window_, interval);
+ }
+}
+
bool OSMesaViewGLContext::Initialize() {
if (!osmesa_context_.Initialize(OSMESA_BGRA, NULL)) {
LOG(ERROR) << "OSMesaGLContext::Initialize failed.";
@@ -403,6 +430,12 @@ void* OSMesaViewGLContext::GetHandle() {
return osmesa_context_.GetHandle();
}
+void OSMesaViewGLContext::SetSwapInterval(int interval) {
+ DCHECK(IsCurrent());
+ // Fail silently. It is legitimate to set the swap interval on a view context
+ // but XLib does not have those semantics.
+}
+
bool OSMesaViewGLContext::UpdateSize() {
// Get the window size.
XWindowAttributes attributes;
@@ -610,6 +643,11 @@ void* PbufferGLContext::GetHandle() {
return context_;
}
+void PbufferGLContext::SetSwapInterval(int interval) {
+ DCHECK(IsCurrent());
+ NOTREACHED();
+}
+
bool PixmapGLContext::Initialize(GLContext* shared_context) {
LOG(INFO) << "GL context: using pixmaps.";
@@ -728,6 +766,11 @@ void* PixmapGLContext::GetHandle() {
return context_;
}
+void PixmapGLContext::SetSwapInterval(int interval) {
+ DCHECK(IsCurrent());
+ NOTREACHED();
+}
+
GLContext* GLContext::CreateOffscreenGLContext(GLContext* shared_context) {
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: {