When fetching from an alpha map, replace the alpha channel of the image
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 16 Jan 2010 15:31:22 +0000 (10:31 -0500)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sun, 17 Jan 2010 21:47:15 +0000 (16:47 -0500)
Previously it would be multiplied onto the image pixel, but the Render
specification is pretty clear that the alpha map should be used
*instead* of any alpha channel within the image.

This makes the assumption that the pixels in the image are already
premultiplied with the alpha channel from the alpha map. If we don't
make this assumption and the image has an alpha channel of its own, we
would have to first unpremultiply that pixel, and then premultiply the
alpha value onto the color channels, and then replace the alpha
channel.

pixman/pixman-bits-image.c

index fb1af922f1f5cb9d2d3473a916e434956192d982..a3bcd69388ad32a8f3d0de7197b8a2dda7b6ef14 100644 (file)
@@ -120,7 +120,8 @@ bits_image_fetch_pixel_alpha (bits_image_t *image, int x, int y)
        pixel_a = ALPHA_8 (pixel_a);
     }
 
-    UN8x4_MUL_UN8 (pixel, pixel_a);
+    pixel &= 0x00ffffff;
+    pixel |= (pixel_a << 24);
 
     return pixel;
 }