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 #ifdef SK_DEBUG | |
152 static bool RoughlyEqual(const SkPoint& a, const SkPoint& b) { | 151 static bool RoughlyEqual(const SkPoint& a, const SkPoint& b) { |
153 if (approximately_equal(a.fX, b.fX) && approximately_equal(a.fY, b.fY))
{ | 152 if (approximately_equal(a.fX, b.fX) && approximately_equal(a.fY, b.fY))
{ |
154 return true; | 153 return true; |
155 } | 154 } |
156 return RoughlyEqualUlps(a.fX, b.fX) && RoughlyEqualUlps(a.fY, b.fY); | 155 return RoughlyEqualUlps(a.fX, b.fX) && RoughlyEqualUlps(a.fY, b.fY); |
157 } | 156 } |
158 #endif | |
159 | 157 |
160 bool approximatelyPEqual(const SkDPoint& a) const { | 158 bool approximatelyPEqual(const SkDPoint& a) const { |
161 if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) { | 159 if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) { |
162 return true; | 160 return true; |
163 } | 161 } |
164 if (!RoughlyEqualUlps(fX, a.fX) || !RoughlyEqualUlps(fY, a.fY)) { | 162 if (!RoughlyEqualUlps(fX, a.fX) || !RoughlyEqualUlps(fY, a.fY)) { |
165 return false; | 163 return false; |
166 } | 164 } |
167 double dist = distance(a); // OPTIMIZATION: can we compare against dist
Sq instead ? | 165 double dist = distance(a); // OPTIMIZATION: can we compare against dist
Sq instead ? |
168 double tiniest = SkTMin(SkTMin(SkTMin(fX, a.fX), fY), a.fY); | 166 double tiniest = SkTMin(SkTMin(SkTMin(fX, a.fX), fY), a.fY); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 bool roughlyEqual(const SkDPoint& a) const { | 223 bool roughlyEqual(const SkDPoint& a) const { |
226 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); | 224 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); |
227 } | 225 } |
228 | 226 |
229 // utilities callable by the user from the debugger when the implementation
code is linked in | 227 // utilities callable by the user from the debugger when the implementation
code is linked in |
230 void dump() const; | 228 void dump() const; |
231 static void Dump(const SkPoint& pt); | 229 static void Dump(const SkPoint& pt); |
232 }; | 230 }; |
233 | 231 |
234 #endif | 232 #endif |
OLD | NEW |