[cairo-commit] 2 commits - pixman/src src/cairo.c src/cairo-clip.c src/cairo-glitz-surface.c src/cairo-gstate.c src/cairoint.h src/cairo-pattern.c src/cairo-surface.c src/cairo-surface-fallback.c src/cairo-xcb-surface.c src/cairo-xlib-surface.c

Carl Worth cworth at kemper.freedesktop.org
Wed Apr 25 11:21:34 PDT 2007


 pixman/src/fbpict.c          |    8 +++++++-
 src/cairo-clip.c             |    3 ++-
 src/cairo-glitz-surface.c    |    5 ++++-
 src/cairo-gstate.c           |    3 ++-
 src/cairo-pattern.c          |   41 ++++++++++++++++++++++++++---------------
 src/cairo-surface-fallback.c |   12 ++++++++----
 src/cairo-surface.c          |    2 +-
 src/cairo-xcb-surface.c      |    3 ++-
 src/cairo-xlib-surface.c     |    3 ++-
 src/cairo.c                  |    2 +-
 src/cairoint.h               |    9 ++++++---
 11 files changed, 61 insertions(+), 30 deletions(-)

New commits:
diff-tree 29670d37665d184d78d568070cb409acf98ee797 (from fea5336e2db201be69256ef1bafd418fee98a21e)
Author: Carl Worth <cworth at cworth.org>
Date:   Mon Apr 23 10:24:03 2007 -0700

    Add a content value to solid patterns
    
    This allows for the surface acquired from the pattern to have the
    same content. In particular, in a case such as cairo_paint_with_alpha
    we can now acquire an A8 mask surface instead of an ARGB32 mask
    surface which can be rendered much more efficiently. This results
    in a 4x speedup when using the OVER operator with the recently
    added paint-with-alpha test:
    
    Speedups
    ========
    image-rgb  paint-with-alpha_image_rgb_over-256 2.25 -> 0.60: 4.45x speedup
    ███▌
    
    It does slowdown the same test when using the SOURCE operator, but
    I don't think we care. Performing SOURCE with a mask is already a very
    slow operation, (hitting compositeGeneral), so the slowdown here is
    likely from having to convert from A8 back to ARGB32 before the
    generalized compositing. So if someone cares about this slowdown,
    (though SOURCE with cairo_paint_with_alpha doesn't seem extremely
    useful), they will probably be motivated enough to contribute a
    customized compositing function to replace compositeGeneral in which
    case this slowdown should go away:
    
    image-rgba paint-with-alpha_image_rgb_source-256 3.84 -> 8.86%: 1.94x slowdown
    â–ˆ

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index bce6117..01c8c46 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -412,7 +412,8 @@ _cairo_clip_intersect_mask (cairo_clip_t
     /* Render the new clipping path into the new mask surface. */
 
     _cairo_traps_translate (traps, -surface_rect.x, -surface_rect.y);
-    _cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE);
+    _cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE,
+			       CAIRO_CONTENT_COLOR);
 
     status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_IN,
 						  &pattern.base,
diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index cfebc32..09e6755 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -822,7 +822,10 @@ _cairo_glitz_pattern_acquire_surfaces (c
 	combined = src_solid->color;
 	_cairo_color_multiply_alpha (&combined, mask_solid->color.alpha);
 
-	_cairo_pattern_init_solid (&tmp.solid, &combined);
+	_cairo_pattern_init_solid (&tmp.solid, &combined,
+				   CAIRO_COLOR_IS_OPAQUE (&combined) ?
+				   CAIRO_CONTENT_COLOR :
+				   CAIRO_CONTENT_COLOR_ALPHA);
 
 	mask = NULL;
     } else {
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index c5d5f38..a048fbb 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -91,7 +91,8 @@ _cairo_gstate_init (cairo_gstate_t  *gst
     _cairo_gstate_identity_matrix (gstate);
     gstate->source_ctm_inverse = gstate->ctm_inverse;
 
-    gstate->source = _cairo_pattern_create_solid (CAIRO_COLOR_BLACK);
+    gstate->source = _cairo_pattern_create_solid (CAIRO_COLOR_BLACK,
+						  CAIRO_CONTENT_COLOR);
     if (gstate->source->status)
 	return CAIRO_STATUS_NO_MEMORY;
 
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index e29778d..b6c8df7 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -209,10 +209,12 @@ _cairo_pattern_fini (cairo_pattern_t *pa
 
 void
 _cairo_pattern_init_solid (cairo_solid_pattern_t *pattern,
-			   const cairo_color_t	 *color)
+			   const cairo_color_t	 *color,
+			   cairo_content_t	  content)
 {
     _cairo_pattern_init (&pattern->base, CAIRO_PATTERN_TYPE_SOLID);
     pattern->color = *color;
+    pattern->content = content;
 }
 
 void
@@ -278,7 +280,8 @@ static struct {
 } solid_pattern_cache;
 
 cairo_pattern_t *
-_cairo_pattern_create_solid (const cairo_color_t *color)
+_cairo_pattern_create_solid (const cairo_color_t *color,
+			     cairo_content_t	  content)
 {
     cairo_solid_pattern_t *pattern = NULL;
 
@@ -301,7 +304,7 @@ _cairo_pattern_create_solid (const cairo
     if (pattern == NULL)
 	pattern = (cairo_solid_pattern_t *) &_cairo_pattern_nil;
     else
-	_cairo_pattern_init_solid (pattern, color);
+	_cairo_pattern_init_solid (pattern, color, content);
 
     return &pattern->base;
 }
@@ -327,7 +330,8 @@ _cairo_pattern_create_in_error (cairo_st
 {
     cairo_pattern_t *pattern;
 
-    pattern = _cairo_pattern_create_solid (_cairo_stock_color (CAIRO_STOCK_BLACK));
+    pattern = _cairo_pattern_create_solid (_cairo_stock_color (CAIRO_STOCK_BLACK),
+					   CAIRO_CONTENT_COLOR);
     /* no-op on a pattern already in error i.e the _cairo_pattern_nil */
     _cairo_pattern_set_error (pattern, status);
 
@@ -366,7 +370,8 @@ cairo_pattern_create_rgb (double red, do
 
     _cairo_color_init_rgb (&color, red, green, blue);
 
-    pattern = _cairo_pattern_create_solid (&color);
+    pattern = _cairo_pattern_create_solid (&color,
+					   CAIRO_CONTENT_COLOR);
     if (pattern->status)
 	_cairo_error (pattern->status);
 
@@ -409,7 +414,8 @@ cairo_pattern_create_rgba (double red, d
 
     _cairo_color_init_rgba (&color, red, green, blue, alpha);
 
-    pattern = _cairo_pattern_create_solid (&color);
+    pattern = _cairo_pattern_create_solid (&color,
+					   CAIRO_CONTENT_COLOR_ALPHA);
     if (pattern->status)
 	_cairo_error (pattern->status);
 
@@ -1246,12 +1252,10 @@ _cairo_pattern_acquire_surface_for_solid
 					  cairo_surface_attributes_t *attribs)
 {
     *out = _cairo_surface_create_similar_solid (dst,
-	                               CAIRO_COLOR_IS_OPAQUE (&pattern->color) ?
-				       CAIRO_CONTENT_COLOR :
-				       CAIRO_CONTENT_COLOR_ALPHA,
-				       1, 1,
-				       &pattern->color,
-				       &pattern->base);
+						pattern->content,
+						1, 1,
+						&pattern->color,
+						&pattern->base);
     if ((*out)->status)
 	return CAIRO_STATUS_NO_MEMORY;
 
@@ -1583,14 +1587,18 @@ _cairo_pattern_acquire_surface (cairo_pa
 					src->stops->color.blue / 65535.0,
 					src->stops->color.alpha / 65535.0);
 
-		_cairo_pattern_init_solid (&solid, &color);
+		_cairo_pattern_init_solid (&solid, &color,
+					   CAIRO_COLOR_IS_OPAQUE (&color) ?
+					   CAIRO_CONTENT_COLOR :
+					   CAIRO_CONTENT_COLOR_ALPHA);
 	    }
 	    else
 	    {
 		const cairo_color_t *color;
 
 		color =	_cairo_stock_color (CAIRO_STOCK_TRANSPARENT);
-		_cairo_pattern_init_solid (&solid, color);
+		_cairo_pattern_init_solid (&solid, color,
+					   CAIRO_CONTENT_ALPHA);
 	    }
 
 	    status = _cairo_pattern_acquire_surface_for_solid (&solid, dst,
@@ -1692,7 +1700,10 @@ _cairo_pattern_acquire_surfaces (cairo_p
 	combined = src_solid->color;
 	_cairo_color_multiply_alpha (&combined, mask_solid->color.alpha);
 
-	_cairo_pattern_init_solid (&src_tmp.solid, &combined);
+	_cairo_pattern_init_solid (&src_tmp.solid, &combined,
+				   CAIRO_COLOR_IS_OPAQUE (&combined) ?
+				   CAIRO_CONTENT_COLOR :
+				   CAIRO_CONTENT_COLOR_ALPHA);
 
 	mask = NULL;
     }
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index a504826..aa43496 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -365,7 +365,8 @@ _clip_and_composite (cairo_clip_t       
 	return CAIRO_STATUS_SUCCESS;
 
     if (op == CAIRO_OPERATOR_CLEAR) {
-	_cairo_pattern_init_solid (&solid_pattern.solid, CAIRO_COLOR_WHITE);
+	_cairo_pattern_init_solid (&solid_pattern.solid, CAIRO_COLOR_WHITE,
+				   CAIRO_CONTENT_COLOR);
 	src = &solid_pattern.base;
 	op = CAIRO_OPERATOR_DEST_OUT;
     }
@@ -420,7 +421,8 @@ _composite_trap_region (cairo_clip_t    
     cairo_surface_t *clip_surface = clip ? clip->surface : NULL;
 
     if (clip_surface && op == CAIRO_OPERATOR_CLEAR) {
-	_cairo_pattern_init_solid (&solid_pattern.solid, CAIRO_COLOR_WHITE);
+	_cairo_pattern_init_solid (&solid_pattern.solid, CAIRO_COLOR_WHITE,
+				   CAIRO_CONTENT_COLOR);
 	src = &solid_pattern.base;
 	op = CAIRO_OPERATOR_DEST_OUT;
     }
@@ -490,7 +492,8 @@ _composite_traps_draw_func (void        
     if (dst_x != 0 || dst_y != 0)
 	_cairo_traps_translate (info->traps, - dst_x, - dst_y);
 
-    _cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE);
+    _cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE,
+			       CAIRO_CONTENT_COLOR);
     if (!src)
 	src = &pattern.base;
 
@@ -894,7 +897,8 @@ _cairo_surface_old_show_glyphs_draw_func
 	}
     }
 
-    _cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE);
+    _cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE,
+			       CAIRO_CONTENT_COLOR);
     if (!src)
 	src = &pattern.base;
 
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 1049964..314413a 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -313,7 +313,7 @@ _cairo_surface_create_similar_solid (cai
     }
 
     if (pattern == NULL) {
-	source = _cairo_pattern_create_solid (color);
+	source = _cairo_pattern_create_solid (color, content);
 	if (source->status) {
 	    cairo_surface_destroy (surface);
 	    _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 0897961..e8ab0fb 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -2344,7 +2344,8 @@ _cairo_xcb_surface_show_glyphs (void    
      * so PictOpClear was never used with CompositeText before.
      */
     if (op == CAIRO_OPERATOR_CLEAR) {
-	_cairo_pattern_init_solid (&solid_pattern.solid, CAIRO_COLOR_WHITE);
+	_cairo_pattern_init_solid (&solid_pattern.solid, CAIRO_COLOR_WHITE,
+				   CAIRO_CONTENT_COLOR);
 	src_pattern = &solid_pattern.base;
 	op = CAIRO_OPERATOR_DEST_OUT;
     }
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 8d9d107..ea34321 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2878,7 +2878,8 @@ _cairo_xlib_surface_show_glyphs (void   
      * so PictOpClear was never used with CompositeText before.
      */
     if (op == CAIRO_OPERATOR_CLEAR) {
-	_cairo_pattern_init_solid (&solid_pattern.solid, CAIRO_COLOR_WHITE);
+	_cairo_pattern_init_solid (&solid_pattern.solid, CAIRO_COLOR_WHITE,
+				   CAIRO_CONTENT_COLOR);
 	src_pattern = &solid_pattern.base;
 	op = CAIRO_OPERATOR_DEST_OUT;
     }
diff --git a/src/cairo.c b/src/cairo.c
index 621dea8..cd28cbb 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -1913,7 +1913,7 @@ cairo_paint_with_alpha (cairo_t *cr,
     }
 
     _cairo_color_init_rgba (&color, 1., 1., 1., alpha);
-    _cairo_pattern_init_solid (&pattern.solid, &color);
+    _cairo_pattern_init_solid (&pattern.solid, &color, CAIRO_CONTENT_ALPHA);
 
     status = _cairo_gstate_mask (cr->gstate, &pattern.base);
     if (status)
diff --git a/src/cairoint.h b/src/cairoint.h
index eba7398..701258f 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -969,6 +969,7 @@ struct _cairo_pattern {
 typedef struct _cairo_solid_pattern {
     cairo_pattern_t base;
     cairo_color_t color;
+    cairo_content_t content;
 } cairo_solid_pattern_t;
 
 extern const cairo_private cairo_solid_pattern_t _cairo_pattern_nil;
@@ -2241,8 +2242,9 @@ _cairo_pattern_init_copy (cairo_pattern_
 			  const cairo_pattern_t *other);
 
 cairo_private void
-_cairo_pattern_init_solid (cairo_solid_pattern_t *pattern,
-			   const cairo_color_t *color);
+_cairo_pattern_init_solid (cairo_solid_pattern_t	*pattern,
+			   const cairo_color_t		*color,
+			   cairo_content_t		 content);
 
 cairo_private void
 _cairo_pattern_init_for_surface (cairo_surface_pattern_t *pattern,
@@ -2261,7 +2263,8 @@ cairo_private void
 _cairo_pattern_fini (cairo_pattern_t *pattern);
 
 cairo_private cairo_pattern_t *
-_cairo_pattern_create_solid (const cairo_color_t *color);
+_cairo_pattern_create_solid (const cairo_color_t	*color,
+			     cairo_content_t		 content);
 
 cairo_private void
 _cairo_pattern_transform (cairo_pattern_t      *pattern,
diff-tree fea5336e2db201be69256ef1bafd418fee98a21e (from 72b812be8c69108c46334841823a2e9103b69516)
Author: Carl Worth <cworth at cworth.org>
Date:   Wed Apr 25 10:36:12 2007 -0700

    Allow fbCompositeSrc_x888x8x8888mmx when destination has alpha
    
    Previously the check for this optimized function would only allow
    the function to be called if the source and destination had
    identical formats. But the function doesn't read the destination
    alpha (if any) so can be used when it exists as well.
    
    (Thanks to Jeff Muizelaar for pointing out this problem.)

diff --git a/pixman/src/fbpict.c b/pixman/src/fbpict.c
index 2535252..03f75f1 100644
--- a/pixman/src/fbpict.c
+++ b/pixman/src/fbpict.c
@@ -1642,8 +1642,14 @@ pixman_composite (pixman_operator_t	op,
 			    break;
 #ifdef USE_MMX
 			case PICT_x8r8g8b8:
+			    if ((pDst->format_code == PICT_a8r8g8b8 ||
+				 pDst->format_code == PICT_x8r8g8b8) &&
+				pMask->format_code == PICT_a8 && fbHaveMMX())
+				func = fbCompositeSrc_x888x8x8888mmx;
+			    break;
 			case PICT_x8b8g8r8:
-			    if (pDst->format_code == pSrc->format_code &&
+			    if ((pDst->format_code == PICT_a8b8g8r8 ||
+				 pDst->format_code == PICT_x8b8g8r8) &&
 				pMask->format_code == PICT_a8 && fbHaveMMX())
 				func = fbCompositeSrc_x888x8x8888mmx;
 			    break;


More information about the cairo-commit mailing list