[cairo-commit] src/cairo.c src/cairo.h

Behdad Esfahbod behdad at kemper.freedesktop.org
Sat Jan 26 10:56:14 PST 2008


 src/cairo.c |   22 ++++++++++++++++++----
 src/cairo.h |    2 +-
 2 files changed, 19 insertions(+), 5 deletions(-)

New commits:
commit b3eea75d1f7b56c2046b5387a5eb186d8f154184
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Jan 26 13:56:08 2008 -0500

    Change cairo_get_current_point() to return cairo_status_t instead of void
    
    So we can return CAIRO_STATUS_NO_CURRENT_POINT.  Previously it wasn't easy
    to fetch that information.

diff --git a/src/cairo.c b/src/cairo.c
index 9535174..8ad1893 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -2881,7 +2881,7 @@ cairo_text_extents (cairo_t              *cr,
     if (utf8 == NULL)
 	return;
 
-    cairo_get_current_point (cr, &x, &y);
+    (void) cairo_get_current_point (cr, &x, &y);
 
     status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8,
 					   x, y,
@@ -2982,7 +2982,7 @@ cairo_show_text (cairo_t *cr, const char *utf8)
     if (utf8 == NULL)
 	return;
 
-    cairo_get_current_point (cr, &x, &y);
+    (void) cairo_get_current_point (cr, &x, &y);
 
     status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8,
 					       x, y,
@@ -3081,7 +3081,7 @@ cairo_text_path  (cairo_t *cr, const char *utf8)
     if (utf8 == NULL)
 	return;
 
-    cairo_get_current_point (cr, &x, &y);
+    (void) cairo_get_current_point (cr, &x, &y);
 
     status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8,
 					   x, y,
@@ -3228,10 +3228,17 @@ 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.
  **/
-void
+cairo_status_t
 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;
 
@@ -3244,6 +3251,11 @@ 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;
     }
@@ -3252,6 +3264,8 @@ 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 cb04f3c..f465636 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -1232,7 +1232,7 @@ cairo_get_tolerance (cairo_t *cr);
 cairo_public cairo_antialias_t
 cairo_get_antialias (cairo_t *cr);
 
-cairo_public void
+cairo_public cairo_status_t
 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