[cairo] Running cairo-test-suite with -as / cairo_surface_set_device_scale() and the test suite / image scaling madness

Uli Schlachter psychon at znc.in
Sat Apr 12 11:49:08 PDT 2014

Hi everyone,

could someone please turn our image scaling code into something sane? I spent
the better part of the day trying to figure out why the heck
test/output/paint-with-alpha.image.argb32.x2.out.png looked like it was offset
by (0.5, 0.5) to the top-left. The result is the following patch.

CAIRO_TEST_TARGET=image ./cairo-test-suite -as

Before this patch:
31 Passed, 489 Failed [1 crashed, 8 expected], 31 Skipped

After this patch:
145 Passed, 375 Failed [1 crashed, 8 expected], 31 Skipped

This removes blatantly wrong scaling artifacts from the test suite's results.
However, obviously this patch is no good.

Can we please turn the image scaling code into something which actually works and
produces remotely useful results?


P.S.: After this is fixed properly, should we handle the remaining problems by
doubling the number of reference images? Or can we do something useful about this?

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 674c8d0..6847f3a 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -321,6 +321,7 @@ _cairo_boilerplate_get_image_surface (cairo_surface_t *src,
     cr = cairo_create (surface);
     cairo_surface_destroy (surface);
     cairo_set_source_surface (cr, src, 0, 0);
+    cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST); /* XXX: This is wrong... */
     cairo_paint (cr);
     status = cairo_status (cr);

"Are you preparing for another war, Plutarch?" I ask.
"Oh, not now. Now we're in that sweet period where everyone agrees that our
recent horrors should never be repeated," he says. "But collective thinking is
usually short-lived. We're fickle, stupid beings with poor memories and a great
gift for self-destruction.

More information about the cairo mailing list