[cairo-commit] src/cairo-spline.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sun Dec 28 13:06:59 PST 2008
src/cairo-spline.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
New commits:
commit efb17160904eda8fdb21fa1fd10a09081cf5cb3e
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 28 16:06:27 2008 -0500
[_cairo_spline_bound] Protect against b == 0
diff --git a/src/cairo-spline.c b/src/cairo-spline.c
index f9b1aaf..85e8a90 100644
--- a/src/cairo-spline.c
+++ b/src/cairo-spline.c
@@ -209,6 +209,7 @@ _cairo_spline_decompose (cairo_spline_t *spline, double tolerance)
return _cairo_spline_add_point (spline, &spline->knots.d);
}
+/* Note: this function is only good for computing bounds in device space. */
void
_cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
void *closure,
@@ -272,7 +273,8 @@ _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
#define FIND_EXTREMES(a,b,c) \
{ \
if (a == 0) { \
- ADD (-c / (2*b)); \
+ if (b != 0) \
+ ADD (-c / (2*b)); \
} else { \
double b2 = b * b; \
double delta = b2 - a * c; \
@@ -329,10 +331,10 @@ _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
t_2_0 = t_1_0 * t_1_0; /* t * t */
t_0_2 = t_0_1 * t_0_1; /* (1 - t) * (1 - t) */
- t_3_0 = t_2_0 * t_1_0; /* t * t * t */
+ t_3_0 = t_2_0 * t_1_0; /* t * t * t */
t_2_1_3 = t_2_0 * t_0_1 * 3; /* t * t * (1 - t) * 3 */
t_1_2_3 = t_1_0 * t_0_2 * 3; /* t * (1 - t) * (1 - t) * 3 */
- t_0_3 = t_0_1 * t_0_2; /* (1 - t) * (1 - t) * (1 - t) */
+ t_0_3 = t_0_1 * t_0_2; /* (1 - t) * (1 - t) * (1 - t) */
/* Bezier polynomial */
x = x0 * t_0_3
More information about the cairo-commit
mailing list