[cairo-commit] src/cairo-gl-composite.c

Chris Wilson ickle at kemper.freedesktop.org
Sun Jun 24 04:16:53 PDT 2012


 src/cairo-gl-composite.c |   27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

New commits:
commit 13d61d7bdb7ec37ebb7324187aca1b9b9b1600cf
Author: Chuanbo Weng <strgnm at gmail.com>
Date:   Sun Jun 24 12:13:02 2012 +0100

    gl: Set correct clip rectangle for non-texture destination surfaces
    
    When the desintation surface is not a texture, it is flipped in the Y
    axis. So we need to correct the Y coordinates when using glScissor to
    the set the clip region.
    
    Fixes 14 cases in cairo-test-suite, for example partial-clip-text-top

diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index d9faa05..45fa042 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -475,11 +475,11 @@ _cairo_gl_composite_begin_component_alpha  (cairo_gl_context_t *ctx,
 }
 
 static void
-_scissor_to_box (cairo_gl_surface_t	*surface,
-		 const cairo_box_t	*box)
+_scissor_to_doubles (cairo_gl_surface_t	*surface,
+		     double x1, double y1,
+		     double x2, double y2)
 {
-    double x1, y1, x2, y2, height;
-    _cairo_box_to_doubles (box, &x1, &y1, &x2, &y2);
+    double height;
 
     height = y2 - y1;
     if (_cairo_gl_surface_is_texture (surface) == FALSE)
@@ -489,6 +489,22 @@ _scissor_to_box (cairo_gl_surface_t	*surface,
 }
 
 static void
+_scissor_to_rectangle (cairo_gl_surface_t *surface,
+		       const cairo_rectangle_int_t *r)
+{
+    _scissor_to_doubles (surface, r->x, r->y, r->x+r->width, r->y+r->height);
+}
+
+static void
+_scissor_to_box (cairo_gl_surface_t	*surface,
+		 const cairo_box_t	*box)
+{
+    double x1, y1, x2, y2;
+    _cairo_box_to_doubles (box, &x1, &y1, &x2, &y2);
+    _scissor_to_doubles (surface, x1, y1, x2, y2);
+}
+
+static void
 _cairo_gl_composite_setup_vbo (cairo_gl_context_t *ctx,
 			       unsigned int size_per_vertex)
 {
@@ -755,9 +771,10 @@ _cairo_gl_composite_draw_triangles_with_clip_region (cairo_gl_context_t *ctx,
     num_rectangles = cairo_region_num_rectangles (ctx->clip_region);
     for (i = 0; i < num_rectangles; i++) {
 	cairo_rectangle_int_t rect;
+
 	cairo_region_get_rectangle (ctx->clip_region, i, &rect);
 
-	glScissor (rect.x, rect.y, rect.width, rect.height);
+	_scissor_to_rectangle (ctx->current_target, &rect);
 	_cairo_gl_composite_draw_triangles (ctx, count);
     }
 }


More information about the cairo-commit mailing list