[cairo] [PATCH] gl: Do operator conversion and judgement in beginning of composite_boxes.

Chris Wilson chris at chris-wilson.co.uk
Thu May 10 09:33:42 PDT 2012


On Thu, 10 May 2012 23:45:13 +0800, Chuanbo Weng <strgnm at gmail.com> wrote:
> The main purpose is to convert CLEAR to DEST_OUT when there's a mask.
> This fix zero-mask case in cairo-test-suite.
> ---
>  src/cairo-gl-spans-compositor.c |   19 +++++++++++++++++++
>  1 files changed, 19 insertions(+), 0 deletions(-)
> 
> diff --git a/src/cairo-gl-spans-compositor.c b/src/cairo-gl-spans-compositor.c
> index 0c2134f..e1fc966 100644
> --- a/src/cairo-gl-spans-compositor.c
> +++ b/src/cairo-gl-spans-compositor.c
> @@ -362,6 +362,25 @@ composite_boxes (void			*_dst,
>  
>      TRACE ((stderr, "%s mask=(%d,%d), dst=(%d, %d)\n", __FUNCTION__,
>  	    mask_x, mask_y, dst_x, dst_y));
> +
> +    if (((cairo_surface_t *)_dst)->is_clear &&
> +        (op == CAIRO_OPERATOR_SOURCE ||
> +         op == CAIRO_OPERATOR_OVER ||
> +         op == CAIRO_OPERATOR_ADD)) {
> +        op = CAIRO_OPERATOR_SOURCE;

Might be useful, I was a little more dubious about whether it would make
much difference for the GL ROPs. Definitely not part of the bug fix. I'd
limit this patch to the if (mask) case so that we can clearly see what
it happening.

> +    } else if (abstract_mask) {
> +        if (op == CAIRO_OPERATOR_CLEAR) {
> +            _cairo_gl_solid_operand_init (source_to_operand (abstract_src), CAIRO_COLOR_WHITE);

Hmm, this assumes that we have passed a solid operand down, or else we
might leak a pattern.

> +            op = CAIRO_OPERATOR_DEST_OUT;
> +        } else if (op == CAIRO_OPERATOR_SOURCE) {
> +            return CAIRO_INT_STATUS_UNSUPPORTED;
> +        } else if(! _cairo_gl_operator_is_supported (op)){
> +            return CAIRO_INT_STATUS_UNSUPPORTED;
> +        }        
> +    } else if (! _cairo_gl_operator_is_supported (op)){
> +            return CAIRO_INT_STATUS_UNSUPPORTED;
> +    }
> +
>      status = _cairo_gl_composite_init (&setup, op, _dst, FALSE);
>      if (unlikely (status))
>          goto FAIL;

My expectation was that we would just implement LERP in the shader. In
the meantime, this still looks to be the best approach. We just need to
make the override of the mask operand cleaner.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the cairo mailing list