diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-10-17 11:40:34 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-10-29 17:31:22 +0200 |
commit | f3e7677109d7ac0b775f2d373796f444cc3bff54 (patch) | |
tree | 5a21823b34f17aa808bfc676473ef4050165fc59 /src/cairo-path-fixed.c | |
parent | 641d314b9a3c670ddade74df99f1443063bd991b (diff) |
path: Simplify close_path
Instead of explicitly computing the flag in close_path, manually close
the path with a line_to, then drop the last operation if it is a
line_to (it might be another operation if the line_to was ignored
because it would have been degenerate).
Diffstat (limited to 'src/cairo-path-fixed.c')
-rw-r--r-- | src/cairo-path-fixed.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c index 2e8da1c6c..3a60653a0 100644 --- a/src/cairo-path-fixed.c +++ b/src/cairo-path-fixed.c @@ -655,27 +655,24 @@ _cairo_path_fixed_close_path (cairo_path_fixed_t *path) if (! path->has_current_point) return CAIRO_STATUS_SUCCESS; - /* If the previous op was also a LINE_TO back to the start, discard it */ - if (_cairo_path_fixed_last_op (path) == CAIRO_PATH_OP_LINE_TO) { - if (path->current_point.x == path->last_move_point.x && - path->current_point.y == path->last_move_point.y) - { - cairo_path_buf_t *buf; - cairo_point_t *p; - - buf = cairo_path_tail (path); - if (likely (buf->num_points >= 2)) { - p = &buf->points[buf->num_points-2]; - } else { - cairo_path_buf_t *prev_buf = cairo_path_buf_prev (buf); - p = &prev_buf->points[prev_buf->num_points - (2 - buf->num_points)]; - } + /* + * Add a line_to, to compute flags and solve any degeneracy. + * It will be removed later (if it was actually added). + */ + status = _cairo_path_fixed_line_to (path, + path->last_move_point.x, + path->last_move_point.y); + if (unlikely (status)) + return status; - path->current_point = *p; - buf->num_ops--; - buf->num_points--; - } - } + /* + * If the command used to close the path is a line_to, drop it. + * We must check that last command is actually a line_to, + * because the path could have been closed with a curve_to (and + * the previous line_to not added as it would be degenerate). + */ + if (_cairo_path_fixed_last_op (path) == CAIRO_PATH_OP_LINE_TO) + _cairo_path_fixed_drop_line_to (path); status = _cairo_path_fixed_add (path, CAIRO_PATH_OP_CLOSE_PATH, NULL, 0); if (unlikely (status)) |