From 7f36405ea3eccc0954921159882b25435bdabe26 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Thu, 6 Feb 2020 11:25:43 -0500 Subject: [PATCH] Remove SkMin32/SkMax32 Use std::max and std::min instead Change-Id: I7fd2626ea9ea8ea09c709ff962523ca3de2f8a16 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269136 Reviewed-by: Mike Klein Reviewed-by: Mike Reed Commit-Queue: Brian Osman --- RELEASE_NOTES.txt | 1 + bench/AlternatingColorPatternBench.cpp | 2 +- bench/BitmapBench.cpp | 2 +- bench/BitmapRectBench.cpp | 2 +- bench/ChartBench.cpp | 2 +- bench/FontCacheBench.cpp | 2 +- bench/RepeatTileBench.cpp | 2 +- gm/fontmgr.cpp | 4 ++-- gm/modecolorfilters.cpp | 2 +- gm/shadertext3.cpp | 2 +- gm/stringart.cpp | 2 +- include/core/SkRect.h | 4 ++-- include/core/SkTypes.h | 12 ------------ include/private/SkTDArray.h | 3 ++- samplecode/SampleChart.cpp | 2 +- src/core/SkAAClip.cpp | 18 +++++++++--------- src/core/SkBitmapProcState.cpp | 6 +++--- src/core/SkColor.cpp | 4 ++-- src/core/SkDraw.cpp | 4 ++-- src/core/SkEdge.cpp | 2 +- src/core/SkMaskFilter.cpp | 2 +- src/core/SkPath.cpp | 4 ++-- src/core/SkRect.cpp | 8 ++++---- src/core/SkRegion.cpp | 6 +++--- src/core/SkRegion_path.cpp | 8 ++++---- src/core/SkScalerContext.cpp | 12 ++++++------ src/core/SkScan_AAAPath.cpp | 4 ++-- src/core/SkScan_Antihair.cpp | 8 ++++---- src/core/SkScan_Path.cpp | 6 +++--- src/core/SkStrikeCache.cpp | 2 +- src/effects/SkEmbossMask.cpp | 2 +- .../imagefilters/SkMagnifierImageFilter.cpp | 4 ++-- .../imagefilters/SkMorphologyImageFilter.cpp | 6 +++--- src/gpu/GrRectanizerSkyline.cpp | 4 +++- src/gpu/gl/GrGLCaps.cpp | 2 +- src/pdf/SkPDFMakeToUnicodeCmap.cpp | 4 ++-- src/ports/SkFontHost_win.cpp | 8 ++++---- src/utils/SkPatchUtils.cpp | 2 +- tests/FontNamesTest.cpp | 2 +- tests/MatrixClipCollapseTest.cpp | 2 +- tests/PathCoverageTest.cpp | 2 +- tests/SrcOverTest.cpp | 2 +- tests/TextBlobCacheTest.cpp | 2 +- tools/skqp/src/skqp_model.cpp | 6 +++--- 44 files changed, 89 insertions(+), 97 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 3bf04f5781bd6..4c9aaeb46197b 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -7,6 +7,7 @@ This file includes a list of high level updates for each milestone release. Milestone 82 + * Removed SkMax32 and SkMin32. * Removed SkMaxScalar and SkMinScalar. * SkColorSetA now warns if the result is unused. diff --git a/bench/AlternatingColorPatternBench.cpp b/bench/AlternatingColorPatternBench.cpp index 4bcf0c3b779df..06afe91dc5c73 100644 --- a/bench/AlternatingColorPatternBench.cpp +++ b/bench/AlternatingColorPatternBench.cpp @@ -42,7 +42,7 @@ static void makebm(SkBitmap* bm, int w, int h) { bm->eraseColor(SK_ColorTRANSPARENT); SkCanvas canvas(*bm); - SkScalar s = SkIntToScalar(SkMin32(w, h)); + SkScalar s = SkIntToScalar(std::min(w, h)); static const SkPoint kPts0[] = { { 0, 0 }, { s, s } }; static const SkPoint kPts1[] = { { s/2, 0 }, { s/2, s } }; static const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; diff --git a/bench/BitmapBench.cpp b/bench/BitmapBench.cpp index aad28a649553e..22e112a598ecf 100644 --- a/bench/BitmapBench.cpp +++ b/bench/BitmapBench.cpp @@ -110,7 +110,7 @@ class BitmapBench : public Benchmark { p.setAntiAlias(true); p.setColor(SK_ColorRED); canvas.drawCircle(SkIntToScalar(w)/2, SkIntToScalar(h)/2, - SkIntToScalar(SkMin32(w, h))*3/8, p); + SkIntToScalar(std::min(w, h))*3/8, p); SkRect r; r.setWH(SkIntToScalar(w), SkIntToScalar(h)); diff --git a/bench/BitmapRectBench.cpp b/bench/BitmapRectBench.cpp index 0a13362336138..612d247f72f56 100644 --- a/bench/BitmapRectBench.cpp +++ b/bench/BitmapRectBench.cpp @@ -23,7 +23,7 @@ static void draw_into_bitmap(const SkBitmap& bm) { p.setAntiAlias(true); p.setColor(SK_ColorRED); canvas.drawCircle(SkIntToScalar(w)/2, SkIntToScalar(h)/2, - SkIntToScalar(SkMin32(w, h))*3/8, p); + SkIntToScalar(std::min(w, h))*3/8, p); SkRect r; r.setWH(SkIntToScalar(w), SkIntToScalar(h)); diff --git a/bench/ChartBench.cpp b/bench/ChartBench.cpp index 1daa63753096e..2bdbbe1c378b0 100644 --- a/bench/ChartBench.cpp +++ b/bench/ChartBench.cpp @@ -115,7 +115,7 @@ class ChartBench : public Benchmark { SkScalar height = SkIntToScalar(fSize.fHeight); if (sizeChanged) { - int dataPointCount = SkMax32(fSize.fWidth / kPixelsPerTick + 1, 2); + int dataPointCount = std::max(fSize.fWidth / kPixelsPerTick + 1, 2); SkRandom random; for (int i = 0; i < kNumGraphs; ++i) { diff --git a/bench/FontCacheBench.cpp b/bench/FontCacheBench.cpp index 72a4d539f963e..40a9669a7d799 100644 --- a/bench/FontCacheBench.cpp +++ b/bench/FontCacheBench.cpp @@ -125,7 +125,7 @@ class FontCacheEfficiency : public Benchmark { int glyphs = 0; const uint16_t* array = gUniqueGlyphIDs; while (*array != gUniqueGlyphIDs_Sentinel) { - int count = SkMin32(count_glyphs(array), limit); + int count = std::min(count_glyphs(array), limit); collisions += count_collisions(array, count, gRec[i].fHasher, hashMask); glyphs += count; array += count + 1; // skip the sentinel diff --git a/bench/RepeatTileBench.cpp b/bench/RepeatTileBench.cpp index 84c52b71ebb9e..6aea6bfed5dcc 100644 --- a/bench/RepeatTileBench.cpp +++ b/bench/RepeatTileBench.cpp @@ -22,7 +22,7 @@ static void draw_into_bitmap(const SkBitmap& bm) { p.setAntiAlias(true); p.setColor(SK_ColorRED); canvas.drawCircle(SkIntToScalar(w)/2, SkIntToScalar(h)/2, - SkIntToScalar(SkMin32(w, h))*3/8, p); + SkIntToScalar(std::min(w, h))*3/8, p); SkRect r; r.setWH(SkIntToScalar(w), SkIntToScalar(h)); diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp index 8eb24f1a4ccba..8328930f8eeba 100644 --- a/gm/fontmgr.cpp +++ b/gm/fontmgr.cpp @@ -88,7 +88,7 @@ class FontMgrGM : public skiagm::GM { font.setSize(17); SkFontMgr* fm = fFM.get(); - int count = SkMin32(fm->countFamilies(), MAX_FAMILIES); + int count = std::min(fm->countFamilies(), MAX_FAMILIES); for (int i = 0; i < count; ++i) { SkString familyName; @@ -316,7 +316,7 @@ class FontMgrBoundsGM : public skiagm::GM { const SkColor boundsColors[2] = { SK_ColorRED, SK_ColorBLUE }; SkFontMgr* fm = fFM.get(); - int count = SkMin32(fm->countFamilies(), 32); + int count = std::min(fm->countFamilies(), 32); int index = 0; SkScalar x = 0, y = 0; diff --git a/gm/modecolorfilters.cpp b/gm/modecolorfilters.cpp index 0e9361c2709d3..ffffa600356ee 100644 --- a/gm/modecolorfilters.cpp +++ b/gm/modecolorfilters.cpp @@ -133,7 +133,7 @@ class ModeColorFilterGM : public GM { SkPaint paint; int idx = 0; - const int kRectsPerRow = SkMax32(this->getISize().fWidth / kRectWidth, 1); + const int kRectsPerRow = std::max(this->getISize().fWidth / kRectWidth, 1); for (size_t cfm = 0; cfm < SK_ARRAY_COUNT(modes); ++cfm) { for (size_t cfc = 0; cfc < SK_ARRAY_COUNT(colors); ++cfc) { paint.setColorFilter(SkColorFilters::Blend(colors[cfc], modes[cfm])); diff --git a/gm/shadertext3.cpp b/gm/shadertext3.cpp index 3fba8cfc68488..4eadad925d053 100644 --- a/gm/shadertext3.cpp +++ b/gm/shadertext3.cpp @@ -34,7 +34,7 @@ static void makebm(SkBitmap* bm, int w, int h) { bm->eraseColor(SK_ColorTRANSPARENT); SkCanvas canvas(*bm); - SkScalar s = SkIntToScalar(SkMin32(w, h)); + SkScalar s = SkIntToScalar(std::min(w, h)); const SkPoint kPts0[] = { { 0, 0 }, { s, s } }; const SkPoint kPts1[] = { { s/2, 0 }, { s/2, s } }; const SkScalar kPos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; diff --git a/gm/stringart.cpp b/gm/stringart.cpp index 3c0be3a14b527..0f766c90eec90 100644 --- a/gm/stringart.cpp +++ b/gm/stringart.cpp @@ -43,7 +43,7 @@ class StringArtGM : public skiagm::GM { void onDraw(SkCanvas* canvas) override { SkScalar angle = kAngle*SK_ScalarPI + SkScalarHalf(SK_ScalarPI); - SkScalar size = SkIntToScalar(SkMin32(kWidth, kHeight)); + SkScalar size = SkIntToScalar(std::min(kWidth, kHeight)); SkPoint center = SkPoint::Make(SkScalarHalf(kWidth), SkScalarHalf(kHeight)); SkScalar length = 5; SkScalar step = angle; diff --git a/include/core/SkRect.h b/include/core/SkRect.h index bee0df5d0eb7d..1ecd385af021e 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -545,8 +545,8 @@ struct SK_API SkIRect { @return sorted SkIRect */ SkIRect makeSorted() const { - return MakeLTRB(SkMin32(fLeft, fRight), SkMin32(fTop, fBottom), - SkMax32(fLeft, fRight), SkMax32(fTop, fBottom)); + return MakeLTRB(std::min(fLeft, fRight), std::min(fTop, fBottom), + std::max(fLeft, fRight), std::max(fTop, fBottom)); } }; diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h index 246c10cb186cb..676277a21dc39 100644 --- a/include/core/SkTypes.h +++ b/include/core/SkTypes.h @@ -175,18 +175,6 @@ template static inline T SkTAbs(T value) { return value; } -static inline int32_t SkMax32(int32_t a, int32_t b) { - if (a < b) - a = b; - return a; -} - -static inline int32_t SkMin32(int32_t a, int32_t b) { - if (a > b) - a = b; - return a; -} - template constexpr const T& SkTMin(const T& a, const T& b) { return (a < b) ? a : b; } diff --git a/include/private/SkTDArray.h b/include/private/SkTDArray.h index f4d2e7c3ea2fc..33d4d7cc2baad 100644 --- a/include/private/SkTDArray.h +++ b/include/private/SkTDArray.h @@ -13,6 +13,7 @@ #include "include/private/SkMalloc.h" #include "include/private/SkTo.h" +#include #include #include @@ -253,7 +254,7 @@ template class SkTDArray { if (index >= fCount) { return 0; } - int count = SkMin32(max, fCount - index); + int count = std::min(max, fCount - index); memcpy(dst, fArray + index, sizeof(T) * count); return count; } diff --git a/samplecode/SampleChart.cpp b/samplecode/SampleChart.cpp index 448e1d7e06c84..6437d3e688809 100644 --- a/samplecode/SampleChart.cpp +++ b/samplecode/SampleChart.cpp @@ -102,7 +102,7 @@ class ChartView : public Sample { SkScalar height = SkIntToScalar(fSize.fHeight); if (sizeChanged) { - int dataPointCount = SkMax32(fSize.fWidth / kPixelsPerTick + 1, 2); + int dataPointCount = std::max(fSize.fWidth / kPixelsPerTick + 1, 2); for (int i = 0; i < kNumGraphs; ++i) { SkScalar y = (kNumGraphs - i) * (height - ySpread) / (kNumGraphs + 1); diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp index c33ea9510d606..22fd36ce1ba08 100644 --- a/src/core/SkAAClip.cpp +++ b/src/core/SkAAClip.cpp @@ -90,7 +90,7 @@ struct SkAAClip::RunHead { int segments = 0; while (width > 0) { segments += 1; - int n = SkMin32(width, 255); + int n = std::min(width, 255); width -= n; } return segments * 2; // each segment is row[0] + row[1] (n + alpha) @@ -106,7 +106,7 @@ struct SkAAClip::RunHead { yoff->fOffset = 0; uint8_t* row = head->data(); while (width > 0) { - int n = SkMin32(width, 255); + int n = std::min(width, 255); row[0] = n; row[1] = 0xFF; width -= n; @@ -722,8 +722,8 @@ bool SkAAClip::setRegion(const SkRegion& rgn) { SkTDArray yArray; SkTDArray xArray; - yArray.setReserve(SkMin32(bounds.height(), 1024)); - xArray.setReserve(SkMin32(bounds.width(), 512) * 128); + yArray.setReserve(std::min(bounds.height(), 1024)); + xArray.setReserve(std::min(bounds.width(), 512) * 128); SkRegion::Iterator iter(rgn); int prevRight = 0; @@ -1496,7 +1496,7 @@ static void operatorX(SkAAClip::Builder& builder, int lastY, } } else { left = leftA; // or leftB, since leftA == leftB - rite = leftA = leftB = SkMin32(riteA, riteB); + rite = leftA = leftB = std::min(riteA, riteB); alphaA = iterA.alpha(); alphaB = iterB.alpha(); } @@ -1571,7 +1571,7 @@ static void operateY(SkAAClip::Builder& builder, const SkAAClip& A, } } else { top = topA; // or topB, since topA == topB - bot = topA = topB = SkMin32(botA, botB); + bot = topA = topB = std::min(botA, botB); rowA = iterA.data(); rowB = iterB.data(); } @@ -1894,7 +1894,7 @@ static void merge(const uint8_t* SK_RESTRICT row, int rowN, SkASSERT(srcN > 0); unsigned newAlpha = SkMulDiv255Round(srcAA[0], row[1]); - int minN = SkMin32(srcN, rowN); + int minN = std::min(srcN, rowN); dstRuns[0] = minN; dstRuns += minN; dstAA[0] = newAlpha; @@ -2005,7 +2005,7 @@ void mergeT(const void* inSrc, int srcN, const uint8_t* SK_RESTRICT row, int row SkASSERT(rowN > 0); SkASSERT(srcN > 0); - int n = SkMin32(rowN, srcN); + int n = std::min(rowN, srcN); unsigned rowA = row[1]; if (0xFF == rowA) { small_memcpy(dst, src, n * sizeof(T)); @@ -2142,7 +2142,7 @@ void SkAAClipBlitter::blitMask(const SkMask& origMask, const SkIRect& clip) { int localStopY SK_INIT_TO_AVOID_WARNING; const uint8_t* row = fAAClip->findRow(y, &localStopY); // findRow returns last Y, not stop, so we add 1 - localStopY = SkMin32(localStopY + 1, stopY); + localStopY = std::min(localStopY + 1, stopY); int initialCount; row = fAAClip->findX(row, clip.fLeft, &initialCount); diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 72b80807a40e0..09a75f24f7e7b 100755 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -316,7 +316,7 @@ static void Clamp_S32_D32_nofilter_trans_shaderproc(const void* sIn, // clamp to the left if (ix < 0) { - int n = SkMin32(-ix, count); + int n = std::min(-ix, count); sk_memset32(colors, row[0], n); count -= n; if (0 == count) { @@ -328,7 +328,7 @@ static void Clamp_S32_D32_nofilter_trans_shaderproc(const void* sIn, } // copy the middle if (ix <= maxX) { - int n = SkMin32(maxX - ix + 1, count); + int n = std::min(maxX - ix + 1, count); memcpy(colors, row + ix, n * sizeof(SkPMColor)); count -= n; if (0 == count) { @@ -378,7 +378,7 @@ static void Repeat_S32_D32_nofilter_trans_shaderproc(const void* sIn, ix = sk_int_mod(ix, stopX); for (;;) { - int n = SkMin32(stopX - ix, count); + int n = std::min(stopX - ix, count); memcpy(colors, row + ix, n * sizeof(SkPMColor)); count -= n; if (0 == count) { diff --git a/src/core/SkColor.cpp b/src/core/SkColor.cpp index efcc4b9c41904..27c81b768efff 100644 --- a/src/core/SkColor.cpp +++ b/src/core/SkColor.cpp @@ -33,8 +33,8 @@ static inline SkScalar ByteDivToScalar(int numer, U8CPU denom) { void SkRGBToHSV(U8CPU r, U8CPU g, U8CPU b, SkScalar hsv[3]) { SkASSERT(hsv); - unsigned min = SkMin32(r, SkMin32(g, b)); - unsigned max = SkMax32(r, SkMax32(g, b)); + unsigned min = std::min(r, std::min(g, b)); + unsigned max = std::max(r, std::max(g, b)); unsigned delta = max - min; SkScalar v = ByteToScalar(max); diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 296329a52dc46..6bd36c64e627e 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1233,8 +1233,8 @@ bool SkDraw::ComputeMaskBounds(const SkRect& devPathBounds, const SkIRect* clipB // quality of large filters like blurs, and the corresponding memory // requests. static const int MAX_MARGIN = 128; - if (!bounds->intersect(clipBounds->makeOutset(SkMin32(margin.fX, MAX_MARGIN), - SkMin32(margin.fY, MAX_MARGIN)))) { + if (!bounds->intersect(clipBounds->makeOutset(std::min(margin.fX, MAX_MARGIN), + std::min(margin.fY, MAX_MARGIN)))) { return false; } } diff --git a/src/core/SkEdge.cpp b/src/core/SkEdge.cpp index 0aa3b618adaf0..7ec629bdf3940 100644 --- a/src/core/SkEdge.cpp +++ b/src/core/SkEdge.cpp @@ -345,7 +345,7 @@ static SkFDot6 cubic_delta_from_line(SkFDot6 a, SkFDot6 b, SkFDot6 c, SkFDot6 d) SkFDot6 oneThird = (a*8 - b*15 + 6*c + d) * 19 >> 9; SkFDot6 twoThird = (a + 6*b - c*15 + d*8) * 19 >> 9; - return SkMax32(SkAbs32(oneThird), SkAbs32(twoThird)); + return std::max(SkAbs32(oneThird), SkAbs32(twoThird)); } bool SkCubicEdge::setCubicWithoutUpdate(const SkPoint pts[4], int shift, bool sortY) { diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp index 81160019a332e..705809de993f9 100644 --- a/src/core/SkMaskFilter.cpp +++ b/src/core/SkMaskFilter.cpp @@ -144,7 +144,7 @@ static void draw_nine_clipped(const SkMask& mask, const SkIRect& outerR, // top r.setLTRB(innerR.left(), outerR.top(), innerR.right(), innerR.top()); if (r.intersect(clipR)) { - int startY = SkMax32(0, r.top() - outerR.top()); + int startY = std::max(0, r.top() - outerR.top()); int stopY = startY + r.height(); int width = r.width(); for (int y = startY; y < stopY; ++y) { diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index bc1940715d03c..6e99bf3cd0270 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -479,7 +479,7 @@ int SkPath::getPoints(SkPoint dst[], int max) const { SkASSERT(max >= 0); SkASSERT(!max || dst); - int count = SkMin32(max, fPathRef->countPoints()); + int count = std::min(max, fPathRef->countPoints()); sk_careful_memcpy(dst, fPathRef->points(), count * sizeof(SkPoint)); return fPathRef->countPoints(); } @@ -500,7 +500,7 @@ int SkPath::getVerbs(uint8_t dst[], int max) const { SkASSERT(max >= 0); SkASSERT(!max || dst); - int count = SkMin32(max, fPathRef->countVerbs()); + int count = std::min(max, fPathRef->countVerbs()); if (count) { memcpy(dst, fPathRef->verbsBegin(), count); } diff --git a/src/core/SkRect.cpp b/src/core/SkRect.cpp index c54e661529fda..b3cabbea77c24 100644 --- a/src/core/SkRect.cpp +++ b/src/core/SkRect.cpp @@ -11,10 +11,10 @@ bool SkIRect::intersect(const SkIRect& a, const SkIRect& b) { SkIRect tmp = { - SkMax32(a.fLeft, b.fLeft), - SkMax32(a.fTop, b.fTop), - SkMin32(a.fRight, b.fRight), - SkMin32(a.fBottom, b.fBottom) + std::max(a.fLeft, b.fLeft), + std::max(a.fTop, b.fTop), + std::min(a.fRight, b.fRight), + std::min(a.fBottom, b.fBottom) }; if (tmp.isEmpty()) { return false; diff --git a/src/core/SkRegion.cpp b/src/core/SkRegion.cpp index 7ef7ae4ff2a4d..73707c2b87602 100644 --- a/src/core/SkRegion.cpp +++ b/src/core/SkRegion.cpp @@ -923,7 +923,7 @@ static int operate(const SkRegionPriv::RunType a_runs[], assert_sentinel(b_top, false); assert_sentinel(b_bot, false); - RgnOper oper(SkMin32(a_top, b_top), dst, op); + RgnOper oper(std::min(a_top, b_top), dst, op); int prevBot = SkRegion_kRunTypeSentinel; // so we fail the first test @@ -1527,10 +1527,10 @@ bool SkRegion::Spanerator::next(int* left, int* right) { SkASSERT(runs[1] > fLeft); if (left) { - *left = SkMax32(fLeft, runs[0]); + *left = std::max(fLeft, runs[0]); } if (right) { - *right = SkMin32(fRight, runs[1]); + *right = std::min(fRight, runs[1]); } fRuns = runs + 2; return true; diff --git a/src/core/SkRegion_path.cpp b/src/core/SkRegion_path.cpp index ff07c466c5cfd..af5d2cdab4e18 100644 --- a/src/core/SkRegion_path.cpp +++ b/src/core/SkRegion_path.cpp @@ -350,8 +350,8 @@ bool SkRegion::setPath(const SkPath& path, const SkRegion& clip) { int clipTop, clipBot; int clipTransitions = clip.count_runtype_values(&clipTop, &clipBot); - int top = SkMax32(pathTop, clipTop); - int bot = SkMin32(pathBot, clipBot); + int top = std::max(pathTop, clipTop); + int bot = std::min(pathBot, clipBot); if (top >= bot) { return check_inverse_on_empty_return(this, path, clip); } @@ -359,7 +359,7 @@ bool SkRegion::setPath(const SkPath& path, const SkRegion& clip) { SkRgnBuilder builder; if (!builder.init(bot - top, - SkMax32(pathTransitions, clipTransitions), + std::max(pathTransitions, clipTransitions), path.isInverseFillType())) { // can't allocate working space, so return false return this->setEmpty(); @@ -413,7 +413,7 @@ struct Edge { } int top() const { - return SkMin32(fY0, fY1); + return std::min(fY0, fY1); } }; diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index 40f0c1d789a88..930692b56b063 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -366,8 +366,8 @@ static void pack4xHToLCD16(const SkPixmap& src, const SkMask& dst, // It should be possible to make it much faster. for (int sample_x = -4; sample_x < sample_width + 4; sample_x += 4) { int fir[LCD_PER_PIXEL] = { 0 }; - for (int sample_index = SkMax32(0, sample_x - 4), coeff_index = sample_index - (sample_x - 4) - ; sample_index < SkMin32(sample_x + 8, sample_width) + for (int sample_index = std::max(0, sample_x - 4), coeff_index = sample_index - (sample_x - 4) + ; sample_index < std::min(sample_x + 8, sample_width) ; ++sample_index, ++coeff_index) { int sample_value = srcP[sample_index]; @@ -377,7 +377,7 @@ static void pack4xHToLCD16(const SkPixmap& src, const SkMask& dst, } for (int subpxl_index = 0; subpxl_index < LCD_PER_PIXEL; ++subpxl_index) { fir[subpxl_index] /= 0x100; - fir[subpxl_index] = SkMin32(fir[subpxl_index], 255); + fir[subpxl_index] = std::min(fir[subpxl_index], 255); } U8CPU r, g, b; @@ -396,7 +396,7 @@ static void pack4xHToLCD16(const SkPixmap& src, const SkMask& dst, b = maskPreBlend.fB[b]; } #if SK_SHOW_TEXT_BLIT_COVERAGE - r = SkMax32(r, 10); g = SkMax32(g, 10); b = SkMax32(b, 10); + r = std::max(r, 10); g = std::max(g, 10); b = std::max(b, 10); #endif *dstP = SkPack888ToRGB16(r, g, b); dstP = SkTAddOffset(dstP, dstPDelta); @@ -587,8 +587,8 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) { fRec.getMatrixFrom2x2(&matrix); if (as_MFB(fMaskFilter)->filterMask(&dstM, srcM, matrix, nullptr)) { - int width = SkMin32(origGlyph.fWidth, dstM.fBounds.width()); - int height = SkMin32(origGlyph.fHeight, dstM.fBounds.height()); + int width = std::min(origGlyph.fWidth, dstM.fBounds.width()); + int height = std::min(origGlyph.fHeight, dstM.fBounds.height()); int dstRB = origGlyph.rowBytes(); int srcRB = dstM.fRowBytes; diff --git a/src/core/SkScan_AAAPath.cpp b/src/core/SkScan_AAAPath.cpp index 3612f059392b8..90a89ce335d56 100644 --- a/src/core/SkScan_AAAPath.cpp +++ b/src/core/SkScan_AAAPath.cpp @@ -1149,11 +1149,11 @@ static void aaa_walk_convex_edges(SkAnalyticEdge* prevHead, std::swap(leftE, riteE); } - SkFixed local_bot_fixed = SkMin32(leftE->fLowerY, riteE->fLowerY); + SkFixed local_bot_fixed = std::min(leftE->fLowerY, riteE->fLowerY); if (is_smooth_enough(leftE, riteE, currE, stop_y)) { local_bot_fixed = SkFixedCeilToFixed(local_bot_fixed); } - local_bot_fixed = SkMin32(local_bot_fixed, SkIntToFixed(stop_y)); + local_bot_fixed = std::min(local_bot_fixed, SkIntToFixed(stop_y)); SkFixed left = SkTMax(leftBound, leftE->fX); SkFixed dLeft = leftE->fDX; diff --git a/src/core/SkScan_Antihair.cpp b/src/core/SkScan_Antihair.cpp index feb96f2470b20..18657cc3dc5c9 100644 --- a/src/core/SkScan_Antihair.cpp +++ b/src/core/SkScan_Antihair.cpp @@ -573,10 +573,10 @@ void SkScan::AntiHairLineRgn(const SkPoint array[], int arrayCount, const SkRegi SkFDot6 y1 = SkScalarToFDot6(pts[1].fY); if (clip) { - SkFDot6 left = SkMin32(x0, x1); - SkFDot6 top = SkMin32(y0, y1); - SkFDot6 right = SkMax32(x0, x1); - SkFDot6 bottom = SkMax32(y0, y1); + SkFDot6 left = std::min(x0, x1); + SkFDot6 top = std::min(y0, y1); + SkFDot6 right = std::max(x0, x1); + SkFDot6 bottom = std::max(y0, y1); SkIRect ir; ir.setLTRB(SkFDot6Floor(left) - 1, diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp index 130d542dd6ed0..7668b5144b265 100644 --- a/src/core/SkScan_Path.cpp +++ b/src/core/SkScan_Path.cpp @@ -228,15 +228,15 @@ static void walk_simple_edges(SkEdge* prevHead, SkBlitter* blitter, int start_y, // our edge choppers for curves can result in the initial edges // not lining up, so we take the max. - int local_top = SkMax32(leftE->fFirstY, riteE->fFirstY); + int local_top = std::max(leftE->fFirstY, riteE->fFirstY); ASSERT_RETURN(local_top >= start_y); while (local_top < stop_y) { SkASSERT(leftE->fFirstY <= stop_y); SkASSERT(riteE->fFirstY <= stop_y); - int local_bot = SkMin32(leftE->fLastY, riteE->fLastY); - local_bot = SkMin32(local_bot, stop_y - 1); + int local_bot = std::min(leftE->fLastY, riteE->fLastY); + local_bot = std::min(local_bot, stop_y - 1); ASSERT_RETURN(local_top <= local_bot); SkFixed left = leftE->fX; diff --git a/src/core/SkStrikeCache.cpp b/src/core/SkStrikeCache.cpp index 205ae28e7aefd..f92a98dc90ec4 100644 --- a/src/core/SkStrikeCache.cpp +++ b/src/core/SkStrikeCache.cpp @@ -400,7 +400,7 @@ size_t SkStrikeCache::internalPurge(size_t minBytesNeeded) { if (fCacheCount > fCacheCountLimit) { countNeeded = fCacheCount - fCacheCountLimit; // no small purges! - countNeeded = SkMax32(countNeeded, fCacheCount >> 2); + countNeeded = std::max(countNeeded, fCacheCount >> 2); } // early exit diff --git a/src/effects/SkEmbossMask.cpp b/src/effects/SkEmbossMask.cpp index dcac971c7d724..6b8f622b225c2 100644 --- a/src/effects/SkEmbossMask.cpp +++ b/src/effects/SkEmbossMask.cpp @@ -81,7 +81,7 @@ void SkEmbossMask::Emboss(SkMask* mask, const SkEmbossMaskFilter::Light& light) int denom = SkSqrt32(nx * nx + ny * ny + kDelta*kDelta); SkFixed dot = numer / denom; dot >>= 8; // now dot is 2^8 instead of 2^16 - mul = SkMin32(mul + dot, 255); + mul = std::min(mul + dot, 255); // now for the reflection diff --git a/src/effects/imagefilters/SkMagnifierImageFilter.cpp b/src/effects/imagefilters/SkMagnifierImageFilter.cpp index a96879dec49ae..7a3d38c8e7133 100644 --- a/src/effects/imagefilters/SkMagnifierImageFilter.cpp +++ b/src/effects/imagefilters/SkMagnifierImageFilter.cpp @@ -183,8 +183,8 @@ sk_sp SkMagnifierImageFilterImpl::onFilterImage(const Context& c int dstWidth = dst.width(), dstHeight = dst.height(); for (int y = 0; y < dstHeight; ++y) { for (int x = 0; x < dstWidth; ++x) { - SkScalar x_dist = SkMin32(x, dstWidth - x - 1) * invInset; - SkScalar y_dist = SkMin32(y, dstHeight - y - 1) * invInset; + SkScalar x_dist = std::min(x, dstWidth - x - 1) * invInset; + SkScalar y_dist = std::min(y, dstHeight - y - 1) * invInset; SkScalar weight = 0; static const SkScalar kScalar2 = SkScalar(2); diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp index c3cc5108aa858..fae622462523b 100644 --- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp +++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp @@ -624,7 +624,7 @@ namespace { const int dstStrideX = direction == MorphDirection::kX ? 1 : dstStride; const int srcStrideY = direction == MorphDirection::kX ? srcStride : 1; const int dstStrideY = direction == MorphDirection::kX ? dstStride : 1; - radius = SkMin32(radius, width - 1); + radius = std::min(radius, width - 1); const SkPMColor* upperSrc = src + radius * srcStrideX; for (int x = 0; x < width; ++x) { const SkPMColor* lp = src; @@ -657,7 +657,7 @@ namespace { const int dstStrideX = direction == MorphDirection::kX ? 1 : dstStride; const int srcStrideY = direction == MorphDirection::kX ? srcStride : 1; const int dstStrideY = direction == MorphDirection::kX ? dstStride : 1; - radius = SkMin32(radius, width - 1); + radius = std::min(radius, width - 1); const SkPMColor* upperSrc = src + radius * srcStrideX; for (int x = 0; x < width; ++x) { const SkPMColor* lp = src; @@ -689,7 +689,7 @@ namespace { const int dstStrideX = direction == MorphDirection::kX ? 1 : dstStride; const int srcStrideY = direction == MorphDirection::kX ? srcStride : 1; const int dstStrideY = direction == MorphDirection::kX ? dstStride : 1; - radius = SkMin32(radius, width - 1); + radius = std::min(radius, width - 1); const SkPMColor* upperSrc = src + radius * srcStrideX; for (int x = 0; x < width; ++x) { const SkPMColor* lp = src; diff --git a/src/gpu/GrRectanizerSkyline.cpp b/src/gpu/GrRectanizerSkyline.cpp index 21931efb9deca..42aff7a657fc2 100644 --- a/src/gpu/GrRectanizerSkyline.cpp +++ b/src/gpu/GrRectanizerSkyline.cpp @@ -8,6 +8,8 @@ #include "src/core/SkIPoint16.h" #include "src/gpu/GrRectanizerSkyline.h" +#include + bool GrRectanizerSkyline::addRect(int width, int height, SkIPoint16* loc) { if ((unsigned)width > (unsigned)this->width() || (unsigned)height > (unsigned)this->height()) { @@ -57,7 +59,7 @@ bool GrRectanizerSkyline::rectangleFits(int skylineIndex, int width, int height, int i = skylineIndex; int y = fSkyline[skylineIndex].fY; while (widthLeft > 0) { - y = SkMax32(y, fSkyline[i].fY); + y = std::max(y, fSkyline[i].fY); if (y + height > this->height()) { return false; } diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 62f637815a6e2..1f2f80bbee689 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -93,7 +93,7 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, } if (fDriverBugWorkarounds.max_fragment_uniform_vectors_32) { - fMaxFragmentUniformVectors = SkMin32(fMaxFragmentUniformVectors, 32); + fMaxFragmentUniformVectors = std::min(fMaxFragmentUniformVectors, 32); } GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); diff --git a/src/pdf/SkPDFMakeToUnicodeCmap.cpp b/src/pdf/SkPDFMakeToUnicodeCmap.cpp index edcaa65eb34a2..e59dacca3c2a8 100644 --- a/src/pdf/SkPDFMakeToUnicodeCmap.cpp +++ b/src/pdf/SkPDFMakeToUnicodeCmap.cpp @@ -87,7 +87,7 @@ static void append_bfchar_section(const std::vector& bfchar, // PDF spec defines that every bf* list can have at most 100 entries. for (size_t i = 0; i < bfchar.size(); i += 100) { int count = SkToInt(bfchar.size() - i); - count = SkMin32(count, 100); + count = std::min(count, 100); cmap->writeDecAsText(count); cmap->writeText(" beginbfchar\n"); for (int j = 0; j < count; ++j) { @@ -107,7 +107,7 @@ static void append_bfrange_section(const std::vector& bfrange, // PDF spec defines that every bf* list can have at most 100 entries. for (size_t i = 0; i < bfrange.size(); i += 100) { int count = SkToInt(bfrange.size() - i); - count = SkMin32(count, 100); + count = std::min(count, 100); cmap->writeDecAsText(count); cmap->writeText(" beginbfrange\n"); for (int j = 0; j < count; ++j) { diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index 873c3f31044b1..66936c17bdbc3 100644 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -496,8 +496,8 @@ const void* HDCOffscreen::draw(const SkGlyph& glyph, bool isBW, } fIsBW = isBW; - fWidth = SkMax32(fWidth, glyph.width()); - fHeight = SkMax32(fHeight, glyph.height()); + fWidth = std::max(fWidth, glyph.width()); + fHeight = std::max(fHeight, glyph.height()); int biWidth = isBW ? alignTo32(fWidth) : fWidth; @@ -1058,7 +1058,7 @@ static inline uint16_t rgb_to_lcd16(SkGdiRGB rgb, const uint8_t* tableR, U8CPU g = sk_apply_lut_if((rgb >> 8) & 0xFF, tableG); U8CPU b = sk_apply_lut_if((rgb >> 0) & 0xFF, tableB); #if SK_SHOW_TEXT_BLIT_COVERAGE - r = SkMax32(r, 10); g = SkMax32(g, 10); b = SkMax32(b, 10); + r = std::max(r, 10); g = std::max(g, 10); b = std::max(b, 10); #endif return SkPack888ToRGB16(r, g, b); } @@ -1074,7 +1074,7 @@ void SkScalerContext_GDI::RGBToA8(const SkGdiRGB* SK_RESTRICT src, size_t srcRB, for (int i = 0; i < width; i++) { dst[i] = rgb_to_a8(src[i], table8); #if SK_SHOW_TEXT_BLIT_COVERAGE - dst[i] = SkMax32(dst[i], 10); + dst[i] = std::max(dst[i], 10); #endif } src = SkTAddOffset(src, srcRB); diff --git a/src/utils/SkPatchUtils.cpp b/src/utils/SkPatchUtils.cpp index 30e807bfe547f..e905bf780da30 100644 --- a/src/utils/SkPatchUtils.cpp +++ b/src/utils/SkPatchUtils.cpp @@ -185,7 +185,7 @@ SkISize SkPatchUtils::GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix* int lodX = static_cast(std::max(topLength, bottomLength) / kPartitionSize); int lodY = static_cast(std::max(leftLength, rightLength) / kPartitionSize); - return SkISize::Make(SkMax32(8, lodX), SkMax32(8, lodY)); + return SkISize::Make(std::max(8, lodX), std::max(8, lodY)); } void SkPatchUtils::GetTopCubic(const SkPoint cubics[12], SkPoint points[4]) { diff --git a/tests/FontNamesTest.cpp b/tests/FontNamesTest.cpp index 101d98e3f06cc..7645c15700d52 100644 --- a/tests/FontNamesTest.cpp +++ b/tests/FontNamesTest.cpp @@ -146,7 +146,7 @@ static void test_systemfonts(skiatest::Reporter* reporter, bool verbose) { static const SkFontTableTag nameTag = SkSetFourByteTag('n','a','m','e'); sk_sp fm(SkFontMgr::RefDefault()); - int count = SkMin32(fm->countFamilies(), MAX_FAMILIES); + int count = std::min(fm->countFamilies(), MAX_FAMILIES); for (int i = 0; i < count; ++i) { sk_sp set(fm->createStyleSet(i)); for (int j = 0; j < set->count(); ++j) { diff --git a/tests/MatrixClipCollapseTest.cpp b/tests/MatrixClipCollapseTest.cpp index c38ed5688e149..e52fefd9a45e6 100644 --- a/tests/MatrixClipCollapseTest.cpp +++ b/tests/MatrixClipCollapseTest.cpp @@ -639,7 +639,7 @@ static void emit_struct3(SkCanvas* canvas, #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE static void print(const SkTDArray& expected, const SkTDArray& actual) { SkDebugf("\n\nexpected %d --- actual %d\n", expected.count(), actual.count()); - int max = SkMax32(expected.count(), actual.count()); + int max = std::max(expected.count(), actual.count()); for (int i = 0; i < max; ++i) { if (i < expected.count()) { diff --git a/tests/PathCoverageTest.cpp b/tests/PathCoverageTest.cpp index a6f676b3309d3..291dd0fa9f74e 100644 --- a/tests/PathCoverageTest.cpp +++ b/tests/PathCoverageTest.cpp @@ -61,7 +61,7 @@ static inline uint32_t compute_pointCount(SkScalar d, SkScalar tol) { return 1; } else { int temp = SkScalarCeilToInt(SkScalarSqrt(d / tol)); - uint32_t count = SkMin32(SkNextPow2(temp), MAX_POINTS_PER_CURVE); + uint32_t count = std::min(SkNextPow2(temp), MAX_POINTS_PER_CURVE); return count; } } diff --git a/tests/SrcOverTest.cpp b/tests/SrcOverTest.cpp index 92237e2a483b7..f8fa6ed8c7d63 100644 --- a/tests/SrcOverTest.cpp +++ b/tests/SrcOverTest.cpp @@ -55,7 +55,7 @@ DEF_TEST(SrcOver, reporter) { unsigned r0 = test_srcover0(dst, i); unsigned r1 = test_srcover1(dst, i); unsigned r2 = test_srcover2(dst, i); - unsigned max = SkMax32(dst, i); + unsigned max = std::max(dst, i); // ignore the known failure if (dst != 255) { REPORTER_ASSERT(reporter, r0 <= 255 && r0 >= max); diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp index bcc7288a2afe8..536b2c1273eee 100644 --- a/tests/TextBlobCacheTest.cpp +++ b/tests/TextBlobCacheTest.cpp @@ -75,7 +75,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* conte sk_sp fm(SkFontMgr::RefDefault()); - int count = SkMin32(fm->countFamilies(), maxFamilies); + int count = std::min(fm->countFamilies(), maxFamilies); // make a ton of text SkAutoTArray text(maxTotalText); diff --git a/tools/skqp/src/skqp_model.cpp b/tools/skqp/src/skqp_model.cpp index 230a14ff77542..2a97cd6f06c96 100644 --- a/tools/skqp/src/skqp_model.cpp +++ b/tools/skqp/src/skqp_model.cpp @@ -60,15 +60,15 @@ SkQP::RenderOutcome skqp::Check(const SkPixmap& minImg, uint8_t v = (c >> component) & 0xFF, vmin = (color(minImg, point) >> component) & 0xFF, vmax = (color(maxImg, point) >> component) & 0xFF; - err = SkMax32(err, SkMax32((int)v - (int)vmax, (int)vmin - (int)v)); + err = std::max(err, std::max((int)v - (int)vmax, (int)vmin - (int)v)); } - error = SkMin32(error, err); + error = std::min(error, err); } } if (error > (int)tolerance) { ++result.fBadPixelCount; result.fTotalError += error; - result.fMaxError = SkMax32(error, result.fMaxError); + result.fMaxError = std::max(error, result.fMaxError); if (errorOut) { if (!errorOut->getPixels()) { errorOut->allocPixels(SkImageInfo::Make(