[cairo-commit] src/cairo-ps-surface.c test/Makefile.am test/rotate-image-surface-paint-ps-argb32-ref.png

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Feb 21 10:43:13 PST 2007


 src/cairo-ps-surface.c                            |   31 ++++++++++++++--------
 test/Makefile.am                                  |    1 
 test/rotate-image-surface-paint-ps-argb32-ref.png |binary
 3 files changed, 21 insertions(+), 11 deletions(-)

New commits:
diff-tree b54174e917e273143455661d565412fb9a185bfb (from 6ae4a4fd71b030376ec373f2a787eac32b21d7f3)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Feb 21 13:43:08 2007 -0500

    [PS] Fix rotated image pattern emission by correcting setting the bbox
    
    The bug was that the bounding box of the image was computed by transforming
    the vector (width,height) and then using 0,0,width,height as the bounding box.
    This is obviously wrong.  We use _cairo_matrix_transform_bounding_box() now.
    This fixes the XFAIL test rotate-image-surface-paint.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index e279824..ce98eb1 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -1685,16 +1685,23 @@ static void
 emit_surface_pattern (cairo_ps_surface_t *surface,
 		      cairo_surface_pattern_t *pattern)
 {
-    double bbox_width, bbox_height;
+    double x_off, y_off;
+    double bbox_x1, bbox_y1, bbox_x2, bbox_y2;
     int xstep, ystep;
     cairo_matrix_t inverse = pattern->base.matrix;
+
     cairo_matrix_invert (&inverse);
+    x_off = inverse.x0;
+    y_off = inverse.y0;
+    inverse.x0 = inverse.y0 = 0.;
 
     if (_cairo_surface_is_meta (pattern->surface)) {
 	_cairo_output_stream_printf (surface->stream, "/MyPattern {\n");
 	_cairo_meta_surface_replay (pattern->surface, &surface->base);
-	bbox_width = surface->width;
-	bbox_height = surface->height;
+	/* XXX: shouldn't we transform bbox and other stuff here too? */
+	bbox_x1 = bbox_y1 = 0.;
+	bbox_x2 = surface->width;
+	bbox_y2 = surface->height;
 	xstep = surface->width;
 	ystep = surface->height;
 	_cairo_output_stream_printf (surface->stream, "} bind def\n");
@@ -1710,10 +1717,13 @@ emit_surface_pattern (cairo_ps_surface_t
 
 	emit_image (surface, image, &pattern->base.matrix, "MyPattern");
 
-	bbox_width = image->width;
-	bbox_height = image->height;
-	cairo_matrix_transform_distance (&inverse,
-					 &bbox_width, &bbox_height);
+	bbox_x1 = bbox_y1 = 0;
+	bbox_x2 = image->width;
+	bbox_y2 = image->height;
+	_cairo_matrix_transform_bounding_box (&inverse,
+					      &bbox_x1, &bbox_y1,
+					      &bbox_x2, &bbox_y2,
+					      NULL);
 
 	/* In PostScript, (as far as I can tell), all patterns are
 	 * repeating. So we support cairo's EXTEND_NONE semantics by
@@ -1747,9 +1757,10 @@ emit_surface_pattern (cairo_ps_surface_t
 				 "<< /PatternType 1\n"
 				 "   /PaintType 1\n"
 				 "   /TilingType 1\n");
+    /* XXX: should we floor/ceil here? */
     _cairo_output_stream_printf (surface->stream,
-				 "   /BBox [0 0 %d %d]\n",
-				 (int) bbox_width, (int) bbox_height);
+				 "   /BBox [%f %f %f %f]\n",
+				 bbox_x1, bbox_y1, bbox_x2, bbox_y2);
     _cairo_output_stream_printf (surface->stream,
 				 "   /XStep %d /YStep %d\n",
 				 xstep, ystep);
@@ -1758,7 +1769,7 @@ emit_surface_pattern (cairo_ps_surface_t
 				 ">>\n");
     _cairo_output_stream_printf (surface->stream,
 				 "[ 1 0 0 1 %f %f ]\n",
-				 inverse.x0, inverse.y0);
+				 x_off, y_off);
     _cairo_output_stream_printf (surface->stream,
 				 "makepattern setpattern\n");
 }
diff --git a/test/Makefile.am b/test/Makefile.am
index 99916b6..c39d4c8 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -360,7 +360,6 @@ big-trap			\
 extend-reflect			\
 filter-nearest-offset		\
 long-lines			\
-rotate-image-surface-paint	\
 self-intersecting		\
 text-glyph-range		\
 text-rotate
diff --git a/test/rotate-image-surface-paint-ps-argb32-ref.png b/test/rotate-image-surface-paint-ps-argb32-ref.png
new file mode 100644
index 0000000..a57a317
Binary files /dev/null and b/test/rotate-image-surface-paint-ps-argb32-ref.png differ


More information about the cairo-commit mailing list