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 #include "SkFloatBits.h" | 7 #include "SkFloatBits.h" |
8 #include "SkPathOpsTypes.h" | 8 #include "SkPathOpsTypes.h" |
9 | 9 |
10 static bool arguments_denormalized(float a, float b, int epsilon) { | 10 static bool arguments_denormalized(float a, float b, int epsilon) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 bool AlmostPequalUlps(float a, float b) { | 95 bool AlmostPequalUlps(float a, float b) { |
96 const int UlpsEpsilon = 8; | 96 const int UlpsEpsilon = 8; |
97 return equal_ulps(a, b, UlpsEpsilon, UlpsEpsilon); | 97 return equal_ulps(a, b, UlpsEpsilon, UlpsEpsilon); |
98 } | 98 } |
99 | 99 |
100 bool AlmostDequalUlps(float a, float b) { | 100 bool AlmostDequalUlps(float a, float b) { |
101 const int UlpsEpsilon = 16; | 101 const int UlpsEpsilon = 16; |
102 return d_equal_ulps(a, b, UlpsEpsilon); | 102 return d_equal_ulps(a, b, UlpsEpsilon); |
103 } | 103 } |
104 | 104 |
| 105 bool AlmostDequalUlps(double a, double b) { |
| 106 if (SkScalarIsFinite(a) || SkScalarIsFinite(b)) { |
| 107 return AlmostDequalUlps(SkDoubleToScalar(a), SkDoubleToScalar(b)); |
| 108 } |
| 109 return fabs(a - b) / SkTMax(fabs(a), fabs(b)) < FLT_EPSILON * 16; |
| 110 } |
| 111 |
105 bool AlmostEqualUlps(float a, float b) { | 112 bool AlmostEqualUlps(float a, float b) { |
106 const int UlpsEpsilon = 16; | 113 const int UlpsEpsilon = 16; |
107 return equal_ulps(a, b, UlpsEpsilon, UlpsEpsilon); | 114 return equal_ulps(a, b, UlpsEpsilon, UlpsEpsilon); |
108 } | 115 } |
109 | 116 |
110 bool NotAlmostEqualUlps(float a, float b) { | 117 bool NotAlmostEqualUlps(float a, float b) { |
111 const int UlpsEpsilon = 16; | 118 const int UlpsEpsilon = 16; |
112 return not_equal_ulps(a, b, UlpsEpsilon); | 119 return not_equal_ulps(a, b, UlpsEpsilon); |
113 } | 120 } |
114 | 121 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 double SkDCubeRoot(double x) { | 191 double SkDCubeRoot(double x) { |
185 if (approximately_zero_cubed(x)) { | 192 if (approximately_zero_cubed(x)) { |
186 return 0; | 193 return 0; |
187 } | 194 } |
188 double result = halley_cbrt3d(fabs(x)); | 195 double result = halley_cbrt3d(fabs(x)); |
189 if (x < 0) { | 196 if (x < 0) { |
190 result = -result; | 197 result = -result; |
191 } | 198 } |
192 return result; | 199 return result; |
193 } | 200 } |
OLD | NEW |