[cairo-commit] 2 commits - src/cairo.c src/cairo.h src/cairo-path-fixed.c test/get-and-set.c

Carl Worth cworth at kemper.freedesktop.org
Thu Jan 18 13:09:31 PST 2007


 src/cairo-path-fixed.c |   16 +++++++++++++---
 src/cairo.c            |   37 +++++++++++--------------------------
 src/cairo.h            |    6 +++---
 test/get-and-set.c     |   17 ++++++-----------
 4 files changed, 33 insertions(+), 43 deletions(-)

New commits:
diff-tree 28d6a228f030dbec05ab5b0ba680db272df67c49 (from bc7072064e421e4c5e5043aada6cae1d8250938f)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Jan 18 13:01:53 2007 -0800

    Fix cairo_get_dash and cairo_get_dash_count APIs
    
    Make these functions consistent with other cairo_get functions
    by making cairo_get_dash_count return the count directly, and
    removing the cairo_status_t return value from cairo_get_dash.

diff --git a/src/cairo.c b/src/cairo.c
index 637c0d0..2e522a6 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -953,26 +953,18 @@ cairo_set_dash (cairo_t	     *cr,
 /**
  * cairo_get_dash_count:
  * @cr: a #cairo_t
- * @count: return value for the number of dash values, or %NULL
  *
- * Gets the length of the dash array in @cr.
+ * Returns the length of the dash array in @cr (0 if dashing is not
+ * currently in effect).
  *
- * Return value: %CAIRO_STATUS_SUCCESS, or error status set on
- * @cr.
+ * See also cairo_set_dash() and cairo_get_dash().
  *
  * Since: 1.4
  */
-cairo_status_t
-cairo_get_dash_count (cairo_t *cr,
-		      int     *count)
+int
+cairo_get_dash_count (cairo_t *cr)
 {
-    if (cr->status)
-	return cr->status;
-
-    if (count)
-	*count = cr->gstate->stroke_style.num_dashes;
-
-    return CAIRO_STATUS_SUCCESS;
+    return cr->gstate->stroke_style.num_dashes;
 }
 
 /**
@@ -985,27 +977,20 @@ cairo_get_dash_count (cairo_t *cr,
  * enough to hold at least the number of values returned by
  * cairo_get_dash_count().
  *
- * Return value: %CAIRO_STATUS_SUCCESS, or error status set on
- * @cr.
- *
  * Since: 1.4
  **/
-cairo_status_t
+void
 cairo_get_dash (cairo_t *cr,
 		double  *dashes,
 		double  *offset)
 {
-    if (cr->status)
-	return cr->status;
-
-    memcpy (dashes,
-	    cr->gstate->stroke_style.dash,
-	    sizeof(double) * cr->gstate->stroke_style.num_dashes);
+    if (dashes)
+	memcpy (dashes,
+		cr->gstate->stroke_style.dash,
+		sizeof (double) * cr->gstate->stroke_style.num_dashes);
 
     if (offset)
 	*offset = cr->gstate->stroke_style.dash_offset;
-
-    return CAIRO_STATUS_SUCCESS;
 }
 
 void
diff --git a/src/cairo.h b/src/cairo.h
index bd2620a..1c3fb25 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -1113,10 +1113,10 @@ cairo_get_line_join (cairo_t *cr);
 cairo_public double
 cairo_get_miter_limit (cairo_t *cr);
 
-cairo_public cairo_status_t
-cairo_get_dash_count (cairo_t *cr, int *count);
+cairo_public int
+cairo_get_dash_count (cairo_t *cr);
 
-cairo_public cairo_status_t
+cairo_public void
 cairo_get_dash (cairo_t *cr, double *dashes, double *offset);
 
 cairo_public void
diff --git a/test/get-and-set.c b/test/get-and-set.c
index ec35834..c23707e 100644
--- a/test/get-and-set.c
+++ b/test/get-and-set.c
@@ -93,6 +93,8 @@ settings_set (cairo_t *cr, settings_t *s
 static int
 settings_get (cairo_t *cr, settings_t *settings)
 {
+    int count;
+
     settings->op = cairo_get_operator (cr);
     settings->tolerance = cairo_get_tolerance (cr);
     settings->fill_rule = cairo_get_fill_rule (cr);
@@ -102,18 +104,11 @@ settings_get (cairo_t *cr, settings_t *s
     settings->miter_limit = cairo_get_miter_limit (cr);
     cairo_get_matrix (cr, &settings->matrix);
 
-    {
-	cairo_status_t status;
-	int count;
+    count = cairo_get_dash_count (cr);
+    if (count != 5)
+	return -1;
 
-	status = cairo_get_dash_count (cr, &count);
-	if (status || count != 5)
-	    return -1;
-
-	status = cairo_get_dash (cr, settings->dash, &settings->dash_offset);
-	if (status)
-	    return -1;
-    }
+    cairo_get_dash (cr, settings->dash, &settings->dash_offset);
 
     return 0;
 }
diff-tree bc7072064e421e4c5e5043aada6cae1d8250938f (from d9df44d8071d038060e0cc987871c185f7733a3d)
Author: Carl Worth <cworth at cworth.org>
Date:   Wed Jan 17 15:07:12 2007 -0800

    cairo-path-fixed: Don't add redundant, succesive MOVE_TO operations to the path
    
    Instead, we can simply tweak the argument value for the last
    MOVE_TO operation that's already at the end of the path.
    
    This helps backends like pdf that are currently emitting all
    of the redundant MOVE_TO operations in the output.

diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index 71d646b..3505c66 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -187,9 +187,19 @@ _cairo_path_fixed_move_to (cairo_path_fi
     point.x = x;
     point.y = y;
 
-    status = _cairo_path_fixed_add (path, CAIRO_PATH_OP_MOVE_TO, &point, 1);
-    if (status)
-	return status;
+    /* If the previous op was also a MOVE_TO, then just change its
+     * point rather than adding a new op. */
+    if (path->op_buf_tail && path->op_buf_tail->num_ops &&
+	path->op_buf_tail->op[path->op_buf_tail->num_ops - 1] == CAIRO_PATH_OP_MOVE_TO)
+    {
+	cairo_point_t *last_move_to_point;
+	last_move_to_point = &path->arg_buf_tail->points[path->arg_buf_tail->num_points - 1];
+	*last_move_to_point = point;
+    } else {
+	status = _cairo_path_fixed_add (path, CAIRO_PATH_OP_MOVE_TO, &point, 1);
+	if (status)
+	    return status;
+    }
 
     path->current_point = point;
     path->has_current_point = TRUE;


More information about the cairo-commit mailing list