[cairo] [RFC] cairo_stroke_to_path implementation
Chris Wilson
chris at chris-wilson.co.uk
Mon Feb 1 04:55:12 PST 2010
On Mon, 1 Feb 2010 13:33:48 +0100, Andrea Canciani <ranma42 at gmail.com> wrote:
> On Fri, Jan 29, 2010 at 7:16 AM, Jeff Muizelaar <jeff at infidigm.net> wrote:
> > Here's my current stroke-to-path work. Algorithmically it's basically where
> > I want it to be, however it's still a bit messy, especially
> > cairo-stroke-to-path.c. I welcome any comments about what needs to be done,
> > stylistically and otherwise, before we can add commit this.
> I put it on a branch on git
> (http://cgit.freedesktop.org/~ranma42/cairo/?h=wip/stroke-to-path) to
> make it easier to read it.
> I think it would be quite interesting to check the stroke-to-path
> behaviour by using it to "emulate" stroking on the test suite as it
> would be used on many degenerate cases and a few complex ones. If
> nobody has tried this yet, I'll do it asap and post the results.
You'll note how trivial it is to write a new stroke-to-polygon that can be
used in place of the current one to enable this path. The changes I had to
make last time were to eliminate all the mallocs and to apply tolerance.
(I think the latter Jeff addressed at some point, but it's wise to check.)
By making those changes, there were a number of visual differences between
the reference image and stroke-to-path, but I favoured the output from
stroke-to-path. (Even more so when you actually compare the polygons
produced by both methods.) And also for real-world applications I measured
a performance improvement (due to fewer edges and fewer intersections) -
but the micro-benchmarks highlight the extra work done by stroke-to-path.
> I started reading the code (mainly comments) and I noticed that you
> chose to flatten before doing stroke-to-path for dashed styles as no
> easy way to split the bezier curve at a given length came to you. On
> Graphics Gems V you can find a chpter about "The Length of Bezier
> Curves". It allows to get upper and lower bounds for a bezier curve,
> thus could be combined with bisection to find the value of the
> parameter t at which the curve should be split (when t is known,
> splitting the curve is just a straightforward application of de
> casteljau).
Next, you'll be computing bezier-bezier intersections and we can then do
full geometric clipping. ;-)
-ickle
--
Chris Wilson, Intel Open Source Technology Centre
More information about the cairo
mailing list