diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-25 23:42:45 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-26 11:10:42 +0100 |
commit | 3cf6551ac71bac4d0ae1d0938bc0205dfc03f65c (patch) | |
tree | e82d665c20cbc5d0b892005e34f4a6d9e48aa377 /src/cairo-path-stroke-polygon.c | |
parent | 74e9ae8cdff31e9a039b17f7dbe6e80f98e2c047 (diff) | |
download | cairo-3cf6551ac71bac4d0ae1d0938bc0205dfc03f65c.tar.gz |
stroke: Use new pen vertex range finders
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-path-stroke-polygon.c')
-rw-r--r-- | src/cairo-path-stroke-polygon.c | 93 |
1 files changed, 27 insertions, 66 deletions
diff --git a/src/cairo-path-stroke-polygon.c b/src/cairo-path-stroke-polygon.c index 242fb24a1..61a782b08 100644 --- a/src/cairo-path-stroke-polygon.c +++ b/src/cairo-path-stroke-polygon.c @@ -161,12 +161,11 @@ add_fan (struct stroker *stroker, const cairo_slope_t *in_vector, const cairo_slope_t *out_vector, const cairo_point_t *midpt, - const cairo_point_t *inpt, - const cairo_point_t *outpt, cairo_bool_t clockwise, struct stroke_contour *c) { - int start, stop, step, i, npoints; + cairo_pen_t *pen = &stroker->pen; + int start, stop; if (stroker->has_bounds && ! _cairo_box_contains_point (&stroker->bounds, midpt)) @@ -175,61 +174,29 @@ add_fan (struct stroker *stroker, assert (stroker->pen.num_vertices); if (clockwise) { - step = 1; - - start = _cairo_pen_find_active_cw_vertex_index (&stroker->pen, - in_vector); - if (_cairo_slope_compare (&stroker->pen.vertices[start].slope_cw, - in_vector) < 0) - start = range_step (start, 1, stroker->pen.num_vertices); - - stop = _cairo_pen_find_active_cw_vertex_index (&stroker->pen, - out_vector); - if (_cairo_slope_compare (&stroker->pen.vertices[stop].slope_ccw, - out_vector) > 0) - { - stop = range_step (stop, -1, stroker->pen.num_vertices); - if (_cairo_slope_compare (&stroker->pen.vertices[stop].slope_cw, - in_vector) < 0) - return; + _cairo_pen_find_active_cw_vertices (pen, + in_vector, out_vector, + &start, &stop); + while (start != stop) { + cairo_point_t p = *midpt; + translate_point (&p, &pen->vertices[start].point); + contour_add_point (stroker, c, &p); + + if (++start == pen->num_vertices) + start = 0; } - - npoints = stop - start; } else { - step = -1; - - start = _cairo_pen_find_active_ccw_vertex_index (&stroker->pen, - in_vector); - if (_cairo_slope_compare (&stroker->pen.vertices[start].slope_ccw, - in_vector) < 0) - start = range_step (start, -1, stroker->pen.num_vertices); - - stop = _cairo_pen_find_active_ccw_vertex_index (&stroker->pen, - out_vector); - if (_cairo_slope_compare (&stroker->pen.vertices[stop].slope_cw, - out_vector) > 0) - { - stop = range_step (stop, 1, stroker->pen.num_vertices); - if (_cairo_slope_compare (&stroker->pen.vertices[stop].slope_ccw, - in_vector) < 0) - return; + _cairo_pen_find_active_ccw_vertices (pen, + in_vector, out_vector, + &start, &stop); + while (start != stop) { + cairo_point_t p = *midpt; + translate_point (&p, &pen->vertices[start].point); + contour_add_point (stroker, c, &p); + + if (start-- == 0) + start += pen->num_vertices; } - - npoints = start - stop; - } - stop = range_step (stop, step, stroker->pen.num_vertices); - if (npoints < 0) - npoints += stroker->pen.num_vertices; - if (npoints <= 1) - return; - - for (i = start; - i != stop; - i = range_step (i, step, stroker->pen.num_vertices)) - { - cairo_point_t p = *midpt; - translate_point (&p, &stroker->pen.vertices[i].point); - contour_add_point (stroker, c, &p); } } @@ -435,9 +402,7 @@ outer_close (struct stroker *stroker, in->dev_slope.y * out->dev_slope.y) < stroker->spline_cusp_tolerance) { add_fan (stroker, - &in->dev_vector, - &out->dev_vector, - &in->point, inpt, outpt, + &in->dev_vector, &out->dev_vector, &in->point, clockwise, outer); } break; @@ -624,9 +589,7 @@ outer_join (struct stroker *stroker, case CAIRO_LINE_JOIN_ROUND: /* construct a fan around the common midpoint */ add_fan (stroker, - &in->dev_vector, - &out->dev_vector, - &in->point, inpt, outpt, + &in->dev_vector, &out->dev_vector, &in->point, clockwise, outer); break; @@ -795,9 +758,7 @@ add_cap (struct stroker *stroker, slope.dx = -f->dev_vector.dx; slope.dy = -f->dev_vector.dy; - add_fan (stroker, &f->dev_vector, &slope, - &f->point, &f->ccw, &f->cw, - FALSE, c); + add_fan (stroker, &f->dev_vector, &slope, &f->point, FALSE, c); break; } @@ -1159,7 +1120,7 @@ spline_to (void *closure, add_fan (stroker, &stroker->current_face.dev_vector, &face.dev_vector, - &stroker->current_face.point, inpt, outpt, + &stroker->current_face.point, clockwise, outer); } else { compute_face (point, tangent, stroker, &face); @@ -1191,7 +1152,7 @@ spline_to (void *closure, add_fan (stroker, &stroker->current_face.dev_vector, &face.dev_vector, - &stroker->current_face.point, inpt, outpt, + &stroker->current_face.point, clockwise, outer); } |