[cairo] [Fwd: CAIRO_OPERATOR_SOURCE issue]
otaylor at redhat.com
Sun May 9 13:50:00 PDT 2010
On Sun, 2010-05-09 at 21:42 +0200, Oscar Lazzarino wrote:
> On Sat, May 8, 2010 at 3:15 PM, Jonathan Morton
> <jonathan.morton at movial.com> wrote:
> > Yes, Cairo uses premultiplied alpha throughout. Presumably
> > cairo_set_source_rgba() is correcting the colour channels of the given
> > colour so that they are limited by the alpha channel.
> If so, what is the correct way to use Cairo with OpenGL to draw on
> screen (with glDrawPixels) or to generate textures (with glTexImage2D
> and friends) since OpenGL assumes non-premultiplied alpha? Is there a
> fast way to un-premultiply?
The best way to do it is to set up your GL drawing to assume
premultiplied textures. See:
To quote myself:
In fact, GL is really agnostic about what's in a texture; a texture is
quadruple of R,G,B,A values. Depending on how you've set up your blending,
these could be premultiplied values, unpremultiplied values or something
entirely different. In particular:
What clutter uses currently. Blend an non-premultiplied
source over a destination without alpha. Not correct
if the destination has alpha.
Blend an non-premultiplied source over a destination with
Blend an premultiplied source over a destination with
There is no way to render to a destination with non-premultiplied alpha. So in
that sense, the native way that GL handles alpha is *premultiplied*.
More information about the cairo