[cairo-commit] src/cairo-pattern.c

Carl Worth cworth at kemper.freedesktop.org
Mon Oct 23 20:46:49 PDT 2006


 src/cairo-pattern.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+)

New commits:
diff-tree 8381e53cc741af73fddebe61d9a0b28a8329c18b (from 670b3ce2432154cc0611a31c5b5e37c8a3ddf1f5)
Author: Carl Worth <cworth at cworth.org>
Date:   Mon Oct 23 20:44:29 2006 -0700

    8711: Fix transformed source surface patterns with xlib backend.
    
    This broke with the clone_similar optimization in
    	 8d7a02ed58e06584eb09575e6ca11d0a81094ab6
    The optimization added an interest rectangle to clone_similar,
    but the acquire_surface path was neglecting to transform its
    rectangle by the pattern matrix.
    
    The test suite did catch this, but apparently we were too
    distracted by the performance improvements to notice. Only
    backends other than image that implemented clone_similar
    would be affected by the bug, (which meant I only saw xlib
    failures in my testing).
    
    This fixes bug #8711

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 0d0940f..08f2321 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1140,6 +1140,8 @@ _cairo_pattern_acquire_surface_for_surfa
     {
 	attr->matrix = pattern->base.matrix;
 	attr->x_offset = attr->y_offset = 0;
+	tx = 0;
+	ty = 0;
     }
 
     if (_cairo_surface_is_image (dst))
@@ -1157,6 +1159,27 @@ _cairo_pattern_acquire_surface_for_surfa
     }
     else
     {
+	/* Before we can clone, we must transform the rectangle to the
+	 * coordinate space of the source surface. */
+	if (! _cairo_matrix_is_identity (&attr->matrix)) {
+	    double src_x = x;
+	    double src_y = y;
+	    double src_width = width;
+	    double src_height = height;
+	    double x2, y2;
+	    cairo_bool_t is_tight;
+
+	    _cairo_matrix_transform_bounding_box  (&attr->matrix, &src_x, &src_y,
+						   &src_width, &src_height,
+						   &is_tight);
+	    x2 = src_x + src_width;
+	    y2 = src_y + src_height;
+	    x = floor (src_x);
+	    y = floor (src_y);
+	    width = ceil (x2) - x;
+	    height = ceil (y2) - y;
+	}
+
 	status = _cairo_surface_clone_similar (dst, pattern->surface,
 					       x+tx, y+ty, width, height, out);
     }


More information about the cairo-commit mailing list