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 SkPathOpsPoint_DEFINED | 7 #ifndef SkPathOpsPoint_DEFINED |
8 #define SkPathOpsPoint_DEFINED | 8 #define SkPathOpsPoint_DEFINED |
9 | 9 |
10 #include "SkPathOpsTypes.h" | 10 #include "SkPathOpsTypes.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 SkTMax(fabs(a.fX), fabs(a.fY)))); | 104 SkTMax(fabs(a.fX), fabs(a.fY)))); |
105 if (denom == 0) { | 105 if (denom == 0) { |
106 return true; | 106 return true; |
107 } | 107 } |
108 double inv = 1 / denom; | 108 double inv = 1 / denom; |
109 return approximately_equal(fX * inv, a.fX * inv) | 109 return approximately_equal(fX * inv, a.fX * inv) |
110 && approximately_equal(fY * inv, a.fY * inv); | 110 && approximately_equal(fY * inv, a.fY * inv); |
111 } | 111 } |
112 | 112 |
113 bool approximatelyEqual(const SkPoint& a) const { | 113 bool approximatelyEqual(const SkPoint& a) const { |
114 double denom = SkTMax(fabs(fX), SkTMax(fabs(fY), | 114 return AlmostEqualUlps(SkDoubleToScalar(fX), a.fX) |
115 SkScalarToDouble(SkTMax(fabsf(a.fX), fabsf(a.fY))))); | 115 && AlmostEqualUlps(SkDoubleToScalar(fY), a.fY); |
116 if (denom == 0) { | |
117 return true; | |
118 } | |
119 double inv = 1 / denom; | |
120 return approximately_equal_double(fX * inv, a.fX * inv) | |
121 && approximately_equal_double(fY * inv, a.fY * inv); | |
122 } | 116 } |
123 | 117 |
124 bool approximatelyEqualHalf(const SkDPoint& a) const { | 118 bool approximatelyEqualHalf(const SkDPoint& a) const { |
125 double denom = SkTMax(fabs(fX), SkTMax(fabs(fY), | 119 double denom = SkTMax(fabs(fX), SkTMax(fabs(fY), |
126 SkTMax(fabs(a.fX), fabs(a.fY)))); | 120 SkTMax(fabs(a.fX), fabs(a.fY)))); |
127 if (denom == 0) { | 121 if (denom == 0) { |
128 return true; | 122 return true; |
129 } | 123 } |
130 double inv = 1 / denom; | 124 double inv = 1 / denom; |
131 return approximately_equal_half(fX * inv, a.fX * inv) | 125 return approximately_equal_half(fX * inv, a.fX * inv) |
(...skipping 29 matching lines...) Expand all Loading... |
161 double moreRoughlyEqual(const SkDPoint& a) const { | 155 double moreRoughlyEqual(const SkDPoint& a) const { |
162 return more_roughly_equal(a.fY, fY) && more_roughly_equal(a.fX, fX); | 156 return more_roughly_equal(a.fY, fY) && more_roughly_equal(a.fX, fX); |
163 } | 157 } |
164 | 158 |
165 double roughlyEqual(const SkDPoint& a) const { | 159 double roughlyEqual(const SkDPoint& a) const { |
166 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); | 160 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); |
167 } | 161 } |
168 }; | 162 }; |
169 | 163 |
170 #endif | 164 #endif |
OLD | NEW |