[cairo] [PATCH 3/3] gl/msaa: Scissor simple rectangular clips
Chris Wilson
chris at chris-wilson.co.uk
Thu Dec 15 12:34:21 PST 2011
On Thu, 15 Dec 2011 11:54:59 -0800, Martin Robinson <mrobinson at igalia.com> wrote:
> Instead of using the stencil buffer to perform simple
> rectangular clips, just scissor the clip rectangle.
Heh, I applied the last of patches too quick as this no longer applies.
One comment inline before you rebase.
> ---
> src/cairo-gl-msaa-compositor.c | 68
> ++++++++++++++++++++++++++++++---------
> 1 files changed, 52 insertions(+), 16 deletions(-)
>
> diff --git a/src/cairo-gl-msaa-compositor.c b/src/cairo-gl-msaa-compositor.c
> index 1f3c006..ceceb15 100644
> --- a/src/cairo-gl-msaa-compositor.c
> +++ b/src/cairo-gl-msaa-compositor.c
> @@ -199,6 +199,49 @@ _draw_clip_to_stencil_buffer (cairo_gl_context_t *ctx,
> return status;;
> }
>
> +static void
> +_scissor_to_box (cairo_gl_surface_t *surface,
> + const cairo_box_t *box)
> +{
> + double x = _cairo_fixed_to_double (box->p1.x);
> + double y = _cairo_fixed_to_double (box->p1.y);
> + double width = _cairo_fixed_to_double (box->p2.x) - x;
> + double height = _cairo_fixed_to_double (box->p2.y) - y;
> +
> + if (_cairo_gl_surface_is_texture (surface) == FALSE)
> + y = surface->height - (y + height);
> + glScissor (x, y, width, height);
> + glEnable (GL_SCISSOR_TEST);
> +}
> +
> +static cairo_int_status_t
> +_scissor_and_clip (cairo_gl_context_t *ctx,
> + cairo_gl_composite_t *setup,
> + cairo_composite_rectangles_t *composite,
> + cairo_bool_t *used_stencil_buffer)
> +{
> + cairo_rectangle_int_t *bounds = &composite->unbounded;
> + cairo_clip_t *clip = composite->clip;
> +
> + cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface;
> + *used_stencil_buffer = FALSE;
> +
> + if (_cairo_composite_rectangles_can_reduce_clip (composite, clip)) {
> + _scissor_to_rectangle (dst, bounds);
> + return CAIRO_INT_STATUS_SUCCESS;
> + }
> +
> + /* If we cannot reduce the clip to a rectangular region,
> + we scissor and clip using the stencil buffer */
> + if (clip->num_boxes > 1 || clip->path != NULL || clip->region !=
> NULL) {
The clip->region part is redundant and could even cause you to miss this
fast-path.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the cairo
mailing list