[cairo-commit] cairo/src cairo_gstate.c,1.85,1.86

Carl Worth commit at pdx.freedesktop.org
Fri Feb 25 12:58:51 PST 2005


Committed by: cworth

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

Modified Files:
	cairo_gstate.c 
Log Message:

        From David Reveman:

        * src/cairo_gstate.c (_cairo_gstate_pattern_init_copy):
        (_cairo_gstate_clip_and_composite_trapezoids)
        (_cairo_gstate_clip_and_composite_trapezoids)
        (_cairo_gstate_show_surface, _cairo_gstate_show_glyphs)
        (_cairo_gstate_show_glyphs): Clean up the mess that was
        the misnamed _cairo_gstate_create_pattern.


Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- cairo_gstate.c	24 Feb 2005 20:28:51 -0000	1.85
+++ cairo_gstate.c	25 Feb 2005 20:58:49 -0000	1.86
@@ -1309,35 +1309,17 @@
 				  &gpi);
 }
 
-/* This function modifies the pattern and the state of the pattern surface it
-   may contain. The pattern surface will be restored to its orignal state
-   when the pattern is destroyed. The appropriate way is to pass a copy of
-   the original pattern to this function just before the pattern should be
-   used and destroy the copy when done. */
+/* XXX: gstate->alpha will be going away before too long, and when it
+ * does, it may make sense for this function to just disappear.
+ */
 static void
-_cairo_gstate_create_pattern (cairo_gstate_t *gstate,
-			      cairo_pattern_t *pattern)
+_cairo_gstate_pattern_init_copy (cairo_gstate_t  *gstate,
+				 cairo_pattern_t *pattern,
+				 cairo_pattern_t *src)
 {
-    if (pattern->type == CAIRO_PATTERN_LINEAR ||
-	pattern->type == CAIRO_PATTERN_RADIAL) {
-	if (pattern->n_stops < 2) {
-	    pattern->type = CAIRO_PATTERN_SOLID;
-      
-	    if (pattern->n_stops) {
-		cairo_color_stop_t *stop = pattern->stops;
-		
-		_cairo_color_set_rgb (&pattern->color,
-				      (double) stop->color_char[0] / 0xff,
-				      (double) stop->color_char[1] / 0xff,
-				      (double) stop->color_char[2] / 0xff);
-		_cairo_color_set_alpha (&pattern->color,
-					(double) stop->color_char[3] / 0xff);
-	    }
-	}
-    }
-  
-    _cairo_pattern_set_alpha (pattern, gstate->alpha);
+    _cairo_pattern_init_copy (pattern, src);
     _cairo_pattern_transform (pattern, &gstate->ctm_inverse);
+    _cairo_pattern_set_alpha (pattern, gstate->alpha);
 }
 
 cairo_status_t
@@ -1556,10 +1538,9 @@
     
 	if (status)
 	    goto BAIL2;
-    
-	_cairo_pattern_init_copy (&pattern, src);
-	_cairo_gstate_create_pattern (gstate, &pattern);
 
+	_cairo_gstate_pattern_init_copy (gstate, &pattern, src);
+	
 	status = _cairo_surface_composite (operator,
 					   &pattern, intermediate, dst,
 					   extents.x, extents.y,
@@ -1611,9 +1592,8 @@
 	    ;
 	}
 
-	_cairo_pattern_init_copy (&pattern, src);
-	_cairo_gstate_create_pattern (gstate, &pattern);
-
+	_cairo_gstate_pattern_init_copy (gstate, &pattern, src);
+	
 	status = _cairo_surface_composite_trapezoids (gstate->operator,
 						      &pattern, dst,
 						      extents.x, extents.y,
@@ -2033,7 +2013,8 @@
 					  &device_width, &device_height);
 
     _cairo_pattern_init_for_surface (&pattern, surface);
-    _cairo_gstate_create_pattern (gstate, &pattern);
+    _cairo_pattern_transform (&pattern, &gstate->ctm_inverse);
+    _cairo_pattern_set_alpha (&pattern, gstate->alpha);
 
     pattern_extents.p1.x = _cairo_fixed_from_double (device_x);
     pattern_extents.p1.y = _cairo_fixed_from_double (device_y);
@@ -2492,8 +2473,7 @@
 	if (status)
 	    goto BAIL2;
 
-	_cairo_pattern_init_copy (&pattern, gstate->pattern);
-	_cairo_gstate_create_pattern (gstate, &pattern);
+	_cairo_gstate_pattern_init_copy (gstate, &pattern, gstate->pattern);
     
 	status = _cairo_surface_composite (gstate->operator,
 					   &pattern,
@@ -2512,8 +2492,7 @@
     }
     else
     {
-	_cairo_pattern_init_copy (&pattern, gstate->pattern);
-	_cairo_gstate_create_pattern (gstate, &pattern);
+	_cairo_gstate_pattern_init_copy (gstate, &pattern, gstate->pattern);
 
 	status = _cairo_font_show_glyphs (gstate->font, 
 					  gstate->operator, &pattern,




More information about the cairo-commit mailing list