diff options
author | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 14:15:28 +0000 |
---|---|---|
committer | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 14:15:28 +0000 |
commit | 1c75a370ce5ea49e230cae711a0b1d17dc072763 (patch) | |
tree | b3612370e93b34c7ce4d631cf22cafb4d71329ea /ui/gfx | |
parent | 9e814828186b00d3ead0edd3884e3185067875d5 (diff) | |
download | chromium_src-1c75a370ce5ea49e230cae711a0b1d17dc072763.zip chromium_src-1c75a370ce5ea49e230cae711a0b1d17dc072763.tar.gz chromium_src-1c75a370ce5ea49e230cae711a0b1d17dc072763.tar.bz2 |
Plumb through EGL_NV_post_sub_buffer and GLX_MESA_copy_sub_buffer.
These two extensions allow a partial swap: just pushing part of the backbuffer to the front buffer. This will allow the WK compositor to push a partial update to the screen instead of a full frame update (https://bugs.webkit.org/show_bug.cgi?id=70533).
We should be able to do something similar for TOUCHUI ImageTransportSurfaces (hence the hooks into GLSurface and the glPostSubBufferCHROMIUM command).
Review URL: http://codereview.chromium.org/8512005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r-- | ui/gfx/gl/generate_bindings.py | 6 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface.cc | 8 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface.h | 4 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_egl.cc | 34 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_egl.h | 5 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_glx.cc | 11 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_glx.h | 2 |
7 files changed, 67 insertions, 3 deletions
diff --git a/ui/gfx/gl/generate_bindings.py b/ui/gfx/gl/generate_bindings.py index 2e1a1e0..4207533 100644 --- a/ui/gfx/gl/generate_bindings.py +++ b/ui/gfx/gl/generate_bindings.py @@ -363,6 +363,9 @@ EGL_FUNCTIONS = [ 'EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target'], ['__eglMustCastToProperFunctionPointerType', ['eglGetProcAddress'], 'const char* procname'], +['EGLBoolean', ['eglPostSubBufferNV'], + 'EGLDisplay dpy, EGLSurface surface, ' + 'EGLint x, EGLint y, EGLint width, EGLint height'], ['EGLBoolean', ['eglQuerySurfacePointerANGLE'], 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value'], ] @@ -396,6 +399,9 @@ WGL_FUNCTIONS = [ GLX_FUNCTIONS = [ ['XVisualInfo*', ['glXChooseVisual'], 'Display* dpy, int screen, int* attribList'], +['void', ['glXCopySubBufferMESA'], + 'Display* dpy, GLXDrawable drawable, ' + 'int x, int y, int width, int height'], ['GLXContext', ['glXCreateContext'], 'Display* dpy, XVisualInfo* vis, GLXContext shareList, int direct'], ['void', ['glXBindTexImageEXT'], diff --git a/ui/gfx/gl/gl_surface.cc b/ui/gfx/gl/gl_surface.cc index 34d4464..78cada4 100644 --- a/ui/gfx/gl/gl_surface.cc +++ b/ui/gfx/gl/gl_surface.cc @@ -94,6 +94,14 @@ unsigned int GLSurface::GetBackingFrameBufferObject() { return 0; } +bool GLSurface::SupportsPostSubBuffer() { + return false; +} + +bool GLSurface::PostSubBuffer(int x, int y, int width, int height) { + return false; +} + bool GLSurface::OnMakeCurrent(GLContext* context) { return true; } diff --git a/ui/gfx/gl/gl_surface.h b/ui/gfx/gl/gl_surface.h index 5843a9c..150182e 100644 --- a/ui/gfx/gl/gl_surface.h +++ b/ui/gfx/gl/gl_surface.h @@ -50,6 +50,10 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { // FBO. Otherwise returns 0. virtual unsigned int GetBackingFrameBufferObject(); + // Copy part of the backbuffer to the frontbuffer. + virtual bool SupportsPostSubBuffer(); + virtual bool PostSubBuffer(int x, int y, int width, int height); + static bool InitializeOneOff(); // Called after a context is made current with this surface. Returns false diff --git a/ui/gfx/gl/gl_surface_egl.cc b/ui/gfx/gl/gl_surface_egl.cc index 6f6d630..8301bc4 100644 --- a/ui/gfx/gl/gl_surface_egl.cc +++ b/ui/gfx/gl/gl_surface_egl.cc @@ -173,7 +173,8 @@ EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, gfx::PluginWindowHandle window) : window_(window), - surface_(NULL) + surface_(NULL), + supports_post_sub_buffer_(false) { software_ = software; } @@ -190,11 +191,18 @@ bool NativeViewGLSurfaceEGL::Initialize() { return false; } + static const EGLint egl_window_attributes_sub_buffer[] = { + EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE, + EGL_NONE + }; + // Create a surface for the native window. surface_ = eglCreateWindowSurface(GetDisplay(), GetConfig(), window_, - NULL); + gfx::g_EGL_NV_post_sub_buffer ? + egl_window_attributes_sub_buffer : + NULL); if (!surface_) { LOG(ERROR) << "eglCreateWindowSurface failed with error " @@ -203,6 +211,13 @@ bool NativeViewGLSurfaceEGL::Initialize() { return false; } + EGLint surfaceVal; + EGLBoolean retVal = eglQuerySurface(GetDisplay(), + surface_, + EGL_POST_SUB_BUFFER_SUPPORTED_NV, + &surfaceVal); + supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; + return true; } @@ -247,6 +262,21 @@ EGLSurface NativeViewGLSurfaceEGL::GetHandle() { return surface_; } +bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { + return supports_post_sub_buffer_; +} + +bool NativeViewGLSurfaceEGL::PostSubBuffer( + int x, int y, int width, int height) { + DCHECK(supports_post_sub_buffer_); + if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) { + VLOG(1) << "eglPostSubBufferNV failed with error " + << GetLastEGLErrorString(); + return false; + } + return true; +} + PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(bool software, const gfx::Size& size) : size_(size), surface_(NULL) { diff --git a/ui/gfx/gl/gl_surface_egl.h b/ui/gfx/gl/gl_surface_egl.h index de68fc8..352c052 100644 --- a/ui/gfx/gl/gl_surface_egl.h +++ b/ui/gfx/gl/gl_surface_egl.h @@ -43,7 +43,7 @@ class GL_EXPORT GLSurfaceEGL : public GLSurface { static EGLDisplay GetSoftwareDisplay(); static EGLNativeDisplayType GetNativeDisplay(); -protected: + protected: bool software_; private: @@ -63,10 +63,13 @@ class NativeViewGLSurfaceEGL : public GLSurfaceEGL { virtual bool SwapBuffers(); virtual gfx::Size GetSize(); virtual EGLSurface GetHandle(); + virtual bool SupportsPostSubBuffer(); + virtual bool PostSubBuffer(int x, int y, int width, int height); private: gfx::PluginWindowHandle window_; EGLSurface surface_; + bool supports_post_sub_buffer_; DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); }; diff --git a/ui/gfx/gl/gl_surface_glx.cc b/ui/gfx/gl/gl_surface_glx.cc index 2f2380f..373bc85 100644 --- a/ui/gfx/gl/gl_surface_glx.cc +++ b/ui/gfx/gl/gl_surface_glx.cc @@ -203,6 +203,17 @@ void* NativeViewGLSurfaceGLX::GetConfig() { return config_; } +bool NativeViewGLSurfaceGLX::SupportsPostSubBuffer() { + return g_GLX_MESA_copy_sub_buffer; +} + +bool NativeViewGLSurfaceGLX::PostSubBuffer( + int x, int y, int width, int height) { + DCHECK(SupportsPostSubBuffer()); + glXCopySubBufferMESA(g_display, window_, x, y, width, height); + return true; +} + PbufferGLSurfaceGLX::PbufferGLSurfaceGLX(const gfx::Size& size) : size_(size), config_(NULL), diff --git a/ui/gfx/gl/gl_surface_glx.h b/ui/gfx/gl/gl_surface_glx.h index 7784a79..f880b66 100644 --- a/ui/gfx/gl/gl_surface_glx.h +++ b/ui/gfx/gl/gl_surface_glx.h @@ -53,6 +53,8 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX { virtual gfx::Size GetSize(); virtual void* GetHandle(); virtual void* GetConfig(); + virtual bool SupportsPostSubBuffer(); + virtual bool PostSubBuffer(int x, int y, int width, int height); protected: NativeViewGLSurfaceGLX(); |