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 <mtklein@google.com> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
18b90bc679
commit
7f36405ea3
@ -7,6 +7,7 @@ This file includes a list of high level updates for each milestone release.
|
||||
Milestone 82
|
||||
|
||||
<Insert new notes here- top is most recent.>
|
||||
* Removed SkMax32 and SkMin32.
|
||||
* Removed SkMaxScalar and SkMinScalar.
|
||||
|
||||
* SkColorSetA now warns if the result is unused.
|
||||
|
@ -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 };
|
||||
|
@ -110,7 +110,7 @@ protected:
|
||||
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));
|
||||
|
@ -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));
|
||||
|
@ -115,7 +115,7 @@ protected:
|
||||
|
||||
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) {
|
||||
|
@ -125,7 +125,7 @@ protected:
|
||||
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
|
||||
|
@ -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));
|
||||
|
@ -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 @@ private:
|
||||
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;
|
||||
|
@ -133,7 +133,7 @@ protected:
|
||||
|
||||
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]));
|
||||
|
@ -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 };
|
||||
|
@ -43,7 +43,7 @@ protected:
|
||||
|
||||
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;
|
||||
|
@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -175,18 +175,6 @@ template <typename T> 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 <typename T> constexpr const T& SkTMin(const T& a, const T& b) {
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "include/private/SkMalloc.h"
|
||||
#include "include/private/SkTo.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <initializer_list>
|
||||
#include <utility>
|
||||
|
||||
@ -253,7 +254,7 @@ public:
|
||||
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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<YOffset> yArray;
|
||||
SkTDArray<uint8_t> 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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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<uint16_t>(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<int>(origGlyph.fWidth, dstM.fBounds.width());
|
||||
int height = std::min<int>(origGlyph.fHeight, dstM.fBounds.height());
|
||||
int dstRB = origGlyph.rowBytes();
|
||||
int srcRB = dstM.fRowBytes;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -183,8 +183,8 @@ sk_sp<SkSpecialImage> 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);
|
||||
|
@ -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;
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "src/core/SkIPoint16.h"
|
||||
#include "src/gpu/GrRectanizerSkyline.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -87,7 +87,7 @@ static void append_bfchar_section(const std::vector<BFChar>& 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>& 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) {
|
||||
|
@ -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<APPLY_PREBLEND>((rgb >> 8) & 0xFF, tableG);
|
||||
U8CPU b = sk_apply_lut_if<APPLY_PREBLEND>((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<APPLY_PREBLEND>(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<const SkGdiRGB>(src, srcRB);
|
||||
|
@ -185,7 +185,7 @@ SkISize SkPatchUtils::GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix*
|
||||
int lodX = static_cast<int>(std::max(topLength, bottomLength) / kPartitionSize);
|
||||
int lodY = static_cast<int>(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]) {
|
||||
|
@ -146,7 +146,7 @@ static void test_systemfonts(skiatest::Reporter* reporter, bool verbose) {
|
||||
static const SkFontTableTag nameTag = SkSetFourByteTag('n','a','m','e');
|
||||
|
||||
sk_sp<SkFontMgr> 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<SkFontStyleSet> set(fm->createStyleSet(i));
|
||||
for (int j = 0; j < set->count(); ++j) {
|
||||
|
@ -639,7 +639,7 @@ static void emit_struct3(SkCanvas* canvas,
|
||||
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
|
||||
static void print(const SkTDArray<DrawType>& expected, const SkTDArray<DrawType>& 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()) {
|
||||
|
@ -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<uint32_t>(SkNextPow2(temp), MAX_POINTS_PER_CURVE);
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -75,7 +75,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* conte
|
||||
|
||||
sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
|
||||
|
||||
int count = SkMin32(fm->countFamilies(), maxFamilies);
|
||||
int count = std::min(fm->countFamilies(), maxFamilies);
|
||||
|
||||
// make a ton of text
|
||||
SkAutoTArray<uint16_t> text(maxTotalText);
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user