[cairo] [PATCH] fix device offset problems

Jeff Muizelaar jeff at infidigm.net
Thu Aug 7 12:30:07 PDT 2008

The attached patch should fix the pdf rendering regressions. I haven't
quite finished the test case to go with it so I'll do that before

-------------- next part --------------
commit dc65d47ecb269fc9cbb29915ba237cb34239a613
Author: Jeff Muizelaar <jrmuizel at jrmuizel-desktop.(none)>
Date:   Thu Aug 7 15:29:35 2008 -0400

    Center the group pattern transform by the device_transform
    When popping a group, transform it by the ctm centered at
    the origin specified by the device_transform. This fixes
    the regressions caused by 1a9809baab5d8adf6ccf165e8f5d294b498c2fd5 seen by
    the pdf backend.

diff --git a/src/cairo.c b/src/cairo.c
index 2dc1acc..3b058a2 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -587,7 +587,15 @@ cairo_pop_group (cairo_t *cr)
     _cairo_gstate_get_matrix (cr->gstate, &group_matrix);
-    cairo_pattern_set_matrix (group_pattern, &group_matrix);
+    /* tranform by group_matrix centered around device_transform */
+    if (_cairo_surface_has_device_transform (group_surface)) {
+	cairo_pattern_set_matrix (group_pattern, &group_surface->device_transform);
+	_cairo_pattern_transform (group_pattern, &group_matrix);
+	_cairo_pattern_transform (group_pattern, &group_surface->device_transform_inverse);
+    } else {
+	cairo_pattern_set_matrix (group_pattern, &group_matrix);
+    }
     cairo_surface_destroy (group_surface);

More information about the cairo mailing list