[patch] gl: fix y-axis origin when map_to_image() for non texture GL surface

"Henry (Yu) Song - SISA" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <3955FA337689574EB32F94B12A7E6E9E0B4F9C6F@ex10mail>
We need to fix y-axis origin when map a GL surface to image surface for non-texture GL surface.  Test cases: extended-blend-alpha-mask, extended-blend-mask.  Although the image outputs is not right, but the image on the first grid (upper-left corner) is right comparing to image output before patch.

commit d4f720ebb2d21aa53b1e6826f3c0fd1d2b07d70e
Author: Henry (Yu) Song <[email protected]>
Date:   Wed Mar 28 18:03:24 2012 -0700

    gl: when read pixels from non texture surface, we need to invert the y-axis
    origin

diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 91c860a..7b6c7ff 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -983,6 +983,7 @@ _cairo_gl_surface_map_to_image (void      *abstract_surface,
     unsigned int cpp;
     cairo_bool_t invert;
     cairo_status_t status;
+    int origin = extents->y;
 
     /* Want to use a switch statement here but the compiler gets whiny. */
     if (surface->base.content == CAIRO_CONTENT_COLOR_ALPHA) {
@@ -1063,7 +1064,11 @@ _cairo_gl_surface_map_to_image (void      *abstract_surface,
 	glPixelStorei (GL_PACK_ROW_LENGTH, image->stride / cpp);
     if (invert)
 	glPixelStorei (GL_PACK_INVERT_MESA, 1);
-    glReadPixels (extents->x, extents->y,
+    
+    if (! _cairo_gl_surface_is_texture (surface))
+	origin = surface->height - extents->y - extents->height;
+
+    glReadPixels (extents->x, origin,
 		  extents->width, extents->height,
 		  format, type, image->data);
     if (invert)
--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.