GNOME Bugzilla – Bug 500787
translation gets ignored when rendering an svg with cairo in the context of a cairo_push_group()
Last modified: 2008-01-19 16:47:59 UTC
When rendering an SVG within a cairo_push_group context, the SVG does not translated properly; instead it is adjusted to touch the upper left corner of the underlying surface. I'll attach a small program that demonstrates the issue, courtesy of Carl Worth. It produces two output images which should be identical. Analysis. This behaviour was introduced in the patch for #412682 - changing the device offset within a cairo_push_group has no effect. Fix. We can get the same effect as changing the device offset by adjusting cairo's ctm for the original context appropriately. I'll attach a patch.
Created attachment 99944 [details] test case
Created attachment 99945 [details] [review] proposed fix
The patch looks fine and passes the regression tests. I guess it should be applied. Dom ?
I'm afraid the patch above is incomplete, most notably because it fails to make adjustments in cairo_clip.c. I'll post an improved patch later.
Created attachment 101266 [details] [review] proposed fix Ok, here's the improved patch as promised. It applies the offset for clips and masks, too, which the previous patch didn't. It passes the test suite and the testcase, and some tests of my own. (I'll look at adding test cases that involve transformations to the test suite when I find the time.)
Created attachment 101268 [details] [review] related cleanup patch This patch applies on top of the proposed fix; it removes some cairo_save() / cairo_restore() pairs that are now superfluous. I've tested this one as well. The remaining cairo_save() and cairo_restore() have different purposes: one pair saves and restores the original caller's cairo state, and one pair saves and restores the clipping area around groups (which may add their own clipping).
Thanks, Bertram!