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

Benjamin Otte company at kemper.freedesktop.org
Thu Aug 26 02:46:50 PDT 2010


 src/cairo-surface-subsurface.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

New commits:
commit 40459dacb52587cc784faf2635e54797d3989408
Author: Benjamin Otte <otte at redhat.com>
Date:   Thu Aug 26 11:45:28 2010 +0200

    subsurface: Don't crash when the device transform isn't integer
    
    Apply the transform before rounding to integer coordinates, so we can
    handle doubles easily.

diff --git a/src/cairo-surface-subsurface.c b/src/cairo-surface-subsurface.c
index a2cdb7e..579a6e4 100644
--- a/src/cairo-surface-subsurface.c
+++ b/src/cairo-surface-subsurface.c
@@ -492,7 +492,6 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
     cairo_surface_subsurface_t *surface;
     cairo_rectangle_int_t target_extents;
     cairo_bool_t ret;
-    int tx, ty;
 
     if (unlikely (target->status))
 	return _cairo_surface_create_in_error (target->status);
@@ -503,6 +502,10 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
     if (unlikely (surface == NULL))
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
 
+    assert (_cairo_matrix_is_translation (&target->device_transform));
+    x += target->device_transform.x0;
+    y += target->device_transform.y0;
+
     _cairo_surface_init (&surface->base,
 			 &_cairo_surface_subsurface_backend,
 			 NULL, /* device */
@@ -514,11 +517,6 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
     surface->extents.width = floor (x + width) - surface->extents.x;
     surface->extents.height = floor (y + height) - surface->extents.y;
 
-    ret = _cairo_matrix_is_integer_translation (&target->device_transform, &tx, &ty);
-    assert (ret);
-    surface->extents.x += tx;
-    surface->extents.y += ty;
-
     if (_cairo_surface_get_extents (target, &target_extents))
         ret = _cairo_rectangle_intersect (&surface->extents, &target_extents);
 


More information about the cairo-commit mailing list