[cairo-commit] cairo/src cairo_pattern.c,1.24,1.25

David Reveman commit at pdx.freedesktop.org
Thu Mar 3 18:46:51 PST 2005


Committed by: davidr

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv31181/src

Modified Files:
	cairo_pattern.c 
Log Message:
Add overall alpha acceleration using mask surface

Index: cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_pattern.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- cairo_pattern.c	4 Mar 2005 02:39:06 -0000	1.24
+++ cairo_pattern.c	4 Mar 2005 02:46:49 -0000	1.25
@@ -1129,21 +1129,61 @@
 				 cairo_surface_attributes_t *src_attributes,
 				 cairo_surface_attributes_t *mask_attributes)
 {
-    cairo_int_status_t status;
+    cairo_int_status_t	  status;
+    cairo_pattern_union_t tmp;
+    double		  src_alpha, mask_alpha;
 
-    status = _cairo_pattern_acquire_surface (src, dst,
+    if (src->type == CAIRO_PATTERN_SURFACE)
+    {
+	if (mask)
+	    mask_alpha = mask->alpha * src->alpha;
+	else
+	    mask_alpha = src->alpha;
+	
+	src_alpha = 1.0;
+    }
+    else
+    {
+	if (mask)
+	{
+	    src_alpha = mask->alpha * src->alpha;
+	    if (mask->type == CAIRO_PATTERN_SOLID)
+		mask = NULL;
+	} else
+	    src_alpha = src->alpha;
+
+	mask_alpha = 1.0;
+    }
+
+    _cairo_pattern_init_copy (&tmp.base, src);
+    _cairo_pattern_set_alpha (&tmp.base, src_alpha);
+	
+    status = _cairo_pattern_acquire_surface (&tmp.base, dst,
 					     src_x, src_y,
 					     width, height,
 					     src_out, src_attributes);
+    
+    _cairo_pattern_fini (&tmp.base);
+
     if (status)
 	return status;
 
-    if (mask)
+    if (mask || mask_alpha != 1.0)
     {
-	status = _cairo_pattern_acquire_surface (mask, dst,
+	if (mask)
+	    _cairo_pattern_init_copy (&tmp.base, mask);
+	else
+	    _cairo_pattern_init_solid (&tmp.solid, 0.0, 0.0, 0.0);
+	
+	_cairo_pattern_set_alpha (&tmp.base, mask_alpha);
+	
+	status = _cairo_pattern_acquire_surface (&tmp.base, dst,
 						 mask_x, mask_y,
 						 width, height,
 						 mask_out, mask_attributes);
+    
+	_cairo_pattern_fini (&tmp.base);
+
 	if (status)
 	{
 	    _cairo_pattern_release_surface (dst, *src_out, src_attributes);




More information about the cairo-commit mailing list