From b54174e917e273143455661d565412fb9a185bfb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 21 Feb 2007 13:43:08 -0500 Subject: [PATCH] [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. --- src/cairo-ps-surface.c | 31 ++++++++++++------ test/Makefile.am | 1 - ...tate-image-surface-paint-ps-argb32-ref.png | Bin 0 -> 276 bytes 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 test/rotate-image-surface-paint-ps-argb32-ref.png diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index e2798240d..ce98eb145 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 *surface, 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 *surface, "<< /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 *surface, ">>\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 99916b63f..c39d4c82b 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 0000000000000000000000000000000000000000..a57a31778e2f2b702f3a7bed469f873ba9961278 GIT binary patch literal 276 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VTavfC3&Vd9T(EcfWS|IVfk$L9 z0|U1Z2s2)~TlWVjC|}|lQ4*Y=R#Ki=l*-^59H8KykzZU=oLrPyP@-UAXsTym{Gf1c z15jzFr;B5VMep4y)_eyHIGo?!`+u$^bG68s^p22~I+98Df;~aJ(&d`|7LotZy1)vh_IEtJ2~bYVsD{BsJayEcdae_;Pdq=HFWOtc-n literal 0 HcmV?d00001