diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-10-30 07:58:45 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-10-30 08:08:27 +0000 |
commit | 19c411a5b8b84d31516d9c85642ad55ef5d29aba (patch) | |
tree | 94c50563a3e4f414ec7da2b3c9a7b0dbface33cb | |
parent | 23bcf91748c4bb04c16e503b913da3bfc237463f (diff) |
path: Skip any secondary degenerate line-to segments.
Only the very first line-to following a move-to can have any
significance if degenerate whilst stroking, so skip all others.
In other words,
0 0 m 0 0 l stroke
produces a capped degenerate path (i.e a dot),
0 0 m 0 0 l 0 0 l stroke
produces the same degenerate stroke, and
0 0 m 0 0 l 1 0 l stroke
produce a horizontal line.
-rw-r--r-- | src/cairo-path-fixed.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c index db0e4937..42172c67 100644 --- a/src/cairo-path-fixed.c +++ b/src/cairo-path-fixed.c @@ -446,6 +446,16 @@ _cairo_path_fixed_line_to (cairo_path_fixed_t *path, if (! path->has_current_point) return _cairo_path_fixed_move_to (path, point.x, point.y); + /* If the previous op was but the initial MOVE_TO and this segment + * is degenerate, then we can simply skip this point. Note that + * a move-to followed by a degenerate line-to is a valid path for + * stroking, but at all other times is simply a degenerate segment. + */ + if (_cairo_path_last_op (path) != CAIRO_PATH_OP_MOVE_TO) { + if (x == path->current_point.x && y == path->current_point.y) + return CAIRO_STATUS_SUCCESS; + } + /* If the previous op was also a LINE_TO with the same gradient, * then just change its end-point rather than adding a new op. */ @@ -453,9 +463,6 @@ _cairo_path_fixed_line_to (cairo_path_fixed_t *path, cairo_path_buf_t *buf; const cairo_point_t *p; - if (x == path->current_point.x && y == path->current_point.y) - return CAIRO_STATUS_SUCCESS; - buf = cairo_path_tail (path); if (likely (buf->num_points >= 2)) { p = &buf->points[buf->num_points-2]; |