[Commit] cairo/src cairo_gstate.c,1.3,1.4

Carl Worth commit at keithp.com
Tue Aug 26 08:14:43 PDT 2003


Committed by: cworth

Update of /local/src/CVS/cairo/src
In directory home.keithp.com:/tmp/cvs-serv13202/src

Modified Files:
	cairo_gstate.c 
Log Message:
Fixed anchoring/transformation of pattern for stroke/fill.

Index: cairo_gstate.c
===================================================================
RCS file: /local/src/CVS/cairo/src/cairo_gstate.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo_gstate.c	30 Jul 2003 15:30:51 -0000	1.3
+++ cairo_gstate.c	26 Aug 2003 14:14:41 -0000	1.4
@@ -318,11 +318,9 @@
     gstate->pattern = pattern;
     _cairo_surface_reference (gstate->pattern);
 
-    gstate->pattern_offset.x = 0;
-    gstate->pattern_offset.y = 0;
-    cairo_matrix_transform_point (&gstate->ctm,
-				  &gstate->pattern_offset.x,
-				  &gstate->pattern_offset.y);
+    _cairo_gstate_get_current_point (gstate,
+				     &gstate->pattern_offset.x,
+				     &gstate->pattern_offset.y);
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -806,8 +804,8 @@
 _cairo_gstate_stroke (cairo_gstate_t *gstate)
 {
     cairo_status_t status;
-
     cairo_traps_t traps;
+    cairo_matrix_t user_to_pattern, device_to_pattern;
 
     _cairo_pen_init (&gstate->pen_regular, gstate->line_width / 2.0, gstate);
 
@@ -819,12 +817,22 @@
 	return status;
     }
 
+    if (gstate->pattern) {
+	cairo_surface_get_matrix (gstate->pattern, &user_to_pattern);
+	cairo_matrix_multiply (&device_to_pattern, &gstate->ctm_inverse, &user_to_pattern);
+	cairo_surface_set_matrix (gstate->pattern, &device_to_pattern);
+    }
+
     _cairo_gstate_clip_and_composite_trapezoids (gstate,
 						 gstate->pattern ? gstate->pattern : gstate->solid,
 						 gstate->operator,
 						 gstate->surface,
 						 &traps);
 
+    /* restore the matrix originally in the pattern surface */
+    if (gstate->pattern)
+	cairo_surface_set_matrix (gstate->pattern, &user_to_pattern);
+
     cairo_traps_fini (&traps);
 
     _cairo_gstate_new_path (gstate);
@@ -929,6 +937,7 @@
 {
     cairo_status_t status;
     cairo_traps_t traps;
+    cairo_matrix_t user_to_pattern, device_to_pattern;
 
     cairo_traps_init (&traps);
 
@@ -938,11 +947,22 @@
 	return status;
     }
 
+    if (gstate->pattern) {
+	cairo_surface_get_matrix (gstate->pattern, &user_to_pattern);
+	cairo_matrix_multiply (&device_to_pattern, &gstate->ctm_inverse, &user_to_pattern);
+	cairo_surface_set_matrix (gstate->pattern, &device_to_pattern);
+    }
+
     _cairo_gstate_clip_and_composite_trapezoids (gstate,
 						 gstate->pattern ? gstate->pattern : gstate->solid,
 						 gstate->operator,
 						 gstate->surface,
 						 &traps);
+
+    /* restore the matrix originally in the pattern surface */
+    if (gstate->pattern)
+	cairo_surface_set_matrix (gstate->pattern, &user_to_pattern);
+
     cairo_traps_fini (&traps);
 
     _cairo_gstate_new_path (gstate);




More information about the Commit mailing list