[cairo-commit] 2 commits - src/cairo-xlib-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Oct 30 03:00:51 PDT 2008


 src/cairo-xlib-surface.c |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

New commits:
commit 42711a5586cba5db5451ce2400ee5fe655700391
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 30 09:54:47 2008 +0000

    [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.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 2b0e2ca..619eb36 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);
commit c3940d342ac506055c2ce6b7e9b27f92d8a63999
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 30 09:59:48 2008 +0000

    [xlib] whitespace
    
    Tweak the whitespace to lose some unnecessary line wrapping, casts and
    blanks.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index ac840b8..2b0e2ca 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -1302,7 +1302,6 @@ _cairo_xlib_surface_create_solid_pattern_surface (void                  *abstrac
     if (status)
 	goto BAIL;
 
-
   BAIL:
     cairo_surface_destroy (&image->base);
 
@@ -1866,7 +1865,7 @@ _cairo_xlib_surface_solid_fill_rectangles (cairo_xlib_surface_t    *surface,
 					   cairo_rectangle_int_t   *rects,
 					   int			   num_rects)
 {
-    cairo_status_t status = CAIRO_STATUS_SUCCESS;
+    cairo_status_t status;
     cairo_solid_pattern_t solid;
     cairo_surface_t *solid_surface = NULL;
     cairo_surface_attributes_t attrs;
@@ -1878,7 +1877,7 @@ _cairo_xlib_surface_solid_fill_rectangles (cairo_xlib_surface_t    *surface,
     if (status)
         return status;
 
-    status = _cairo_pattern_acquire_surface (&solid.base, (cairo_surface_t *) surface,
+    status = _cairo_pattern_acquire_surface (&solid.base, &surface->base,
 					     0, 0,
 					     ARRAY_LENGTH (dither_pattern[0]),
 					     ARRAY_LENGTH (dither_pattern),
@@ -1887,7 +1886,7 @@ _cairo_xlib_surface_solid_fill_rectangles (cairo_xlib_surface_t    *surface,
     if (status)
         return status;
 
-    if (!_cairo_surface_is_xlib (solid_surface)) {
+    if (! _cairo_surface_is_xlib (solid_surface)) {
 	status = CAIRO_INT_STATUS_UNSUPPORTED;
 	goto BAIL;
     }
@@ -1895,7 +1894,8 @@ _cairo_xlib_surface_solid_fill_rectangles (cairo_xlib_surface_t    *surface,
     XSetTSOrigin (surface->dpy, surface->gc,
 		  - (surface->base.device_transform.x0 + attrs.x_offset),
 		  - (surface->base.device_transform.y0 + attrs.y_offset));
-    XSetTile (surface->dpy, surface->gc, ((cairo_xlib_surface_t *) solid_surface)->drawable);
+    XSetTile (surface->dpy, surface->gc,
+	      ((cairo_xlib_surface_t *) solid_surface)->drawable);
     XSetFillStyle (surface->dpy, surface->gc, FillTiled);
 
     for (i = 0; i < num_rects; i++) {


More information about the cairo-commit mailing list