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

Bill Spitzak spitzak at gmail.com
Tue Jun 10 13:08:30 PDT 2014

I have a patch that does not produce an offset in the given test. Will 
post is in another email. With this version there is no shift in the image.

Most of the failures seem to be in 3 catagories:

1. Excessive blur. This is due to the (IMHO) incorrect computation of 
the filters.

2. Filtering applied to A1 and other low-bit-depth sources. IMHO this is 
desirable but it means the results will vary depending on the device 
scale. My recommendation is to remove the device-scaling tests when 
these surfaces are used as sources. Or use CAIRO_FILTER_NEAREST. Or use 
the pdf reference images or otherwise generate correct ones.

3. Ringing from the edges. The main culprit is the interpretation of 
"NONE" by Cairo. In my opinion Cairo must be changed so that "NONE" 
instead results in the same output as "PAD" but with the current clip 
intersected with the transformed bounding box of the source surface. 
Until this is fixed my recommendation is to use filters with no negative 

I am going to try to generate better filter arrays for use by the pixman 
separate convolution. My plan is to do a true box filter, which has the 
following advantages:

1. no ringing

2. smallest usable size, to maximize speed until we get a real 2-pass 

3. Same as bilinear as scale approaches 1

I am hoping this will reduce the number of failures, and produce 
less-blurry images.

On 04/12/2014 11:49 AM, Uli Schlachter wrote:
> 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?
> Uli
> 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);

More information about the cairo mailing list