[cairo] [RFC] Cairo operators expressed in shader syntax

Jeff Muizelaar jeff at infidigm.net
Sat May 12 15:32:13 PDT 2007


On Sat, May 12, 2007 at 03:05:37PM -0700, Daniel Amelang wrote:
> On 5/12/07, Jeff Muizelaar <jeff at infidigm.net> wrote:
> >On Fri, May 11, 2007 at 04:22:11PM -0700, Daniel Amelang wrote:
> >> ; SOURCE
> >> result = src
> >> ; src IN mask SOURCE dst
> >> result = src * mask.a
> >> ; src COMPONENT_IN mask SOURCE dst
> >> result = src * mask
> >
> >Just as a note, although pixman's SOURCE operator behaves this way,
> >Cairo's does not. It looks more like:
> >result = src * mask.a + (1.0 - mask.a) * dst
> 
> Wait a sec...then why does the xlib backend seem to just pass along
> CAIRO_OPERATOR_SOURCE to XRenderComposite as PictOpSrc? This from
> cairo-xlib-surface.c:
> 
> static int
> _render_operator (cairo_operator_t op)
> {
>    ...
>    case CAIRO_OPERATOR_SOURCE:
> 	return PictOpSrc;
>   ...
> }
> 
> which is then used like this (from _cairo_xlib_surface_composite):
> 
> XRenderComposite (dst->dpy,
> 			      _render_operator (op),
> 			      src->src_picture,
> 			      mask->src_picture,
> 			      dst->dst_picture,
> 			      src_x + src_attr.x_offset,
> 			      src_y + src_attr.y_offset,
> 			      mask_x + mask_attr.x_offset,
> 			      mask_y + mask_attr.y_offset,
> 			      dst_x, dst_y,
> 			      width, height);
> 

This should've been in the first email but I missed the first question.

Anyways, currently the backends will not get called with SOURCE when
there's a mask; it gets special cased higher up. As discussed before,
this is not really the correct behaviour.
(http://lists.freedesktop.org/archives/cairo/2007-March/010122.html)

So, the xlib backend is arguably broken because it purports to support
the SOURCE operator when it really doesn't. In reality, this isn't a
problem and is likely just left over from when SOURCE was unbounded by
the mask.

-Jeff


More information about the cairo mailing list