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

Daniel Amelang daniel.amelang at gmail.com
Mon May 14 17:46:18 PDT 2007

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

That's a lot closer to OVER than SOURCE, observe them side by side:

result = src * mask.a + dst * (1.0 - src.a * mask.a)
; cairo SOURCE
result = src * mask.a + dst * (1.0 - mask.a)

Hmmm...I wonder if the shader syntax isn't fully capturing all the
differences. Looking at the cairo SOURCE, it seems awfully strange to
combine a premultipied source image with a dest image w/out applying
the other side of the multiplication. Perhaps this only useful when
the source only has an alpha component?

So reading through the old thread behind all this, it does seem
unfortunate that an existing operator's name (SOURCE) was hijacked to
mean something very different (i.e. a blend operation, essentially
just a special OVER case). I'm surprised the new operator semantics
wasn't given a new operator name. But it's water under the bridge.
Maybe worth bringing it up after the pixman shakeup, but for now, I'm
just going to ignore all of cairo's operator "improvements" and stick
to xrender/pixman semantics.


More information about the cairo mailing list