diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2008-12-27 23:13:45 -0500 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2008-12-27 23:44:58 -0500 |
commit | ef0f6c3ca311c41c9062e1298b020eae1212984e (patch) | |
tree | 8cf73cf584c1fcf565b3a4c5092a734b48cd2b9e /src/cairo-path-bounds.c | |
parent | f2f62c7c4402a28a65c8171238d163af6b2fb95a (diff) | |
download | cairo-ef0f6c3ca311c41c9062e1298b020eae1212984e.tar.gz |
[spline] Add an analytical bounder for splines
The way this works is very simple: Once for X, and once for Y, it
takes the derivative of the bezier equation, equals it to zero and
solves to find the extreme points, and if the extreme points are
interesting, adds them to the bounder.
Not the fastest algorithm out there, but my estimate is that if
_de_casteljau() ends up breaking a stroke in at least 10 pieces,
then the new bounder is faster. Would be good to see some real
perf data.
Diffstat (limited to 'src/cairo-path-bounds.c')
-rw-r--r-- | src/cairo-path-bounds.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/cairo-path-bounds.c b/src/cairo-path-bounds.c index dca237b0e..698d1fa5b 100644 --- a/src/cairo-path-bounds.c +++ b/src/cairo-path-bounds.c @@ -123,21 +123,11 @@ _cairo_path_bounder_curve_to (void *closure, const cairo_point_t *d) { cairo_path_bounder_t *bounder = closure; - cairo_spline_t spline; - - /* XXX Is there a faster way to determine the bounding box of a - * Bezier curve than its decomposition? - * - * Using the control points alone can be wildly inaccurate. - */ - if (! _cairo_spline_init (&spline, - _cairo_path_bounder_line_to, bounder, - &bounder->current_point, b, c, d)) - { - return _cairo_path_bounder_line_to (bounder, d); - } - return _cairo_spline_decompose (&spline, bounder->tolerance); + _cairo_spline_bound (_cairo_path_bounder_line_to, bounder, + &bounder->current_point, b, c, d); + + return CAIRO_STATUS_SUCCESS; } static cairo_status_t |