[cairo-commit] src/cairo-glitz-surface.c

Jinghua Luo jinghua at kemper.freedesktop.org
Sun Nov 30 05:49:10 PST 2008


 src/cairo-glitz-surface.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

New commits:
commit 51a75ad932af4a3c3da96ef98de79328afa200c3
Author: Luo Jinghua <sunmoon1997 at gmail.com>
Date:   Sun Nov 30 20:42:49 2008 +0800

    glitz: Replace specified color with an opaque one if dst surface don't have an alpha channel.
    
    Otherwise if underlying glitz drawable has an alpha channel, glitz_set_rectangles
    will set its alpha channel to specified value instead of opaque one and effects following
    composite operations since glitz draws to attached drawable then copies its content to
    the dst surface. With this commit, three test cases such as operator, operator-alpha and
    unbounded-operator passes now.

diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index d4eb068..589e14f 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -999,23 +999,29 @@ _cairo_glitz_surface_fill_rectangles (void		      *abstract_dst,
     }
 
     switch (op) {
+    case CAIRO_OPERATOR_CLEAR:
     case CAIRO_OPERATOR_SOURCE: {
 	glitz_color_t glitz_color;
+	glitz_format_t *format;
 
 	glitz_color.red = color->red_short;
 	glitz_color.green = color->green_short;
 	glitz_color.blue = color->blue_short;
 	glitz_color.alpha = color->alpha_short;
 
+	/*
+	 * XXX even if the dst surface don't have an alpha channel, the
+	 * above alpha still effect the dst surface because the
+	 * underlying glitz drawable may have an alpha channel. So
+	 * replacing the color with an opaque one is needed.
+	 */
+	format = glitz_surface_get_format (dst->surface);
+	if (format->color.alpha_size == 0)
+	    glitz_color.alpha = 0xffff;
+
         glitz_set_rectangles (dst->surface, &glitz_color,
                               glitz_rects, n_rects);
     } break;
-    case CAIRO_OPERATOR_CLEAR: {
-	static const glitz_color_t glitz_color = { 0, 0, 0, 0 };
-
-	glitz_set_rectangles (dst->surface, &glitz_color,
-			      glitz_rects, n_rects);
-    } break;
     case CAIRO_OPERATOR_SATURATE:
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     case CAIRO_OPERATOR_OVER:


More information about the cairo-commit mailing list