summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-10-30 09:54:47 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-10-30 10:00:30 +0000
commit42711a5586cba5db5451ce2400ee5fe655700391 (patch)
tree6432df15b5e0485b3ae7ca66018ac8144abc4aa8
parentc3940d342ac506055c2ce6b7e9b27f92d8a63999 (diff)
[xlib] Fix _draw_image_surface() with opaque images.
If the image was opaque with no alpha channel, we filled the output alpha with 0. Typically, the destination surface for dithering is an RGB window, so this bug went unnoticed. However, test/xlib-expose-event is an example where we generate an intermediate alpha-only pixmap for use as a stencil and this was failing as the mask was left completely transparent. The simple solution is to ensure that for opaque images, the output alpha is set to the maximum permissible value.
-rw-r--r--src/cairo-xlib-surface.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 2b0e2ca3..619eb36d 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -1055,7 +1055,14 @@ _draw_image_surface (cairo_xlib_surface_t *surface,
else
in_pixel = row[x];
- a = _field_to_8 (in_pixel & image_masks.alpha_mask, i_a_width, i_a_shift);
+ /* If the incoming image has no alpha channel, then the input
+ * is opaque and the output should have the maximum alpha value.
+ * For all other channels, their absence implies 0.
+ */
+ if (image_masks.alpha_mask == 0x0)
+ a = 0xff;
+ else
+ a = _field_to_8 (in_pixel & image_masks.alpha_mask, i_a_width, i_a_shift);
r = _field_to_8 (in_pixel & image_masks.red_mask , i_r_width, i_r_shift);
g = _field_to_8 (in_pixel & image_masks.green_mask, i_g_width, i_g_shift);
b = _field_to_8 (in_pixel & image_masks.blue_mask , i_b_width, i_b_shift);