From e104fcab1c8c8d9a7a7962a1dbea0c87867c8f9a Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Thu, 31 Jan 2008 01:33:50 +0000 Subject: [PATCH] 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. --- doc/public/cairo-sections.txt | 1 + src/cairo.c | 25 +++++++++++++++++++++++-- src/cairo.h | 3 +++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/doc/public/cairo-sections.txt b/doc/public/cairo-sections.txt index f7c838d25..abfda0eb7 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 14bfdc0e8..fd65a34f8 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -3244,6 +3244,26 @@ cairo_get_antialias (cairo_t *cr) return _cairo_gstate_get_antialias (cr->gstate); } +/** + * 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 @@ -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 01a6a2ed1..0c244ba30 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);