[cairo] Avoiding seams with CAIRO_OPERATOR_SATURATE (the OpenGL way)
cworth at cworth.org
Fri Jun 10 12:25:35 PDT 2005
On Sat, 11 Jun 2005 06:48:22 +1200, Robert O'Callahan wrote:
> > 4) Draw all objects front to back, taking advantage of
> > CAIRO_OPERATOR_SATURATE.
> I forgot about that one. What does CAIRO_OPERATOR_SATURATE do? Last I
> checked this wasn't covered in any documentation.
It's based on the behavior of the OpenGL blending factor
GL_SRC_ALPHA_SATURATE, (or perhaps more specifically
GL_SRC_ALPHA_SATURATE for the source and GL_ONE for the destination
--- I would have to look at the equations involved to know for
My high-level understanding is that this operator allows a sort of a
painter's algorithm in reverse, (hence the front-to-back drawing
order). The destination alpha buffer is used for all the hidden
surface removal. Once a pixel's alpha value is saturated, it won't be
affected by subsequent operations, so the objects in the front
win. And the mathematics of the SATURATE operator prevent seams.
See, for example, the description of "Antialiasing Polygons" here:
(Though some people may have better references. This is just what I
turned up with a little googling.)
PS. Another interesting point in this regard is that the Render
extension, (and hence libpixman and cairo), support the SATURATE
operator as a separate operator from the traditional Porter/Duff
operators. It was included because it was known to be useful in OpenGL
for operations like this.
But Keith later discovered that the SATURATE operator is just one
instance of two new classes of more generalized Porter/Duff
operators. The traditional operators assume uncorrelated geometry
between the two object being composited. Porter and Duff mention two
other obvious choices in their paper: assuming as much correlation as
possible, (eg. overlapping brush application) and assuming as little
as possible, (eg. polygon tessellation). Their paper doesn't develop
the math for these more generalized forms, but the Render extension
provides them in the CONJOINT and DISJOINT variations of all the
The cool part is that the previously special SATURATE operator falls
out as simply DISJOINT_OVER. So Render gives a lot more flexibility by
allowing disjoint variations of all the other Porter/Duff operators in
addition to OVER.
But, we decided not to advertise the disjoint and conjoint operators
in cairo since most backends won't provide direct support for
them. But we could add them again at some point with software
fallbacks where necessary.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050610/f6d98e2a/attachment.pgp
More information about the cairo