diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-12-09 22:00:10 +0100 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-12-10 11:04:47 +0100 |
commit | 75f34b595aead729b6f6a7017c8790d68dfa0326 (patch) | |
tree | 35b9443f58bc7d50199ea18cb367b69a5047cdda /src/cairo-polygon.c | |
parent | df453b7aca5ad7c4b796f150c8a90e78c1b96e04 (diff) | |
download | cairo-75f34b595aead729b6f6a7017c8790d68dfa0326.tar.gz |
fill: Simplify path to polygon conversion
Using _cairo_path_fixed_interpret_flat() greatly simplifies the path
to polygon conversion (because it already converts curve_to's to
line_to's).
This commit also removes the optimization which merges two consecutive
lines if they have the same slope, because it's unlikely (since it
should already happen during path construction), it doesn't provide
better performance (at least not measurable with the currently
available cairo-traces) and bloats the code.
Diffstat (limited to 'src/cairo-polygon.c')
-rw-r--r-- | src/cairo-polygon.c | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c index 64fef47e1..e5c4f96c8 100644 --- a/src/cairo-polygon.c +++ b/src/cairo-polygon.c @@ -37,7 +37,6 @@ #include "cairoint.h" #include "cairo-error-private.h" -#include "cairo-slope-private.h" void _cairo_polygon_init (cairo_polygon_t *polygon) @@ -51,8 +50,6 @@ _cairo_polygon_init (cairo_polygon_t *polygon) polygon->edges = polygon->edges_embedded; polygon->edges_size = ARRAY_LENGTH (polygon->edges_embedded); - polygon->has_current_point = FALSE; - polygon->has_current_edge = FALSE; polygon->num_limits = 0; polygon->extents.p1.x = polygon->extents.p1.y = INT32_MAX; @@ -408,88 +405,3 @@ _cairo_polygon_add_line (cairo_polygon_t *polygon, return polygon->status; } - -/* flattened path operations */ - -cairo_status_t -_cairo_polygon_move_to (cairo_polygon_t *polygon, - const cairo_point_t *point) -{ - if (polygon->has_current_edge) { - _cairo_polygon_add_edge (polygon, - &polygon->last_point, - &polygon->current_point); - polygon->has_current_edge = FALSE; - } - - if (! polygon->has_current_point) { - polygon->first_point = *point; - polygon->has_current_point = TRUE; - } - - polygon->current_point = *point; - return polygon->status; -} - -cairo_status_t -_cairo_polygon_line_to (cairo_polygon_t *polygon, - const cairo_point_t *point) -{ - /* squash collinear edges */ - if (polygon->has_current_edge) { - if (polygon->current_point.x != point->x || - polygon->current_point.y != point->y) - { - cairo_slope_t this; - - _cairo_slope_init (&this, &polygon->current_point, point); - if (_cairo_slope_equal (&polygon->current_edge, &this)) { - polygon->current_point = *point; - return CAIRO_STATUS_SUCCESS; - } - - _cairo_polygon_add_edge (polygon, - &polygon->last_point, - &polygon->current_point); - - polygon->last_point = polygon->current_point; - polygon->current_edge = this; - } - } else if (polygon->has_current_point) { - if (polygon->current_point.x != point->x || - polygon->current_point.y != point->y) - { - polygon->last_point = polygon->current_point; - _cairo_slope_init (&polygon->current_edge, - &polygon->last_point, - point); - polygon->has_current_edge = TRUE; - } - } else { - polygon->first_point = *point; - polygon->has_current_point = TRUE; - } - - polygon->current_point = *point; - return polygon->status; -} - -cairo_status_t -_cairo_polygon_close (cairo_polygon_t *polygon) -{ - cairo_status_t status; - - if (polygon->has_current_point) { - status = _cairo_polygon_line_to (polygon, &polygon->first_point); - polygon->has_current_point = FALSE; - } - - if (polygon->has_current_edge) { - _cairo_polygon_add_edge (polygon, - &polygon->last_point, - &polygon->current_point); - polygon->has_current_edge = FALSE; - } - - return polygon->status; -} |