[cairo-commit] 2 commits - src/cairo.c src/cairo-font-face.c src/cairo-pattern.c src/cairo-pdf-operators.c src/cairo-scaled-font.c src/cairo-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Sep 23 12:09:19 PDT 2008


 src/cairo-font-face.c     |    2 +-
 src/cairo-pattern.c       |    2 +-
 src/cairo-pdf-operators.c |   14 ++++++++++++--
 src/cairo-scaled-font.c   |    2 +-
 src/cairo-surface.c       |    2 +-
 src/cairo.c               |    2 +-
 6 files changed, 17 insertions(+), 7 deletions(-)

New commits:
commit ae0511fbbe6c01b5fe8dfa531b3eaa791314931f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Sep 23 20:00:18 2008 +0100

    [pdf] Do not modify the dashes in-place.
    
    As PS has different semantics regarding a zero-length dash, we need to
    adjust the dash array before emitting. However, we need to modify a copy
    of the dash array since the same array may be used by the meta-surface
    when replaying to an image fallback.

diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 0b6c00e..baa36de 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -571,6 +571,16 @@ _cairo_pdf_operators_emit_stroke_style (cairo_pdf_operators_t	*pdf_operators,
 
 	for (i = 0; i < num_dashes; i += 2) {
 	    if (dash[i] == 0.0) {
+		/* Do not modify the dashes in-place, as we may need to also
+		 * replay this stroke to an image fallback.
+		 */
+		if (dash == style->dash) {
+		    dash = _cairo_malloc_ab (num_dashes, sizeof (double));
+		    if (dash == NULL)
+			return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+		    memcpy (dash, style->dash, num_dashes * sizeof (double));
+		}
+
 		/* If we're at the front of the list, we first rotate
 		 * two elements from the end of the list to the front
 		 * of the list before folding away the 0.0. Or, if
@@ -581,10 +591,10 @@ _cairo_pdf_operators_emit_stroke_style (cairo_pdf_operators_t	*pdf_operators,
 		    double last_two[2];
 
 		    if (num_dashes == 2) {
-			if (dash != style->dash)
-			    free (dash);
+			free (dash);
 			return CAIRO_INT_STATUS_NOTHING_TO_DO;
 		    }
+
 		    /* The cases of num_dashes == 0, 1, or 3 elements
 		     * cannot exist, so the rotation of 2 elements
 		     * will always be safe */
commit b7ab1fc791139f5d0fd38692b63514ed02bc8b51
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Sep 23 10:51:13 2008 +0100

    Return the real error status for set_user_data()
    
    Instead of returning a new NO_MEMORY error, return the status from the
    error object.

diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c
index 4f822a2..5af0c63 100644
--- a/src/cairo-font-face.c
+++ b/src/cairo-font-face.c
@@ -306,7 +306,7 @@ cairo_font_face_set_user_data (cairo_font_face_t	   *font_face,
 			       cairo_destroy_func_t	    destroy)
 {
     if (CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	return font_face->status;
 
     return _cairo_user_data_array_set_data (&font_face->user_data,
 					    key, user_data, destroy);
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 2b8771c..b6c40e3 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -814,7 +814,7 @@ cairo_pattern_set_user_data (cairo_pattern_t		 *pattern,
 			     cairo_destroy_func_t	  destroy)
 {
     if (CAIRO_REFERENCE_COUNT_IS_INVALID (&pattern->ref_count))
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	return pattern->status;
 
     return _cairo_user_data_array_set_data (&pattern->user_data,
 					    key, user_data, destroy);
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index dce4eaa..7bf0dac 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -1103,7 +1103,7 @@ cairo_scaled_font_set_user_data (cairo_scaled_font_t	     *scaled_font,
 				 cairo_destroy_func_t	      destroy)
 {
     if (CAIRO_REFERENCE_COUNT_IS_INVALID (&scaled_font->ref_count))
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	return scaled_font->status;
 
     return _cairo_user_data_array_set_data (&scaled_font->user_data,
 					    key, user_data, destroy);
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index ead6f1b..7c7f797 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -584,7 +584,7 @@ cairo_surface_set_user_data (cairo_surface_t		 *surface,
 			     cairo_destroy_func_t	 destroy)
 {
     if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count))
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	return surface->status;
 
     return _cairo_user_data_array_set_data (&surface->user_data,
 					    key, user_data, destroy);
diff --git a/src/cairo.c b/src/cairo.c
index 399c38d..525d1f9 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -288,7 +288,7 @@ cairo_set_user_data (cairo_t			 *cr,
 		     cairo_destroy_func_t	 destroy)
 {
     if (CAIRO_REFERENCE_COUNT_IS_INVALID (&cr->ref_count))
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	return cr->status;
 
     return _cairo_user_data_array_set_data (&cr->user_data,
 					    key, user_data, destroy);


More information about the cairo-commit mailing list