A question about Render alpha maps

Soeren Sandmann sandmann at daimi.au.dk
Sat Jan 16 08:55:08 PST 2010


The Render spec says this about alpha maps:

        The alpha channel of alpha-map is used in place of any alpha
        channel contained within the drawable for all rendering
        operations. 

Which says that the alpha channel of the drawable is directly replaced
with that of the alpha map. This was the interpretation in the
original Render code that Keith wrote. There is an implicit assumption
that the color components are already premultiplied with the alpha
channel from the alpha map.

However, commit

        2de24db63eb65974ac547facf2a99aa4709d54b3

from 2005 which simply says 

        Render performance improvements. (Lars Knoll, Zack Rusin)

changed the interpretation to be that in addition to replacing the
alpha channel, it was also multiplied onto the color channels. The
implicit assumption is now that the image components are not already
premultiplied with the alpha map's channel.

However, this interpretation implies that if the image already has an
alpha channel of its own, the color components should first be
*unpremultiplied*. But the code doesn't actually do that.

In pixman 0.16.0 there is further breakage because there the alpha
channel isn't replaced at all; instead the alpha value is multiplied
onto the entire pixel, so that it now only works if the image doesn't
have an alpha channel at all.

So, do we

- go back to Keith's original interpretation?

- use the existing interpretation where the alpha map is simply
  multiplied onto the color channels?

- or, do we first unpremultiply any existing alpha channel, and *then*
  multiply the new alpha channel onto the components?


The branch here:

        http://cgit.freedesktop.org/~sandmann/pixman/log/?h=alpha-fixes

goes back to the original interpretation and also fixes a couple of
other alpha-map-related bugs. There is also a test program.

If nobody cares, I'll just merge that, but I don't feel particularly
strongly about it, so if someone else does, let me know.



Thanks,
Soren


More information about the xorg-devel mailing list