OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #ifndef SkPathOpsTypes_DEFINED | 7 #ifndef SkPathOpsTypes_DEFINED |
8 #define SkPathOpsTypes_DEFINED | 8 #define SkPathOpsTypes_DEFINED |
9 | 9 |
10 #include <float.h> // for FLT_EPSILON | 10 #include <float.h> // for FLT_EPSILON |
(...skipping 10 matching lines...) Expand all Loading... |
21 kNo_PathOpsMask = 0, | 21 kNo_PathOpsMask = 0, |
22 kEvenOdd_PathOpsMask = 1 | 22 kEvenOdd_PathOpsMask = 1 |
23 }; | 23 }; |
24 | 24 |
25 // Use Almost Equal when comparing coordinates. Use epsilon to compare T values. | 25 // Use Almost Equal when comparing coordinates. Use epsilon to compare T values. |
26 bool AlmostEqualUlps(float A, float B); | 26 bool AlmostEqualUlps(float A, float B); |
27 inline bool AlmostEqualUlps(double A, double B) { | 27 inline bool AlmostEqualUlps(double A, double B) { |
28 return AlmostEqualUlps(SkDoubleToScalar(A), SkDoubleToScalar(B)); | 28 return AlmostEqualUlps(SkDoubleToScalar(A), SkDoubleToScalar(B)); |
29 } | 29 } |
30 | 30 |
| 31 bool RoughlyEqualUlps(float A, float B); |
| 32 inline bool RoughlyEqualUlps(double A, double B) { |
| 33 return RoughlyEqualUlps(SkDoubleToScalar(A), SkDoubleToScalar(B)); |
| 34 } |
| 35 |
31 // FLT_EPSILON == 1.19209290E-07 == 1 / (2 ^ 23) | 36 // FLT_EPSILON == 1.19209290E-07 == 1 / (2 ^ 23) |
32 // DBL_EPSILON == 2.22045e-16 | 37 // DBL_EPSILON == 2.22045e-16 |
33 const double FLT_EPSILON_CUBED = FLT_EPSILON * FLT_EPSILON * FLT_EPSILON; | 38 const double FLT_EPSILON_CUBED = FLT_EPSILON * FLT_EPSILON * FLT_EPSILON; |
34 const double FLT_EPSILON_HALF = FLT_EPSILON / 2; | 39 const double FLT_EPSILON_HALF = FLT_EPSILON / 2; |
35 const double FLT_EPSILON_DOUBLE = FLT_EPSILON * 2; | 40 const double FLT_EPSILON_DOUBLE = FLT_EPSILON * 2; |
36 const double FLT_EPSILON_SQUARED = FLT_EPSILON * FLT_EPSILON; | 41 const double FLT_EPSILON_SQUARED = FLT_EPSILON * FLT_EPSILON; |
37 const double FLT_EPSILON_SQRT = sqrt(FLT_EPSILON); | 42 const double FLT_EPSILON_SQRT = sqrt(FLT_EPSILON); |
38 const double FLT_EPSILON_INVERSE = 1 / FLT_EPSILON; | 43 const double FLT_EPSILON_INVERSE = 1 / FLT_EPSILON; |
39 const double DBL_EPSILON_ERR = DBL_EPSILON * 4; // FIXME: tune -- allow a few b
its of error | 44 const double DBL_EPSILON_ERR = DBL_EPSILON * 4; // FIXME: tune -- allow a few b
its of error |
40 const double DBL_EPSILON_SUBDIVIDE_ERR = DBL_EPSILON * 16; | 45 const double DBL_EPSILON_SUBDIVIDE_ERR = DBL_EPSILON * 16; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return (x > 0) + (x >= 0); | 254 return (x > 0) + (x >= 0); |
250 } | 255 } |
251 | 256 |
252 /* Returns 1 if negative, 2 if zero, 4 if positive | 257 /* Returns 1 if negative, 2 if zero, 4 if positive |
253 */ | 258 */ |
254 inline int SkDSideBit(double x) { | 259 inline int SkDSideBit(double x) { |
255 return 1 << SKDSide(x); | 260 return 1 << SKDSide(x); |
256 } | 261 } |
257 | 262 |
258 #endif | 263 #endif |
OLD | NEW |