diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-10-17 11:54:19 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-10-29 17:31:22 +0200 |
commit | 641d314b9a3c670ddade74df99f1443063bd991b (patch) | |
tree | c36437cebcc41af49599f83e70d09d47592d21c5 /src/cairo-path-fixed.c | |
parent | 4075ed9686483defa9fb1cffca6509f079f9a91d (diff) |
path: Add utility functions
Add a function to get the penultimate point and another one to drop
the last operation (assuming it is a line_to).
This allows some more abstraction in the line_to and close_path code.
Diffstat (limited to 'src/cairo-path-fixed.c')
-rw-r--r-- | src/cairo-path-fixed.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c index dfc1474b3..2e8da1c6c 100644 --- a/src/cairo-path-fixed.c +++ b/src/cairo-path-fixed.c @@ -374,6 +374,34 @@ _cairo_path_fixed_last_op (cairo_path_fixed_t *path) return buf->op[buf->num_ops - 1]; } +static inline const cairo_point_t * +_cairo_path_fixed_penultimate_point (cairo_path_fixed_t *path) +{ + cairo_path_buf_t *buf; + + buf = cairo_path_tail (path); + if (likely (buf->num_points >= 2)) { + return &buf->points[buf->num_points - 2]; + } else { + cairo_path_buf_t *prev_buf = cairo_path_buf_prev (buf); + + assert (prev_buf->num_points >= 2 - buf->num_points); + return &prev_buf->points[prev_buf->num_points - (2 - buf->num_points)]; + } +} + +static inline void +_cairo_path_fixed_drop_line_to (cairo_path_fixed_t *path) +{ + cairo_path_buf_t *buf; + + assert (_cairo_path_fixed_last_op (path) == CAIRO_PATH_OP_LINE_TO); + + buf = cairo_path_tail (path); + buf->num_points--; + buf->num_ops--; +} + static inline void _cairo_path_fixed_extents_add (cairo_path_fixed_t *path, const cairo_point_t *point) |