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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 SkDPoint dA, dB; | 141 SkDPoint dA, dB; |
142 dA.set(a); | 142 dA.set(a); |
143 dB.set(b); | 143 dB.set(b); |
144 double dist = dA.distance(dB); // OPTIMIZATION: can we compare against
distSq instead ? | 144 double dist = dA.distance(dB); // OPTIMIZATION: can we compare against
distSq instead ? |
145 float tiniest = SkTMin(SkTMin(SkTMin(a.fX, b.fX), a.fY), b.fY); | 145 float tiniest = SkTMin(SkTMin(SkTMin(a.fX, b.fX), a.fY), b.fY); |
146 float largest = SkTMax(SkTMax(SkTMax(a.fX, b.fX), a.fY), b.fY); | 146 float largest = SkTMax(SkTMax(SkTMax(a.fX, b.fX), a.fY), b.fY); |
147 largest = SkTMax(largest, -tiniest); | 147 largest = SkTMax(largest, -tiniest); |
148 return AlmostBequalUlps((double) largest, largest + dist); // is dist wi
thin ULPS tolerance? | 148 return AlmostBequalUlps((double) largest, largest + dist); // is dist wi
thin ULPS tolerance? |
149 } | 149 } |
150 | 150 |
151 #if SK_DEBUG | 151 #ifdef SK_DEBUG |
152 static bool RoughlyEqual(const SkPoint& a, const SkPoint& b) { | 152 static bool RoughlyEqual(const SkPoint& a, const SkPoint& b) { |
153 if (approximately_equal(a.fX, b.fX) && approximately_equal(a.fY, b.fY))
{ | 153 if (approximately_equal(a.fX, b.fX) && approximately_equal(a.fY, b.fY))
{ |
154 return true; | 154 return true; |
155 } | 155 } |
156 return RoughlyEqualUlps(a.fX, b.fX) && RoughlyEqualUlps(a.fY, b.fY); | 156 return RoughlyEqualUlps(a.fX, b.fX) && RoughlyEqualUlps(a.fY, b.fY); |
157 } | 157 } |
158 #endif | 158 #endif |
159 | 159 |
160 bool approximatelyPEqual(const SkDPoint& a) const { | 160 bool approximatelyPEqual(const SkDPoint& a) const { |
161 if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) { | 161 if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 bool roughlyEqual(const SkDPoint& a) const { | 225 bool roughlyEqual(const SkDPoint& a) const { |
226 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); | 226 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); |
227 } | 227 } |
228 | 228 |
229 // utilities callable by the user from the debugger when the implementation
code is linked in | 229 // utilities callable by the user from the debugger when the implementation
code is linked in |
230 void dump() const; | 230 void dump() const; |
231 static void Dump(const SkPoint& pt); | 231 static void Dump(const SkPoint& pt); |
232 }; | 232 }; |
233 | 233 |
234 #endif | 234 #endif |
OLD | NEW |