summaryrefslogtreecommitdiff
path: root/src/cairo-path-fill.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-11-14 17:18:47 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-11-16 16:21:25 +0000
commitd7873eecc598a558a2a862add8e9b056c4a23a4a (patch)
tree014431ef8925f64c68dd2901d4ec38144e0c6a21 /src/cairo-path-fill.c
parent3bf8379408ce9b1e08d130bcd1076766e36f1bef (diff)
downloadcairo-d7873eecc598a558a2a862add8e9b056c4a23a4a.tar.gz
[spline] Eliminate intermediate allocations during spline decomposition.
The spline decomposition code allocates and stores points in a temporary buffer which is immediately consumed by the caller. If the caller supplies a callback that handles each point computed along the spline, then we can use the point immediately and avoid the allocation.
Diffstat (limited to 'src/cairo-path-fill.c')
-rw-r--r--src/cairo-path-fill.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/cairo-path-fill.c b/src/cairo-path-fill.c
index 1cef20e4a..46046bb9b 100644
--- a/src/cairo-path-fill.c
+++ b/src/cairo-path-fill.c
@@ -118,30 +118,23 @@ _cairo_filler_curve_to (void *closure,
cairo_point_t *c,
cairo_point_t *d)
{
- int i;
- cairo_status_t status = CAIRO_STATUS_SUCCESS;
cairo_filler_t *filler = closure;
- cairo_polygon_t *polygon = &filler->polygon;
cairo_spline_t spline;
- status = _cairo_spline_init (&spline, &filler->current_point, b, c, d);
-
- if (status == CAIRO_INT_STATUS_DEGENERATE)
+ if (! _cairo_spline_init (&spline,
+ (cairo_add_point_func_t) _cairo_polygon_line_to,
+ &filler->polygon,
+ &filler->current_point, b, c, d))
+ {
return CAIRO_STATUS_SUCCESS;
+ }
- status = _cairo_spline_decompose (&spline, filler->tolerance);
- if (status)
- goto CLEANUP_SPLINE;
-
- for (i = 1; i < spline.num_points; i++)
- _cairo_polygon_line_to (polygon, &spline.points[i]);
-
- CLEANUP_SPLINE:
+ _cairo_spline_decompose (&spline, filler->tolerance);
_cairo_spline_fini (&spline);
filler->current_point = *d;
- return status;
+ return CAIRO_STATUS_SUCCESS;
}
static cairo_status_t