Index: src/pathops/SkPathOpsPoint.h |
diff --git a/src/pathops/SkPathOpsPoint.h b/src/pathops/SkPathOpsPoint.h |
index 40688d80728c9f95fd441d5a2197bf971f121c62..c3e0b40ab9f619620e2a0e0afd045068564226b7 100644 |
--- a/src/pathops/SkPathOpsPoint.h |
+++ b/src/pathops/SkPathOpsPoint.h |
@@ -98,7 +98,7 @@ struct SkDPoint { |
// note: this can not be implemented with |
// return approximately_equal(a.fY, fY) && approximately_equal(a.fX, fX); |
- // because that will not take the magnitude of the values |
+ // because that will not take the magnitude of the values into account |
bool approximatelyEqual(const SkDPoint& a) const { |
if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) { |
return true; |
@@ -136,6 +136,20 @@ struct SkDPoint { |
return AlmostBequalUlps((double) largest, largest + dist); // is dist within ULPS tolerance? |
} |
+ bool approximatelyPEqual(const SkDPoint& a) const { |
+ if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) { |
+ return true; |
+ } |
+ if (!RoughlyEqualUlps(fX, a.fX) || !RoughlyEqualUlps(fY, a.fY)) { |
+ return false; |
+ } |
+ double dist = distance(a); // OPTIMIZATION: can we compare against distSq instead ? |
+ double tiniest = SkTMin(SkTMin(SkTMin(fX, a.fX), fY), a.fY); |
+ double largest = SkTMax(SkTMax(SkTMax(fX, a.fX), fY), a.fY); |
+ largest = SkTMax(largest, -tiniest); |
+ return AlmostPequalUlps(largest, largest + dist); // is the dist within ULPS tolerance? |
+ } |
+ |
bool approximatelyZero() const { |
return approximately_zero(fX) && approximately_zero(fY); |
} |
@@ -186,7 +200,7 @@ struct SkDPoint { |
SkDebugf("}"); |
} |
- static void DumpSkPoint(const SkPoint& pt) { |
+ static void dump(const SkPoint& pt) { |
SkDebugf("{"); |
DebugDumpFloat(pt.fX); |
SkDebugf(", "); |