[cairo] [cairo-commit] 7 commits - src/cairo-path-fixed.c src/cairo-pdf-surface.c src/cairo-rtree.c src/cairo-rtree-private.h src/cairo-spline.c src/cairo-xlib-display.c src/Makefile.sources test/Makefile.am test/Makefile.sources test/meta-surface-pattern.pdf.argb32.ref.png test/meta-surface-pattern.pdf.rgb24.ref.png test/overlapping-glyphs.argb32.ref.png test/overlapping-glyphs.c test/overlapping-glyphs.pdf.argb32.xfail.png test/overlapping-glyphs.pdf.rgb24.xfail.png test/overlapping-glyphs.rgb24.ref.png test/scale-offset-image.pdf.xfail.png test/scale-offset-similar.pdf.xfail.png util/cairo-script

Chris Wilson chris at chris-wilson.co.uk
Mon Jul 27 10:19:41 PDT 2009


On Mon, 2009-07-27 at 11:45 -0400, Jeff Muizelaar wrote:
> On Mon, Jul 27, 2009 at 02:19:57AM -0700, Chris Wilson wrote:
> > commit c72ca2f2296b5fbc5859059b98221e5ffe087dae
> > Author: Chris Wilson <chris at chris-wilson.co.uk>
> > Date:   Sun Jul 26 09:07:48 2009 +0100
> > 
> >     [path] Convert straight curve-to to line-to
> >     
> >     Avoid the high cost associated with curves if we can convert the curve to
> >     a straight line.
> > 
> > diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
> > index 9819353..3befe42 100644
> > --- a/src/cairo-path-fixed.c
> > +++ b/src/cairo-path-fixed.c
> > @@ -488,6 +488,7 @@ _cairo_path_fixed_curve_to (cairo_path_fixed_t	*path,
> >  {
> >      cairo_status_t status;
> >      cairo_point_t point[3];
> > +    cairo_slope_t slope, tangent;
> >  
> >      /* make sure subpaths are started properly */
> >      if (! path->has_current_point) {
> > @@ -502,6 +503,17 @@ _cairo_path_fixed_curve_to (cairo_path_fixed_t	*path,
> >      point[0].x = x0; point[0].y = y0;
> >      point[1].x = x1; point[1].y = y1;
> >      point[2].x = x2; point[2].y = y2;
> > +
> > +    _cairo_slope_init (&slope, &path->current_point, &point[2]);
> > +    _cairo_slope_init (&tangent, &path->current_point, &point[0]);
> > +    if (_cairo_slope_compare (&slope, &tangent) == 0) {
> > +	_cairo_slope_init (&tangent, &point[1], &point[2]);
> > +	if (_cairo_slope_compare (&slope, &tangent) == 0) {
> > +	    /* just a straight line... */
> > +	    return _cairo_path_fixed_line_to (path, x2, y2);
> > +	}
> > +    }
> > +
> 
> What's the motivation behind this? Is it worth paying for the degeneracy
> test in the common case of a non-degenerate curve?

The motivation here is that we are starting to rely much more on the
properties of the path determined during construction and that the cost
of performing 2 extra pairs of 32x32 multiplies per-curve is negligible.
The difference doesn't appear in the profiles, for example, due to the
comparative insignificance of path construction. Callgrinding (of a not
particularly curve heavy PDF file) suggests the overhead is around .02%.
I'm waiting on a callgrind of an extremely curve happy swfdec to get a
more realistic measurement.

If you have a profile that shows an impact, I'd like to add that to my
set. :) And of course I'm still a long way from being able to routinely
run performance tests across all architectures.
-ickle



More information about the cairo mailing list