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/SkOpAngle.cpp b/src/pathops/SkOpAngle.cpp
index a701d0f..8efdc5d 100644
--- a/src/pathops/SkOpAngle.cpp
+++ b/src/pathops/SkOpAngle.cpp
@@ -326,8 +326,8 @@
}
bool SkOpAngle::checkCrossesZero() const {
- int start = SkTMin(fSectorStart, fSectorEnd);
- int end = SkTMax(fSectorStart, fSectorEnd);
+ int start = std::min(fSectorStart, fSectorEnd);
+ int end = std::max(fSectorStart, fSectorEnd);
bool crossesZero = end - start > 16;
return crossesZero;
}
@@ -494,7 +494,7 @@
SkDVector v;
v.set(pts[idx2] - pts[idx1]);
double lenSq = v.lengthSquared();
- longest = SkTMax(longest, lenSq);
+ longest = std::max(longest, lenSq);
}
}
return sqrt(longest) / dist;
@@ -533,7 +533,7 @@
if (approximately_equal_orderable(tStart, testT)) {
continue;
}
- smallTs[index] = t = testAscends ? SkTMax(t, testT) : SkTMin(t, testT);
+ smallTs[index] = t = testAscends ? std::max(t, testT) : std::min(t, testT);
limited[index] = approximately_equal_orderable(t, tEnd);
}
}
@@ -580,12 +580,12 @@
const SkDCurve& curve = index ? rh->fPart.fCurve : this->fPart.fCurve;
int ptCount = index ? rPts : lPts;
for (int idx2 = 0; idx2 <= ptCount; ++idx2) {
- minX = SkTMin(minX, curve[idx2].fX);
- minY = SkTMin(minY, curve[idx2].fY);
- maxX = SkTMax(maxX, curve[idx2].fX);
- maxY = SkTMax(maxY, curve[idx2].fY);
+ minX = std::min(minX, curve[idx2].fX);
+ minY = std::min(minY, curve[idx2].fY);
+ maxX = std::max(maxX, curve[idx2].fX);
+ maxY = std::max(maxY, curve[idx2].fY);
}
- double maxWidth = SkTMax(maxX - minX, maxY - minY);
+ double maxWidth = std::max(maxX - minX, maxY - minY);
delta = sk_ieee_double_divide(delta, maxWidth);
// FIXME: move these magic numbers
// This fixes skbug.com/8380
@@ -665,12 +665,12 @@
const SkDCurve& curve = rh->fPart.fCurve;
int oppPts = SkPathOpsVerbToPoints(oppVerb);
for (int idx2 = 0; idx2 <= oppPts; ++idx2) {
- minX = SkTMin(minX, curve[idx2].fX);
- minY = SkTMin(minY, curve[idx2].fY);
- maxX = SkTMax(maxX, curve[idx2].fX);
- maxY = SkTMax(maxY, curve[idx2].fY);
+ minX = std::min(minX, curve[idx2].fX);
+ minY = std::min(minY, curve[idx2].fY);
+ maxX = std::max(maxX, curve[idx2].fX);
+ maxY = std::max(maxY, curve[idx2].fY);
}
- double maxWidth = SkTMax(maxX - minX, maxY - minY);
+ double maxWidth = std::max(maxX - minX, maxY - minY);
endDist = sk_ieee_double_divide(endDist, maxWidth);
if (!(endDist >= 5e-12)) { // empirically found
return false; // ! above catches NaN
@@ -1088,7 +1088,7 @@
return;
}
bool crossesZero = this->checkCrossesZero();
- int start = SkTMin(fSectorStart, fSectorEnd);
+ int start = std::min(fSectorStart, fSectorEnd);
bool curveBendsCCW = (fSectorStart == start) ^ crossesZero;
// bump the start and end of the sector span if they are on exact compass points
if ((fSectorStart & 3) == 3) {
@@ -1098,8 +1098,8 @@
fSectorEnd = (fSectorEnd + (curveBendsCCW ? 31 : 1)) & 0x1f;
}
crossesZero = this->checkCrossesZero();
- start = SkTMin(fSectorStart, fSectorEnd);
- int end = SkTMax(fSectorStart, fSectorEnd);
+ start = std::min(fSectorStart, fSectorEnd);
+ int end = std::max(fSectorStart, fSectorEnd);
if (!crossesZero) {
fSectorMask = (unsigned) -1 >> (31 - end + start) << start;
} else {