[cairo] [PATCH] Fix bug in test suite causing PS and PDF to fail with rgb24 and device offsets.

Carl Worth cworth at cworth.org
Tue Feb 28 17:50:45 PST 2006


The trick with this one is that the test suite is using device offsets
in a rather fabricated way, and the final copy from an offset surface
to a non-offset surface is between two surfaces of the same size, so
must be 1:1. To get this we turn the device offset off before the
copy.

In a more conventional use of device offsets the surfaces would be of
different sizes, and the offset would be desired during the copy.

---

 Vlad,

 This is the patch we talked about already. It is ready for your
 device-offset-rework branch. It fixes a bunch of failures that were
 specific to PS and PDF surfaces with rgb24 format and device offset
 applied.

 When I applied this patch, the device-offset branch went from 49 to
 27 failures. So it's getting there, (I know your text fixes drop a
 lot of the remaining failures as well).

 -Carl

 test/cairo-test.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

a36e139e8622ecba5e45fe20829c654ffecbea18
diff --git a/test/cairo-test.c b/test/cairo-test.c
index b82151b..d37bd47 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -1173,6 +1173,15 @@ ps_surface_write_to_png (cairo_surface_t
     ps_target_closure_t *ptc = cairo_surface_get_user_data (surface, &ps_closure_key);
     char    command[4096];
 
+    /* Both surface and ptc->target were originally created at the
+     * same dimensions. We want a 1:1 copy here, so we first clear any
+     * device offset on surface.
+     *
+     * In a more realistic use case of device offsets, the target of
+     * this copying would be of a different size than the source, and
+     * the offset would be desirable during the copy operation. */
+    cairo_surface_set_device_offset (surface, 0, 0);
+
     if (ptc->target) {
 	cairo_t *cr;
 	cr = cairo_create (ptc->target);
@@ -1265,6 +1274,15 @@ pdf_surface_write_to_png (cairo_surface_
     pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, &pdf_closure_key);
     char    command[4096];
 
+    /* Both surface and ptc->target were originally created at the
+     * same dimensions. We want a 1:1 copy here, so we first clear any
+     * device offset on surface.
+     *
+     * In a more realistic use case of device offsets, the target of
+     * this copying would be of a different size than the source, and
+     * the offset would be desirable during the copy operation. */
+    cairo_surface_set_device_offset (surface, 0, 0);
+
     if (ptc->target) {
 	cairo_t *cr;
 	cr = cairo_create (ptc->target);
-- 
1.2.3.g2656-dirty

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060228/4890a604/attachment.pgp


More information about the cairo mailing list