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

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

Issue 8772021: Enable GL_CHROMIUM_post_sub_buffer for osmesa (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "" 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/base/x/x11_util.cc ('k') | ui/gfx/gl/gl_surface_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/gl/gl_surface_linux.cc
diff --git a/ui/gfx/gl/gl_surface_linux.cc b/ui/gfx/gl/gl_surface_linux.cc
index cf067c2bee39c68da14fb5d2cd67a51a475b9ea8..b152b46e688dd6de4d668caa4bf69c4840d638ff 100644
--- a/ui/gfx/gl/gl_surface_linux.cc
+++ b/ui/gfx/gl/gl_surface_linux.cc
@@ -42,6 +42,8 @@ class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa {
virtual void Destroy();
virtual bool IsOffscreen();
virtual bool SwapBuffers();
+ virtual std::string GetExtensions();
+ virtual bool PostSubBuffer(int x, int y, int width, int height);
private:
bool UpdateSize();
@@ -194,6 +196,59 @@ bool NativeViewGLSurfaceOSMesa::SwapBuffers() {
return true;
}
+std::string NativeViewGLSurfaceOSMesa::GetExtensions() {
+ std::string extensions = gfx::GLSurfaceOSMesa::GetExtensions();
+ extensions += extensions.empty() ? "" : " ";
+ extensions += "GL_CHROMIUM_post_sub_buffer";
+ return extensions;
+}
+
+bool NativeViewGLSurfaceOSMesa::PostSubBuffer(
+ int x, int y, int width, int height) {
+ // Update the size before blitting so that the blit size is exactly the same
+ // as the window.
+ if (!UpdateSize()) {
+ LOG(ERROR) << "Failed to update size of GLContextOSMesa.";
+ return false;
+ }
+
+ gfx::Size size = GetSize();
+
+ // Move (0,0) from lower-left to upper-left
+ y = size.height() - y - height;
+
+ XWindowAttributes attributes;
+ if (!XGetWindowAttributes(g_osmesa_display, window_, &attributes)) {
+ LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << ".";
+ return false;
+ }
+
+ // Copy the frame into the pixmap.
+ ui::PutARGBImage(g_osmesa_display,
+ attributes.visual,
+ attributes.depth,
+ pixmap_,
+ pixmap_graphics_context_,
+ static_cast<const uint8*>(GetHandle()),
+ size.width(),
+ size.height(),
+ x, y,
+ x, y,
+ width,
+ height);
+
+ // Copy the pixmap to the window.
+ XCopyArea(g_osmesa_display,
+ pixmap_,
+ window_,
+ window_graphics_context_,
+ x, y,
+ width, height,
+ x, y);
+
+ return true;
+}
+
bool NativeViewGLSurfaceOSMesa::UpdateSize() {
// Get the window size.
XWindowAttributes attributes;
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/gfx/gl/gl_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698