[cairo-commit] 2 commits - src/cairo-spline.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sat Dec 27 23:49:59 PST 2008
src/cairo-spline.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
New commits:
commit 0b59e29004bb19eb9bd458bbe6a48a7c367f72d0
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 28 02:49:39 2008 -0500
[_cairo_spline_bound] Simplify condition
diff --git a/src/cairo-spline.c b/src/cairo-spline.c
index d2c45c3..f9b1aaf 100644
--- a/src/cairo-spline.c
+++ b/src/cairo-spline.c
@@ -277,18 +277,22 @@ _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
double b2 = b * b; \
double delta = b2 - a * c; \
if (delta > 0) { \
- double a2_b2 = a * a + b2; \
+ cairo_bool_t feasible; \
double _2ab = 2 * a * b; \
- double _b_a = - b / a; \
/* We are only interested in solutions t that satisfy 0<t<1 \
* here. We do some checks to avoid sqrt if the solutions \
* are not in that range. The checks can be derived from: \
* \
* 0 < (-b屉delta)/a < 1 \
*/ \
- if ((_2ab >= 0 && delta > b2 && delta < a2_b2 - _2ab) || \
- (_2ab < 0 && ((_b_a>=1 && (delta < b2 && delta > a2_b2 + _2ab)) || \
- (_b_a< 1 && (delta < b2 || delta < a2_b2 + _2ab))))) { \
+ if (_2ab >= 0) \
+ feasible = delta > b2 && delta < a*a + b2 - _2ab; \
+ else if (-b / a >= 1) \
+ feasible = delta < b2 && delta > a*a + b2 + _2ab; \
+ else \
+ feasible = delta < b2 || delta < a*a + b2 + _2ab; \
+ \
+ if (unlikely (feasible)) { \
double sqrt_delta = sqrt (delta); \
ADD ((-b - sqrt_delta) / a); \
ADD ((-b + sqrt_delta) / a); \
commit 3bf1b7d574620b1ab3c1fa50977a23d36ab04a40
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 28 02:41:39 2008 -0500
[_cairo_spline_bound] Fix the check for feasible solutions
Also make it more strict. The only times we call sqrt now is
when a solution in (0,1) exists.
diff --git a/src/cairo-spline.c b/src/cairo-spline.c
index 5f2dc6c..d2c45c3 100644
--- a/src/cairo-spline.c
+++ b/src/cairo-spline.c
@@ -277,15 +277,18 @@ _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func,
double b2 = b * b; \
double delta = b2 - a * c; \
if (delta > 0) { \
- double a2 = a * a; \
- double ab = a * b; \
+ double a2_b2 = a * a + b2; \
+ double _2ab = 2 * a * b; \
+ double _b_a = - b / a; \
/* We are only interested in solutions t that satisfy 0<t<1 \
* here. We do some checks to avoid sqrt if the solutions \
* are not in that range. The checks can be derived from: \
* \
* 0 < (-b屉delta)/a < 1 \
*/ \
- if (delta > (ab >= 0 ? b2 : a2 + b2 + 2*ab)) { \
+ if ((_2ab >= 0 && delta > b2 && delta < a2_b2 - _2ab) || \
+ (_2ab < 0 && ((_b_a>=1 && (delta < b2 && delta > a2_b2 + _2ab)) || \
+ (_b_a< 1 && (delta < b2 || delta < a2_b2 + _2ab))))) { \
double sqrt_delta = sqrt (delta); \
ADD ((-b - sqrt_delta) / a); \
ADD ((-b + sqrt_delta) / a); \
More information about the cairo-commit
mailing list