summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/skia/src/pathops/SkPathOpsPoint.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/skia/src/pathops/SkPathOpsPoint.h')
-rw-r--r--chromium/third_party/skia/src/pathops/SkPathOpsPoint.h57
1 files changed, 38 insertions, 19 deletions
diff --git a/chromium/third_party/skia/src/pathops/SkPathOpsPoint.h b/chromium/third_party/skia/src/pathops/SkPathOpsPoint.h
index c3e0b40ab9f..5c2e3a50ddd 100644
--- a/chromium/third_party/skia/src/pathops/SkPathOpsPoint.h
+++ b/chromium/third_party/skia/src/pathops/SkPathOpsPoint.h
@@ -15,7 +15,13 @@ inline bool AlmostEqualUlps(const SkPoint& pt1, const SkPoint& pt2) {
}
struct SkDVector {
- double fX, fY;
+ double fX;
+ double fY;
+
+ void set(const SkVector& pt) {
+ fX = pt.fX;
+ fY = pt.fY;
+ }
friend SkDPoint operator+(const SkDPoint& a, const SkDVector& b);
@@ -48,6 +54,13 @@ struct SkDVector {
return fX * a.fY - fY * a.fX;
}
+ // similar to cross, this bastardization considers nearly coincident to be zero
+ double crossCheck(const SkDVector& a) const {
+ double xy = fX * a.fY;
+ double yx = fY * a.fX;
+ return AlmostEqualUlps(xy, yx) ? 0 : xy - yx;
+ }
+
double dot(const SkDVector& a) const {
return fX * a.fX + fY * a.fY;
}
@@ -85,7 +98,6 @@ struct SkDPoint {
fY = pt.fY;
}
-
void operator+=(const SkDVector& v) {
fX += v.fX;
fY += v.fY;
@@ -136,6 +148,13 @@ struct SkDPoint {
return AlmostBequalUlps((double) largest, largest + dist); // is dist within ULPS tolerance?
}
+ static bool RoughlyEqual(const SkPoint& a, const SkPoint& b) {
+ if (approximately_equal(a.fX, b.fX) && approximately_equal(a.fY, b.fY)) {
+ return true;
+ }
+ return RoughlyEqualUlps(a.fX, b.fX) && RoughlyEqualUlps(a.fY, b.fY);
+ }
+
bool approximatelyPEqual(const SkDPoint& a) const {
if (approximately_equal(fX, a.fX) && approximately_equal(fY, a.fY)) {
return true;
@@ -150,6 +169,20 @@ struct SkDPoint {
return AlmostPequalUlps(largest, largest + dist); // is the dist within ULPS tolerance?
}
+ bool approximatelyDEqual(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 AlmostDequalUlps(largest, largest + dist); // is the dist within ULPS tolerance?
+ }
+
bool approximatelyZero() const {
return approximately_zero(fX) && approximately_zero(fY);
}
@@ -191,23 +224,9 @@ struct SkDPoint {
return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX);
}
- #ifdef SK_DEBUG
- void dump() {
- SkDebugf("{");
- DebugDumpDouble(fX);
- SkDebugf(", ");
- DebugDumpDouble(fY);
- SkDebugf("}");
- }
-
- static void dump(const SkPoint& pt) {
- SkDebugf("{");
- DebugDumpFloat(pt.fX);
- SkDebugf(", ");
- DebugDumpFloat(pt.fY);
- SkDebugf("}");
- }
- #endif
+ // utilities callable by the user from the debugger when the implementation code is linked in
+ void dump() const;
+ static void Dump(const SkPoint& pt);
};
#endif