[cairo] Alpha masks

Owen Taylor otaylor at redhat.com
Wed Jan 5 14:49:18 PST 2005


On Wed, 2005-01-05 at 17:07 -0500, Carl Worth wrote:
[...]
> I had always expected we would want to add functions to set the
> "current mask" in ways analogous to setting the current color. I
> suppose that gives us:
> 
> 	void
> 	cairo_set_mask_rgb_color (cairo_t *cr, double red, double green, double blue);
> 
> 	void
> 	cairo_set_mask_alpha (cairo_t *cr, double alpha);
> 
> 	void
> 	cairo_set_mask_pattern (cairo_t *cr, cairo_pattern_t *pattern);
> 
> And the current mask would affect all drawing operations.

Hmm, that makes the drawing "equation" even more complex than it is now.
The drawn pixel is a function of 
 
 shape (polygon)
 clip
 pattern (or solid color)
 mask

Seems to me to be simpler to use the mask in place of either shape or
clip and keep the operands to three. Of the two, shape looks more
logical to me.

> > My expectation would be that showing a RGB or RGBA surface would ignore the pattern,
> > showing a A-only surface would use the surface as a mask for the pattern. Does this
> > make sense to other people?
> 
> That strikes me as inconsistent. But we could add another new function
> to paint the current pattern/color through a mask surface. This would
> be analogous to PostScript's imagemask operator. We could name it
> cairo_show_surface_mask perhaps? or maybe cairo_show_mask_surface?
> 
> Then, your example could be simplified to:
> 
> 	cairo_show_surface_mask (cr, image_surface, width, height);
> 
> which is starting to look quite reasonable.  (Oh, and I want to
> eliminate the width/height arguments from show_surface already, in
> which case we should drop them here as well).

I don't really quite understand the claim of inconsistency ... the color
information has to come from somewhere, falling back to the pattern when
the surface has no color information seems pretty logical. Postscript
needs separate image/imagemask operators because there is no
distinguishing between a 1-bit b&w image and a 1-bit mask. But Cairo
doesn't support single channel no-alpha images, so there is no
ambiguity.

Using a separate operator does allow ARGB masks, likely making some
people happy.

What's the interpretation of show_surface() with an A-only image? Does
it draw in black always? Does it act like show_surface_mask()?

What's the interpretation of show_surface_mask() with a RGB-surface?
Just the rectangular
surface bounds?

Regards,
				Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050105/bb61b849/attachment.pgp


More information about the cairo mailing list