[cairo] [Bisected] Bugs in cairo's "contour" stroking

Carl Worth cworth at cworth.org
Sat Jun 23 10:50:40 PDT 2012

A cairo user recently reported to me that cairo is not robust when
stroking wide splines with tight curvature, (and showed me a rather
striking example).

Compare these two images (the first rendered with cairo 1.10, the second
rendered with cairo master) rendered with the attached demo program.



I was quite surprised since the original spline stroking algorithm was
designed to be particularly robust in cases like this. Git bisect was
kind enough to identify the recent "contour" stroker as the source of
the bug. It points to this commit as the commit that introduces the bug:

  commit 545f30856aac98199a49cf66c72dbcb66c1f3a4f
  Author: Chris Wilson <chris at chris-wilson.co.uk>
  Date:   Mon Aug 15 09:44:03 2011 +0100

    stroke: Convert the outlines into contour and then into a polygon
    In step 1 of speeding up stroking, we introduce contours as a means for
    tracking the connected edges around the stroke. By keeping track of
    these chains, we can analyse the edges as we proceed and eliminate
    redundant vertices speeding up rasterisation.
    Coincidentally fixes line-width-tolerance (looks like a combination of
    using spline tangent vectors and tolerance).
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

I would really like to see this bug fixed. I have not yet had a chance
to dive into the new code. But the new code should be able to maintain
the same approach as the old algorithm, (namely, the final contour
should be constructed from translated pieces of the pen or translated
pieces of the path).

The attached code should provide a reasonable test case to be added to
the test suite. I've also (long ago) written an interactive program
which makes it easy to explore "difficult" splines like the one seen
here. That program is available here:

    git clone git://git.cworth.org/git/cairo-spline

Chris, I'll look forward to your thoughts.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-spline-image.c
Type: text/x-csrc
Size: 2546 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120623/09effeee/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120623/09effeee/attachment.pgp>

More information about the cairo mailing list