[cairo-commit] src/cairo-image-surface.c

M. Joonas Pihlaja joonas at kemper.freedesktop.org
Sat Feb 27 15:50:16 PST 2010


 src/cairo-image-surface.c |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit 9ecb0f3cec491264041d0d3718595ad95164980a
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun Feb 28 01:42:10 2010 +0200

    image: Fix bug optimizing surface pattern extend modes.
    
    The image surface tries to convert surface pattern's extend
    modes to EXTEND_NONE, if it can, when converting a cairo_pattern_t
    to a pixman_image_t. The check was not taking into account the
    transformation matrix on the pattern, so it was possible to
    trick it into using EXTEND_NONE by downscaling the source
    pattern enough.  This patch changes the optimization to only
    take if the pattern has no transformation.
    
    Fixes surface-pattern-scale-down-extend-{pad,reflect,repeat}
    failures in the test suite for the image backend.

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 854e98d..9b86419 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -1208,6 +1208,8 @@ _pixman_image_for_surface (const cairo_surface_pattern_t *pattern,
     if (pattern->surface->type == CAIRO_SURFACE_TYPE_IMAGE) {
 	cairo_image_surface_t *source = (cairo_image_surface_t *) pattern->surface;
 	cairo_surface_type_t type;
+	cairo_bool_t has_identity_transform =
+	    _cairo_matrix_is_identity (&pattern->base.matrix);
 
 	if (source->base.backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT)
 	    source = (cairo_image_surface_t *) ((cairo_surface_snapshot_t *) pattern->surface)->target;
@@ -1215,6 +1217,7 @@ _pixman_image_for_surface (const cairo_surface_pattern_t *pattern,
 	type = source->base.backend->type;
 	if (type == CAIRO_SURFACE_TYPE_IMAGE) {
 	    if (extend != CAIRO_EXTEND_NONE &&
+		has_identity_transform &&
 		extents->x >= 0 && extents->y >= 0 &&
 		extents->x + extents->width  <= source->width &&
 		extents->y + extents->height <= source->height)
@@ -1247,6 +1250,7 @@ _pixman_image_for_surface (const cairo_surface_pattern_t *pattern,
 	    source = (cairo_image_surface_t *) sub->target;
 
 	    if (extend != CAIRO_EXTEND_NONE &&
+		has_identity_transform &&
 		extents->x >= 0 && extents->y >= 0 &&
 		extents->x + extents->width  <= sub->extents.width &&
 		extents->y + extents->height <= sub->extents.height)


More information about the cairo-commit mailing list