summaryrefslogtreecommitdiff
path: root/src/cairo-path-in-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-in-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-in-fill.c')
-rw-r--r--src/cairo-path-in-fill.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/cairo-path-in-fill.c b/src/cairo-path-in-fill.c
index fcac9b134..2b9b057dc 100644
--- a/src/cairo-path-in-fill.c
+++ b/src/cairo-path-in-fill.c
@@ -165,8 +165,6 @@ _cairo_in_fill_curve_to (void *closure,
cairo_in_fill_t *in_fill = closure;
cairo_spline_t spline;
cairo_fixed_t top, bot, left;
- cairo_status_t status;
- int i;
/* first reject based on bbox */
bot = top = in_fill->current_point.y;
@@ -187,21 +185,18 @@ _cairo_in_fill_curve_to (void *closure,
return CAIRO_STATUS_SUCCESS;
/* XXX Investigate direct inspection of the inflections? */
- status = _cairo_spline_init (&spline, &in_fill->current_point, b, c, d);
- if (status == CAIRO_INT_STATUS_DEGENERATE)
+ if (! _cairo_spline_init (&spline,
+ (cairo_add_point_func_t) _cairo_in_fill_line_to,
+ in_fill,
+ &in_fill->current_point, b, c, d))
+ {
return CAIRO_STATUS_SUCCESS;
+ }
- status = _cairo_spline_decompose (&spline, in_fill->tolerance);
- if (status)
- goto CLEANUP_SPLINE;
-
- for (i = 1; i < spline.num_points; i++)
- _cairo_in_fill_line_to (in_fill, &spline.points[i]);
-
- CLEANUP_SPLINE:
+ _cairo_spline_decompose (&spline, in_fill->tolerance);
_cairo_spline_fini (&spline);
- return status;
+ return CAIRO_STATUS_SUCCESS;
}
static cairo_status_t