[cairo] Question about CAIRO_OPERATOR_SOURCE if paint operation doesn't cover whole target surface

Carl Worth cworth at cworth.org
Thu Nov 30 15:48:40 PST 2006


On Thu, 30 Nov 2006 13:14:36 -0600, Boris Zbarsky wrote:
> The question I have is whether I need to paint the target surface with rgba(0,
> 0, 0, 0) first, given that |data| is not initialized, that
> cairo_image_surface_create_for_data does not initialize the buffer in any way,
> that I'm masking out part of the paint, and that the source surface may be
> smaller than the target surface in this case.  Or does using
> CAIRO_OPERATOR_SOURCE just set all pixels that are not being painted to
> transparent?  There doesn't seem to be much documentation on the different
> operators at
> <http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-operator-t>,
> unfortunately.

You're correct that the operators are not well documented. As for
SOURCE it simply copies from the source pattern to the destination
regardless of what the destination was before. So there's not much to
say about the operator, per se.

More than the individual operator, though, what your question points
out is the bigger problem that the fundamental rendering equation is
not documented at all. That's a really nasty documentation bug, (and
about as bad a bug as could be here).

And your question here is actually a really good one. The short answer
is that to do what you want you do need to clear the destination
first. So just before doing your SOURCE mask you might do:

	cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
	cairo_paint (cr);

The reason this is such a good question is that there was a (very
short) time before the 1.0 release when the SOURCE operator would have
cleared everything outside the mask as well. We changed that, (knowing
that it would cost an extra clear operation in a case like this), in
order to allow things like rectangle;fill to be used to apply a SOURCE
operation to a rectangular area, (without affecting everything outside
that area as well).

The thread that led to that change is here:

	http://thread.gmane.org/gmane.comp.lib.cairo/4791

It's a confusing thread to read now because it talks about "old" and
"new" modes and debates the merits of each. But it's got some useful
notation for the rendering equations in there, and it would be great
to have some of that pulled so that we can finally write up the
"introduction to cairo's rendering model" that we've been needing for
so long.

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20061130/bc1cbed1/attachment.pgp


More information about the cairo mailing list