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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (roughly_equal(fX, a.fX) && roughly_equal(fY, a.fY)) { | 186 if (roughly_equal(fX, a.fX) && roughly_equal(fY, a.fY)) { |
187 return true; | 187 return true; |
188 } | 188 } |
189 double dist = distance(a); // OPTIMIZATION: can we compare against dist
Sq instead ? | 189 double dist = distance(a); // OPTIMIZATION: can we compare against dist
Sq instead ? |
190 double tiniest = SkTMin(SkTMin(SkTMin(fX, a.fX), fY), a.fY); | 190 double tiniest = SkTMin(SkTMin(SkTMin(fX, a.fX), fY), a.fY); |
191 double largest = SkTMax(SkTMax(SkTMax(fX, a.fX), fY), a.fY); | 191 double largest = SkTMax(SkTMax(SkTMax(fX, a.fX), fY), a.fY); |
192 largest = SkTMax(largest, -tiniest); | 192 largest = SkTMax(largest, -tiniest); |
193 return RoughlyEqualUlps(largest, largest + dist); // is the dist within
ULPS tolerance? | 193 return RoughlyEqualUlps(largest, largest + dist); // is the dist within
ULPS tolerance? |
194 } | 194 } |
195 | 195 |
| 196 static bool RoughlyEqual(const SkPoint& a, const SkPoint& b) { |
| 197 if (!RoughlyEqualUlps(a.fX, b.fX) || !RoughlyEqualUlps(a.fY, b.fY)) { |
| 198 return false; |
| 199 } |
| 200 SkDPoint dA, dB; |
| 201 dA.set(a); |
| 202 dB.set(b); |
| 203 double dist = dA.distance(dB); // OPTIMIZATION: can we compare against
distSq instead ? |
| 204 float tiniest = SkTMin(SkTMin(SkTMin(a.fX, b.fX), a.fY), b.fY); |
| 205 float largest = SkTMax(SkTMax(SkTMax(a.fX, b.fX), a.fY), b.fY); |
| 206 largest = SkTMax(largest, -tiniest); |
| 207 return RoughlyEqualUlps((double) largest, largest + dist); // is dist wi
thin ULPS tolerance? |
| 208 } |
| 209 |
196 // utilities callable by the user from the debugger when the implementation
code is linked in | 210 // utilities callable by the user from the debugger when the implementation
code is linked in |
197 void dump() const; | 211 void dump() const; |
198 static void Dump(const SkPoint& pt); | 212 static void Dump(const SkPoint& pt); |
199 static void DumpHex(const SkPoint& pt); | 213 static void DumpHex(const SkPoint& pt); |
200 }; | 214 }; |
201 | 215 |
202 #endif | 216 #endif |
OLD | NEW |