[cairo-commit] 3 commits - src/cairo-pdf-operators.c src/cairo-pdf-operators-private.h src/cairo-pdf-surface.c src/cairo-pdf-surface-private.h src/cairo-ps-surface.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Sun Feb 17 03:10:09 PST 2008


 src/cairo-pdf-operators-private.h |   10 +++++-----
 src/cairo-pdf-operators.c         |   10 +++++-----
 src/cairo-pdf-surface-private.h   |    1 +
 src/cairo-pdf-surface.c           |   38 ++++++++++++++++++++++++--------------
 src/cairo-ps-surface.c            |   10 +++++-----
 5 files changed, 40 insertions(+), 29 deletions(-)

New commits:
commit 8fb624dbf2c660fbbf6d6964f7876656e1b62e41
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Feb 17 19:49:39 2008 +1030

    Use correct prefix for _cairo_pdf_operators_stroke
    
    s/operator/operators/

diff --git a/src/cairo-pdf-operators-private.h b/src/cairo-pdf-operators-private.h
index 5957a89..36bd2e1 100644
--- a/src/cairo-pdf-operators-private.h
+++ b/src/cairo-pdf-operators-private.h
@@ -86,11 +86,11 @@ _cairo_pdf_operators_clip (cairo_pdf_operators_t 	*pdf_operators,
 			   cairo_fill_rule_t		 fill_rule);
 
 cairo_private cairo_int_status_t
-_cairo_pdf_operator_stroke (cairo_pdf_operators_t 	*pdf_operators,
-			    cairo_path_fixed_t		*path,
-			    cairo_stroke_style_t	*style,
-			    cairo_matrix_t		*ctm,
-			    cairo_matrix_t		*ctm_inverse);
+_cairo_pdf_operators_stroke (cairo_pdf_operators_t 	*pdf_operators,
+			     cairo_path_fixed_t		*path,
+			     cairo_stroke_style_t	*style,
+			     cairo_matrix_t		*ctm,
+			     cairo_matrix_t		*ctm_inverse);
 
 cairo_private cairo_int_status_t
 _cairo_pdf_operators_fill (cairo_pdf_operators_t 	*pdf_operators,
diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 7b66ebb..75b4b7b 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -546,11 +546,11 @@ _cairo_pdf_operators_emit_stroke_style (cairo_pdf_operators_t	*pdf_operators,
 
 
 cairo_int_status_t
-_cairo_pdf_operator_stroke (cairo_pdf_operators_t	*pdf_operators,
-			    cairo_path_fixed_t		*path,
-			    cairo_stroke_style_t	*style,
-			    cairo_matrix_t		*ctm,
-			    cairo_matrix_t		*ctm_inverse)
+_cairo_pdf_operators_stroke (cairo_pdf_operators_t	*pdf_operators,
+			     cairo_path_fixed_t		*path,
+			     cairo_stroke_style_t	*style,
+			     cairo_matrix_t		*ctm,
+			     cairo_matrix_t		*ctm_inverse)
 {
     cairo_status_t status;
     cairo_matrix_t m;
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 0cf5404..cd7cec4 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -3868,11 +3868,11 @@ _cairo_pdf_surface_write_smask_group (cairo_pdf_surface_t     *surface,
 					    group->fill_rule);
 	break;
     case PDF_STROKE:
-	status = _cairo_pdf_operator_stroke (&surface->pdf_operators,
-					     &group->path,
-					     group->style,
-					     &group->ctm,
-					     &group->ctm_inverse);
+	status = _cairo_pdf_operators_stroke (&surface->pdf_operators,
+					      &group->path,
+					      group->style,
+					      &group->ctm,
+					      &group->ctm_inverse);
 	break;
     case PDF_SHOW_GLYPHS:
 	status = _cairo_pdf_operators_show_glyphs (&surface->pdf_operators,
@@ -4369,11 +4369,11 @@ _cairo_pdf_surface_stroke (void			*abstract_surface,
 	if (status)
 	    return status;
 
-	status = _cairo_pdf_operator_stroke (&surface->pdf_operators,
-					     path,
-					     style,
-					     ctm,
-					     ctm_inverse);
+	status = _cairo_pdf_operators_stroke (&surface->pdf_operators,
+					      path,
+					      style,
+					      ctm,
+					      ctm_inverse);
 	if (status)
 	    return status;
 
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 4263e4a..760ddd2 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -2966,11 +2966,11 @@ _cairo_ps_surface_stroke (void			*abstract_surface,
     if (status == CAIRO_INT_STATUS_NOTHING_TO_DO)
         return CAIRO_STATUS_SUCCESS;
 
-    return _cairo_pdf_operator_stroke (&surface->pdf_operators,
-				       path,
-				       style,
-				       ctm,
-				       ctm_inverse);
+    return _cairo_pdf_operators_stroke (&surface->pdf_operators,
+					path,
+					style,
+					ctm,
+					ctm_inverse);
 }
 
 static cairo_int_status_t
commit d2a1576941e46fb71eda8b27bd3df4de691df6ff
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Feb 17 19:48:01 2008 +1030

    PDF/PS: Fix mismatched save restore when using fill-stroke

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 33b83eb..0cf5404 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -267,6 +267,7 @@ _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t	*output,
     surface->paginated_mode = CAIRO_PAGINATED_MODE_ANALYZE;
 
     surface->force_fallbacks = FALSE;
+    surface->select_pattern_gstate_saved = FALSE;
 
     _cairo_pdf_operators_init (&surface->pdf_operators,
 			       surface->output,
@@ -2591,13 +2592,18 @@ _cairo_pdf_surface_select_pattern (cairo_pdf_surface_t *surface,
 	if (status)
 	    return status;
 
+	/* fill-stroke calls select_pattern twice. Don't save if the
+	 * gstate is already saved. */
+	if (!surface->select_pattern_gstate_saved)
+	    _cairo_output_stream_printf (surface->output, "q ");
+
 	if (is_stroke) {
 	    _cairo_output_stream_printf (surface->output,
-					 "q /Pattern CS /p%d SCN ",
+					 "/Pattern CS /p%d SCN ",
 					 pattern_res.id);
 	} else {
 	    _cairo_output_stream_printf (surface->output,
-					 "q /Pattern cs /p%d scn ",
+					 "/Pattern cs /p%d scn ",
 					 pattern_res.id);
 	}
 	_cairo_output_stream_printf (surface->output,
@@ -2614,6 +2620,7 @@ _cairo_pdf_surface_unselect_pattern (cairo_pdf_surface_t *surface)
 {
     if (surface->select_pattern_gstate_saved)
 	_cairo_output_stream_printf (surface->output, "Q\r\n");
+    surface->select_pattern_gstate_saved = FALSE;
 }
 
 static cairo_int_status_t
commit 3a05b5d2d5989386e1500ffcf8738ca89ef8457d
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Feb 17 19:45:45 2008 +1030

    PDF/PS: No need to use save/restore for solid colors

diff --git a/src/cairo-pdf-surface-private.h b/src/cairo-pdf-surface-private.h
index dfb6aae..98ba217 100644
--- a/src/cairo-pdf-surface-private.h
+++ b/src/cairo-pdf-surface-private.h
@@ -149,6 +149,7 @@ struct _cairo_pdf_surface {
 
     cairo_pdf_operators_t pdf_operators;
     cairo_paginated_mode_t paginated_mode;
+    cairo_bool_t select_pattern_gstate_saved;
 
     cairo_bool_t force_fallbacks;
 
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 822bd43..33b83eb 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -2568,7 +2568,7 @@ _cairo_pdf_surface_select_pattern (cairo_pdf_surface_t *surface,
 	    return status;
 
 	_cairo_output_stream_printf (surface->output,
-				     "q %f %f %f ",
+				     "%f %f %f ",
 				     solid_pattern->color.red,
 				     solid_pattern->color.green,
 				     solid_pattern->color.blue);
@@ -2581,6 +2581,7 @@ _cairo_pdf_surface_select_pattern (cairo_pdf_surface_t *surface,
         _cairo_output_stream_printf (surface->output,
                                      "/a%d gs\r\n",
                                      alpha);
+	surface->select_pattern_gstate_saved = FALSE;
     } else {
 	status = _cairo_pdf_surface_add_alpha (surface, 1.0, &alpha);
 	if (status)
@@ -2602,6 +2603,7 @@ _cairo_pdf_surface_select_pattern (cairo_pdf_surface_t *surface,
 	_cairo_output_stream_printf (surface->output,
 				     "/a%d gs\r\n",
 				     alpha);
+	surface->select_pattern_gstate_saved = TRUE;
     }
 
     return _cairo_output_stream_get_status (surface->output);
@@ -2610,7 +2612,8 @@ _cairo_pdf_surface_select_pattern (cairo_pdf_surface_t *surface,
 static void
 _cairo_pdf_surface_unselect_pattern (cairo_pdf_surface_t *surface)
 {
-    _cairo_output_stream_printf (surface->output, "Q\r\n");
+    if (surface->select_pattern_gstate_saved)
+	_cairo_output_stream_printf (surface->output, "Q\r\n");
 }
 
 static cairo_int_status_t


More information about the cairo-commit mailing list