Remove SkTMin and SkTMax
Use std::min and std::max everywhere.
SkTPin still exists. We can't use std::clamp yet, and even when
we can, it has undefined behavior with NaN. SkTPin is written
to ensure that we return a value in the [lo, hi] range.
Change-Id: I506852a36e024ae405358d5078a872e2c77fa71e
Docs-Preview: https://skia.org/?cl=269357
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269357
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/pathops/SkPathOpsPoint.h b/src/pathops/SkPathOpsPoint.h
index bca0530..63de458 100644
--- a/src/pathops/SkPathOpsPoint.h
+++ b/src/pathops/SkPathOpsPoint.h
@@ -160,9 +160,9 @@
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);
+ double tiniest = std::min(std::min(std::min(fX, a.fX), fY), a.fY);
+ double largest = std::max(std::max(std::max(fX, a.fX), fY), a.fY);
+ largest = std::max(largest, -tiniest);
return AlmostDequalUlps(largest, largest + dist); // is the dist within ULPS tolerance?
}
@@ -180,9 +180,9 @@
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);
+ double tiniest = std::min(std::min(std::min(fX, a.fX), fY), a.fY);
+ double largest = std::max(std::max(std::max(fX, a.fX), fY), a.fY);
+ largest = std::max(largest, -tiniest);
return AlmostPequalUlps(largest, largest + dist); // is the dist within ULPS tolerance?
}
@@ -203,9 +203,9 @@
dA.set(a);
dB.set(b);
double dist = dA.distance(dB); // OPTIMIZATION: can we compare against distSq instead ?
- float tiniest = SkTMin(SkTMin(SkTMin(a.fX, b.fX), a.fY), b.fY);
- float largest = SkTMax(SkTMax(SkTMax(a.fX, b.fX), a.fY), b.fY);
- largest = SkTMax(largest, -tiniest);
+ float tiniest = std::min(std::min(std::min(a.fX, b.fX), a.fY), b.fY);
+ float largest = std::max(std::max(std::max(a.fX, b.fX), a.fY), b.fY);
+ largest = std::max(largest, -tiniest);
return AlmostDequalUlps((double) largest, largest + dist); // is dist within ULPS tolerance?
}
@@ -241,9 +241,9 @@
return true;
}
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);
+ double tiniest = std::min(std::min(std::min(fX, a.fX), fY), a.fY);
+ double largest = std::max(std::max(std::max(fX, a.fX), fY), a.fY);
+ largest = std::max(largest, -tiniest);
return RoughlyEqualUlps(largest, largest + dist); // is the dist within ULPS tolerance?
}
@@ -255,18 +255,18 @@
dA.set(a);
dB.set(b);
double dist = dA.distance(dB); // OPTIMIZATION: can we compare against distSq instead ?
- float tiniest = SkTMin(SkTMin(SkTMin(a.fX, b.fX), a.fY), b.fY);
- float largest = SkTMax(SkTMax(SkTMax(a.fX, b.fX), a.fY), b.fY);
- largest = SkTMax(largest, -tiniest);
+ float tiniest = std::min(std::min(std::min(a.fX, b.fX), a.fY), b.fY);
+ float largest = std::max(std::max(std::max(a.fX, b.fX), a.fY), b.fY);
+ largest = std::max(largest, -tiniest);
return RoughlyEqualUlps((double) largest, largest + dist); // is dist within ULPS tolerance?
}
// very light weight check, should only be used for inequality check
static bool WayRoughlyEqual(const SkPoint& a, const SkPoint& b) {
- float largestNumber = SkTMax(SkTAbs(a.fX), SkTMax(SkTAbs(a.fY),
- SkTMax(SkTAbs(b.fX), SkTAbs(b.fY))));
+ float largestNumber = std::max(SkTAbs(a.fX), std::max(SkTAbs(a.fY),
+ std::max(SkTAbs(b.fX), SkTAbs(b.fY))));
SkVector diffs = a - b;
- float largestDiff = SkTMax(diffs.fX, diffs.fY);
+ float largestDiff = std::max(diffs.fX, diffs.fY);
return roughly_zero_when_compared_to(largestDiff, largestNumber);
}