[cairo-commit] 4 commits - src/cairo-ps-surface.c test/composite-integer-translate-over-pdf-argb32-ref.png test/paint-source-alpha-pdf-argb32-ref.png test/scale-source-surface-paint-pdf-argb32-ref.png

Carl Worth cworth at kemper.freedesktop.org
Fri Jun 30 07:16:12 PDT 2006


 src/cairo-ps-surface.c                                   |   61 +++++++++------
 test/composite-integer-translate-over-pdf-argb32-ref.png |binary
 test/paint-source-alpha-pdf-argb32-ref.png               |binary
 test/scale-source-surface-paint-pdf-argb32-ref.png       |binary
 4 files changed, 38 insertions(+), 23 deletions(-)

New commits:
diff-tree 057c0abeea1ee80c7156be5a1c15594765d88fe0 (from 54ce585817d78ffeeb0ba6b03b868e63b9552cb8)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Jun 30 16:07:11 2006 +0200

    ps: Fix transformation of source surfaces.
    
    This makes the following four tests pass, (which were previously
    failing on the ps backend).
    
    	move-to-show-surface
    	scale-source-surface-paint
    	source-surface-scale-paint
    	translate-show-surface

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index f8915a2..a4e52f8 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -1434,7 +1434,6 @@ emit_image (cairo_ps_surface_t    *surfa
     cairo_surface_t *opaque;
     cairo_image_surface_t *opaque_image;
     cairo_pattern_union_t pattern;
-    cairo_matrix_t d2i;
     int x, y, i;
     cairo_output_stream_t *base85_stream, *string_array_stream;
 
@@ -1521,12 +1520,6 @@ emit_image (cairo_ps_surface_t    *surfa
     _cairo_output_stream_printf (surface->stream,
 				 "/%sDataIndex 0 def\n", name);
 
-    /* matrix transforms from user space to image space.  We need to
-     * transform from device space to image space to compensate for
-     * postscripts coordinate system. */
-    cairo_matrix_init (&d2i, 1, 0, 0, 1, 0, 0);
-    cairo_matrix_multiply (&d2i, &d2i, matrix);
-
     _cairo_output_stream_printf (surface->stream,
 				 "/%s {\n"
 				 "    /DeviceRGB setcolorspace\n"
@@ -1549,9 +1542,9 @@ emit_image (cairo_ps_surface_t    *surfa
 				 opaque_image->width,
 				 opaque_image->height,
 				 name, name, name, name, name, name, name,
-				 d2i.xx, d2i.yx,
-				 d2i.xy, d2i.yy,
-				 d2i.x0, d2i.y0);
+				 matrix->xx, matrix->yx,
+				 matrix->xy, matrix->yy,
+				 0.0, 0.0);
 
     status = CAIRO_STATUS_SUCCESS;
 
@@ -1583,7 +1576,8 @@ emit_solid_pattern (cairo_ps_surface_t *
 
 static void
 emit_surface_pattern (cairo_ps_surface_t *surface,
-		      cairo_surface_pattern_t *pattern)
+		      cairo_surface_pattern_t *pattern,
+		      double x, double y)
 {
     cairo_rectangle_int16_t extents;
 
@@ -1597,17 +1591,25 @@ emit_surface_pattern (cairo_ps_surface_t
 	cairo_image_surface_t	*image;
 	void			*image_extra;
 	cairo_status_t		status;
+	cairo_matrix_t		inverse = pattern->base.matrix;
+
+	cairo_matrix_invert (&inverse);
 
 	status = _cairo_surface_acquire_source_image (pattern->surface,
 						      &image,
 						      &image_extra);
-	_cairo_surface_get_extents (&image->base, &extents);
 	assert (status == CAIRO_STATUS_SUCCESS);
+
+	_cairo_pattern_get_extents (&pattern->base, &extents);
+
 	emit_image (surface, image, &pattern->base.matrix, "MyPattern");
 	_cairo_surface_release_source_image (pattern->surface, image,
 					     image_extra);
     }
     _cairo_output_stream_printf (surface->stream,
+				 "%f %f translate\n",
+				 x, y);
+    _cairo_output_stream_printf (surface->stream,
 				 "<< /PatternType 1\n"
 				 "   /PaintType 1\n"
 				 "   /TilingType 1\n");
@@ -1620,6 +1622,9 @@ emit_surface_pattern (cairo_ps_surface_t
     _cairo_output_stream_printf (surface->stream,
 				 "   /PaintProc { MyPattern } bind\n"
 				 ">> matrix makepattern setpattern\n");
+    _cairo_output_stream_printf (surface->stream,
+				 "-%f -%f translate\n",
+				 x, y);
 }
 
 static void
@@ -1637,7 +1642,8 @@ emit_radial_pattern (cairo_ps_surface_t 
 }
 
 static void
-emit_pattern (cairo_ps_surface_t *surface, cairo_pattern_t *pattern)
+emit_pattern (cairo_ps_surface_t *surface, cairo_pattern_t *pattern,
+	      double x, double y)
 {
     /* FIXME: We should keep track of what pattern is currently set in
      * the postscript file and only emit code if we're setting a
@@ -1649,7 +1655,7 @@ emit_pattern (cairo_ps_surface_t *surfac
 	break;
 
     case CAIRO_PATTERN_TYPE_SURFACE:
-	emit_surface_pattern (surface, (cairo_surface_pattern_t *) pattern);
+	emit_surface_pattern (surface, (cairo_surface_pattern_t *) pattern, x, y);
 	break;
 
     case CAIRO_PATTERN_TYPE_LINEAR:
@@ -1741,6 +1747,7 @@ _cairo_ps_surface_paint (void			*abstrac
 {
     cairo_ps_surface_t *surface = abstract_surface;
     cairo_output_stream_t *stream = surface->stream;
+    cairo_rectangle_int16_t extents;
 
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
 	return _analyze_operation (surface, op, source);
@@ -1758,13 +1765,21 @@ _cairo_ps_surface_paint (void			*abstrac
     _cairo_output_stream_printf (stream,
 				 "%% _cairo_ps_surface_paint\n");
 
-    emit_pattern (surface, source);
+    _cairo_pattern_get_extents (source, &extents);
+
+    emit_pattern (surface, source, extents.x, extents.y);
 
-    _cairo_output_stream_printf (stream, "0 0 M\n");
-    _cairo_output_stream_printf (stream, "%f 0 L\n", surface->width);
-    _cairo_output_stream_printf (stream, "%f %f L\n",
-				 surface->width, surface->height);
-    _cairo_output_stream_printf (stream, "0 %f L\n", surface->height);
+    _cairo_output_stream_printf (stream, "%d %d M\n",
+				 extents.x, extents.y);
+    _cairo_output_stream_printf (stream, "%d %d L\n",
+				 extents.x + extents.width,
+				 extents.y);
+    _cairo_output_stream_printf (stream, "%d %d L\n",
+				 extents.x + extents.width,
+				 extents.y + extents.height);
+    _cairo_output_stream_printf (stream, "%d %d L\n",
+				 extents.x,
+				 extents.y + extents.height);
     _cairo_output_stream_printf (stream, "P F\n");
     return CAIRO_STATUS_SUCCESS;
 }
@@ -1891,7 +1906,7 @@ _cairo_ps_surface_stroke (void			*abstra
 	}
     }
 
-    emit_pattern (surface, source);
+    emit_pattern (surface, source, 0, 0);
 
     _cairo_output_stream_printf (stream,
 				 "gsave\n");
@@ -1957,7 +1972,7 @@ _cairo_ps_surface_fill (void		*abstract_
     _cairo_output_stream_printf (stream,
 				 "%% _cairo_ps_surface_fill\n");
 
-    emit_pattern (surface, source);
+    emit_pattern (surface, source, 0, 0);
 
     status = _cairo_ps_surface_emit_path (stream, path);
 
@@ -2002,7 +2017,7 @@ _cairo_ps_surface_show_glyphs (void		   
 				 "%% _cairo_ps_surface_show_glyphs\n");
 
     if (num_glyphs)
-	emit_pattern (surface, source);
+	emit_pattern (surface, source, 0, 0);
 
     for (i = 0; i < num_glyphs; i++) {
 	status = _cairo_scaled_font_subsets_map_glyph (surface->font_subsets,
diff-tree 54ce585817d78ffeeb0ba6b03b868e63b9552cb8 (from a6fc321d1793e97e4601429a98c36bed9af365a0)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Jun 29 23:34:29 2006 +0200

    Update PDF-specific reference image for scale-source-surface-paint

diff --git a/test/scale-source-surface-paint-pdf-argb32-ref.png b/test/scale-source-surface-paint-pdf-argb32-ref.png
index bb940f8..de274f9 100644
Binary files a/test/scale-source-surface-paint-pdf-argb32-ref.png and b/test/scale-source-surface-paint-pdf-argb32-ref.png differ
diff-tree a6fc321d1793e97e4601429a98c36bed9af365a0 (from aaef92f8307fedd864fca66054b06c8bfe7ae40d)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Jun 29 23:28:48 2006 +0200

    Add PDF-specific reference image for paint-source-alpha

diff --git a/test/paint-source-alpha-pdf-argb32-ref.png b/test/paint-source-alpha-pdf-argb32-ref.png
new file mode 100644
index 0000000..98004a3
Binary files /dev/null and b/test/paint-source-alpha-pdf-argb32-ref.png differ
diff-tree aaef92f8307fedd864fca66054b06c8bfe7ae40d (from 45ebf2d1f3c6cb4588c3bebf6acf1818eb723515)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Jun 29 23:27:05 2006 +0200

    Add PDF-specific reference image for composite-integer-translate-over

diff --git a/test/composite-integer-translate-over-pdf-argb32-ref.png b/test/composite-integer-translate-over-pdf-argb32-ref.png
new file mode 100644
index 0000000..821e38b
Binary files /dev/null and b/test/composite-integer-translate-over-pdf-argb32-ref.png differ


More information about the cairo-commit mailing list