Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(909)

Side by Side Diff: src/pathops/SkPathOpsPoint.h

Issue 2237223002: pathops coincident work (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove unused code Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pathops/SkPathOpsDebug.cpp ('k') | src/pathops/SkPathOpsTypes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // only used by testing 137 // only used by testing
138 SkDPoint operator-(const SkDVector& v) { 138 SkDPoint operator-(const SkDVector& v) {
139 SkDPoint result = *this; 139 SkDPoint result = *this;
140 result -= v; 140 result -= v;
141 return result; 141 return result;
142 } 142 }
143 143
144 // note: this can not be implemented with 144 // note: this can not be implemented with
145 // return approximately_equal(a.fY, fY) && approximately_equal(a.fX, fX); 145 // return approximately_equal(a.fY, fY) && approximately_equal(a.fX, fX);
146 // because that will not take the magnitude of the values into account 146 // because that will not take the magnitude of the values into account
147 bool approximatelyDEqual(const SkDPoint& a) const {
148 if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) {
149 return true;
150 }
151 if (!RoughlyEqualUlps(fX, a.fX) || !RoughlyEqualUlps(fY, a.fY)) {
152 return false;
153 }
154 double dist = distance(a); // OPTIMIZATION: can we compare against dist Sq instead ?
155 double tiniest = SkTMin(SkTMin(SkTMin(fX, a.fX), fY), a.fY);
156 double largest = SkTMax(SkTMax(SkTMax(fX, a.fX), fY), a.fY);
157 largest = SkTMax(largest, -tiniest);
158 return AlmostDequalUlps(largest, largest + dist); // is the dist within ULPS tolerance?
159 }
160
161 bool approximatelyDEqual(const SkPoint& a) const {
162 SkDPoint dA;
163 dA.set(a);
164 return approximatelyDEqual(dA);
165 }
166
147 bool approximatelyEqual(const SkDPoint& a) const { 167 bool approximatelyEqual(const SkDPoint& a) const {
148 if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) { 168 if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) {
149 return true; 169 return true;
150 } 170 }
151 if (!RoughlyEqualUlps(fX, a.fX) || !RoughlyEqualUlps(fY, a.fY)) { 171 if (!RoughlyEqualUlps(fX, a.fX) || !RoughlyEqualUlps(fY, a.fY)) {
152 return false; 172 return false;
153 } 173 }
154 double dist = distance(a); // OPTIMIZATION: can we compare against dist Sq instead ? 174 double dist = distance(a); // OPTIMIZATION: can we compare against dist Sq instead ?
155 double tiniest = SkTMin(SkTMin(SkTMin(fX, a.fX), fY), a.fY); 175 double tiniest = SkTMin(SkTMin(SkTMin(fX, a.fX), fY), a.fY);
156 double largest = SkTMax(SkTMax(SkTMax(fX, a.fX), fY), a.fY); 176 double largest = SkTMax(SkTMax(SkTMax(fX, a.fX), fY), a.fY);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 SkDPoint dA, dB; 246 SkDPoint dA, dB;
227 dA.set(a); 247 dA.set(a);
228 dB.set(b); 248 dB.set(b);
229 double dist = dA.distance(dB); // OPTIMIZATION: can we compare against distSq instead ? 249 double dist = dA.distance(dB); // OPTIMIZATION: can we compare against distSq instead ?
230 float tiniest = SkTMin(SkTMin(SkTMin(a.fX, b.fX), a.fY), b.fY); 250 float tiniest = SkTMin(SkTMin(SkTMin(a.fX, b.fX), a.fY), b.fY);
231 float largest = SkTMax(SkTMax(SkTMax(a.fX, b.fX), a.fY), b.fY); 251 float largest = SkTMax(SkTMax(SkTMax(a.fX, b.fX), a.fY), b.fY);
232 largest = SkTMax(largest, -tiniest); 252 largest = SkTMax(largest, -tiniest);
233 return RoughlyEqualUlps((double) largest, largest + dist); // is dist wi thin ULPS tolerance? 253 return RoughlyEqualUlps((double) largest, largest + dist); // is dist wi thin ULPS tolerance?
234 } 254 }
235 255
256 // very light weight check, should only be used for inequality check
257 static bool WayRoughlyEqual(const SkPoint& a, const SkPoint& b) {
258 float largestNumber = SkTMax(SkTAbs(a.fX), SkTMax(SkTAbs(a.fY),
259 SkTMax(SkTAbs(b.fX), SkTAbs(b.fY))));
260 SkVector diffs = a - b;
261 float largestDiff = SkTMax(diffs.fX, diffs.fY);
262 return roughly_zero_when_compared_to(largestDiff, largestNumber);
263 }
264
236 // utilities callable by the user from the debugger when the implementation code is linked in 265 // utilities callable by the user from the debugger when the implementation code is linked in
237 void dump() const; 266 void dump() const;
238 static void Dump(const SkPoint& pt); 267 static void Dump(const SkPoint& pt);
239 static void DumpHex(const SkPoint& pt); 268 static void DumpHex(const SkPoint& pt);
240 }; 269 };
241 270
242 #endif 271 #endif
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsDebug.cpp ('k') | src/pathops/SkPathOpsTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698