[cairo] Compositing Operations

jose_ogp at juno.com jose_ogp at juno.com
Sun Feb 26 12:01:03 PST 2006


	If I may, I'd like to bring up some questions related
to certain kinds of 'compositing' operations.. Namely, those
operations which do not alter the dst surface alpha channel.
	Such operations can be seen as allowing for 'painting'
onto dst surfaces, without altering their given shape/opacity.

	One way to obtain these types of operations is from
another given composite operation via a process roughly as
follows:
	Let's assume we're given some compositing operation
op (assumed to affect the dst somehow), a source surface s,
and a destination surface d.
	Let x denote the surface obtained from d by un-
pre-multiplying d, and give x alpha equal to 1 everywhere,
so that we may obtain d from x via an "in" type of operation
with d's alpha channel.
	Let y denote the result of applying (s op x), and
let's give y alpha equal to 1 everywhere as well, if it's not
already so (if op does not decrease alphas, then this will
obtain automatically).
	Finally, let r denote the result of performing an "in"
of y with d's alpha channel, so that, by construction, r has
the same alpha channel as d.
	This process defines a new operation, let's call it
'rel-op', from the given operation op.

	If we take as our op the "over" operation, then the
corresponding rel-over is what is known as one of the "Atop"
operations, ie. one has:
	rc = (1 - sa)*dc + da*sc;

	If we instead take as our op the "add" operation, the
resulting rel-add can be defined by:
	rc = min{da, dc + da*sc}
	This operation, however, does not seem to be readily
obtainable with Cairo..?

	Many others are possible of course, eg. a 'subtractive'
version of the above, given by:
	rc = max{0, dc - da*sc},  but with ra = da.

	The above notions assume there's no 'a priory' relationship
between s and d, but one may also consider operations which simply
do not increase d's opacity - rather than requiring that they do not
alter it. In particular, notions of compositing for "sub-surfaces"
of d, ie. of surfaces s which satisfy sa <= da.
	Such notions might be useful in GUI work when one begins
to consider "windows" with alpha, so that eg. a "child" window
might denote a sub-surface of the surface defining the parent
window.
	Given such 'children' s1,s2, of d, what is an appropiate
notion of compositing s1 "over" s2, or of composite "add" s1 to
s2, so that the result is again a sub-surface of d? 

	I wonder if anyone has any thoughts on the utility of such
operations for GUI work, their viability in Cairo, and their
relation to render's concept of 'conjoint' compositing.





More information about the cairo mailing list