[cairo] cairo_in_fill() problems

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Wed Mar 25 21:23:38 PDT 2009


Soeren Sandmann wrote:
> The attached program produces this image:
> 
>         http://imgur.com/ABJ5K.png
> 
> The light area is a circular path. The blue areas are where
> cairo_in_fill() returned FALSE, the red where it returned
> TRUE. The bug was introduced by this commit:
> 
>     commit f5965cb7d6559e051c2581fe446d0b9f40427eb2
>     Author: Chris Wilson <chris at chris-wilson.co.uk>
>     Date:   Wed Nov 5 23:48:52 2008 +0000
> 
>     [in-fill] Avoid tessellation by counting number of edge crossing to -∞

cairo_in_fill doesn't track the current point correctly when it's
discarding a Bezier segment. It's easy to fix:

diff --git a/src/cairo-path-in-fill.c b/src/cairo-path-in-fill.c
index 21cd0bd..d43b1ca 100644
--- a/src/cairo-path-in-fill.c
+++ b/src/cairo-path-in-fill.c
@@ -184,15 +184,19 @@ _cairo_in_fill_curve_to (void *closure,
     if (c->y > bot) bot = c->y;
     if (d->y < top) top = d->y;
     if (d->y > bot) bot = d->y;
-    if (bot < in_fill->y || top > in_fill->y)
+    if (bot < in_fill->y || top > in_fill->y) {
+	in_fill->current_point = *d;
 	return CAIRO_STATUS_SUCCESS;
+    }
 
     left = in_fill->current_point.x;
     if (b->x < left) left = b->x;
     if (c->x < left) left = c->x;
     if (d->x < left) left = d->x;
-    if (left > in_fill->x)
+    if (left > in_fill->x) {
+	in_fill->current_point = *d;
 	return CAIRO_STATUS_SUCCESS;
+    }
 
     /* XXX Investigate direct inspection of the inflections? */
     if (! _cairo_spline_init (&spline,

I've gone ahead and pushed it.

regards,

Bertram


More information about the cairo mailing list