diff options
author | Carl Worth <cworth@cworth.org> | 2006-08-18 06:27:45 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2006-08-18 06:32:12 -0700 |
commit | 53f74e59faf1af78f2f0741ccf1f23aa5dad4efc (patch) | |
tree | 913177c33b47d7e85db7d5aceac971333b1a841a | |
parent | 200a2d811efab2e48d6b584b9da202effaddf99f (diff) |
Fix close-path failure by adding explicit move_to after close_path.
Besides the bug fix, this is a user-visible change since the new
move_to element after the close_path element can be seen in the
results of cairo_copy_path, so we document that here.
We are also careful to fix up _cairo_path_fixed_line_to to defer to
_cairo_path_fixed_move_to to avoid letting the last_move_point state
get stale. This avoids introducing the second bug that is also tested
by the close-path test case.
-rw-r--r-- | src/cairo-path.c | 15 | ||||
-rw-r--r-- | src/cairo.c | 8 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/cairo-path.c b/src/cairo-path.c index b0c094ed1..9549f8d3f 100644 --- a/src/cairo-path.c +++ b/src/cairo-path.c @@ -228,8 +228,13 @@ _cairo_path_fixed_line_to (cairo_path_fixed_t *path, point.x = x; point.y = y; + /* When there is not yet a current point, the line_to operation + * becomes a move_to instead. Note: We have to do this by + * explicitly calling into _cairo_path_fixed_line_to to ensure + * that the last_move_point state is updated properly. + */ if (! path->has_current_point) - status = _cairo_path_fixed_add (path, CAIRO_PATH_OP_MOVE_TO, &point, 1); + status = _cairo_path_fixed_move_to (path, point.x, point.y); else status = _cairo_path_fixed_add (path, CAIRO_PATH_OP_LINE_TO, &point, 1); @@ -328,9 +333,11 @@ _cairo_path_fixed_close_path (cairo_path_fixed_t *path) if (status) return status; - path->current_point.x = path->last_move_point.x; - path->current_point.y = path->last_move_point.y; - path->has_current_point = TRUE; + status = _cairo_path_fixed_move_to (path, + path->last_move_point.x, + path->last_move_point.y); + if (status) + return status; return CAIRO_STATUS_SUCCESS; } diff --git a/src/cairo.c b/src/cairo.c index 837976fd7..928ebca4e 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -1645,6 +1645,14 @@ cairo_stroke_to_path (cairo_t *cr) * * If there is no current point before the call to cairo_close_path, * this function will have no effect. + * + * Note: As of cairo version 1.2.4 any call to cairo_close_path will + * place an explicit MOVE_TO element into the path immediately after + * the CLOSE_PATH element, (which can be seen in cairo_copy_path() for + * example). This can simplify path processing in some cases as it may + * not be necessary to save the "last move_to point" during processing + * as the MOVE_TO immediately after the CLOSE_PATH will provide that + * point. **/ void cairo_close_path (cairo_t *cr) |