[cairo] [PATCH] gl/msaa: Add a fast path for fills that are simple quads

Chris Wilson chris at chris-wilson.co.uk
Wed Jan 23 00:40:17 PST 2013


On Tue, Jan 22, 2013 at 08:36:47PM -0800, Martin Robinson wrote:
> Sending this one to the list because it touches some code used
> outside the MSAA compositor.
> 
> From e3ec524717225437be3caf1ffa48bd620c30b65a Mon Sep 17 00:00:00 2001
> From: Martin Robinson <mrobinson at igalia.com>
> Date: Tue, 22 Jan 2013 20:09:01 -0800
> Subject: [PATCH] gl/msaa: Add a fast path for fills that are simple quads
> 
> Instead of invoking Bentley-Ottman for fills that are simple
> quadrilaterals, just pass the geometry straight to OpenGL.
> ---

> @@ -1265,22 +1258,107 @@ _cairo_path_fixed_is_box (const cairo_path_fixed_t *path,
>  	}
>      }
>  
> +    points[0] = buf->points[0];
> +    points[1] = buf->points[1];
> +    points[2] = buf->points[2];
> +    points[3] = buf->points[3];

These copies are not required.

> +    return TRUE;
> +}
> +
> +
> +/* Determine whether two lines A->B and C->D intersect based on the 
> + * algorithm described here: http://paulbourke.net/geometry/lineline2d/ */
> +static cairo_bool_t
> +_lines_intersect_or_are_coincident (cairo_point_t a,
> +				    cairo_point_t b,
> +				    cairo_point_t c,
> +				    cairo_point_t d)

Passing 4x2x4 bytes on the stack, otoh populating a cacheline... However
your inputs are already in a cacheline...

> +{
> +    cairo_fixed_t numerator_a, numerator_b, denominator;
> +
> +    denominator = _cairo_fixed_mul (d.y - c.y, b.x - a.x) -
> +		  _cairo_fixed_mul (d.x - c.x, b.y - a.y);
> +    numerator_a = _cairo_fixed_mul (d.x - c.x, a.y - c.y) -
> +		  _cairo_fixed_mul (d.y - c.y, a.x - c.x);
> +    numerator_b = _cairo_fixed_mul (b.x - a.x, a.y - c.y) -
> +		  _cairo_fixed_mul (b.y - a.y, a.x - c.x);

This and the following computations disregard the precision required.
Compare and contrast with _cairo_slope_compare(), for a simple example.
Even there we are effectively limiting the valid precision of our
inputs, just not as severely as the above.

I think you may want to do the simple box check first, then simple quad.
The former being cheaper and more prevalent.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the cairo mailing list