[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

Jeff Muizelaar jeff at infidigm.net
Mon Jul 27 08:45:40 PDT 2009


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?

-Jeff


More information about the cairo mailing list