[cairo] Seams with CAIRO_ANTIALIAS_FAST

Chris Wilson chris at chris-wilson.co.uk
Sat Jul 28 11:52:04 PDT 2012


On Sat, 28 Jul 2012 20:08:40 +0200, sandmann at cs.au.dk (=?utf-8?Q?S=C3=B8ren?= Sandmann) wrote:
> The CAIRO_ANTIALIAS_FAST option uses a 2x2 sampling grid where each
> sample has a weight of 64 when the depth of the mask is 8 bits.
> 
> This is problematic because the four samples then sum to 256, which
> causes a seam a pixel is fully covered by a combination of independent
> polygons.
> 
> The attached program demonstrates this. The blue rectangle is drawn as
> four separate rectangles and the cross where they meet has a blue
> channel of 0x74 where the rest of the rectangle is 0x73.

For the sake of completeness, afaict this is actually another bug but
tor22 suffers the same sampling issue.

> There are various fixes possible:
> 
> (a) Make ANTIALIAS_FAST use a 3x5 sampling grid. This is tempting
>     because X Render already supports this antialiasing mode (rendering
>     trapezoids to a 4 bit mask will use it).

This makes the most sense to me. Any objection to using a 5x3 sampling
grid instead?

> (b) Make the weight of one of the samples 63 instead of 64. I don't know
>     how difficult this will be in the tor22 rasterizer.
> 
> (c) Ignore it and document that cairo can't draw seamless polygons.
> 
>     Considering that the bug-seams.c test has been failing ever since
>     the tor rasterizer was added, and that fixing that test will
>     probably involve a performance hit from turning off analytical
>     antialiasing, maybe this is the more honest way to go.

Can we use the hints to our advantage in this case? Fast is documented
as erring on the side of speed over quality issues (but obviously we
still need to make sure that it is reasonable otherwise fast is
unusable.) But we can use the 'best' hint to drop the analytic phase of
the rasteriser.

As always thanks for the example code, I'll extend the seams test case
to cover the issues you've raised.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the cairo mailing list