[cairo] Render to image buffer artifacts

Carl Worth cworth at cworth.org
Thu Jan 13 16:33:43 PST 2005


On Tue, 11 Jan 2005 20:40:06 -0500, Carl Worth wrote:
> Oddly, the bug does not appear with either trapezoid alone, only with
> the two together.

Which now makes sense.

This was really an old bug that we knew about, but didn't work around
completely. The current algorithm for rasterizing trapezoids has a
weird edge effect that can cause it to compute an alpha value of 1 in
pixels outside of the trapezoids.

I've now committed the below fix to libpixman to fixes the bug. I've
also committed a test case to the regression suite called
leaky_polygon.

Oh, and the X server probably needs a similar fix, (and we should fix
the test suite to check the output of the Xlib backend in addition to
the image backend).

-Carl

Index: src/ictrap.c
===================================================================
RCS file: /mirrors/freedesktop/cairo/libpixman/src/ictrap.c,v
retrieving revision 1.13
diff -u -p -r1.13 ictrap.c
--- src/ictrap.c        16 Apr 2004 15:32:53 -0000      1.13
+++ src/ictrap.c        13 Jan 2005 22:18:42 -0000
@@ -1227,8 +1227,18 @@ IcRasterizeTrapezoid (pixman_image_t		*p
         */
        while (left.row.top.y == pixel_y && pixel_x < first_right_x)
        {
-           alpha = (RectAlpha (pixel_y, y, y_next, depth)
-                    - PixelAlpha(pixel_x, pixel_y, y, y_next, &left, depth));
+           /* When the left edge is entirely above top we "know" the
+            * alpha is 0. Due to a subtle edge effect, the
+            * calculations below return a non-zero result in some
+            * situations. This defect in the algorithm is bad enough
+            * that we plan to discard the current approach
+            * entirely. But in the meantime, we do want to have the
+            * correct alpha == 0 in these cases. */
+           if (left.lower.y < y)
+               alpha = 0;
+           else
+               alpha = (RectAlpha (pixel_y, y, y_next, depth)
+                        - PixelAlpha(pixel_x, pixel_y, y, y_next, &left, depth));
            if (alpha > 0)
            {
                if (0 <= pixel_x && pixel_x < buf_width_fixed)
-------------- 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/20050113/72ecc9d7/attachment.pgp


More information about the cairo mailing list