[cairo-commit] 2 commits - doc/public src/cairo.c src/cairo.h

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Feb 5 22:06:06 PST 2008


 doc/public/cairo-sections.txt |    1 
 src/cairo.c                   |   47 ++++++++++++++++++++++++------------------
 src/cairo.h                   |    5 +++-
 3 files changed, 32 insertions(+), 21 deletions(-)

New commits:
commit e104fcab1c8c8d9a7a7962a1dbea0c87867c8f9a
Author: Alp Toker <alp at atoker.com>
Date:   Thu Jan 31 01:33:50 2008 +0000

    Introduce cairo_has_current_point()
    
    cairo_has_current_point() can be used to determine whether a current
    point is defined. We introduce this new symbol with a boolean return
    value to avoid the versioning ambiguity of modifying
    cairo_get_current_point(). This way we also don't have to map what
    should be a routine operation to an error condition as was previously
    proposed.

diff --git a/doc/public/cairo-sections.txt b/doc/public/cairo-sections.txt
index f7c838d..abfda0e 100644
--- a/doc/public/cairo-sections.txt
+++ b/doc/public/cairo-sections.txt
@@ -322,6 +322,7 @@ cairo_copy_path
 cairo_copy_path_flat
 cairo_path_destroy
 cairo_append_path
+cairo_has_current_point
 cairo_get_current_point
 cairo_new_path
 cairo_new_sub_path
diff --git a/src/cairo.c b/src/cairo.c
index 14bfdc0..fd65a34 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -3245,6 +3245,26 @@ cairo_get_antialias (cairo_t *cr)
 }
 
 /**
+ * cairo_has_current_point:
+ * @cr: a cairo context
+ *
+ * Returns whether a current point is defined on the current path.
+ * See cairo_get_current_point() for details on the current point.
+ *
+ * Return value: whether a current point is defined.
+ *
+ * Since: 1.6
+ **/
+cairo_bool_t
+cairo_has_current_point (cairo_t *cr)
+{
+    if (cr->status)
+    return FALSE;
+
+    return cr->path->has_current_point;
+}
+
+/**
  * cairo_get_current_point:
  * @cr: a cairo context
  * @x: return value for X coordinate of the current point
@@ -3254,8 +3274,9 @@ cairo_get_antialias (cairo_t *cr)
  * conceptually the final point reached by the path so far.
  *
  * The current point is returned in the user-space coordinate
- * system. If there is no defined current point then @x and @y will
- * both be set to 0.0.
+ * system. If there is no defined current point or if @cr is in an
+ * error status, @x and @y will both be set to 0.0. It is possible to
+ * check this in advance with cairo_has_current_point().
  *
  * Most path construction functions alter the current point. See the
  * following for details on how they affect the current point:
diff --git a/src/cairo.h b/src/cairo.h
index 01a6a2e..0c244ba 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -1276,6 +1276,9 @@ cairo_get_tolerance (cairo_t *cr);
 cairo_public cairo_antialias_t
 cairo_get_antialias (cairo_t *cr);
 
+cairo_public cairo_bool_t
+cairo_has_current_point (cairo_t *cr);
+
 cairo_public void
 cairo_get_current_point (cairo_t *cr, double *x, double *y);
 
commit 1f0c3d06895ebcbfbae252e6b7298da0b64b37a9
Author: Alp Toker <alp at atoker.com>
Date:   Thu Jan 31 00:54:52 2008 +0000

    Revert "Change cairo_get_current_point() to return cairo_status_t instead of void"
    
    This reverts commit b3eea75d1f7b56c2046b5387a5eb186d8f154184.
    
    Reverted in favour of an alternative approach.
    
    Conflicts:
    
    	src/cairo.c

diff --git a/src/cairo.c b/src/cairo.c
index b047d99..14bfdc0 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -2925,7 +2925,7 @@ cairo_text_extents (cairo_t              *cr,
     if (utf8 == NULL)
 	return;
 
-    (void) cairo_get_current_point (cr, &x, &y);
+    cairo_get_current_point (cr, &x, &y);
 
     status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8,
 					   x, y,
@@ -3026,7 +3026,7 @@ cairo_show_text (cairo_t *cr, const char *utf8)
     if (utf8 == NULL)
 	return;
 
-    (void) cairo_get_current_point (cr, &x, &y);
+    cairo_get_current_point (cr, &x, &y);
 
     status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8,
 					       x, y,
@@ -3125,7 +3125,7 @@ cairo_text_path  (cairo_t *cr, const char *utf8)
     if (utf8 == NULL)
 	return;
 
-    (void) cairo_get_current_point (cr, &x, &y);
+    cairo_get_current_point (cr, &x, &y);
 
     status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8,
 					   x, y,
@@ -3272,17 +3272,10 @@ cairo_get_antialias (cairo_t *cr)
  *
  * Some functions unset the current path and as a result, current point:
  * cairo_fill(), cairo_stroke().
- *
- * Returns: %CAIRO_STATUS_SUCCESS if current point was successfully
- * retrieved.  Otherwise, if @cr has been in an error status, that status
- * is returned, otherwise %CAIRO_STATUS_NO_CURRENT_POINT is returned if
- * no current point exists.  In all error cases, both @x and @y will be
- * set to 0.0.
  **/
-cairo_status_t
+void
 cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret)
 {
-    cairo_status_t status = CAIRO_STATUS_SUCCESS;
     cairo_fixed_t x_fixed, y_fixed;
     double x, y;
 
@@ -3295,11 +3288,6 @@ cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret)
     }
     else
     {
-	if (cr->status)
-	    status = cr->status;
-	else
-	    status = CAIRO_STATUS_NO_CURRENT_POINT;
-
 	x = 0.0;
 	y = 0.0;
     }
@@ -3308,8 +3296,6 @@ cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret)
 	*x_ret = x;
     if (y_ret)
 	*y_ret = y;
-
-    return status;
 }
 slim_hidden_def(cairo_get_current_point);
 
diff --git a/src/cairo.h b/src/cairo.h
index 0aea4b5..01a6a2e 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -1276,7 +1276,7 @@ cairo_get_tolerance (cairo_t *cr);
 cairo_public cairo_antialias_t
 cairo_get_antialias (cairo_t *cr);
 
-cairo_public cairo_status_t
+cairo_public void
 cairo_get_current_point (cairo_t *cr, double *x, double *y);
 
 cairo_public cairo_fill_rule_t


More information about the cairo-commit mailing list