Index: src/pathops/SkPathOpsTypes.h |
=================================================================== |
--- src/pathops/SkPathOpsTypes.h (revision 9425) |
+++ src/pathops/SkPathOpsTypes.h (working copy) |
@@ -7,8 +7,6 @@ |
#ifndef SkPathOpsTypes_DEFINED |
#define SkPathOpsTypes_DEFINED |
-#define SK_CONIC_SUPPORT_ENABLED 1 |
- |
#include <float.h> // for FLT_EPSILON |
#include <math.h> // for fabs, sqrt |
@@ -25,7 +23,7 @@ |
}; |
// Use Almost Equal when comparing coordinates. Use epsilon to compare T values. |
-extern bool AlmostEqualUlps(float A, float B); |
+bool AlmostEqualUlps(float A, float B); |
inline bool AlmostEqualUlps(double A, double B) { |
return AlmostEqualUlps(SkDoubleToScalar(A), SkDoubleToScalar(B)); |
} |
@@ -34,10 +32,12 @@ |
// DBL_EPSILON == 2.22045e-16 |
const double FLT_EPSILON_CUBED = FLT_EPSILON * FLT_EPSILON * FLT_EPSILON; |
const double FLT_EPSILON_HALF = FLT_EPSILON / 2; |
+const double FLT_EPSILON_DOUBLE = FLT_EPSILON * 2; |
const double FLT_EPSILON_SQUARED = FLT_EPSILON * FLT_EPSILON; |
const double FLT_EPSILON_SQRT = sqrt(FLT_EPSILON); |
const double FLT_EPSILON_INVERSE = 1 / FLT_EPSILON; |
const double DBL_EPSILON_ERR = DBL_EPSILON * 4; // FIXME: tune -- allow a few bits of error |
+const double DBL_EPSILON_SUBDIVIDE_ERR = DBL_EPSILON * 16; |
const double ROUGH_EPSILON = FLT_EPSILON * 64; |
const double MORE_ROUGH_EPSILON = FLT_EPSILON * 256; |
@@ -49,6 +49,10 @@ |
return fabs(x) < DBL_EPSILON_ERR; |
} |
+inline bool precisely_subdivide_zero(double x) { |
+ return fabs(x) < DBL_EPSILON_SUBDIVIDE_ERR; |
+} |
+ |
inline bool approximately_zero(float x) { |
return fabs(x) < FLT_EPSILON; |
} |
@@ -61,6 +65,10 @@ |
return fabs(x) < FLT_EPSILON_HALF; |
} |
+inline bool approximately_zero_double(double x) { |
+ return fabs(x) < FLT_EPSILON_DOUBLE; |
+} |
+ |
inline bool approximately_zero_squared(double x) { |
return fabs(x) < FLT_EPSILON_SQUARED; |
} |
@@ -69,6 +77,10 @@ |
return fabs(x) < FLT_EPSILON_SQRT; |
} |
+inline bool roughly_zero(double x) { |
+ return fabs(x) < ROUGH_EPSILON; |
+} |
+ |
inline bool approximately_zero_inverse(double x) { |
return fabs(x) > FLT_EPSILON_INVERSE; |
} |
@@ -88,10 +100,18 @@ |
return precisely_zero(x - y); |
} |
+inline bool precisely_subdivide_equal(double x, double y) { |
+ return precisely_subdivide_zero(x - y); |
+} |
+ |
inline bool approximately_equal_half(double x, double y) { |
return approximately_zero_half(x - y); |
} |
+inline bool approximately_equal_double(double x, double y) { |
+ return approximately_zero_double(x - y); |
+} |
+ |
inline bool approximately_equal_squared(double x, double y) { |
return approximately_equal(x, y); |
} |
@@ -112,14 +132,6 @@ |
return x - FLT_EPSILON < y; |
} |
-inline double approximately_pin(double x) { |
- return approximately_zero(x) ? 0 : x; |
-} |
- |
-inline float approximately_pin(float x) { |
- return approximately_zero(x) ? 0 : x; |
-} |
- |
inline bool approximately_greater_than_one(double x) { |
return x > 1 - FLT_EPSILON; |
} |
@@ -192,8 +204,6 @@ |
struct SkDCubic; |
struct SkDRect; |
-#if SK_CONIC_SUPPORT_ENABLED |
- |
inline SkPath::Verb SkPathOpsPointsToVerb(int points) { |
int verb = (1 << points) >> 1; |
#ifdef SK_DEBUG |
@@ -221,18 +231,6 @@ |
return points; |
} |
-#else |
- |
-inline SkPath::Verb SkOpPointsToVerb(int points) { |
- return (SkPath::Verb) (points); |
-} |
- |
-inline SkPath::Verb SkOpVerbToPoints(SkPath::Verb verb) { |
- return (int) verb ; |
-} |
- |
-#endif |
- |
inline double SkDInterp(double A, double B, double t) { |
return A + (B - A) * t; |
} |