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/tests/ApplyGammaTest.cpp b/tests/ApplyGammaTest.cpp
index a854549..afc49f3 100644
--- a/tests/ApplyGammaTest.cpp
+++ b/tests/ApplyGammaTest.cpp
@@ -67,8 +67,8 @@
 
     for (int c = 0; c < 3; ++c) {
         float srcComponent = ((src & (0xff << (c * 8))) >> (c * 8)) * invScale;
-        float lower = SkTMax(0.f, srcComponent - error);
-        float upper = SkTMin(255.f, srcComponent + error);
+        float lower = std::max(0.f, srcComponent - error);
+        float upper = std::min(255.f, srcComponent + error);
         if (toSRGB) {
             lower = linear_to_srgb(lower / 255.f);
             upper = linear_to_srgb(upper / 255.f);
diff --git a/tests/CodecPartialTest.cpp b/tests/CodecPartialTest.cpp
index 0ab6bdf..43ea226 100644
--- a/tests/CodecPartialTest.cpp
+++ b/tests/CodecPartialTest.cpp
@@ -131,7 +131,7 @@
 
     // This size is arbitrary, but deliberately different from the buffer size used by SkPngCodec.
     constexpr size_t kIncrement = 1000;
-    test_partial(r, name, file, SkTMax(file->size() / 2, minBytes), kIncrement);
+    test_partial(r, name, file, std::max(file->size() / 2, minBytes), kIncrement);
 }
 
 DEF_TEST(Codec_partial, r) {
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 7f29fd6..7ec94dd 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -150,7 +150,7 @@
     for (int oddEven = 1; oddEven >= 0; oddEven--) {
         for (int y = oddEven * stripeHeight; y < height; y += 2 * stripeHeight) {
             SkIRect subset = SkIRect::MakeLTRB(0, y, info.width(),
-                                               SkTMin(y + stripeHeight, height));
+                                               std::min(y + stripeHeight, height));
             SkCodec::Options options;
             options.fSubset = &subset;
             if (SkCodec::kSuccess != codec->startIncrementalDecode(info, bm.getAddr(0, y),
@@ -847,7 +847,7 @@
         , fLimit(limit) {}
 
     size_t peek(void* buf, size_t bytes) const override {
-        return fStream.peek(buf, SkTMin(bytes, fLimit));
+        return fStream.peek(buf, std::min(bytes, fLimit));
     }
     size_t read(void* buf, size_t bytes) override {
         return fStream.read(buf, bytes);
diff --git a/tests/CompressedBackendAllocationTest.cpp b/tests/CompressedBackendAllocationTest.cpp
index 00d208c..bd4f02b 100644
--- a/tests/CompressedBackendAllocationTest.cpp
+++ b/tests/CompressedBackendAllocationTest.cpp
@@ -185,7 +185,7 @@
         GrFillInCompressedData(compression, dimensions,
                                GrMipMapped::kNo, &data[mipMapOffsets[level]], levelColors[level]);
 
-        dimensions = {SkTMax(1, dimensions.width() /2), SkTMax(1, dimensions.height()/2)};
+        dimensions = {std::max(1, dimensions.width() /2), std::max(1, dimensions.height()/2)};
     }
 
     return std::unique_ptr<const char[]>(data);
diff --git a/tests/FakeStreams.h b/tests/FakeStreams.h
index a5577e9..b527adf 100644
--- a/tests/FakeStreams.h
+++ b/tests/FakeStreams.h
@@ -52,7 +52,7 @@
     {}
 
     void addNewData(size_t extra) {
-        fLimit = SkTMin(fTotalSize, fLimit + extra);
+        fLimit = std::min(fTotalSize, fLimit + extra);
     }
 
     size_t read(void* buffer, size_t size) override {
diff --git a/tests/FontMgrAndroidParserTest.cpp b/tests/FontMgrAndroidParserTest.cpp
index 2a41b60..12c2fd3 100644
--- a/tests/FontMgrAndroidParserTest.cpp
+++ b/tests/FontMgrAndroidParserTest.cpp
@@ -144,7 +144,7 @@
             double f2 = fix * SK_FixedEpsilon_double;
             double error = fabs(f - f2);
             REPORTER_ASSERT(reporter,  error <= SK_FixedEpsilon_double);
-            maxError = SkTMax(maxError, error);
+            maxError = std::max(maxError, error);
         } else {
             REPORTER_ASSERT(reporter, f < -SK_FixedMax_double || SK_FixedMax_double < f);
         }
diff --git a/tests/FrontBufferedStreamTest.cpp b/tests/FrontBufferedStreamTest.cpp
index e3f4352..99fe861 100644
--- a/tests/FrontBufferedStreamTest.cpp
+++ b/tests/FrontBufferedStreamTest.cpp
@@ -239,7 +239,7 @@
         REPORTER_ASSERT(reporter, !bufferedStream->isAtEnd());
         test_read(reporter, bufferedStream.get(), gAbcs + arbitraryOffset + currentPosition,
                   amountToRead);
-        currentPosition = SkTMin(currentPosition + amountToRead, bufferedLength);
+        currentPosition = std::min(currentPosition + amountToRead, bufferedLength);
         REPORTER_ASSERT(reporter, memStream->getPosition() - arbitraryOffset == currentPosition);
     }
     REPORTER_ASSERT(reporter, bufferedStream->isAtEnd());
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index 6af9ba1..3c40731 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -675,7 +675,7 @@
                     } else {
                         REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
                     }
-                    nextFlush = SkTMin(j + (int)rand.nextRangeU(1, 29), kNumPaths - 1);
+                    nextFlush = std::min(j + (int)rand.nextRangeU(1, 29), kNumPaths - 1);
                 }
             }
             SkASSERT(endPathIdx == pathIdx % kNumPaths);
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index 6f04c50..9253ffc 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -181,7 +181,7 @@
                 // index.
                 while (i < kBoxCount) {
                     static_assert(kIndexPatternRepeatCount >= 3);
-                    int repetitionCount = SkTMin(3 - baseRepetition, kBoxCount - i);
+                    int repetitionCount = std::min(3 - baseRepetition, kBoxCount - i);
 
                     GrMesh mesh(GrPrimitiveType::kTriangles);
                     mesh.setIndexed(helper->fIndexBuffer, repetitionCount * 6, baseRepetition * 6,
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index a2c70c1..b3421fd 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -1208,7 +1208,7 @@
     for (int a = 0; a < 256; ++a) {
         for (int r = 0; r < 256; ++r) {
             // make all valid premul combinations
-            int c = SkTMin(a, r);
+            int c = std::min(a, r);
             *bm->getAddr32(a, r) = SkPackARGB32(a, c, c, c);
         }
     }
diff --git a/tests/IncrTopoSortTest.cpp b/tests/IncrTopoSortTest.cpp
index 9f5aa66..9f8d66a 100644
--- a/tests/IncrTopoSortTest.cpp
+++ b/tests/IncrTopoSortTest.cpp
@@ -159,7 +159,7 @@
                 this->dfs(dependent, (*dependedOn)[i]->indexInSort());
             }
 
-            lowerBound = SkTMin(dependent->indexInSort(), lowerBound);
+            lowerBound = std::min(dependent->indexInSort(), lowerBound);
         }
 
         this->shift(lowerBound);
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index ed358de..7d7427f 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -642,14 +642,7 @@
         int i = sk_float_saturate2int(r.fFloat);
         REPORTER_ASSERT(reporter, r.fExpectedInt == i);
 
-        // ensure that these bound even non-finite values (including NaN)
-
-        SkScalar mx = SkTMax<SkScalar>(r.fFloat, 50);
-        REPORTER_ASSERT(reporter, mx >= 50);
-
-        SkScalar mn = SkTMin<SkScalar>(r.fFloat, 50);
-        REPORTER_ASSERT(reporter, mn <= 50);
-
+        // Ensure that SkTPin bounds even non-finite values (including NaN)
         SkScalar p = SkTPin<SkScalar>(r.fFloat, 0, 100);
         REPORTER_ASSERT(reporter, p >= 0 && p <= 100);
     }
diff --git a/tests/PDFDeflateWStreamTest.cpp b/tests/PDFDeflateWStreamTest.cpp
index 20ee249..29a6b85 100644
--- a/tests/PDFDeflateWStreamTest.cpp
+++ b/tests/PDFDeflateWStreamTest.cpp
@@ -120,7 +120,7 @@
             uint32_t j = 0;
             while (j < size) {
                 uint32_t writeSize =
-                        SkTMin(size - j, random.nextRangeU(1, 400));
+                        std::min(size - j, random.nextRangeU(1, 400));
                 if (!deflateWStream.write(&buffer[j], writeSize)) {
                     ERRORF(r, "something went wrong.");
                     return;
@@ -151,7 +151,7 @@
 
             continue;
         }
-        uint32_t minLength = SkTMin(size,
+        uint32_t minLength = std::min(size,
                                     (uint32_t)(decompressed->getLength()));
         for (uint32_t i = 0; i < minLength; ++i) {
             uint8_t c;
diff --git a/tests/PDFGlyphsToUnicodeTest.cpp b/tests/PDFGlyphsToUnicodeTest.cpp
index 7b9131d..a3400a3 100644
--- a/tests/PDFGlyphsToUnicodeTest.cpp
+++ b/tests/PDFGlyphsToUnicodeTest.cpp
@@ -82,7 +82,7 @@
         subset.set(v);
     }
     SkPDFAppendCmapSections(&glyphToUnicode[0], &subset, &buffer, true, 0,
-                            SkTMin<SkGlyphID>(0xFFFF,  lastGlyphID));
+                            std::min<SkGlyphID>(0xFFFF,  lastGlyphID));
 
     char expectedResult[] =
 "4 beginbfchar\n\
@@ -105,7 +105,7 @@
     buffer.reset();
 
     SkPDFAppendCmapSections(&glyphToUnicode[0], &subset, &buffer, true, 8,
-                            SkTMin<SkGlyphID>(0x00FF, lastGlyphID));
+                            std::min<SkGlyphID>(0x00FF, lastGlyphID));
 
     char expectedResultChop1[] =
 "2 beginbfchar\n\
@@ -124,7 +124,7 @@
     buffer.reset();
 
     SkPDFAppendCmapSections(&glyphToUnicode[0], &subset, &buffer, true, 0x00D,
-                            SkTMin<SkGlyphID>(0x00FE, lastGlyphID));
+                            std::min<SkGlyphID>(0x00FE, lastGlyphID));
 
     char expectedResultChop2[] =
 "2 beginbfchar\n\
@@ -138,7 +138,7 @@
     buffer.reset();
 
     SkPDFAppendCmapSections(&glyphToUnicode[0], nullptr, &buffer, false, 0xFC,
-                            SkTMin<SkGlyphID>(0x110, lastGlyphID));
+                            std::min<SkGlyphID>(0x110, lastGlyphID));
 
     char expectedResultSingleBytes[] =
 "2 beginbfchar\n\
@@ -178,7 +178,7 @@
         subset2.set(v);
     }
     SkPDFAppendCmapSections(&glyphToUnicode[0], &subset2, &buffer2, true, 0,
-                            SkTMin<SkGlyphID>(0xFFFF, lastGlyphID));
+                            std::min<SkGlyphID>(0xFFFF, lastGlyphID));
 
     char expectedResult2[] =
 "4 beginbfchar\n\
diff --git a/tests/PathOpsAngleIdeas.cpp b/tests/PathOpsAngleIdeas.cpp
index bbf5e7a..e2cc2e0 100644
--- a/tests/PathOpsAngleIdeas.cpp
+++ b/tests/PathOpsAngleIdeas.cpp
@@ -122,7 +122,7 @@
 
 static double distEndRatio(double dist, const SkDQuad& quad) {
     SkDVector v[] = {quad[2] - quad[0], quad[1] - quad[0], quad[2] - quad[1]};
-    double longest = SkTMax(v[0].length(), SkTMax(v[1].length(), v[2].length()));
+    double longest = std::max(v[0].length(), std::max(v[1].length(), v[2].length()));
     return longest / dist;
 }
 
@@ -245,7 +245,7 @@
     bool refCCW = angleDirection(a1, a2);
     result->t1 = t1;
     result->t2 = t2;
-    result->tMin = SkTMin(t1, t2);
+    result->tMin = std::min(t1, t2);
     result->a1 = a1;
     result->a2 = a2;
     result->ccw = refCCW;
@@ -268,7 +268,7 @@
     };
     double max = 0;
     for (unsigned index = 0; index < SK_ARRAY_COUNT(corner); ++index) {
-        max = SkTMax(max, corner[index].length());
+        max = std::max(max, corner[index].length());
     }
     return max;
 }
@@ -276,16 +276,16 @@
 static double maxQuad(const SkDQuad& quad) {
     double max = 0;
     for (int index = 0; index < 2; ++index) {
-        max = SkTMax(max, fabs(quad[index].fX));
-        max = SkTMax(max, fabs(quad[index].fY));
+        max = std::max(max, fabs(quad[index].fX));
+        max = std::max(max, fabs(quad[index].fY));
     }
     return max;
 }
 
 static bool bruteMinT(skiatest::Reporter* reporter, const SkDQuad& quad1, const SkDQuad& quad2,
         TRange* lowerRange, TRange* upperRange) {
-    double maxRadius = SkTMin(maxDist(quad1), maxDist(quad2));
-    double maxQuads = SkTMax(maxQuad(quad1), maxQuad(quad2));
+    double maxRadius = std::min(maxDist(quad1), maxDist(quad2));
+    double maxQuads = std::max(maxQuad(quad1), maxQuad(quad2));
     double r = maxRadius / 2;
     double rStep = r / 2;
     SkDPoint best1 = {SK_ScalarInfinity, SK_ScalarInfinity};
@@ -378,7 +378,7 @@
                         *lowerRange = tRange;
                     }
                 }
-                lastHighR = SkTMin(r, lastHighR);
+                lastHighR = std::min(r, lastHighR);
             }
             r += success ? -rStep : rStep;
             rStep /= 2;
@@ -487,11 +487,11 @@
     for (unsigned index = 0; index < SK_ARRAY_COUNT(quads); ++index) {
         const SkDQuad& q = *quads[index];
         midSpokes[index] = q.ptAtT(0.5) - origin;
-        minX = SkTMin(SkTMin(SkTMin(minX, origin.fX), q[1].fX), q[2].fX);
-        minY = SkTMin(SkTMin(SkTMin(minY, origin.fY), q[1].fY), q[2].fY);
-        maxX = SkTMax(SkTMax(SkTMax(maxX, origin.fX), q[1].fX), q[2].fX);
-        maxY = SkTMax(SkTMax(SkTMax(maxY, origin.fY), q[1].fY), q[2].fY);
-        maxWidth = SkTMax(maxWidth, SkTMax(maxX - minX, maxY - minY));
+        minX = std::min(std::min(std::min(minX, origin.fX), q[1].fX), q[2].fX);
+        minY = std::min(std::min(std::min(minY, origin.fY), q[1].fY), q[2].fY);
+        maxX = std::max(std::max(std::max(maxX, origin.fX), q[1].fX), q[2].fX);
+        maxY = std::max(std::max(std::max(maxY, origin.fY), q[1].fY), q[2].fY);
+        maxWidth = std::max(maxWidth, std::max(maxX - minX, maxY - minY));
         intersect[index].intersectRay(q, rays[index]);
         const SkIntersections& i = intersect[index];
         REPORTER_ASSERT(reporter, i.used() >= 1);
@@ -636,7 +636,7 @@
         TRange lowerRange, upperRange;
         bool result = bruteMinT(reporter, q1, q2, &lowerRange, &upperRange);
         REPORTER_ASSERT(reporter, result);
-        double min = SkTMin(upperRange.t1, upperRange.t2);
+        double min = std::min(upperRange.t1, upperRange.t2);
         if (smaller > min) {
             small[0] = q1;
             small[1] = q2;
@@ -833,7 +833,7 @@
         REPORTER_ASSERT(reporter, s0xt0 != 0);
         bool ccw = s0xt0 < 0;
         bool agrees = bruteForceCheck(reporter, quad1, quad2, ccw);
-        maxR = SkTMin(maxR, mDistance(reporter, agrees, quad1, quad2));
+        maxR = std::min(maxR, mDistance(reporter, agrees, quad1, quad2));
         if (agrees) {
             continue;
         }
@@ -849,7 +849,7 @@
             q2[1].fX = quad2[0].fX * (1 - hiPass) + quad2[1].fX * hiPass;
             q2[1].fY = quad2[0].fY * (1 - hiPass) + quad2[1].fY * hiPass;
             agrees = bruteForceCheck(reporter, q1, q2, ccw);
-            maxR = SkTMin(maxR, mDistance(reporter, agrees, q1, q2));
+            maxR = std::min(maxR, mDistance(reporter, agrees, q1, q2));
             if (agrees) {
                 break;
             }
@@ -866,7 +866,7 @@
             q2[1].fX = quad2[0].fX * (1 - midTest) + quad2[1].fX * midTest;
             q2[1].fY = quad2[0].fY * (1 - midTest) + quad2[1].fY * midTest;
             agrees = bruteForceCheck(reporter, q1, q2, ccw);
-            maxR = SkTMin(maxR, mDistance(reporter, agrees, q1, q2));
+            maxR = std::min(maxR, mDistance(reporter, agrees, q1, q2));
             if (!agrees) {
                 midPointAgrees(reporter, quad1, quad2, !ccw);
             }
diff --git a/tests/PathOpsCubicLineIntersectionIdeas.cpp b/tests/PathOpsCubicLineIntersectionIdeas.cpp
index 449cdb3..8977992 100644
--- a/tests/PathOpsCubicLineIntersectionIdeas.cpp
+++ b/tests/PathOpsCubicLineIntersectionIdeas.cpp
@@ -80,7 +80,7 @@
         // use larger x/y difference to choose step
         if (calcDist > lessDist) {
             t -= step;
-            t = SkTMax(0., t);
+            t = std::max(0., t);
         } else {
             SkDPoint morePt = cubic.ptAtT(t + lastStep);
             double moreX = morePt.fX - pt.fX;
@@ -90,7 +90,7 @@
                 continue;
             }
             t += step;
-            t = SkTMin(1., t);
+            t = std::min(1., t);
         }
     } while (true);
     return t;
@@ -177,13 +177,13 @@
 #if 0
         double R2MinusQ3;
         if (r2check(A, B, C, D, &R2MinusQ3)) {
-            smallestR2 = SkTMin(smallestR2, R2MinusQ3);
-            largestR2 = SkTMax(largestR2, R2MinusQ3);
+            smallestR2 = std::min(smallestR2, R2MinusQ3);
+            largestR2 = std::max(largestR2, R2MinusQ3);
         }
 #endif
-        double largest = SkTMax(fabs(allRoots[0]), fabs(allRoots[1]));
+        double largest = std::max(fabs(allRoots[0]), fabs(allRoots[1]));
         if (realRoots == 3) {
-            largest = SkTMax(largest, fabs(allRoots[2]));
+            largest = std::max(largest, fabs(allRoots[2]));
         }
         int largeBits;
         if (largest <= 1) {
@@ -192,9 +192,9 @@
                 realRoots, allRoots[0], allRoots[1], allRoots[2], valid, validRoots[0],
                 validRoots[1], validRoots[2]);
 #endif
-            double smallest = SkTMin(allRoots[0], allRoots[1]);
+            double smallest = std::min(allRoots[0], allRoots[1]);
             if (realRoots == 3) {
-                smallest = SkTMin(smallest, allRoots[2]);
+                smallest = std::min(smallest, allRoots[2]);
             }
             SkASSERT_RELEASE(smallest < 0);
             SkASSERT_RELEASE(smallest >= -1);
@@ -226,7 +226,7 @@
             step *= 1.5;
             SkASSERT_RELEASE(step < 1);
         } while (true);
-        worstStep[largeBits] = SkTMax(worstStep[largeBits], diff);
+        worstStep[largeBits] = std::max(worstStep[largeBits], diff);
 #if 0
         {
             cubic.dump();
diff --git a/tests/PathOpsDebug.cpp b/tests/PathOpsDebug.cpp
index 94664c1..511edb8 100644
--- a/tests/PathOpsDebug.cpp
+++ b/tests/PathOpsDebug.cpp
@@ -1191,7 +1191,7 @@
         if (between(test->fStartT, t, test->fEndT)) {
             return test;
         }
-        double testDist = SkTMin(fabs(test->fStartT - t), fabs(test->fEndT - t));
+        double testDist = std::min(fabs(test->fStartT - t), fabs(test->fEndT - t));
         if (bestDist > testDist) {
             bestDist = testDist;
             closest = test;
diff --git a/tests/PathOpsLineIntersectionTest.cpp b/tests/PathOpsLineIntersectionTest.cpp
index e094978..8f7969b 100644
--- a/tests/PathOpsLineIntersectionTest.cpp
+++ b/tests/PathOpsLineIntersectionTest.cpp
@@ -118,29 +118,29 @@
         return;
     }
     if (line1[0].fY == line1[1].fY) {
-        double left = SkTMin(line1[0].fX, line1[1].fX);
-        double right = SkTMax(line1[0].fX, line1[1].fX);
+        double left = std::min(line1[0].fX, line1[1].fX);
+        double right = std::max(line1[0].fX, line1[1].fX);
         SkIntersections ts;
         ts.horizontal(line2, left, right, line1[0].fY, line1[0].fX != left);
         check_results(reporter, line2, line1, ts, nearAllowed);
     }
     if (line2[0].fY == line2[1].fY) {
-        double left = SkTMin(line2[0].fX, line2[1].fX);
-        double right = SkTMax(line2[0].fX, line2[1].fX);
+        double left = std::min(line2[0].fX, line2[1].fX);
+        double right = std::max(line2[0].fX, line2[1].fX);
         SkIntersections ts;
         ts.horizontal(line1, left, right, line2[0].fY, line2[0].fX != left);
         check_results(reporter, line1, line2, ts, nearAllowed);
     }
     if (line1[0].fX == line1[1].fX) {
-        double top = SkTMin(line1[0].fY, line1[1].fY);
-        double bottom = SkTMax(line1[0].fY, line1[1].fY);
+        double top = std::min(line1[0].fY, line1[1].fY);
+        double bottom = std::max(line1[0].fY, line1[1].fY);
         SkIntersections ts;
         ts.vertical(line2, top, bottom, line1[0].fX, line1[0].fY != top);
         check_results(reporter, line2, line1, ts, nearAllowed);
     }
     if (line2[0].fX == line2[1].fX) {
-        double top = SkTMin(line2[0].fY, line2[1].fY);
-        double bottom = SkTMax(line2[0].fY, line2[1].fY);
+        double top = std::min(line2[0].fY, line2[1].fY);
+        double bottom = std::max(line2[0].fY, line2[1].fY);
         SkIntersections ts;
         ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top);
         check_results(reporter, line1, line2, ts, nearAllowed);
@@ -161,8 +161,8 @@
         return;
     }
     if (line1[0].fY == line1[1].fY) {
-        double left = SkTMin(line1[0].fX, line1[1].fX);
-        double right = SkTMax(line1[0].fX, line1[1].fX);
+        double left = std::min(line1[0].fX, line1[1].fX);
+        double right = std::max(line1[0].fX, line1[1].fX);
         SkIntersections ts;
         ts.horizontal(line2, left, right, line1[0].fY, line1[0].fX != left);
         REPORTER_ASSERT(reporter, pts == 2);
@@ -170,8 +170,8 @@
         check_results(reporter, line2, line1, ts, false);
     }
     if (line2[0].fY == line2[1].fY) {
-        double left = SkTMin(line2[0].fX, line2[1].fX);
-        double right = SkTMax(line2[0].fX, line2[1].fX);
+        double left = std::min(line2[0].fX, line2[1].fX);
+        double right = std::max(line2[0].fX, line2[1].fX);
         SkIntersections ts;
         ts.horizontal(line1, left, right, line2[0].fY, line2[0].fX != left);
         REPORTER_ASSERT(reporter, pts == 2);
@@ -179,8 +179,8 @@
         check_results(reporter, line1, line2, ts, false);
     }
     if (line1[0].fX == line1[1].fX) {
-        double top = SkTMin(line1[0].fY, line1[1].fY);
-        double bottom = SkTMax(line1[0].fY, line1[1].fY);
+        double top = std::min(line1[0].fY, line1[1].fY);
+        double bottom = std::max(line1[0].fY, line1[1].fY);
         SkIntersections ts;
         ts.vertical(line2, top, bottom, line1[0].fX, line1[0].fY != top);
         REPORTER_ASSERT(reporter, pts == 2);
@@ -188,8 +188,8 @@
         check_results(reporter, line2, line1, ts, false);
     }
     if (line2[0].fX == line2[1].fX) {
-        double top = SkTMin(line2[0].fY, line2[1].fY);
-        double bottom = SkTMax(line2[0].fY, line2[1].fY);
+        double top = std::min(line2[0].fY, line2[1].fY);
+        double bottom = std::max(line2[0].fY, line2[1].fY);
         SkIntersections ts;
         ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top);
         REPORTER_ASSERT(reporter, pts == 2);
diff --git a/tests/PathOpsTightBoundsTest.cpp b/tests/PathOpsTightBoundsTest.cpp
index 2af11be..eef7fd1 100644
--- a/tests/PathOpsTightBoundsTest.cpp
+++ b/tests/PathOpsTightBoundsTest.cpp
@@ -91,14 +91,14 @@
                     continue;
                 }
                 lineWritten = true;
-                bitsWritten.fLeft = SkTMin(bitsWritten.fLeft, x);
-                bitsWritten.fRight = SkTMax(bitsWritten.fRight, x);
+                bitsWritten.fLeft = std::min(bitsWritten.fLeft, x);
+                bitsWritten.fRight = std::max(bitsWritten.fRight, x);
             }
             if (!lineWritten) {
                 continue;
             }
-            bitsWritten.fTop = SkTMin(bitsWritten.fTop, y);
-            bitsWritten.fBottom = SkTMax(bitsWritten.fBottom, y);
+            bitsWritten.fTop = std::min(bitsWritten.fTop, y);
+            bitsWritten.fBottom = std::max(bitsWritten.fBottom, y);
         }
         if (!bitsWritten.isEmpty()) {
             SkIRect tightOut;
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 86cb016..529eb1e 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -638,7 +638,7 @@
                                         "doesn't match actual output. Error: %f, Tolerance: %f, "
                                         "input: (%f, %f, %f, %f), actual: (%f, %f, %f, %f), "
                                         "expected(%f, %f, %f, %f)", fp->name(),
-                                        SkTMax(rDiff, SkTMax(gDiff, SkTMax(bDiff, aDiff))), kTol,
+                                        std::max(rDiff, std::max(gDiff, std::max(bDiff, aDiff))), kTol,
                                         input4f.fR, input4f.fG, input4f.fB, input4f.fA,
                                         output4f.fR, output4f.fG, output4f.fB, output4f.fA,
                                         expected4f.fR, expected4f.fG, expected4f.fB, expected4f.fA);
diff --git a/tests/ProgramsTest.cpp b/tests/ProgramsTest.cpp
index ae61788..b979f31 100644
--- a/tests/ProgramsTest.cpp
+++ b/tests/ProgramsTest.cpp
@@ -154,7 +154,7 @@
 
     int sampleCnt = random->nextBool() ? caps->getRenderTargetSampleCount(2, format) : 1;
     // Above could be 0 if msaa isn't supported.
-    sampleCnt = SkTMax(1, sampleCnt);
+    sampleCnt = std::max(1, sampleCnt);
 
     return GrRenderTargetContext::Make(
             context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp
index b54026b..14a90f1 100644
--- a/tests/SRGBReadWritePixelsTest.cpp
+++ b/tests/SRGBReadWritePixelsTest.cpp
@@ -47,8 +47,8 @@
 
     for (int c = 0; c < 3; ++c) {
         uint8_t inputComponent = (uint8_t) ((input & (0xff << (c*8))) >> (c*8));
-        float lower = SkTMax(0.f, (float) inputComponent - error);
-        float upper = SkTMin(255.f, (float) inputComponent + error);
+        float lower = std::max(0.f, (float) inputComponent - error);
+        float upper = std::min(255.f, (float) inputComponent + error);
         lower = CONVERT(lower / 255.f);
         upper = CONVERT(upper / 255.f);
         SkASSERT(lower >= 0.f && lower <= 255.f);
@@ -72,16 +72,16 @@
 
     for (int c = 0; c < 3; ++c) {
         uint8_t inputComponent = (uint8_t) ((input & (0xff << (c*8))) >> (c*8));
-        float lower = SkTMax(0.f, (float) inputComponent - error);
-        float upper = SkTMin(255.f, (float) inputComponent + error);
+        float lower = std::max(0.f, (float) inputComponent - error);
+        float upper = std::min(255.f, (float) inputComponent + error);
         lower = FORWARD(lower / 255.f);
         upper = FORWARD(upper / 255.f);
         SkASSERT(lower >= 0.f && lower <= 255.f);
         SkASSERT(upper >= 0.f && upper <= 255.f);
         uint8_t upperComponent = SkScalarCeilToInt(upper * 255.f);
         uint8_t lowerComponent = SkScalarFloorToInt(lower * 255.f);
-        lower = SkTMax(0.f, (float) lowerComponent - error);
-        upper = SkTMin(255.f, (float) upperComponent + error);
+        lower = std::max(0.f, (float) lowerComponent - error);
+        upper = std::min(255.f, (float) upperComponent + error);
         lower = BACKWARD(lowerComponent / 255.f);
         upper = BACKWARD(upperComponent / 255.f);
         SkASSERT(lower >= 0.f && lower <= 255.f);
diff --git a/tests/SkNxTest.cpp b/tests/SkNxTest.cpp
index b6b0085..0f189df 100644
--- a/tests/SkNxTest.cpp
+++ b/tests/SkNxTest.cpp
@@ -133,7 +133,7 @@
     for (int a = 0; a < (1<<8); a++) {
     for (int b = 0; b < (1<<8); b++) {
         Sk16b aw(a), bw(b);
-        REPORTER_ASSERT(r, Sk16b::Min(aw, bw)[0] == SkTMin(a, b));
+        REPORTER_ASSERT(r, Sk16b::Min(aw, bw)[0] == std::min(a, b));
         REPORTER_ASSERT(r, !(aw < bw)[0] == !(a < b));
     }}
 
@@ -143,12 +143,12 @@
     for (int i = 0; i < (1<<16); i++) {
         uint16_t a = rand.nextU() >> 16,
                  b = rand.nextU() >> 16;
-        REPORTER_ASSERT(r, Sk16h::Min(Sk16h(a), Sk16h(b))[0] == SkTMin(a, b));
+        REPORTER_ASSERT(r, Sk16h::Min(Sk16h(a), Sk16h(b))[0] == std::min(a, b));
     }
 #else
     for (int a = 0; a < (1<<16); a++) {
     for (int b = 0; b < (1<<16); b++) {
-        REPORTER_ASSERT(r, Sk16h::Min(Sk16h(a), Sk16h(b))[0] == SkTMin(a, b));
+        REPORTER_ASSERT(r, Sk16h::Min(Sk16h(a), Sk16h(b))[0] == std::min(a, b));
     }}
 #endif
 }
@@ -230,8 +230,8 @@
     auto min = Sk4i::Min(a, b);
     auto max = Sk4i::Max(a, b);
     for(int i = 0; i < 4; ++i) {
-        REPORTER_ASSERT(r, min[i] == SkTMin(a[i], b[i]));
-        REPORTER_ASSERT(r, max[i] == SkTMax(a[i], b[i]));
+        REPORTER_ASSERT(r, min[i] == std::min(a[i], b[i]));
+        REPORTER_ASSERT(r, max[i] == std::max(a[i], b[i]));
     }
 }
 
diff --git a/tests/StreamTest.cpp b/tests/StreamTest.cpp
index bc00f45..8a2390d 100644
--- a/tests/StreamTest.cpp
+++ b/tests/StreamTest.cpp
@@ -343,7 +343,7 @@
     const uint8_t* expect = expected->bytes();
     for (size_t i = 0; i < asset->getLength(); ++i) {
         uint32_t maxSize =
-                SkToU32(SkTMin(sizeof(buffer), asset->getLength() - i));
+                SkToU32(std::min(sizeof(buffer), asset->getLength() - i));
         size_t size = rand.nextRangeU(1, maxSize);
         SkASSERT(size >= 1);
         SkASSERT(size <= sizeof(buffer));
@@ -401,7 +401,7 @@
     DumbStream(const uint8_t* data, size_t n)
         : fData(data), fCount(n), fIdx(0) {}
     size_t read(void* buffer, size_t size) override {
-        size_t copyCount = SkTMin(fCount - fIdx, size);
+        size_t copyCount = std::min(fCount - fIdx, size);
         if (copyCount) {
             memcpy(buffer, &fData[fIdx], copyCount);
             fIdx += copyCount;
diff --git a/tests/StrokerTest.cpp b/tests/StrokerTest.cpp
index c851523..9f902bb 100644
--- a/tests/StrokerTest.cpp
+++ b/tests/StrokerTest.cpp
@@ -207,8 +207,8 @@
                 SkDebugf("fill:\n");
                 fill.dumpHex();
             }
-            bestTan = SkTMax(bestTan, gMaxRecursion[0]);
-            bestCubic = SkTMax(bestCubic, gMaxRecursion[1]);
+            bestTan = std::max(bestTan, gMaxRecursion[0]);
+            bestCubic = std::max(bestCubic, gMaxRecursion[1]);
         }
     #endif
         if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
@@ -317,8 +317,8 @@
                 SkDebugf("fill:\n");
                 fill.dumpHex();
             }
-            bestTan = SkTMax(bestTan, gMaxRecursion[0]);
-            bestCubic = SkTMax(bestCubic, gMaxRecursion[1]);
+            bestTan = std::max(bestTan, gMaxRecursion[0]);
+            bestCubic = std::max(bestCubic, gMaxRecursion[1]);
         }
 #endif
         if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
@@ -402,8 +402,8 @@
                 SkDebugf("fill:\n");
                 fill.dumpHex();
             }
-            best[0] = SkTMax(best[0], gMaxRecursion[0]);
-            best[1] = SkTMax(best[1], gMaxRecursion[1]);
+            best[0] = std::max(best[0], gMaxRecursion[0]);
+            best[1] = std::max(best[1], gMaxRecursion[1]);
         }
 #endif
         if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
diff --git a/tests/TextBlobTest.cpp b/tests/TextBlobTest.cpp
index acb8dc2..77cc108 100644
--- a/tests/TextBlobTest.cpp
+++ b/tests/TextBlobTest.cpp
@@ -328,7 +328,7 @@
     memcpy(run.glyphs, glyphs.get(), sizeof(uint16_t) * glyphCount);
     memcpy(run.utf8text, text2, strlen(text2));
     for (int i = 0; i < glyphCount; ++i) {
-        run.clusters[i] = SkTMin(SkToU32(i), SkToU32(strlen(text2)));
+        run.clusters[i] = std::min(SkToU32(i), SkToU32(strlen(text2)));
     }
     sk_sp<SkTextBlob> blob(textBlobBuilder.make());
     REPORTER_ASSERT(reporter, blob);
diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp
index 520bbc7..e23b7ec 100644
--- a/tests/TransferPixelsTest.cpp
+++ b/tests/TransferPixelsTest.cpp
@@ -318,7 +318,7 @@
     size_t bufferSize = fullBufferRowBytes * kTextureHeight;
     // Arbitrary starting offset for the partial read.
     size_t partialReadOffset = GrAlignTo(11, offsetAlignment);
-    bufferSize = SkTMax(bufferSize, partialReadOffset + partialBufferRowBytes * kPartialHeight);
+    bufferSize = std::max(bufferSize, partialReadOffset + partialBufferRowBytes * kPartialHeight);
 
     sk_sp<GrGpuBuffer> buffer(resourceProvider->createBuffer(
             bufferSize, GrGpuBufferType::kXferGpuToCpu, kDynamic_GrAccessPattern));
diff --git a/tests/VkPriorityExtensionTest.cpp b/tests/VkPriorityExtensionTest.cpp
index 71e2cd4..1f4f13c 100644
--- a/tests/VkPriorityExtensionTest.cpp
+++ b/tests/VkPriorityExtensionTest.cpp
@@ -85,7 +85,7 @@
         apiVersion = VK_MAKE_VERSION(1, 1, 0);
     }
 
-    instanceVersion = SkTMin(instanceVersion, apiVersion);
+    instanceVersion = std::min(instanceVersion, apiVersion);
 
     VkPhysicalDevice physDev;
     VkDevice device;