[cairo] Component-alpha in compositing operations.

jose_ogp at juno.com jose_ogp at juno.com
Fri Oct 20 04:09:35 PDT 2006


	If I may, I'd like to bring up some observations on the
the semantics of how the 'component-alpha' attribute is currently
used in xrender's compositing operations. I thought to bring it up
here, on the cairo list, since cairo mirrors xrender's compositing
semantics and as cairo seems more directly concerned with these
kinds of things than the xorg list.


	One fairly common operation that one seems to find in gui
effects is to 'modulate' an image with some given color prior to
blending with a destination.. ie. one wants to multiply the image
channels by the given color's channels, and composite this result.

	Unfortunately, it seems that such an operation is not very
efficiently supported (in general) via render's compositing semantics.

	As far as I can tell, the only way to do this is to first
create a relevant tmp picture, set a 1x1 mask picture containing the
color with repeat and component-alpha attribute set to true, perform
a SRC op of this (src, mask) with the tmp pict, and finally composite
tmp with the dst (with whatever the compositing op one wanted to use
with the dst). One would've expected to be able to simply composite
(src, mask) with the dst...

	The reason for this seems to be that the setting of the
component-alpha attribute to 1 on the mask, may actually affect the
semantics of compositing (src, mask) with the dst, but has no effect
whatever if it's set on the src. It may, and it may may not... that
seems to depend somewhat mysteriously on the type of op.

	Consider another case of seemingly inefficient compositing
semantics - Let's consider 'multiplying' a src picture with the dst,
ie. one desires a component-wise IN of src and dst.
	One would've expected that setting the src pict's component-
alpha attribute to true and using an IN op would do this.. But, it
appears that this is not so. Instead, it seems that one has to create
a tmp pict, copy the dst to it, set that as a mask with att component-
alpha, and perform a SRC op of this (src, mask) with the dst.

	It's likely that I'm mistaken, and there are indeed efficient
ways to do these kinds of things with xrender..

	But, would it not make sense to allow for the component-alpha
attribute to modify both src and mask individually... so that its
value on the mask would apply to the IN that joins src and mask, and
its value on the src (or perhaps the dst) would apply to the op that
one sets for the compositing with the dst?  And for this to hold
consistently across all compositing ops?

   jose.




More information about the cairo mailing list