Created attachment 22487 [details]
In metacity-clutter (Mutter) we use multi-texturing to render shaped windows. The shape of the window is copied into a GL_ALPHA texture which is blended with the window's texture using multi-texturing such that the areas outside the window's shape end up with zero alpha and aren't displayed.
The texture for the window should usually be GL_RGB format and is updated using the texture from pixmap extension. The texture environment is set up so that layer 0 (the window texture) is left at the default and layer 1 uses GL_COMBINE. The RGB is set to GL_REPLACE with the values from the previous texture (the window texture). The alpha is set to GL_MODULATE with the mask layer and the previous layer.
As far as I understand from the man pages for glTexEnv, the alpha from an RGB texture when used for blending will be constant 1 so it should work. It works fine on my i965 laptop with Mesa 7.2 (from Ubuntu Intrepid) when LIBGL_ALWAYS_INDIRECT enabled and also on an Nvidia box.
However, when testing on an Aspire One (i945) with the Moblin alpha release image, the blending does not work correctly. The shaped windows appear completely transparent as if maybe the non-existent alpha value from the window texture is being used.
We currently workaround this in Mutter by using a different blending mode when the window has a 24 bit depth. In this case we ignore the alpha from the window texture and modulate directly with GL_PRIMARY_COLOR.
The attached test case demonstrates this without using Clutter. It creates a small white window with a black circle outline drawn it and then creates another window which clones the small window using texture from pixmap. The texture is blended with a 2x2 GL_ALPHA texture which is full opacity except the bottom left pixel. So the window should appear as a black scaled up circle on a white background except for the bottom left corner which should show the blue underneath.
Under Moblin, it shows a completely blue window instead. You can enable the workaround by setting the WORKAROUND environment variable.
Created attachment 22488 [details]
Image of what it should look like
In case it's not clear from my description of the test, this is what it should look like when it's working.
Thanks for the excellent testcase! I've come up with a more minimal case and put it into piglit as texturing/tfp. I've also pushed the fix:
Author: Eric Anholt <email@example.com>
Date: Wed Mar 18 12:07:09 2009 -0700
Fix DRI2 accelerated EXT_texture_from_pixmap with GL_RGB format.