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>
This commit is contained in:
Brian Osman 2020-02-07 10:36:46 -05:00 committed by Skia Commit-Bot
parent 3a17a32305
commit 788b91678f
269 changed files with 837 additions and 851 deletions

View File

@ -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 SkTMax and SkTMin.
* Removed SkTClamp and SkClampMax.
* Removed SkScalarClampMax and SkScalarPin.
* Removed SkMax32 and SkMin32.

View File

@ -59,11 +59,11 @@ private:
for (int i = 0; i < kNumDraws; ++i) {
const SkPath& glyph = fGlyphs[i % kNumGlyphs];
const SkRect& bounds = glyph.getBounds();
float glyphSize = SkTMax(bounds.width(), bounds.height());
float glyphSize = std::max(bounds.width(), bounds.height());
float t0 = pow(rand.nextF(), 100);
float size = (1 - t0) * SkTMin(kScreenWidth, kScreenHeight) / 50 +
t0 * SkTMin(kScreenWidth, kScreenHeight) / 3;
float size = (1 - t0) * std::min(kScreenWidth, kScreenHeight) / 50 +
t0 * std::min(kScreenWidth, kScreenHeight) / 3;
float scale = size / glyphSize;
float t1 = rand.nextF(), t2 = rand.nextF();
fXforms[i].setTranslate((1 - t1) * sqrt(2) * scale/2 * glyphSize +

View File

@ -55,8 +55,8 @@ void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) {
int tileW = gpu ? FLAGS_GPUbenchTileW : FLAGS_CPUbenchTileW,
tileH = gpu ? FLAGS_GPUbenchTileH : FLAGS_CPUbenchTileH;
tileW = SkTMin(tileW, bounds.width());
tileH = SkTMin(tileH, bounds.height());
tileW = std::min(tileW, bounds.width());
tileH = std::min(tileH, bounds.height());
int xTiles = SkScalarCeilToInt(bounds.width() / SkIntToScalar(tileW));
int yTiles = SkScalarCeilToInt(bounds.height() / SkIntToScalar(tileH));

View File

@ -102,7 +102,7 @@ public:
private:
void clampShapeSize() {
float maxDiagonal = static_cast<float>(SkTMin(kBenchWidth, kBenchHeight));
float maxDiagonal = static_cast<float>(std::min(kBenchWidth, kBenchHeight));
float diagonal = sqrtf(static_cast<float>(fShapesSize.width() * fShapesSize.width()) +
static_cast<float>(fShapesSize.height() * fShapesSize.height()));
if (diagonal > maxDiagonal) {

View File

@ -956,7 +956,7 @@ public:
while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(sampleSizes)) {
int sampleSize = sampleSizes[fCurrentSampleSize];
fCurrentSampleSize++;
if (10 * sampleSize > SkTMin(codec->getInfo().width(), codec->getInfo().height())) {
if (10 * sampleSize > std::min(codec->getInfo().width(), codec->getInfo().height())) {
// Avoid benchmarking scaled decodes of already small images.
break;
}

View File

@ -205,8 +205,8 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
// We will not allow the border to be larger than the image dimensions. Allowing
// these large borders causes off by one errors that indicate a problem with the
// test suite, not a problem with the implementation.
const uint32_t maxBorder = SkTMin(width, height) / (fSampleSize * divisor);
const uint32_t scaledBorder = SkTMin(5u, maxBorder);
const uint32_t maxBorder = std::min(width, height) / (fSampleSize * divisor);
const uint32_t scaledBorder = std::min(5u, maxBorder);
const uint32_t unscaledBorder = scaledBorder * fSampleSize;
// We may need to clear the canvas to avoid uninitialized memory.
@ -270,8 +270,8 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
SkISize BRDSrc::size() const {
std::unique_ptr<SkBitmapRegionDecoder> brd(create_brd(fPath));
if (brd) {
return {SkTMax(1, brd->width() / (int)fSampleSize),
SkTMax(1, brd->height() / (int)fSampleSize)};
return {std::max(1, brd->width() / (int)fSampleSize),
std::max(1, brd->height() / (int)fSampleSize)};
}
return {0, 0};
}
@ -599,12 +599,12 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
for (int i = 0; i < numStripes; i += 2) {
// Skip a stripe
const int linesToSkip = SkTMin(stripeHeight, height - i * stripeHeight);
const int linesToSkip = std::min(stripeHeight, height - i * stripeHeight);
codec->skipScanlines(linesToSkip);
// Read a stripe
const int startY = (i + 1) * stripeHeight;
const int linesToRead = SkTMin(stripeHeight, height - startY);
const int linesToRead = std::min(stripeHeight, height - startY);
if (linesToRead > 0) {
codec->getScanlines(SkTAddOffset<void>(dst, rowBytes * startY), linesToRead,
rowBytes);
@ -619,12 +619,12 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
for (int i = 0; i < numStripes; i += 2) {
// Read a stripe
const int startY = i * stripeHeight;
const int linesToRead = SkTMin(stripeHeight, height - startY);
const int linesToRead = std::min(stripeHeight, height - startY);
codec->getScanlines(SkTAddOffset<void>(dst, rowBytes * startY), linesToRead,
rowBytes);
// Skip a stripe
const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight);
const int linesToSkip = std::min(stripeHeight, height - (i + 1) * stripeHeight);
if (linesToSkip > 0) {
codec->skipScanlines(linesToSkip);
}
@ -642,7 +642,7 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
const int tileSize = 36;
SkIRect subset;
for (int x = 0; x < width; x += tileSize) {
subset = SkIRect::MakeXYWH(x, 0, SkTMin(tileSize, width - x), height);
subset = SkIRect::MakeXYWH(x, 0, std::min(tileSize, width - x), height);
options.fSubset = &subset;
if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, &options)) {
return "Could not start scanline decoder.";
@ -682,14 +682,14 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
int top = 0;
for (int y = 0; y < H; y+= h) {
// Do not make the subset go off the edge of the image.
const int preScaleW = SkTMin(w, W - x);
const int preScaleH = SkTMin(h, H - y);
const int preScaleW = std::min(w, W - x);
const int preScaleH = std::min(h, H - y);
subset.setXYWH(x, y, preScaleW, preScaleH);
// And scale
// FIXME: Should we have a version of getScaledDimensions that takes a subset
// into account?
const int scaledW = SkTMax(1, SkScalarRoundToInt(preScaleW * fScale));
const int scaledH = SkTMax(1, SkScalarRoundToInt(preScaleH * fScale));
const int scaledW = std::max(1, SkScalarRoundToInt(preScaleW * fScale));
const int scaledH = std::max(1, SkScalarRoundToInt(preScaleH * fScale));
decodeInfo = decodeInfo.makeWH(scaledW, scaledH);
SkImageInfo subsetBitmapInfo = bitmapInfo.makeWH(scaledW, scaledH);
size_t subsetRowBytes = subsetBitmapInfo.minRowBytes();
@ -1207,7 +1207,7 @@ SVGSrc::SVGSrc(Path path)
// no intrinsic size
fDom->setContainerSize(kDefaultSVGSize);
} else {
fScale = SkTMax(1.f, SkTMax(kMinimumSVGSize.width() / sz.width(),
fScale = std::max(1.f, std::max(kMinimumSVGSize.width() / sz.width(),
kMinimumSVGSize.height() / sz.height()));
}
}
@ -1380,7 +1380,7 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
initContext(context);
}
const int maxDimension = context->priv().caps()->maxTextureSize();
if (maxDimension < SkTMax(size.width(), size.height())) {
if (maxDimension < std::max(size.width(), size.height())) {
return Error::Nonfatal("Src too large to create a texture.\n");
}
uint32_t flags = fUseDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;

View File

@ -12,9 +12,9 @@ void paintOctopus(int x, int y, int size_base, SkColor color, SkCanvas* canvas)
canvas->drawCircle(x - radius + (2 * radius / 7.5 * leg),
y + radius - pow(abs(4 - leg), 2), size_base / 2 + 2, paint);
}
paint.setColor(SkColorSetRGB(SkTMin(255u, SkColorGetR(color) + 20),
SkTMin(255u, SkColorGetG(color) + 20),
SkTMin(255u, SkColorGetB(color) + 20)));
paint.setColor(SkColorSetRGB(std::min(255u, SkColorGetR(color) + 20),
std::min(255u, SkColorGetG(color) + 20),
std::min(255u, SkColorGetB(color) + 20)));
canvas->drawCircle(x - size_base, y + size_base, size_base / 2, paint);
canvas->drawCircle(x + size_base, y + size_base, size_base / 2, paint);
}

View File

@ -12,9 +12,9 @@ void paintOctopus(int x, int y, int size_base, SkColor color, SkCanvas* canvas)
canvas->drawCircle(x - radius + (2*radius/7.5*leg),
y + radius - pow(abs(4-leg), 2), size_base/2 + 2, paint);
}
paint.setColor(SkColorSetRGB(SkTMin(255u, SkColorGetR(color) + 20),
SkTMin(255u, SkColorGetG(color) + 20),
SkTMin(255u, SkColorGetB(color) + 20)));
paint.setColor(SkColorSetRGB(std::min(255u, SkColorGetR(color) + 20),
std::min(255u, SkColorGetG(color) + 20),
std::min(255u, SkColorGetB(color) + 20)));
canvas->drawCircle(x-size_base, y+size_base, size_base/2, paint);
canvas->drawCircle(x+size_base, y+size_base, size_base/2, paint);
}

View File

@ -7,7 +7,7 @@ void draw(SkCanvas* canvas) {
auto debugster = [](const char* prefix, const SkPath& path, SkPoint* points, int max) -> void {
int count = path.getPoints(points, max);
SkDebugf("%s point count: %d ", prefix, count);
for (int i = 0; i < SkTMin(count, max) && points; ++i) {
for (int i = 0; i < std::min(count, max) && points; ++i) {
SkDebugf("(%1.8g,%1.8g) ", points[i].fX, points[i].fY);
}
SkDebugf("\n");

View File

@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) {
int count = path.getVerbs(verbs, max);
SkDebugf("%s verb count: %d ", prefix, count);
const char* verbStr[] = { "move", "line", "quad", "conic", "cubic", "close" };
for (int i = 0; i < SkTMin(count, max) && verbs; ++i) {
for (int i = 0; i < std::min(count, max) && verbs; ++i) {
SkDebugf("%s ", verbStr[verbs[i]]);
}
SkDebugf("\n");

View File

@ -8,7 +8,7 @@ void dump_txt(const SkData* data, const char* name) {
size_t s = data->size();
const char* d = (const char*)data->bytes();
while (s > 0) {
int l = (int)SkTMin(s, (size_t)1024);
int l = (int)std::min(s, (size_t)1024);
SkDebugf("%.*s", l, d);
s -= l;
d += l;

View File

@ -30,7 +30,7 @@ public:
size_t len = fStorage.size();
SkASSERT(fPos <= len);
size_t overwrite = SkTMin(len - fPos, bytes);
size_t overwrite = std::min(len - fPos, bytes);
if (overwrite) {
SkDebugf("overwrite %zu bytes at %zu offset with %zu remaining\n", overwrite, fPos, bytes - overwrite);
memcpy(&fStorage[fPos], src, overwrite);

View File

@ -504,12 +504,12 @@ static void fuzz_img(sk_sp<SkData> bytes, uint8_t scale, uint8_t mode) {
for (int i = 0; i < numStripes; i += 2) {
// Skip a stripe
const int linesToSkip = SkTMin(stripeHeight, height - i * stripeHeight);
const int linesToSkip = std::min(stripeHeight, height - i * stripeHeight);
codec->skipScanlines(linesToSkip);
// Read a stripe
const int startY = (i + 1) * stripeHeight;
const int linesToRead = SkTMin(stripeHeight, height - startY);
const int linesToRead = std::min(stripeHeight, height - startY);
if (linesToRead > 0) {
codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitmap.rowBytes());
}
@ -524,11 +524,11 @@ static void fuzz_img(sk_sp<SkData> bytes, uint8_t scale, uint8_t mode) {
for (int i = 0; i < numStripes; i += 2) {
// Read a stripe
const int startY = i * stripeHeight;
const int linesToRead = SkTMin(stripeHeight, height - startY);
const int linesToRead = std::min(stripeHeight, height - startY);
codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitmap.rowBytes());
// Skip a stripe
const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight);
const int linesToSkip = std::min(stripeHeight, height - (i + 1) * stripeHeight);
if (linesToSkip > 0) {
codec->skipScanlines(linesToSkip);
}
@ -565,15 +565,15 @@ static void fuzz_img(sk_sp<SkData> bytes, uint8_t scale, uint8_t mode) {
int top = 0;
for (int y = 0; y < H; y+= h) {
// Do not make the subset go off the edge of the image.
const int preScaleW = SkTMin(w, W - x);
const int preScaleH = SkTMin(h, H - y);
const int preScaleW = std::min(w, W - x);
const int preScaleH = std::min(h, H - y);
subset.setXYWH(x, y, preScaleW, preScaleH);
// And fscale
// FIXME: Should we have a version of getScaledDimensions that takes a subset
// into account?
decodeInfo = decodeInfo.makeWH(
SkTMax(1, SkScalarRoundToInt(preScaleW * fscale)),
SkTMax(1, SkScalarRoundToInt(preScaleH * fscale)));
std::max(1, SkScalarRoundToInt(preScaleW * fscale)),
std::max(1, SkScalarRoundToInt(preScaleH * fscale)));
size_t rowBytes = decodeInfo.minRowBytes();
if (!subsetBm.installPixels(decodeInfo, pixels, rowBytes)) {
SkDebugf("[terminated] Could not install pixels.\n");

View File

@ -21,7 +21,7 @@ DEF_FUZZ(PathMeasure, fuzz) {
SkPath path;
FuzzEvilPath(fuzz, &path, SkPath::Verb::kDone_Verb);
SkRect bounds = path.getBounds();
SkScalar maxDim = SkTMax(bounds.width(), bounds.height());
SkScalar maxDim = std::max(bounds.width(), bounds.height());
SkScalar resScale = maxDim / 1000;
SkPathMeasure measure(path, bits & 1, resScale);
SkPoint position;

View File

@ -213,9 +213,9 @@ protected:
if (mode == SkBlendMode::kPlus) {
// Check for overflow, otherwise we might get confusing AA artifacts.
int maxSum = SkTMax(SkTMax(SkColorGetA(kBGColor) + SkColorGetA(color),
int maxSum = std::max(std::max(SkColorGetA(kBGColor) + SkColorGetA(color),
SkColorGetR(kBGColor) + SkColorGetR(color)),
SkTMax(SkColorGetG(kBGColor) + SkColorGetG(color),
std::max(SkColorGetG(kBGColor) + SkColorGetG(color),
SkColorGetB(kBGColor) + SkColorGetB(color)));
if (maxSum > 255) {

View File

@ -345,8 +345,8 @@ protected:
SkPoint corners[] = {{0, 0}, { 0, kBottom }, { kWidth, kBottom }, {kWidth, 0} };
matrices[matrices.count()-1].mapPoints(corners, 4);
SkScalar y = (corners[0].fY + corners[1].fY + corners[2].fY + corners[3].fY) / 4;
SkScalar x = SkTMax(SkTMax(corners[0].fX, corners[1].fX),
SkTMax(corners[2].fX, corners[3].fX));
SkScalar x = std::max(std::max(corners[0].fX, corners[1].fX),
std::max(corners[2].fX, corners[3].fX));
m.setTranslate(x, y);
m.preScale(0.2f, 0.2f);
*matrices.append() = m;
@ -404,9 +404,9 @@ protected:
SkPoint corners[] = { { 0, 0 },{ 0, kBottom },{ kWidth, kBottom },{ kWidth, 0 } };
matrices[m].mapPoints(corners, 4);
SkScalar x = kBlockSize + SkTMax(SkTMax(corners[0].fX, corners[1].fX),
SkTMax(corners[2].fX, corners[3].fX));
maxX = SkTMax(maxX, x);
SkScalar x = kBlockSize + std::max(std::max(corners[0].fX, corners[1].fX),
std::max(corners[2].fX, corners[3].fX));
maxX = std::max(maxX, x);
canvas->restore();
}
canvas->restore();

View File

@ -155,7 +155,7 @@ protected:
void onDraw(SkCanvas* canvas) override {
// Draw a giant AA circle as the background.
SkISize size = this->getISize();
SkScalar giantRadius = SkTMin(SkIntToScalar(size.fWidth),
SkScalar giantRadius = std::min(SkIntToScalar(size.fWidth),
SkIntToScalar(size.fHeight)) / 2.f;
SkPoint giantCenter = SkPoint::Make(SkIntToScalar(size.fWidth/2),
SkIntToScalar(size.fHeight/2));

View File

@ -60,7 +60,7 @@ static SkPath make_gear(SkISize dimensions, int numTeeth) {
tmp.close();
float fInnerRad = 0.1f * SkTMin(dimensions.fWidth, dimensions.fHeight);
float fInnerRad = 0.1f * std::min(dimensions.fWidth, dimensions.fHeight);
if (fInnerRad > 0.5f) {
tmp.addCircle(0.0f, 0.0f, fInnerRad, SkPathDirection::kCCW);
}
@ -138,7 +138,7 @@ static sk_sp<SkData> make_compressed_data(SkISize dimensions,
}
offset += levelSize;
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 tmp;
@ -278,8 +278,8 @@ private:
offset.fY += levelDimensions.height()+1;
}
levelDimensions = {SkTMax(1, levelDimensions.width()/2),
SkTMax(1, levelDimensions.height()/2)};
levelDimensions = {std::max(1, levelDimensions.width()/2),
std::max(1, levelDimensions.height()/2)};
}
}

View File

@ -168,8 +168,8 @@ protected:
// update x and y for the next test case.
SkScalar height = renderRect.height();
SkScalar width = SkTMax(inputLabelBounds.fRight, procLabelBounds.fRight);
maxW = SkTMax(maxW, width);
SkScalar width = std::max(inputLabelBounds.fRight, procLabelBounds.fRight);
maxW = std::max(maxW, width);
y += height + kPad;
if (y + height > kHeight) {
y = kPad;

View File

@ -567,7 +567,7 @@ DEF_SIMPLE_GM(dash_line_zero_off_interval, canvas, 160, 330) {
canvas->save();
SkScalar h = 0.f;
for (const auto& line : kLines) {
h = SkTMax(h, SkScalarAbs(line.fA.fY - line.fB.fY));
h = std::max(h, SkScalarAbs(line.fA.fY - line.fB.fY));
}
for (const auto& line : kLines) {
SkScalar w = SkScalarAbs(line.fA.fX - line.fB.fX);

View File

@ -90,7 +90,7 @@ protected:
}
this->drawBlob(canvas, blob.get(), SK_ColorBLACK, x, y + h, pm, twm);
x += w + 20.f;
maxH = SkTMax(h, maxH);
maxH = std::max(h, maxH);
canvas->restore();
}
}

View File

@ -140,8 +140,8 @@ static void draw_text_on_path(SkCanvas* canvas, const void* text, size_t length,
// Compute a conservative bounds so we can cull the draw
const SkRect fontb = SkFontPriv::GetFontBounds(font);
const SkScalar max = SkTMax(SkTMax(SkScalarAbs(fontb.fLeft), SkScalarAbs(fontb.fRight)),
SkTMax(SkScalarAbs(fontb.fTop), SkScalarAbs(fontb.fBottom)));
const SkScalar max = std::max(std::max(SkScalarAbs(fontb.fLeft), SkScalarAbs(fontb.fRight)),
std::max(SkScalarAbs(fontb.fTop), SkScalarAbs(fontb.fBottom)));
const SkRect bounds = path.getBounds().makeOutset(max, max);
SkAutoTArray<SkGlyphID> glyphs(count);

View File

@ -239,7 +239,7 @@ private:
paint.setFilterQuality(kLow_SkFilterQuality);
paint.setBlendMode(SkBlendMode::kSrcOver);
static constexpr SkScalar kTranslate = SkTMax(kW, kH) * 2.f + 10.f;
static constexpr SkScalar kTranslate = std::max(kW, kH) * 2.f + 10.f;
canvas->translate(5.f, 5.f);
canvas->save();
for (SkScalar frac : {0.f, 0.5f}) {

View File

@ -42,8 +42,8 @@
//
// I think the KHR version is just wrong... it produces values >1. So we use the web version.
static float min(float r, float g, float b) { return SkTMin(r, SkTMin(g, b)); }
static float max(float r, float g, float b) { return SkTMax(r, SkTMax(g, b)); }
static float min(float r, float g, float b) { return std::min(r, std::min(g, b)); }
static float max(float r, float g, float b) { return std::max(r, std::max(g, b)); }
static float sat(float r, float g, float b) { return max(r,g,b) - min(r,g,b); }
static float lum(float r, float g, float b) { return r*0.30f + g*0.59f + b*0.11f; }

View File

@ -495,7 +495,7 @@ protected:
int numPtsArray[] = { 5, 7, 8, 20, 100 };
size_t arrayIndex = index - SK_ARRAY_COUNT(PolygonOffsetData::gSimplePoints);
arrayIndex = SkTMin(arrayIndex, SK_ARRAY_COUNT(numPtsArray) - 1);
arrayIndex = std::min(arrayIndex, SK_ARRAY_COUNT(numPtsArray) - 1);
SkASSERT(arrayIndex < SK_ARRAY_COUNT(numPtsArray));
*numPts = numPtsArray[arrayIndex];
// squash horizontally

View File

@ -28,7 +28,7 @@ static skiagm::DrawResult draw_rotated_image(SkCanvas* canvas, const SkImage* im
SkRect rect = SkRect::MakeLTRB(-68.0f, -68.0f, 68.0f, 68.0f);
SkPaint paint;
paint.setColor(SkColorSetRGB(49, 48, 49));
SkScalar scale = SkTMin(128.0f / image->width(),
SkScalar scale = std::min(128.0f / image->width(),
128.0f / image->height());
SkScalar point[2] = {-0.5f * image->width(), -0.5f * image->height()};
for (int j = 0; j < 4; ++j) {

View File

@ -156,7 +156,7 @@ void draw_paths(SkCanvas* canvas, ShadowMode mode) {
canvas->translate(dx, 0);
x += dx;
dy = SkTMax(dy, postMBounds.height() + kPad + kHeight);
dy = std::max(dy, postMBounds.height() + kPad + kHeight);
++pathCounter;
}
}
@ -207,7 +207,7 @@ void draw_paths(SkCanvas* canvas, ShadowMode mode) {
canvas->translate(dx, 0);
x += dx;
dy = SkTMax(dy, postMBounds.height() + kPad + kHeight);
dy = std::max(dy, postMBounds.height() + kPad + kHeight);
}
}

View File

@ -139,7 +139,7 @@ private:
for (int i = 0; i < fShapes.count(); i++) {
const SkRRect& outer = fShapes[i];
const SkRRect& inner = fShapes[(i * 7 + 11) % fSimpleShapeCount];
float s = 0.95f * SkTMin(outer.rect().width() / inner.rect().width(),
float s = 0.95f * std::min(outer.rect().width() / inner.rect().width(),
outer.rect().height() / inner.rect().height());
SkMatrix innerXform;
float dx = (rand.nextF() - 0.5f) * (outer.rect().width() - s * inner.rect().width());

View File

@ -120,7 +120,7 @@ protected:
path.lineTo(points[triangle[2]]);
path.close();
}
SkScalar scale = kBoxSize / SkTMax(path.getBounds().height(), path.getBounds().width());
SkScalar scale = kBoxSize / std::max(path.getBounds().height(), path.getBounds().width());
path.transform(SkMatrix::MakeScale(scale, scale));
this->drawRow(canvas, path);

View File

@ -35,10 +35,10 @@ static const SkPoint kCubics[][4] = {
static SkRect calc_tight_cubic_bounds(const SkPoint P[4], int depth=5) {
if (0 == depth) {
SkRect bounds;
bounds.fLeft = SkTMin(SkTMin(P[0].x(), P[1].x()), SkTMin(P[2].x(), P[3].x()));
bounds.fTop = SkTMin(SkTMin(P[0].y(), P[1].y()), SkTMin(P[2].y(), P[3].y()));
bounds.fRight = SkTMax(SkTMax(P[0].x(), P[1].x()), SkTMax(P[2].x(), P[3].x()));
bounds.fBottom = SkTMax(SkTMax(P[0].y(), P[1].y()), SkTMax(P[2].y(), P[3].y()));
bounds.fLeft = std::min(std::min(P[0].x(), P[1].x()), std::min(P[2].x(), P[3].x()));
bounds.fTop = std::min(std::min(P[0].y(), P[1].y()), std::min(P[2].y(), P[3].y()));
bounds.fRight = std::max(std::max(P[0].x(), P[1].x()), std::max(P[2].x(), P[3].x()));
bounds.fBottom = std::max(std::max(P[0].y(), P[1].y()), std::max(P[2].y(), P[3].y()));
return bounds;
}

View File

@ -252,7 +252,7 @@ static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
SkScalar dx = SkScalarCeilToScalar(
font.measureText(&character, 1, SkTextEncoding::kUTF8)) + 5;
x += dx;
xMax = SkTMax(x, xMax);
xMax = std::max(x, xMax);
}
}
}

View File

@ -584,18 +584,10 @@ template <typename T> static inline T SkTAbs(T value) {
return value;
}
template <typename T> constexpr const T& SkTMin(const T& a, const T& b) {
return (a < b) ? a : b;
}
template <typename T> constexpr const T& SkTMax(const T& a, const T& b) {
return (b < a) ? a : b;
}
/** @return value pinned (clamped) between min and max, inclusively.
*/
template <typename T> static constexpr const T& SkTPin(const T& value, const T& min, const T& max) {
return SkTMax(SkTMin(value, max), min);
return value < min ? min : (value < max ? value : max);
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -61,7 +61,7 @@ struct SK_API SkYUVAIndex {
} else if (yuvaIndices[i].fIndex > 3) {
valid = false; // A maximum of four input textures is allowed
} else {
maxSlotUsed = SkTMax(yuvaIndices[i].fIndex, maxSlotUsed);
maxSlotUsed = std::max(yuvaIndices[i].fIndex, maxSlotUsed);
used[i] = true;
}
}

View File

@ -118,8 +118,8 @@ static inline bool sk_float_isnan(float x) {
* Return the closest int for the given float. Returns SK_MaxS32FitsInFloat for NaN.
*/
static inline int sk_float_saturate2int(float x) {
x = SkTMin<float>(x, SK_MaxS32FitsInFloat);
x = SkTMax<float>(x, SK_MinS32FitsInFloat);
x = x < SK_MaxS32FitsInFloat ? x : SK_MaxS32FitsInFloat;
x = x > SK_MinS32FitsInFloat ? x : SK_MinS32FitsInFloat;
return (int)x;
}
@ -127,8 +127,8 @@ static inline int sk_float_saturate2int(float x) {
* Return the closest int for the given double. Returns SK_MaxS32 for NaN.
*/
static inline int sk_double_saturate2int(double x) {
x = SkTMin<double>(x, SK_MaxS32);
x = SkTMax<double>(x, SK_MinS32);
x = x < SK_MaxS32 ? x : SK_MaxS32;
x = x > SK_MinS32 ? x : SK_MinS32;
return (int)x;
}
@ -136,8 +136,8 @@ static inline int sk_double_saturate2int(double x) {
* Return the closest int64_t for the given float. Returns SK_MaxS64FitsInFloat for NaN.
*/
static inline int64_t sk_float_saturate2int64(float x) {
x = SkTMin<float>(x, SK_MaxS64FitsInFloat);
x = SkTMax<float>(x, SK_MinS64FitsInFloat);
x = x < SK_MaxS64FitsInFloat ? x : SK_MaxS64FitsInFloat;
x = x > SK_MinS64FitsInFloat ? x : SK_MinS64FitsInFloat;
return (int64_t)x;
}

View File

@ -105,8 +105,8 @@ struct SkNx {
Half::Store2(ptr + 2*N/2*sizeof(T), a.fHi, b.fHi);
}
AI T min() const { return SkTMin(fLo.min(), fHi.min()); }
AI T max() const { return SkTMax(fLo.max(), fHi.max()); }
AI T min() const { return std::min(fLo.min(), fHi.min()); }
AI T max() const { return std::max(fLo.max(), fHi.max()); }
AI bool anyTrue() const { return fLo.anyTrue() || fHi.anyTrue(); }
AI bool allTrue() const { return fLo.allTrue() && fHi.allTrue(); }

View File

@ -267,7 +267,7 @@ public:
return vminvq_f32(fVec);
#else
SkNx min = Min(*this, vrev64q_f32(fVec));
return SkTMin(min[0], min[2]);
return std::min(min[0], min[2]);
#endif
}
@ -276,7 +276,7 @@ public:
return vmaxvq_f32(fVec);
#else
SkNx max = Max(*this, vrev64q_f32(fVec));
return SkTMax(max[0], max[2]);
return std::max(max[0], max[2]);
#endif
}

View File

@ -11,6 +11,7 @@
#include "include/core/SkTypes.h"
#include "include/private/SkOnce.h"
#include "include/private/SkThreadAnnotations.h"
#include <algorithm>
#include <atomic>
class SkSemaphore {
@ -59,11 +60,11 @@ inline void SkSemaphore::signal(int n) {
//
// This is easiest to think about with specific examples of prev and n.
// If n == 5 and prev == -3, there are 3 threads sleeping and we signal
// SkTMin(-(-3), 5) == 3 times on the OS semaphore, leaving the count at 2.
// std::min(-(-3), 5) == 3 times on the OS semaphore, leaving the count at 2.
//
// If prev >= 0, no threads are waiting, SkTMin(-prev, n) is always <= 0,
// If prev >= 0, no threads are waiting, std::min(-prev, n) is always <= 0,
// so we don't call the OS semaphore, leaving the count at (prev + n).
int toSignal = SkTMin(-prev, n);
int toSignal = std::min(-prev, n);
if (toSignal > 0) {
this->osSignal(toSignal);
}

View File

@ -454,7 +454,7 @@ private:
fOwnMemory = true;
fReserved = false;
} else {
fAllocCount = SkTMax(count, SkTMax(kMinHeapAllocCount, reserveCount));
fAllocCount = std::max(count, std::max(kMinHeapAllocCount, reserveCount));
fItemArray = (T*)sk_malloc_throw(fAllocCount, sizeof(T));
fOwnMemory = true;
fReserved = reserveCount > 0;
@ -469,7 +469,7 @@ private:
fItemArray = nullptr;
fReserved = false;
if (count > preallocCount) {
fAllocCount = SkTMax(count, kMinHeapAllocCount);
fAllocCount = std::max(count, kMinHeapAllocCount);
fItemArray = (T*)sk_malloc_throw(fAllocCount, sizeof(T));
fOwnMemory = true;
} else {

View File

@ -78,7 +78,7 @@ public:
void draw(SkCanvas* canvas, const SkParticles& particles, int count,
const SkPaint& paint) override {
int r = SkTMax(fRadius, 1);
int r = std::max(fRadius, 1);
SkPoint center = { SkIntToScalar(r), SkIntToScalar(r) };
DrawAtlasArrays arrays(particles, count, center);
for (int i = 0; i < count; ++i) {
@ -89,7 +89,7 @@ public:
}
void prepare(const skresources::ResourceProvider*) override {
int r = SkTMax(fRadius, 1);
int r = std::max(fRadius, 1);
if (!fImage || fImage->width() != 2 * r) {
fImage = make_circle_image(r);
}
@ -119,8 +119,8 @@ public:
void draw(SkCanvas* canvas, const SkParticles& particles, int count,
const SkPaint& paint) override {
int cols = SkTMax(fCols, 1),
rows = SkTMax(fRows, 1);
int cols = std::max(fCols, 1),
rows = std::max(fRows, 1);
SkRect baseRect = SkRect::MakeWH(static_cast<float>(fImage->width()) / cols,
static_cast<float>(fImage->height()) / rows);
SkPoint center = { baseRect.width() * 0.5f, baseRect.height() * 0.5f };

View File

@ -494,7 +494,7 @@ void SkParticleEffect::setCapacity(int capacity) {
fStableRandoms.realloc(capacity);
fCapacity = capacity;
fCount = SkTMin(fCount, fCapacity);
fCount = std::min(fCount, fCapacity);
}
void SkParticleEffect::RegisterParticleTypes() {

View File

@ -116,7 +116,7 @@ protected:
SkPoint prev_c0 = { 0, 0 },
prev_c1 = prev_c0;
fRecs.reserve(SkTMax<size_t>(jframes.size(), 1) - 1);
fRecs.reserve(std::max<size_t>(jframes.size(), 1) - 1);
for (const skjson::ObjectValue* jframe : jframes) {
if (!jframe) continue;

View File

@ -36,7 +36,7 @@ SkM44 ComputeCameraMatrix(const SkV3& position,
// * size -> composition size (TODO: AE seems to base it on width only?)
// * distance -> "zoom" camera attribute
//
const auto view_size = SkTMax(viewport_size.width(), viewport_size.height()),
const auto view_size = std::max(viewport_size.width(), viewport_size.height()),
view_distance = zoom,
view_angle = std::atan(sk_ieee_float_divide(view_size * 0.5f, view_distance));

View File

@ -378,7 +378,7 @@ sk_sp<Animation> Animation::Builder::make(const char* data, size_t data_len) {
ParseDefault<float>(json["h"], 0.0f));
const auto fps = ParseDefault<float>(json["fr"], -1.0f),
inPoint = ParseDefault<float>(json["ip"], 0.0f),
outPoint = SkTMax(ParseDefault<float>(json["op"], SK_ScalarMax), inPoint),
outPoint = std::max(ParseDefault<float>(json["op"], SK_ScalarMax), inPoint),
duration = sk_ieee_float_divide(outPoint - inPoint, fps);
if (size.isEmpty() || version.isEmpty() || fps <= 0 ||

View File

@ -47,7 +47,7 @@ public:
SkPaint::kBevel_Join,
};
this->node()->setStrokeJoin(
gJoins[SkTMin<size_t>(ParseDefault<size_t>(jpaint["lj"], 1) - 1,
gJoins[std::min<size_t>(ParseDefault<size_t>(jpaint["lj"], 1) - 1,
SK_ARRAY_COUNT(gJoins) - 1)]);
static constexpr SkPaint::Cap gCaps[] = {
@ -56,7 +56,7 @@ public:
SkPaint::kSquare_Cap,
};
this->node()->setStrokeCap(
gCaps[SkTMin<size_t>(ParseDefault<size_t>(jpaint["lc"], 1) - 1,
gCaps[std::min<size_t>(ParseDefault<size_t>(jpaint["lc"], 1) - 1,
SK_ARRAY_COUNT(gCaps) - 1)]);
}

View File

@ -38,7 +38,7 @@ std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AttachMergeGeometryEffect(
sksg::Merge::Mode::kXOR , // "mm": 5
};
const auto mode = gModes[SkTMin<size_t>(ParseDefault<size_t>(jmerge["mm"], 1) - 1,
const auto mode = gModes[std::min<size_t>(ParseDefault<size_t>(jmerge["mm"], 1) - 1,
SK_ARRAY_COUNT(gModes) - 1)];
std::vector<sk_sp<sksg::GeometryNode>> merged;

View File

@ -38,8 +38,8 @@ private:
end = fEnd / 100,
offset = fOffset / 360;
auto startT = SkTMin(start, end) + offset,
stopT = SkTMax(start, end) + offset;
auto startT = std::min(start, end) + offset,
stopT = std::max(start, end) + offset;
auto mode = SkTrimPathEffect::Mode::kNormal;
if (stopT - startT < 1) {
@ -80,7 +80,7 @@ std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AttachTrimGeometryEffect(
kSerial, // "m": 2 (Trim Multiple Shapes: Individually)
} gModes[] = { Mode::kParallel, Mode::kSerial};
const auto mode = gModes[SkTMin<size_t>(ParseDefault<size_t>(jtrim["m"], 1) - 1,
const auto mode = gModes[std::min<size_t>(ParseDefault<size_t>(jtrim["m"], 1) - 1,
SK_ARRAY_COUNT(gModes) - 1)];
std::vector<sk_sp<sksg::GeometryNode>> inputs;

View File

@ -82,9 +82,9 @@ public:
SkFontMetrics metrics;
info.fFont.getMetrics(&metrics);
if (!fLineCount) {
fFirstLineAscent = SkTMin(fFirstLineAscent, metrics.fAscent);
fFirstLineAscent = std::min(fFirstLineAscent, metrics.fAscent);
}
fLastLineDescent = SkTMax(fLastLineDescent, metrics.fDescent);
fLastLineDescent = std::max(fLastLineDescent, metrics.fDescent);
}
void commitRunInfo() override {}

View File

@ -47,7 +47,7 @@ bool ValueTraits<TextValue>::FromJSON(const skjson::Value& jv,
SkTextUtils::kRight_Align, // 'j': 1
SkTextUtils::kCenter_Align // 'j': 2
};
v->fHAlign = gAlignMap[SkTMin<size_t>(ParseDefault<size_t>((*jtxt)["j"], 0),
v->fHAlign = gAlignMap[std::min<size_t>(ParseDefault<size_t>((*jtxt)["j"], 0),
SK_ARRAY_COUNT(gAlignMap))];
// Optional text box size.
@ -72,7 +72,7 @@ bool ValueTraits<TextValue>::FromJSON(const skjson::Value& jv,
Shaper::ResizePolicy::kScaleToFit, // 'sk_rs': 1
Shaper::ResizePolicy::kDownscaleToFit, // 'sk_rs': 2
};
v->fResize = gResizeMap[SkTMin<size_t>(ParseDefault<size_t>((*jtxt)["sk_rs"], 0),
v->fResize = gResizeMap[std::min<size_t>(ParseDefault<size_t>((*jtxt)["sk_rs"], 0),
SK_ARRAY_COUNT(gResizeMap))];
// In point mode, the text is baseline-aligned.

View File

@ -96,7 +96,7 @@ template <typename T> struct SkRange {
}
bool intersects(SkRange<size_t> other) const {
return SkTMax(start, other.start) <= SkTMin(end, other.end);
return std::max(start, other.start) <= std::min(end, other.end);
}
bool empty() const {

View File

@ -275,8 +275,8 @@ void OneLineShaper::addUnresolvedWithRun(GlyphRange glyphRange) {
} else if (lastUnresolved.fText.intersects(unresolved.fText)) {
// Few pieces of the same unresolved text block can ignore the second one
lastUnresolved.fGlyphs.start =
SkTMin(lastUnresolved.fGlyphs.start, glyphRange.start);
lastUnresolved.fGlyphs.end = SkTMax(lastUnresolved.fGlyphs.end, glyphRange.end);
std::min(lastUnresolved.fGlyphs.start, glyphRange.start);
lastUnresolved.fGlyphs.end = std::max(lastUnresolved.fGlyphs.end, glyphRange.end);
lastUnresolved.fText = clusteredText(lastUnresolved.fGlyphs);
return;
}
@ -361,7 +361,7 @@ void OneLineShaper::iterateThroughFontStyles(TextRange textRange,
};
for (auto& block : styleSpan) {
BlockRange blockRange(SkTMax(block.fRange.start, textRange.start), SkTMin(block.fRange.end, textRange.end));
BlockRange blockRange(std::max(block.fRange.start, textRange.start), std::min(block.fRange.end, textRange.end));
if (blockRange.empty()) {
continue;
}
@ -433,8 +433,8 @@ bool OneLineShaper::iterateThroughShapingRegions(const ShapeVisitor& shape) {
// Shape the text by bidi regions
while (bidiIndex < bidiRegions.size()) {
BidiRegion& bidiRegion = bidiRegions[bidiIndex];
auto start = SkTMax(bidiRegion.text.start, placeholder.fTextBefore.start);
auto end = SkTMin(bidiRegion.text.end, placeholder.fTextBefore.end);
auto start = std::max(bidiRegion.text.start, placeholder.fTextBefore.start);
auto end = std::min(bidiRegion.text.end, placeholder.fTextBefore.end);
// Set up the iterators (the style iterator points to a bigger region that it could
TextRange textRange(start, end);

View File

@ -36,8 +36,8 @@ static inline SkUnichar utf8_next(const char** ptr, const char* end) {
TextRange operator*(const TextRange& a, const TextRange& b) {
if (a.start == b.start && a.end == b.end) return a;
auto begin = SkTMax(a.start, b.start);
auto end = SkTMin(a.end, b.end);
auto begin = std::max(a.start, b.start);
auto end = std::min(a.end, b.end);
return end > begin ? TextRange(begin, end) : EMPTY_TEXT;
}
@ -414,7 +414,7 @@ void ParagraphImpl::breakShapedTextIntoLines(SkScalar maxWidth) {
}
}
fLongestLine = SkTMax(fLongestLine, nearlyZero(advance.fX) ? widthWithSpaces : advance.fX);
fLongestLine = std::max(fLongestLine, nearlyZero(advance.fX) ? widthWithSpaces : advance.fX);
});
fHeight = textWrapper.height();
fWidth = maxWidth;
@ -787,8 +787,8 @@ std::vector<TextBox> ParagraphImpl::getRectsForRange(unsigned start,
(nearlyEqual(lastBox.rect.fLeft, clip.fRight) ||
nearlyEqual(lastBox.rect.fRight, clip.fLeft)))
{
lastBox.rect.fLeft = SkTMin(lastBox.rect.fLeft, clip.fLeft);
lastBox.rect.fRight = SkTMax(lastBox.rect.fRight, clip.fRight);
lastBox.rect.fLeft = std::min(lastBox.rect.fLeft, clip.fLeft);
lastBox.rect.fRight = std::max(lastBox.rect.fRight, clip.fRight);
mergedBoxes = true;
}
}

View File

@ -334,7 +334,7 @@ SkScalar Cluster::trimmedWidth(size_t pos) const {
// Find the width until the pos and return the min between trimmedWidth and the width(pos)
// We don't have to take in account cluster shift since it's the same for 0 and for pos
auto& run = fMaster->run(fRunIndex);
return SkTMin(run.positionX(pos) - run.positionX(fStart), fWidth - fSpacing);
return std::min(run.positionX(pos) - run.positionX(fStart), fWidth - fSpacing);
}
SkScalar Run::positionX(size_t pos) const {

View File

@ -353,15 +353,15 @@ public:
return;
}
fAscent = SkTMin(fAscent, run->correctAscent());
fDescent = SkTMax(fDescent, run->correctDescent());
fLeading = SkTMax(fLeading, run->correctLeading());
fAscent = std::min(fAscent, run->correctAscent());
fDescent = std::max(fDescent, run->correctDescent());
fLeading = std::max(fLeading, run->correctLeading());
}
void add(InternalLineMetrics other) {
fAscent = SkTMin(fAscent, other.fAscent);
fDescent = SkTMax(fDescent, other.fDescent);
fLeading = SkTMax(fLeading, other.fLeading);
fAscent = std::min(fAscent, other.fAscent);
fDescent = std::max(fDescent, other.fDescent);
fLeading = std::max(fLeading, other.fLeading);
}
void clean() {
fAscent = 0;
@ -378,8 +378,8 @@ public:
metrics.fLeading = fLeading;
} else {
// This is another of those flutter changes. To be removed...
metrics.fAscent = SkTMin(metrics.fAscent, fAscent - fLeading / 2.0f);
metrics.fDescent = SkTMax(metrics.fDescent, fDescent + fLeading / 2.0f);
metrics.fAscent = std::min(metrics.fAscent, fAscent - fLeading / 2.0f);
metrics.fDescent = std::max(metrics.fDescent, fDescent + fLeading / 2.0f);
}
}

View File

@ -16,8 +16,8 @@ namespace {
// TODO: deal with all the intersection functionality
TextRange intersected(const TextRange& a, const TextRange& b) {
if (a.start == b.start && a.end == b.end) return a;
auto begin = SkTMax(a.start, b.start);
auto end = SkTMin(a.end, b.end);
auto begin = std::max(a.start, b.start);
auto end = std::min(a.end, b.end);
return end >= begin ? TextRange(begin, end) : EMPTY_TEXT;
}
@ -32,7 +32,7 @@ int compareRound(SkScalar a, SkScalar b) {
// Canvas scaling affects it
// Letter spacing affects it
// It has to be relative to be useful
auto base = SkTMax(SkScalarAbs(a), SkScalarAbs(b));
auto base = std::max(SkScalarAbs(a), SkScalarAbs(b));
auto diff = SkScalarAbs(a - b);
if (nearlyZero(base) || diff / base < 0.001f) {
return 0;
@ -294,7 +294,7 @@ void TextLine::scanStyles(StyleType styleType, const RunStyleVisitor& visitor) {
SkRect TextLine::extendHeight(const ClipContext& context) const {
SkRect result = context.clip;
result.fBottom += SkTMax(this->fMaxRunMetrics.height() - this->height(), 0.0f);
result.fBottom += std::max(this->fMaxRunMetrics.height() - this->height(), 0.0f);
return result;
}
@ -741,9 +741,9 @@ void TextLine::iterateThroughClustersInGlyphsOrder(bool reverse,
for (size_t r = 0; r != fRunsInVisualOrder.size(); ++r) {
auto& runIndex = fRunsInVisualOrder[reverse ? fRunsInVisualOrder.size() - r - 1 : r];
auto run = this->fMaster->runs().begin() + runIndex;
auto start = SkTMax(run->clusterRange().start, fClusterRange.start);
auto end = SkTMin(run->clusterRange().end, fClusterRange.end);
auto ghosts = SkTMin(run->clusterRange().end, fGhostClusterRange.end);
auto start = std::max(run->clusterRange().start, fClusterRange.start);
auto end = std::min(run->clusterRange().end, fClusterRange.end);
auto ghosts = std::min(run->clusterRange().end, fGhostClusterRange.end);
if (run->leftToRight() != reverse) {
for (auto index = start; index < ghosts; ++index) {

View File

@ -31,7 +31,7 @@ void TextWrapper::lookAhead(SkScalar maxWidth, Cluster* endOfClusters) {
if (cluster->isWhitespaces()) {
// It's the end of the word
fClusters.extend(cluster);
fMinIntrinsicWidth = SkTMax(fMinIntrinsicWidth, getClustersTrimmedWidth());
fMinIntrinsicWidth = std::max(fMinIntrinsicWidth, getClustersTrimmedWidth());
fWords.extend(fClusters);
break;
}
@ -46,7 +46,7 @@ void TextWrapper::lookAhead(SkScalar maxWidth, Cluster* endOfClusters) {
}
if (nextWordLength > maxWidth) {
// If the word is too long we can break it right now and hope it's enough
fMinIntrinsicWidth = SkTMax(fMinIntrinsicWidth, nextWordLength);
fMinIntrinsicWidth = std::max(fMinIntrinsicWidth, nextWordLength);
fTooLongWord = true;
}
@ -62,7 +62,7 @@ void TextWrapper::lookAhead(SkScalar maxWidth, Cluster* endOfClusters) {
// Keep adding clusters/words
if (fClusters.endOfWord()) {
fMinIntrinsicWidth = SkTMax(fMinIntrinsicWidth, getClustersTrimmedWidth());
fMinIntrinsicWidth = std::max(fMinIntrinsicWidth, getClustersTrimmedWidth());
fWords.extend(fClusters);
}
@ -289,15 +289,15 @@ void TextWrapper::breakTextIntoLines(ParagraphImpl* parent,
while (cluster != end || cluster->endPos() < end->endPos()) {
fExceededMaxLines = true;
if (cluster->isHardBreak()) {
fMaxIntrinsicWidth = SkTMax(fMaxIntrinsicWidth, softLineMaxIntrinsicWidth);
fMaxIntrinsicWidth = std::max(fMaxIntrinsicWidth, softLineMaxIntrinsicWidth);
softLineMaxIntrinsicWidth = 0;
fMinIntrinsicWidth = SkTMax(fMinIntrinsicWidth, lastWordLength);
fMinIntrinsicWidth = std::max(fMinIntrinsicWidth, lastWordLength);
lastWordLength = 0;
} else if (cluster->isWhitespaces()) {
SkASSERT(cluster->isWhitespaces());
softLineMaxIntrinsicWidth += cluster->width();
fMinIntrinsicWidth = SkTMax(fMinIntrinsicWidth, lastWordLength);
fMinIntrinsicWidth = std::max(fMinIntrinsicWidth, lastWordLength);
lastWordLength = 0;
} else {
softLineMaxIntrinsicWidth += cluster->width();
@ -305,10 +305,10 @@ void TextWrapper::breakTextIntoLines(ParagraphImpl* parent,
}
++cluster;
}
fMinIntrinsicWidth = SkTMax(fMinIntrinsicWidth, lastWordLength);
fMaxIntrinsicWidth = SkTMax(fMaxIntrinsicWidth, softLineMaxIntrinsicWidth);
fMinIntrinsicWidth = std::max(fMinIntrinsicWidth, lastWordLength);
fMaxIntrinsicWidth = std::max(fMaxIntrinsicWidth, softLineMaxIntrinsicWidth);
// In case we could not place a single cluster on the line
fHeight = SkTMax(fHeight, fEndLine.metrics().height());
fHeight = std::max(fHeight, fEndLine.metrics().height());
}
if (fHardLineBreak) {

View File

@ -100,9 +100,9 @@ void RunHandler::beginLine() {
void RunHandler::runInfo(const SkShaper::RunHandler::RunInfo& info) {
SkFontMetrics metrics;
info.fFont.getMetrics(&metrics);
fMaxRunAscent = SkTMin(fMaxRunAscent, metrics.fAscent);
fMaxRunDescent = SkTMax(fMaxRunDescent, metrics.fDescent);
fMaxRunLeading = SkTMax(fMaxRunLeading, metrics.fLeading);
fMaxRunAscent = std::min(fMaxRunAscent, metrics.fAscent);
fMaxRunDescent = std::max(fMaxRunDescent, metrics.fDescent);
fMaxRunLeading = std::max(fMaxRunLeading, metrics.fLeading);
}
void RunHandler::commitRunInfo() {
@ -154,7 +154,7 @@ void RunHandler::commitRunBuffer(const RunInfo& info) {
fClusters[i] -= fClusterOffset;
}
fCurrentPosition += info.fAdvance;
fTextOffset = SkTMax(fTextOffset, info.utf8Range.end());
fTextOffset = std::max(fTextOffset, info.utf8Range.end());
}
void RunHandler::commitLine() {

View File

@ -191,9 +191,9 @@ void SkTextBlobBuilderRunHandler::beginLine() {
void SkTextBlobBuilderRunHandler::runInfo(const RunInfo& info) {
SkFontMetrics metrics;
info.fFont.getMetrics(&metrics);
fMaxRunAscent = SkTMin(fMaxRunAscent, metrics.fAscent);
fMaxRunDescent = SkTMax(fMaxRunDescent, metrics.fDescent);
fMaxRunLeading = SkTMax(fMaxRunLeading, metrics.fLeading);
fMaxRunAscent = std::min(fMaxRunAscent, metrics.fAscent);
fMaxRunDescent = std::max(fMaxRunDescent, metrics.fDescent);
fMaxRunLeading = std::max(fMaxRunLeading, metrics.fLeading);
}
void SkTextBlobBuilderRunHandler::commitRunInfo() {

View File

@ -197,7 +197,7 @@ protected:
} else if (-2 == ptClick->fIndex) {
SkScalar yDiff = click->fCurr.fY - click->fPrev.fY;
fTexScale += yDiff / 10.0f;
fTexScale = SkTMax(0.1f, SkTMin(20.f, fTexScale));
fTexScale = std::max(0.1f, std::min(20.f, fTexScale));
}
return true;
}

View File

@ -393,7 +393,7 @@ static void add_to_map(SkScalar coverage, int x, int y, uint8_t* distanceMap, in
}
SkASSERT(x < w);
SkASSERT(y < h);
distanceMap[y * w + x] = SkTMax(distanceMap[y * w + x], (uint8_t) byteCoverage);
distanceMap[y * w + x] = std::max(distanceMap[y * w + x], (uint8_t) byteCoverage);
}
static void filter_coverage(const uint8_t* map, int len, uint8_t min, uint8_t max,
@ -918,7 +918,7 @@ public:
bool scaleToFit() {
SkMatrix matrix;
SkRect bounds = fPath.getBounds();
SkScalar scale = SkTMin(this->width() / bounds.width(), this->height() / bounds.height())
SkScalar scale = std::min(this->width() / bounds.width(), this->height() / bounds.height())
* 0.8f;
matrix.setScale(scale, scale, bounds.centerX(), bounds.centerY());
fPath.transform(matrix);
@ -1226,16 +1226,16 @@ public:
return -radius;
}
rotated.fY /= SkScalarSqrt(lenSq);
return SkTMax(-radius, SkTMin(radius, rotated.fY));
return std::max(-radius, std::min(radius, rotated.fY));
}
// given a line, compute the interior and exterior gradient coverage
bool coverage(SkPoint s, SkPoint e, uint8_t* distanceMap, int w, int h) {
SkScalar radius = fWidthControl.fValLo;
int minX = SkTMax(0, (int) (SkTMin(s.fX, e.fX) - radius));
int minY = SkTMax(0, (int) (SkTMin(s.fY, e.fY) - radius));
int maxX = SkTMin(w, (int) (SkTMax(s.fX, e.fX) + radius) + 1);
int maxY = SkTMin(h, (int) (SkTMax(s.fY, e.fY) + radius) + 1);
int minX = std::max(0, (int) (std::min(s.fX, e.fX) - radius));
int minY = std::max(0, (int) (std::min(s.fY, e.fY) - radius));
int maxX = std::min(w, (int) (std::max(s.fX, e.fX) + radius) + 1);
int maxY = std::min(h, (int) (std::max(s.fY, e.fY) + radius) + 1);
for (int y = minY; y < maxY; ++y) {
for (int x = minX; x < maxX; ++x) {
SkScalar ptToLineDist = pt_to_line(s, e, x, y);
@ -1571,7 +1571,7 @@ public:
}
static SkScalar MapScreenYtoValue(int y, const UniControl& control) {
return SkTMin(1.f, SkTMax(0.f,
return std::min(1.f, std::max(0.f,
SkIntToScalar(y) - control.fBounds.fTop) / control.fBounds.height())
* (control.fMax - control.fMin) + control.fMin;
}
@ -1615,9 +1615,9 @@ public:
case MyClick::kFilterControl: {
SkScalar val = MapScreenYtoValue(click->fCurr.fY, fFilterControl);
if (val - fFilterControl.fValLo < fFilterControl.fValHi - val) {
fFilterControl.fValLo = SkTMax(0.f, val);
fFilterControl.fValLo = std::max(0.f, val);
} else {
fFilterControl.fValHi = SkTMin(255.f, val);
fFilterControl.fValHi = std::min(255.f, val);
}
} break;
case MyClick::kResControl:

View File

@ -191,55 +191,55 @@ class ShadowsView : public Sample {
paint.setColor(SK_ColorWHITE);
canvas->translate(200, 90);
zPlaneParams.fZ = SkTMax(1.0f, 2 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 2 + fZDelta);
this->drawShadowedPath(canvas, fRRPath, zPlaneParams, paint, fAnimAlpha*kAmbientAlpha,
lightPos, kLightWidth, fAnimAlpha*kSpotAlpha);
paint.setColor(SK_ColorRED);
canvas->translate(250, 0);
zPlaneParams.fZ = SkTMax(1.0f, 8 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 8 + fZDelta);
this->drawShadowedPath(canvas, fRectPath, zPlaneParams, paint, fAnimAlpha*kAmbientAlpha,
lightPos, kLightWidth, fAnimAlpha*kSpotAlpha);
paint.setColor(SK_ColorBLUE);
canvas->translate(-250, 110);
zPlaneParams.fZ = SkTMax(1.0f, 12 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 12 + fZDelta);
this->drawShadowedPath(canvas, fCirclePath, zPlaneParams, paint, fAnimAlpha*kAmbientAlpha,
lightPos, kLightWidth, fAnimAlpha*0.5f);
paint.setColor(SK_ColorGREEN);
canvas->translate(250, 0);
zPlaneParams.fZ = SkTMax(1.0f, 64 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 64 + fZDelta);
this->drawShadowedPath(canvas, fRRPath, zPlaneParams, paint, fAnimAlpha*kAmbientAlpha,
lightPos, kLightWidth, fAnimAlpha*kSpotAlpha);
paint.setColor(SK_ColorYELLOW);
canvas->translate(-250, 110);
zPlaneParams.fZ = SkTMax(1.0f, 8 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 8 + fZDelta);
this->drawShadowedPath(canvas, fFunkyRRPath, zPlaneParams, paint, fAnimAlpha*kAmbientAlpha,
lightPos, kLightWidth, fAnimAlpha*kSpotAlpha);
paint.setColor(SK_ColorCYAN);
canvas->translate(250, 0);
zPlaneParams.fZ = SkTMax(1.0f, 16 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 16 + fZDelta);
this->drawShadowedPath(canvas, fCubicPath, zPlaneParams, paint, fAnimAlpha*kAmbientAlpha,
lightPos, kLightWidth, fAnimAlpha*kSpotAlpha);
paint.setColor(SK_ColorWHITE);
canvas->translate(250, -180);
zPlaneParams.fZ = SkTMax(1.0f, 8 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 8 + fZDelta);
this->drawShadowedPath(canvas, fStarPath, zPlaneParams, paint,
kAmbientAlpha, lightPos, kLightWidth, kSpotAlpha);
paint.setColor(SK_ColorWHITE);
canvas->translate(150, 0);
zPlaneParams.fZ = SkTMax(1.0f, 2 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 2 + fZDelta);
this->drawShadowedPath(canvas, fNotchPath, zPlaneParams, paint,
kAmbientAlpha, lightPos, kLightWidth, kSpotAlpha);
paint.setColor(SK_ColorWHITE);
canvas->translate(200, 0);
zPlaneParams.fZ = SkTMax(1.0f, 16 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 16 + fZDelta);
this->drawShadowedPath(canvas, fTabPath, zPlaneParams, paint,
kAmbientAlpha, lightPos, kLightWidth, kSpotAlpha);
@ -251,7 +251,7 @@ class ShadowsView : public Sample {
paint.setColor(SK_ColorMAGENTA);
canvas->translate(-725, 240);
zPlaneParams.fZ = SkTMax(1.0f, 32 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 32 + fZDelta);
this->drawShadowedPath(canvas, tmpPath, zPlaneParams, paint, .1f,
lightPos, kLightWidth, .5f);
@ -261,7 +261,7 @@ class ShadowsView : public Sample {
Op(fSquareRRectPath, tmpClipPathBug, kIntersect_SkPathOp, &tmpPath);
canvas->translate(250, 0);
zPlaneParams.fZ = SkTMax(1.0f, 32 + fZDelta);
zPlaneParams.fZ = std::max(1.0f, 32 + fZDelta);
this->drawShadowedPath(canvas, tmpPath, zPlaneParams, paint, .1f,
lightPos, kLightWidth, .5f);
@ -281,7 +281,7 @@ class ShadowsView : public Sample {
SkScalar radians = SkDegreesToRadians(fAnimAngle);
zPlaneParams = SkPoint3::Make(0,
SkScalarSin(radians),
SkTMax(1.0f, 16 + fZDelta) - SkScalarSin(radians)*pivot.fY);
std::max(1.0f, 16 + fZDelta) - SkScalarSin(radians)*pivot.fY);
this->drawShadowedPath(canvas, fWideRectPath, zPlaneParams, paint, .1f,
lightPos, kLightWidth, .5f);
@ -297,7 +297,7 @@ class ShadowsView : public Sample {
canvas->setMatrix(persp);
zPlaneParams = SkPoint3::Make(-SkScalarSin(radians),
0,
SkTMax(1.0f, 32 + fZDelta) + SkScalarSin(radians)*pivot.fX);
std::max(1.0f, 32 + fZDelta) + SkScalarSin(radians)*pivot.fX);
this->drawShadowedPath(canvas, fWideOvalPath, zPlaneParams, paint, .1f,
lightPos, kLightWidth, .5f);
@ -312,7 +312,7 @@ class ShadowsView : public Sample {
canvas->setMatrix(persp);
zPlaneParams = SkPoint3::Make(-SkScalarSin(radians),
0,
SkTMax(1.0f, 8 + fZDelta) + SkScalarSin(radians)*pivot.fX);
std::max(1.0f, 8 + fZDelta) + SkScalarSin(radians)*pivot.fX);
this->drawShadowedPath(canvas, fStarPath, zPlaneParams, paint, .1f,
lightPos, kLightWidth, .5f);
}

View File

@ -191,7 +191,7 @@ class ChineseZoomView : public Sample {
auto paragraphLength = kParagraphLength;
SkScalar y = 0;
while (paragraphLength - 45 > 0) {
auto currentLineLength = SkTMin(45, paragraphLength - 45);
auto currentLineLength = std::min(45, paragraphLength - 45);
this->createRandomLine(glyphs, currentLineLength);
ToolUtils::add_to_text_blob_w_len(&builder,

View File

@ -115,14 +115,14 @@ void PathText::Glyph::init(SkRandom& rand, const SkPath& path) {
}
void PathText::Glyph::reset(SkRandom& rand, int w, int h) {
int screensize = SkTMax(w, h);
int screensize = std::max(w, h);
const SkRect& bounds = fPath.getBounds();
SkScalar t;
fPosition = {rand.nextF() * w, rand.nextF() * h};
t = pow(rand.nextF(), 100);
fZoom = ((1 - t) * screensize / 50 + t * screensize / 3) /
SkTMax(bounds.width(), bounds.height());
std::max(bounds.width(), bounds.height());
fSpin = rand.nextF() * 360;
fMidpt = {bounds.centerX(), bounds.centerY()};
}
@ -143,7 +143,7 @@ public:
}
void reset() override {
const SkScalar screensize = static_cast<SkScalar>(SkTMax(this->width(), this->height()));
const SkScalar screensize = static_cast<SkScalar>(std::max(this->width(), this->height()));
this->INHERITED::reset();
for (auto& v : fVelocities) {
@ -356,7 +356,7 @@ private:
};
void WavyPathText::Waves::reset(SkRandom& rand, int w, int h) {
const double pixelsPerMeter = 0.06 * SkTMax(w, h);
const double pixelsPerMeter = 0.06 * std::max(w, h);
const double medianWavelength = 8 * pixelsPerMeter;
const double medianWaveAmplitude = 0.05 * 4 * pixelsPerMeter;
const double gravity = 9.8 * pixelsPerMeter;

View File

@ -218,7 +218,7 @@ protected:
fText = "";
break;
case '-':
fTextSize = SkTMax(1.0f, fTextSize - 1);
fTextSize = std::max(1.0f, fTextSize - 1);
break;
case '+':
case '=':
@ -478,7 +478,7 @@ protected:
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(width);
SkPath path;
SkScalar maxSide = SkTMax(rect.width(), rect.height()) / 2;
SkScalar maxSide = std::max(rect.width(), rect.height()) / 2;
SkPoint center = { rect.fLeft + maxSide, rect.fTop + maxSide };
path.addCircle(center.fX, center.fY, maxSide);
canvas->drawPath(path, paint);
@ -793,13 +793,13 @@ protected:
}
#ifdef SK_DEBUG
else if (index == (int) SK_ARRAY_COUNT(fPts) + 3) {
gDebugStrokerError = SkTMax(FLT_EPSILON, MapScreenYtoValue(click->fCurr.fY,
gDebugStrokerError = std::max(FLT_EPSILON, MapScreenYtoValue(click->fCurr.fY,
fErrorControl, kStrokerErrorMin, kStrokerErrorMax));
gDebugStrokerErrorSet = true;
}
#endif
else if (index == (int) SK_ARRAY_COUNT(fPts) + 4) {
fWidth = SkTMax(FLT_EPSILON, MapScreenYtoValue(click->fCurr.fY, fWidthControl,
fWidth = std::max(FLT_EPSILON, MapScreenYtoValue(click->fCurr.fY, fWidthControl,
kWidthMin, kWidthMax));
fAnimate = fWidth <= kWidthMin;
}

View File

@ -74,11 +74,11 @@ protected:
handled = true;
break;
case '>':
fZIndex = SkTMin(9, fZIndex+1);
fZIndex = std::min(9, fZIndex+1);
handled = true;
break;
case '<':
fZIndex = SkTMax(0, fZIndex-1);
fZIndex = std::max(0, fZIndex-1);
handled = true;
break;
default:
@ -115,9 +115,9 @@ protected:
if (paint.getColor() != SK_ColorBLACK) {
SkColor color = paint.getColor();
uint8_t max = SkTMax(SkTMax(SkColorGetR(color), SkColorGetG(color)),
uint8_t max = std::max(std::max(SkColorGetR(color), SkColorGetG(color)),
SkColorGetB(color));
uint8_t min = SkTMin(SkTMin(SkColorGetR(color), SkColorGetG(color)),
uint8_t min = std::min(std::min(SkColorGetR(color), SkColorGetG(color)),
SkColorGetB(color));
SkScalar luminance = 0.5f*(max + min) / 255.f;
SkScalar alpha = (.6 - .4*luminance)*luminance*luminance + 0.3f;

View File

@ -177,7 +177,7 @@ protected:
SkPaint paint;
paint.setColor(SK_ColorGREEN);
paint.setAntiAlias(true);
SkPoint3 zPlaneParams = SkPoint3::Make(0, 0, SkTMax(1.0f, kHeight + fZDelta));
SkPoint3 zPlaneParams = SkPoint3::Make(0, 0, std::max(1.0f, kHeight + fZDelta));
// convex paths
for (auto& m : matrices) {
@ -203,7 +203,7 @@ protected:
canvas->translate(dx, 0);
x += dx;
dy = SkTMax(dy, postMBounds.height() + kPad + kHeight);
dy = std::max(dy, postMBounds.height() + kPad + kHeight);
}
}
}
@ -229,7 +229,7 @@ protected:
canvas->translate(dx, 0);
x += dx;
dy = SkTMax(dy, postMBounds.height() + kPad + kHeight);
dy = std::max(dy, postMBounds.height() + kPad + kHeight);
}
}

View File

@ -67,12 +67,12 @@ class TextureUploadSample : public Sample {
fDrawTexturesToScreen = !fDrawTexturesToScreen;
return true;
} else if ('>' == uni) {
fTileSize = SkTMin(kMaxTileSize, 2*fTileSize);
fTileSize = std::min(kMaxTileSize, 2*fTileSize);
fTileRows = kMaxTileSize/fTileSize;
fTileCols = kMaxTileSize/fTileSize;
fCachedContext = nullptr;
} else if ('<' == uni) {
fTileSize = SkTMax(kMinTileSize, fTileSize/2);
fTileSize = std::max(kMinTileSize, fTileSize/2);
fTileRows = kMaxTileSize/fTileSize;
fTileCols = kMaxTileSize/fTileSize;
fCachedContext = nullptr;

View File

@ -2164,7 +2164,7 @@
"stdout": "point 0: (-10,-10)\\npoint 1: (10,10)\\n"
},
"SkPath_getPoints": {
"code": "void draw(SkCanvas* canvas) {\n auto debugster = [](const char* prefix, const SkPath& path, SkPoint* points, int max) -> void {\n int count = path.getPoints(points, max);\n SkDebugf(\"%s point count: %d \", prefix, count);\n for (int i = 0; i < SkTMin(count, max) && points; ++i) {\n SkDebugf(\"(%1.8g,%1.8g) \", points[i].fX, points[i].fY);\n }\n SkDebugf(\"\\n\");\n };\n SkPath path;\n path.lineTo(20, 20);\n path.lineTo(-10, -10);\n SkPoint points[3];\n debugster(\"no points\", path, nullptr, 0);\n debugster(\"zero max\", path, points, 0);\n debugster(\"too small\", path, points, 2);\n debugster(\"just right\", path, points, path.countPoints());\n}\n",
"code": "void draw(SkCanvas* canvas) {\n auto debugster = [](const char* prefix, const SkPath& path, SkPoint* points, int max) -> void {\n int count = path.getPoints(points, max);\n SkDebugf(\"%s point count: %d \", prefix, count);\n for (int i = 0; i < std::min(count, max) && points; ++i) {\n SkDebugf(\"(%1.8g,%1.8g) \", points[i].fX, points[i].fY);\n }\n SkDebugf(\"\\n\");\n };\n SkPath path;\n path.lineTo(20, 20);\n path.lineTo(-10, -10);\n SkPoint points[3];\n debugster(\"no points\", path, nullptr, 0);\n debugster(\"zero max\", path, points, 0);\n debugster(\"too small\", path, points, 2);\n debugster(\"just right\", path, points, path.countPoints());\n}\n",
"hash": "9bc86efda08cbcd9c6f7c5f220294a24",
"file": "SkPath_Reference",
"name": "SkPath::getPoints",
@ -2178,7 +2178,7 @@
"stdout": "mask quad set\\n"
},
"SkPath_getVerbs": {
"code": "void draw(SkCanvas* canvas) {\n auto debugster = [](const char* prefix, const SkPath& path, uint8_t* verbs, int max) -> void {\n int count = path.getVerbs(verbs, max);\n SkDebugf(\"%s verb count: %d \", prefix, count);\n const char* verbStr[] = { \"move\", \"line\", \"quad\", \"conic\", \"cubic\", \"close\" };\n for (int i = 0; i < SkTMin(count, max) && verbs; ++i) {\n SkDebugf(\"%s \", verbStr[verbs[i]]);\n }\n SkDebugf(\"\\n\");\n };\n SkPath path;\n path.lineTo(20, 20);\n path.lineTo(-10, -10);\n uint8_t verbs[3];\n debugster(\"no verbs\", path, nullptr, 0);\n debugster(\"zero max\", path, verbs, 0);\n debugster(\"too small\", path, verbs, 2);\n debugster(\"just right\", path, verbs, path.countVerbs());\n}\n",
"code": "void draw(SkCanvas* canvas) {\n auto debugster = [](const char* prefix, const SkPath& path, uint8_t* verbs, int max) -> void {\n int count = path.getVerbs(verbs, max);\n SkDebugf(\"%s verb count: %d \", prefix, count);\n const char* verbStr[] = { \"move\", \"line\", \"quad\", \"conic\", \"cubic\", \"close\" };\n for (int i = 0; i < std::min(count, max) && verbs; ++i) {\n SkDebugf(\"%s \", verbStr[verbs[i]]);\n }\n SkDebugf(\"\\n\");\n };\n SkPath path;\n path.lineTo(20, 20);\n path.lineTo(-10, -10);\n uint8_t verbs[3];\n debugster(\"no verbs\", path, nullptr, 0);\n debugster(\"zero max\", path, verbs, 0);\n debugster(\"too small\", path, verbs, 2);\n debugster(\"just right\", path, verbs, path.countVerbs());\n}\n",
"hash": "2ec66880966a6133ddd9331ce7323438",
"file": "SkPath_Reference",
"name": "SkPath::getVerbs",
@ -3982,7 +3982,7 @@
"name": "Image_Info_Color_Type_RGB_888"
},
"Illustrations_Path_Arc": {
"code": "struct data {\n const char* name;\n char super;\n int yn[10];\n};\nconst data dataSet[] = {\n{ \"arcTo sweep\", '1', {1, 3, 1, 0, 0, 0, 0, 1, 0, 0 }},\n{ \"drawArc\", 0, {1, -1, 1, 1, 1, 1, 1, 0, 0, 0 }},\n{ \"addArc\", 0, {1, 1, 1, 4, 0, 1, 1, 1, 0, 0 }},\n{ \"arcTo tangents\", '4', {0, 0, 0, 0, 0, 0, 0, 1, 1, 0 }},\n{ \"arcTo radii\", '5', {1, 0, 1, 0, 0, 0, 0, 1, 1, 0 }},\n{ \"conicTo\", 0, {1, 1, 0, 0, 0, 0, 0, 1, 1, 1 }}\n};\n#define __degree_symbol__ \"\\xC2\" \"\\xB0\"\nconst char* headers[] = {\n \"Oval part\",\n \"force moveTo\",\n \"can draw 180\" __degree_symbol__,\n \"can draw 360\" __degree_symbol__,\n \"can draw greater than 360\" __degree_symbol__,\n \"ignored if radius is zero\",\n \"ignored if sweep is zero\",\n \"requires Path\",\n \"describes rotation\",\n \"describes perspective\",\n};\nconst char* yna[] = {\n \"n/a\",\n \"no\",\n \"yes\"\n};\n\nvoid draw(SkCanvas* canvas) {\n SkPaint lp;\n lp.setAntiAlias(true);\n SkPaint tp(lp);\n SkPaint sp(tp);\n SkPaint bp(tp);\n bp.setFakeBoldText(true);\n sp.setTextSize(10);\n lp.setColor(SK_ColorGRAY);\n canvas->translate(0, 32);\n const int tl = 115;\n for (unsigned col = 0; col <= SK_ARRAY_COUNT(headers); ++col) {\n canvas->drawLine(tl + col * 35, 100, tl + col * 35, 250, lp);\n if (0 == col) {\n continue;\n }\n canvas->drawLine( tl + col * 35, 100, tl + 100 + col * 35, 0, lp);\n SkPoint pts[] = {{tl - 10.f + col * 35, 98}, {tl + 90.f + col * 35, -2}};\n SkVector v = pts[1] - pts[0];\n v.normalize();\n SkMatrix matrix;\n matrix.setSinCos(v.fY, v.fX, pts[0].fX, pts[0].fY);\n canvas->save();\n canvas->concat(matrix);\n canvas->drawText(headers[col -1], strlen(headers[col -1]), pts[0].fX, pts[0].fY, bp);\n canvas->restore();\n }\n for (unsigned row = 0; row <= SK_ARRAY_COUNT(dataSet); ++row) {\n if (0 == row) {\n canvas->drawLine(tl, 100, tl + 350, 100, lp);\n } else {\n canvas->drawLine(5, 100 + row * 25, tl + 350, 100 + row * 25, lp);\n }\n if (row == SK_ARRAY_COUNT(dataSet)) {\n break;\n }\n canvas->drawString(dataSet[row].name, 5, 117 + row * 25, bp);\n if (dataSet[row].super) {\n SkScalar width = bp.measureText(dataSet[row].name, strlen(dataSet[row].name));\n canvas->drawText(&dataSet[row].super, 1, 8 + width, 112 + row * 25, sp);\n }\n for (unsigned col = 0; col < SK_ARRAY_COUNT(headers); ++col) {\n int val = dataSet[row].yn[col];\n canvas->drawString(yna[SkTMin(2, val + 1)], tl + 5 + col * 35, 117 + row * 25, tp);\n if (val > 1) {\n char supe = '0' + val - 1;\n canvas->drawText(&supe, 1, tl + 25 + col * 35, 112 + row * 25, sp);\n }\n }\n }\n}\n",
"code": "struct data {\n const char* name;\n char super;\n int yn[10];\n};\nconst data dataSet[] = {\n{ \"arcTo sweep\", '1', {1, 3, 1, 0, 0, 0, 0, 1, 0, 0 }},\n{ \"drawArc\", 0, {1, -1, 1, 1, 1, 1, 1, 0, 0, 0 }},\n{ \"addArc\", 0, {1, 1, 1, 4, 0, 1, 1, 1, 0, 0 }},\n{ \"arcTo tangents\", '4', {0, 0, 0, 0, 0, 0, 0, 1, 1, 0 }},\n{ \"arcTo radii\", '5', {1, 0, 1, 0, 0, 0, 0, 1, 1, 0 }},\n{ \"conicTo\", 0, {1, 1, 0, 0, 0, 0, 0, 1, 1, 1 }}\n};\n#define __degree_symbol__ \"\\xC2\" \"\\xB0\"\nconst char* headers[] = {\n \"Oval part\",\n \"force moveTo\",\n \"can draw 180\" __degree_symbol__,\n \"can draw 360\" __degree_symbol__,\n \"can draw greater than 360\" __degree_symbol__,\n \"ignored if radius is zero\",\n \"ignored if sweep is zero\",\n \"requires Path\",\n \"describes rotation\",\n \"describes perspective\",\n};\nconst char* yna[] = {\n \"n/a\",\n \"no\",\n \"yes\"\n};\n\nvoid draw(SkCanvas* canvas) {\n SkPaint lp;\n lp.setAntiAlias(true);\n SkPaint tp(lp);\n SkPaint sp(tp);\n SkPaint bp(tp);\n bp.setFakeBoldText(true);\n sp.setTextSize(10);\n lp.setColor(SK_ColorGRAY);\n canvas->translate(0, 32);\n const int tl = 115;\n for (unsigned col = 0; col <= SK_ARRAY_COUNT(headers); ++col) {\n canvas->drawLine(tl + col * 35, 100, tl + col * 35, 250, lp);\n if (0 == col) {\n continue;\n }\n canvas->drawLine( tl + col * 35, 100, tl + 100 + col * 35, 0, lp);\n SkPoint pts[] = {{tl - 10.f + col * 35, 98}, {tl + 90.f + col * 35, -2}};\n SkVector v = pts[1] - pts[0];\n v.normalize();\n SkMatrix matrix;\n matrix.setSinCos(v.fY, v.fX, pts[0].fX, pts[0].fY);\n canvas->save();\n canvas->concat(matrix);\n canvas->drawText(headers[col -1], strlen(headers[col -1]), pts[0].fX, pts[0].fY, bp);\n canvas->restore();\n }\n for (unsigned row = 0; row <= SK_ARRAY_COUNT(dataSet); ++row) {\n if (0 == row) {\n canvas->drawLine(tl, 100, tl + 350, 100, lp);\n } else {\n canvas->drawLine(5, 100 + row * 25, tl + 350, 100 + row * 25, lp);\n }\n if (row == SK_ARRAY_COUNT(dataSet)) {\n break;\n }\n canvas->drawString(dataSet[row].name, 5, 117 + row * 25, bp);\n if (dataSet[row].super) {\n SkScalar width = bp.measureText(dataSet[row].name, strlen(dataSet[row].name));\n canvas->drawText(&dataSet[row].super, 1, 8 + width, 112 + row * 25, sp);\n }\n for (unsigned col = 0; col < SK_ARRAY_COUNT(headers); ++col) {\n int val = dataSet[row].yn[col];\n canvas->drawString(yna[std::min(2, val + 1)], tl + 5 + col * 35, 117 + row * 25, tp);\n if (val > 1) {\n char supe = '0' + val - 1;\n canvas->drawText(&supe, 1, tl + 25 + col * 35, 112 + row * 25, sp);\n }\n }\n }\n}\n",
"width": 600,
"height": 300,
"hash": "e17e48e9d2182e9afc0f5d26b72c60f0",

View File

@ -62,8 +62,8 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat
scaledOutX = outX / sampleSize;
scaledOutY = outY / sampleSize;
// We need to be safe here because getSupportedSubset() may have modified the subset.
const int extraX = SkTMax(0, desiredSubset.width() - outX - subset.width());
const int extraY = SkTMax(0, desiredSubset.height() - outY - subset.height());
const int extraX = std::max(0, desiredSubset.width() - outX - subset.width());
const int extraY = std::max(0, desiredSubset.height() - outY - subset.height());
const int scaledExtraX = extraX / sampleSize;
const int scaledExtraY = extraY / sampleSize;
scaledOutWidth += scaledOutX + scaledExtraX;

View File

@ -35,16 +35,16 @@ enum SubsetType {
inline SubsetType adjust_subset_rect(const SkISize& imageDims, SkIRect* subset, int* outX,
int* outY) {
// These must be at least zero, we can't start decoding the image at a negative coordinate.
int left = SkTMax(0, subset->fLeft);
int top = SkTMax(0, subset->fTop);
int left = std::max(0, subset->fLeft);
int top = std::max(0, subset->fTop);
// If input offsets are less than zero, we decode to an offset location in the output bitmap.
*outX = left - subset->fLeft;
*outY = top - subset->fTop;
// Make sure we don't decode pixels past the edge of the image or past the edge of the subset.
int width = SkTMin(imageDims.width() - left, subset->width() - *outX);
int height = SkTMin(imageDims.height() - top, subset->height() - *outY);
int width = std::min(imageDims.width() - left, subset->width() - *outX);
int height = std::min(imageDims.height() - top, subset->height() - *outY);
if (width <= 0 || height <= 0) {
return SubsetType::kOutside_SubsetType;
}

View File

@ -176,7 +176,7 @@ void SkInternalAtlasTextTarget::addDrawOp(const GrClip& clip, std::unique_ptr<Gr
}
const GrCaps& caps = *this->context()->internal().grContext()->priv().caps();
op->finalizeForTextTarget(fColor, caps);
int n = SkTMin(kMaxBatchLookBack, fOps.count());
int n = std::min(kMaxBatchLookBack, fOps.count());
GrRecordingContext::Arenas arenas = this->arenas();
for (int i = 0; i < n; ++i) {

View File

@ -71,7 +71,7 @@ SkCodec::Result SkBmpRLECodec::onGetPixels(const SkImageInfo& dstInfo,
uint32_t maxColors = 1 << this->bitsPerPixel();
// Don't bother reading more than maxColors.
const uint32_t numColorsToRead =
fNumColors == 0 ? maxColors : SkTMin(fNumColors, maxColors);
fNumColors == 0 ? maxColors : std::min(fNumColors, maxColors);
// Read the color table from the stream
colorBytes = numColorsToRead * fBytesPerColor;
@ -479,7 +479,7 @@ int SkBmpRLECodec::decodeRLE(const SkImageInfo& dstInfo, void* dst, size_t dstRo
// If the first byte read is not a flag, it indicates the number of
// pixels to set in RLE mode.
const uint8_t numPixels = flag;
const int endX = SkTMin<int>(x + numPixels, width);
const int endX = std::min<int>(x + numPixels, width);
if (24 == this->bitsPerPixel()) {
// In RLE24, the second byte read is part of the pixel color.

View File

@ -71,7 +71,7 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
uint32_t maxColors = 1 << this->bitsPerPixel();
// Don't bother reading more than maxColors.
const uint32_t numColorsToRead =
fNumColors == 0 ? maxColors : SkTMin(fNumColors, maxColors);
fNumColors == 0 ? maxColors : std::min(fNumColors, maxColors);
// Read the color table from the stream
colorBytes = numColorsToRead * fBytesPerColor;

View File

@ -37,7 +37,7 @@ bool SkParseEncodedOrigin(const uint8_t* data, size_t data_length, SkEncodedOrig
// Tag (2 bytes), Datatype (2 bytes), Number of elements (4 bytes), Data (4 bytes)
const uint32_t kEntrySize = 12;
const auto max = SkTo<uint32_t>((data_length - offset - 2) / kEntrySize);
numEntries = SkTMin(numEntries, max);
numEntries = std::min(numEntries, max);
// Advance the data to the start of the entries.
data += offset + 2;

View File

@ -257,7 +257,7 @@ public:
data = SkData::MakeSubset(data.get(), 0, bytesRead);
}
} else {
const size_t alreadyBuffered = SkTMin(fStreamBuffer.bytesWritten() - offset, size);
const size_t alreadyBuffered = std::min(fStreamBuffer.bytesWritten() - offset, size);
if (alreadyBuffered > 0 &&
!fStreamBuffer.read(data->writable_data(), offset, alreadyBuffered)) {
return nullptr;
@ -301,7 +301,7 @@ private:
// Try to read at least 8192 bytes to avoid to many small reads.
const size_t kMinSizeToRead = 8192;
const size_t sizeRequested = newSize - fStreamBuffer.bytesWritten();
const size_t sizeToRead = SkTMax(kMinSizeToRead, sizeRequested);
const size_t sizeToRead = std::max(kMinSizeToRead, sizeRequested);
SkAutoSTMalloc<kMinSizeToRead, uint8> tempBuffer(sizeToRead);
const size_t bytesRead = fStream->read(tempBuffer.get(), sizeToRead);
if (bytesRead < sizeRequested) {
@ -360,7 +360,7 @@ public:
// This will allow read less than the requested "size", because the JPEG codec wants to
// handle also a partial JPEG file.
const size_t bytesToRead = SkTMin(sum, fStream->getLength()) - offset;
const size_t bytesToRead = std::min(sum, fStream->getLength()) - offset;
if (bytesToRead == 0) {
return nullptr;
}
@ -463,7 +463,7 @@ public:
}
// DNG SDK preserves the aspect ratio, so it only needs to know the longer dimension.
const int preferredSize = SkTMax(width, height);
const int preferredSize = std::max(width, height);
try {
// render() takes ownership of fHost, fInfo, fNegative and fDngStream when available.
std::unique_ptr<dng_host> host(fHost.release());
@ -494,7 +494,7 @@ public:
render.SetFinalPixelType(ttByte);
dng_point stage3_size = negative->Stage3Image()->Size();
render.SetMaximumSize(SkTMax(stage3_size.h, stage3_size.v));
render.SetMaximumSize(std::max(stage3_size.h, stage3_size.v));
return render.Render();
} catch (...) {
@ -759,7 +759,7 @@ SkISize SkRawCodec::onGetScaledDimensions(float desiredScale) const {
}
// Limits the minimum size to be 80 on the short edge.
const float shortEdge = static_cast<float>(SkTMin(dim.fWidth, dim.fHeight));
const float shortEdge = static_cast<float>(std::min(dim.fWidth, dim.fHeight));
if (desiredScale < 80.f / shortEdge) {
desiredScale = 80.f / shortEdge;
}
@ -778,8 +778,8 @@ SkISize SkRawCodec::onGetScaledDimensions(float desiredScale) const {
bool SkRawCodec::onDimensionsSupported(const SkISize& dim) {
const SkISize fullDim = this->dimensions();
const float fullShortEdge = static_cast<float>(SkTMin(fullDim.fWidth, fullDim.fHeight));
const float shortEdge = static_cast<float>(SkTMin(dim.fWidth, dim.fHeight));
const float fullShortEdge = static_cast<float>(std::min(fullDim.fWidth, fullDim.fHeight));
const float shortEdge = static_cast<float>(std::min(dim.fWidth, dim.fHeight));
SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEdge / shortEdge));
SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge / shortEdge));

View File

@ -20,8 +20,8 @@ protected:
SkISize dim = this->dimensions();
// SkCodec treats zero dimensional images as errors, so the minimum size
// that we will recommend is 1x1.
dim.fWidth = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fWidth));
dim.fHeight = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fHeight));
dim.fWidth = std::max(1, SkScalarRoundToInt(desiredScale * dim.fWidth));
dim.fHeight = std::max(1, SkScalarRoundToInt(desiredScale * dim.fHeight));
return dim;
}

View File

@ -45,7 +45,7 @@ bool SkStreamBuffer::buffer(size_t totalBytesToBuffer) {
if (fHasLengthAndPosition) {
const size_t remaining = fStream->getLength() - fStream->getPosition() + fTrulyBuffered;
fBytesBuffered = SkTMin(remaining, totalBytesToBuffer);
fBytesBuffered = std::min(remaining, totalBytesToBuffer);
} else {
const size_t extraBytes = totalBytesToBuffer - fBytesBuffered;
const size_t bytesBuffered = fStream->read(fBuffer + fBytesBuffered, extraBytes);

View File

@ -397,8 +397,8 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
return kSuccess;
}
int minXOffset = SkTMin(dstX, subset.x());
int minYOffset = SkTMin(dstY, subset.y());
int minXOffset = std::min(dstX, subset.x());
int minYOffset = std::min(dstY, subset.y());
dstX -= minXOffset;
dstY -= minYOffset;
frameRect.offset(-minXOffset, -minYOffset);

View File

@ -383,10 +383,10 @@ bool SkAnalyticQuadraticEdge::updateQuadratic() {
SkFDot6 diffY = SkFixedToFDot6(newy - fSnappedY);
slope = diffY ? quick_div(SkFixedToFDot6(newx - fSnappedX), diffY)
: SK_MaxS32;
newSnappedY = SkTMin<SkFixed>(fQEdge.fQLastY, SkFixedRoundToFixed(newy));
newSnappedY = std::min<SkFixed>(fQEdge.fQLastY, SkFixedRoundToFixed(newy));
newSnappedX = newx - SkFixedMul(slope, newy - newSnappedY);
} else {
newSnappedY = SkTMin(fQEdge.fQLastY, SnapY(newy));
newSnappedY = std::min(fQEdge.fQLastY, SnapY(newy));
newSnappedX = newx;
SkFDot6 diffY = SkFixedToFDot6(newSnappedY - fSnappedY);
slope = diffY ? quick_div(SkFixedToFDot6(newx - fSnappedX), diffY)

View File

@ -185,10 +185,10 @@ bool SkComputeBlurredRRectParams(const SkRRect& srcRRect, const SkRRect& devRRec
const SkVector& devRadiiLR = devRRect.radii(SkRRect::kLowerRight_Corner);
const SkVector& devRadiiLL = devRRect.radii(SkRRect::kLowerLeft_Corner);
const int devLeft = SkScalarCeilToInt(SkTMax<SkScalar>(devRadiiUL.fX, devRadiiLL.fX));
const int devTop = SkScalarCeilToInt(SkTMax<SkScalar>(devRadiiUL.fY, devRadiiUR.fY));
const int devRight = SkScalarCeilToInt(SkTMax<SkScalar>(devRadiiUR.fX, devRadiiLR.fX));
const int devBot = SkScalarCeilToInt(SkTMax<SkScalar>(devRadiiLL.fY, devRadiiLR.fY));
const int devLeft = SkScalarCeilToInt(std::max<SkScalar>(devRadiiUL.fX, devRadiiLL.fX));
const int devTop = SkScalarCeilToInt(std::max<SkScalar>(devRadiiUL.fY, devRadiiUR.fY));
const int devRight = SkScalarCeilToInt(std::max<SkScalar>(devRadiiUR.fX, devRadiiLR.fX));
const int devBot = SkScalarCeilToInt(std::max<SkScalar>(devRadiiLL.fY, devRadiiLR.fY));
// This is a conservative check for nine-patchability
if (devOrig.fLeft + devLeft + devBlurRadius >= devOrig.fRight - devRight - devBlurRadius ||
@ -201,10 +201,10 @@ bool SkComputeBlurredRRectParams(const SkRRect& srcRRect, const SkRRect& devRRec
const SkVector& srcRadiiLR = srcRRect.radii(SkRRect::kLowerRight_Corner);
const SkVector& srcRadiiLL = srcRRect.radii(SkRRect::kLowerLeft_Corner);
const SkScalar srcLeft = SkTMax<SkScalar>(srcRadiiUL.fX, srcRadiiLL.fX);
const SkScalar srcTop = SkTMax<SkScalar>(srcRadiiUL.fY, srcRadiiUR.fY);
const SkScalar srcRight = SkTMax<SkScalar>(srcRadiiUR.fX, srcRadiiLR.fX);
const SkScalar srcBot = SkTMax<SkScalar>(srcRadiiLL.fY, srcRadiiLR.fY);
const SkScalar srcLeft = std::max<SkScalar>(srcRadiiUL.fX, srcRadiiLL.fX);
const SkScalar srcTop = std::max<SkScalar>(srcRadiiUL.fY, srcRadiiUR.fY);
const SkScalar srcRight = std::max<SkScalar>(srcRadiiUR.fX, srcRadiiLR.fX);
const SkScalar srcBot = std::max<SkScalar>(srcRadiiLL.fY, srcRadiiLR.fY);
int newRRWidth = 2*devBlurRadius + devLeft + devRight + 1;
int newRRHeight = 2*devBlurRadius + devTop + devBot + 1;
@ -491,8 +491,8 @@ SkBlurMaskFilterImpl::filterRRectToNine(const SkRRect& rrect, const SkMatrix& ma
const SkVector& LR = rrect.radii(SkRRect::kLowerRight_Corner);
const SkVector& LL = rrect.radii(SkRRect::kLowerLeft_Corner);
const SkScalar leftUnstretched = SkTMax(UL.fX, LL.fX) + SkIntToScalar(2 * margin.fX);
const SkScalar rightUnstretched = SkTMax(UR.fX, LR.fX) + SkIntToScalar(2 * margin.fX);
const SkScalar leftUnstretched = std::max(UL.fX, LL.fX) + SkIntToScalar(2 * margin.fX);
const SkScalar rightUnstretched = std::max(UR.fX, LR.fX) + SkIntToScalar(2 * margin.fX);
// Extra space in the middle to ensure an unchanging piece for stretching. Use 3 to cover
// any fractional space on either side plus 1 for the part to stretch.
@ -504,8 +504,8 @@ SkBlurMaskFilterImpl::filterRRectToNine(const SkRRect& rrect, const SkMatrix& ma
return kUnimplemented_FilterReturn;
}
const SkScalar topUnstretched = SkTMax(UL.fY, UR.fY) + SkIntToScalar(2 * margin.fY);
const SkScalar bottomUnstretched = SkTMax(LL.fY, LR.fY) + SkIntToScalar(2 * margin.fY);
const SkScalar topUnstretched = std::max(UL.fY, UR.fY) + SkIntToScalar(2 * margin.fY);
const SkScalar bottomUnstretched = std::max(LL.fY, LR.fY) + SkIntToScalar(2 * margin.fY);
const SkScalar totalSmallHeight = topUnstretched + bottomUnstretched + stretchSize;
if (totalSmallHeight >= rrect.rect().height()) {

View File

@ -537,7 +537,7 @@ SkCanvas::SkCanvas(int width, int height, const SkSurfaceProps* props)
{
inc_canvas();
this->init(sk_make_sp<SkNoPixelsDevice>(
SkIRect::MakeWH(SkTMax(width, 0), SkTMax(height, 0)), fProps));
SkIRect::MakeWH(std::max(width, 0), std::max(height, 0)), fProps));
}
SkCanvas::SkCanvas(const SkIRect& bounds)

View File

@ -268,7 +268,7 @@ size_t SkCompressedDataSize(SkImage::CompressionType type, SkISize dimensions,
static_assert(sizeof(ETC1Block) == sizeof(BC1Block));
totalSize += numBlocks * sizeof(ETC1Block);
dimensions = {SkTMax(1, dimensions.width()/2), SkTMax(1, dimensions.height()/2)};
dimensions = {std::max(1, dimensions.width()/2), std::max(1, dimensions.height()/2)};
}
break;
}

View File

@ -80,8 +80,8 @@ static inline bool coeff_nearly_zero(float delta) {
SkCubicMap::SkCubicMap(SkPoint p1, SkPoint p2) {
// Clamp X values only (we allow Ys outside [0..1]).
p1.fX = SkTMin(SkTMax(p1.fX, 0.0f), 1.0f);
p2.fX = SkTMin(SkTMax(p2.fX, 0.0f), 1.0f);
p1.fX = std::min(std::max(p1.fX, 0.0f), 1.0f);
p2.fX = std::min(std::max(p2.fX, 0.0f), 1.0f);
Sk2s s1 = Sk2s::Load(&p1) * 3;
Sk2s s2 = Sk2s::Load(&p2) * 3;

View File

@ -807,7 +807,7 @@ SkScalar SkDraw::ComputeResScaleForStroking(const SkMatrix& matrix) {
SkScalar sx = SkPoint::Length(matrix[SkMatrix::kMScaleX], matrix[SkMatrix::kMSkewY]);
SkScalar sy = SkPoint::Length(matrix[SkMatrix::kMSkewX], matrix[SkMatrix::kMScaleY]);
if (SkScalarsAreFinite(sx, sy)) {
SkScalar scale = SkTMax(sx, sy);
SkScalar scale = std::max(sx, sy);
if (scale > 0) {
return scale;
}

View File

@ -121,11 +121,11 @@ void GetLocalBounds(const SkPath& path, const SkDrawShadowRec& rec, const SkMatr
occluderZ = rec.fZPlaneParams.fZ;
} else {
occluderZ = compute_z(ambientBounds.fLeft, ambientBounds.fTop, rec.fZPlaneParams);
occluderZ = SkTMax(occluderZ, compute_z(ambientBounds.fRight, ambientBounds.fTop,
occluderZ = std::max(occluderZ, compute_z(ambientBounds.fRight, ambientBounds.fTop,
rec.fZPlaneParams));
occluderZ = SkTMax(occluderZ, compute_z(ambientBounds.fLeft, ambientBounds.fBottom,
occluderZ = std::max(occluderZ, compute_z(ambientBounds.fLeft, ambientBounds.fBottom,
rec.fZPlaneParams));
occluderZ = SkTMax(occluderZ, compute_z(ambientBounds.fRight, ambientBounds.fBottom,
occluderZ = std::max(occluderZ, compute_z(ambientBounds.fRight, ambientBounds.fBottom,
rec.fZPlaneParams));
}
SkScalar ambientBlur;

View File

@ -42,11 +42,11 @@ static inline float divide_and_pin(float numer, float denom, float min, float ma
}
inline SkScalar AmbientBlurRadius(SkScalar height) {
return SkTMin(height*kAmbientHeightFactor*kAmbientGeomFactor, kMaxAmbientRadius);
return std::min(height*kAmbientHeightFactor*kAmbientGeomFactor, kMaxAmbientRadius);
}
inline SkScalar AmbientRecipAlpha(SkScalar height) {
return 1.0f + SkTMax(height*kAmbientHeightFactor, 0.0f);
return 1.0f + std::max(height*kAmbientHeightFactor, 0.0f);
}
inline SkScalar SpotBlurRadius(SkScalar occluderZ, SkScalar lightZ, SkScalar lightRadius) {

View File

@ -27,7 +27,7 @@
#define kDefault_Hinting SkPaintDefaults_Hinting
static inline SkScalar valid_size(SkScalar size) {
return SkTMax<SkScalar>(0, size);
return std::max<SkScalar>(0, size);
}
SkFont::SkFont(sk_sp<SkTypeface> face, SkScalar size, SkScalar scaleX, SkScalar skewX)

View File

@ -201,8 +201,8 @@ static std::tuple<SkScalar, SkScalar> calculate_path_gap(
SkScalar left = SK_ScalarMax,
right = SK_ScalarMin;
auto expandGap = [&left, &right](SkScalar v) {
left = SkTMin(left, v);
right = SkTMax(right, v);
left = std::min(left, v);
right = std::max(right, v);
};
// Handle all the different verbs for the path.
@ -257,9 +257,9 @@ static std::tuple<SkScalar, SkScalar> calculate_path_gap(
break;
}
case SkPath::kQuad_Verb: {
SkScalar quadTop = SkTMin(SkTMin(pts[0].fY, pts[1].fY), pts[2].fY);
SkScalar quadTop = std::min(std::min(pts[0].fY, pts[1].fY), pts[2].fY);
if (bottomOffset < quadTop) { break; }
SkScalar quadBottom = SkTMax(SkTMax(pts[0].fY, pts[1].fY), pts[2].fY);
SkScalar quadBottom = std::max(std::max(pts[0].fY, pts[1].fY), pts[2].fY);
if (topOffset > quadBottom) { break; }
addQuad(topOffset);
addQuad(bottomOffset);
@ -272,10 +272,10 @@ static std::tuple<SkScalar, SkScalar> calculate_path_gap(
}
case SkPath::kCubic_Verb: {
SkScalar quadTop =
SkTMin(SkTMin(SkTMin(pts[0].fY, pts[1].fY), pts[2].fY), pts[3].fY);
std::min(std::min(std::min(pts[0].fY, pts[1].fY), pts[2].fY), pts[3].fY);
if (bottomOffset < quadTop) { break; }
SkScalar quadBottom =
SkTMax(SkTMax(SkTMax(pts[0].fY, pts[1].fY), pts[2].fY), pts[3].fY);
std::max(std::max(std::max(pts[0].fY, pts[1].fY), pts[2].fY), pts[3].fY);
if (topOffset > quadBottom) { break; }
addCubic(topOffset);
addCubic(bottomOffset);

View File

@ -45,7 +45,7 @@ public:
}
void reject(size_t index, int rejectedMaxDimension) {
fRejectedMaxDimension = SkTMax(fRejectedMaxDimension, rejectedMaxDimension);
fRejectedMaxDimension = std::max(fRejectedMaxDimension, rejectedMaxDimension);
this->reject(index);
}

View File

@ -121,10 +121,6 @@ static inline unsigned SkDiv255Round(unsigned prod) {
return (prod + (prod >> 8)) >> 8;
}
static inline float SkPinToUnitFloat(float x) {
return SkTMin(SkTMax(x, 0.0f), 1.0f);
}
/**
* Swap byte order of a 4-byte value, e.g. 0xaarrggbb -> 0xbbggrraa.
*/

View File

@ -614,8 +614,8 @@ SkMipMap* SkMipMap::Build(const SkPixmap& src, SkDiscardableFactoryProc fact) {
proc = proc_2_2;
}
}
width = SkTMax(1, width >> 1);
height = SkTMax(1, height >> 1);
width = std::max(1, width >> 1);
height = std::max(1, height >> 1);
rowBytes = SkToU32(SkColorTypeMinRowBytes(ct, width));
// We make the Info w/o any colorspace, since that storage is not under our control, and
@ -654,7 +654,7 @@ int SkMipMap::ComputeLevelCount(int baseWidth, int baseHeight) {
// (or original_width) where i is the mipmap level.
// Continue scaling down until both axes are size 1.
const int largestAxis = SkTMax(baseWidth, baseHeight);
const int largestAxis = std::max(baseWidth, baseHeight);
if (largestAxis < 2) {
// SkMipMap::Build requires a minimum size of 2.
return 0;
@ -695,8 +695,8 @@ SkISize SkMipMap::ComputeLevelSize(int baseWidth, int baseHeight, int level) {
// For example, it contains levels 1-x instead of 0-x.
// This is because the image used to create SkMipMap is the base level.
// So subtract 1 from the mip level to get the index stored by SkMipMap.
int width = SkTMax(1, baseWidth >> (level + 1));
int height = SkTMax(1, baseHeight >> (level + 1));
int width = std::max(1, baseWidth >> (level + 1));
int height = std::max(1, baseHeight >> (level + 1));
return SkISize::Make(width, height);
}
@ -712,7 +712,7 @@ bool SkMipMap::extractLevel(const SkSize& scaleSize, Level* levelPtr) const {
#ifndef SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE
// Use the smallest scale to match the GPU impl.
const SkScalar scale = SkTMin(scaleSize.width(), scaleSize.height());
const SkScalar scale = std::min(scaleSize.width(), scaleSize.height());
#else
// Ideally we'd pick the smaller scale, to match Ganesh. But ignoring one of the
// scales can produce some atrocious results, so for now we use the geometric mean.

View File

@ -180,7 +180,7 @@ void SkNormalMapSourceImpl::Provider::fillScanLine(int x, int y, SkPoint3 output
SkPMColor tmpNormalColors[BUFFER_MAX];
do {
int n = SkTMin(count, BUFFER_MAX);
int n = std::min(count, BUFFER_MAX);
fMapContext->shadeSpan(x, y, tmpNormalColors, n);

View File

@ -1189,7 +1189,7 @@ SkPath& SkPath::arcTo(SkScalar rx, SkScalar ry, SkScalar angle, SkPath::ArcSize
SkVector delta = unitPts[1] - unitPts[0];
SkScalar d = delta.fX * delta.fX + delta.fY * delta.fY;
SkScalar scaleFactorSquared = SkTMax(1 / d - 0.25f, 0.f);
SkScalar scaleFactorSquared = std::max(1 / d - 0.25f, 0.f);
SkScalar scaleFactor = SkScalarSqrt(scaleFactorSquared);
if ((arcSweep == SkPathDirection::kCCW) != SkToBool(arcLarge)) { // flipped from the original implementation
@ -2088,9 +2088,9 @@ private:
if (!SkScalarIsFinite(cross)) {
return kUnknown_DirChange;
}
SkScalar smallest = SkTMin(fCurrPt.fX, SkTMin(fCurrPt.fY, SkTMin(fLastPt.fX, fLastPt.fY)));
SkScalar largest = SkTMax(fCurrPt.fX, SkTMax(fCurrPt.fY, SkTMax(fLastPt.fX, fLastPt.fY)));
largest = SkTMax(largest, -smallest);
SkScalar smallest = std::min(fCurrPt.fX, std::min(fCurrPt.fY, std::min(fLastPt.fX, fLastPt.fY)));
SkScalar largest = std::max(fCurrPt.fX, std::max(fCurrPt.fY, std::max(fLastPt.fX, fLastPt.fY)));
largest = std::max(largest, -smallest);
if (almost_equal(largest, largest + cross)) {
constexpr SkScalar nearlyZeroSqd = SK_ScalarNearlyZero * SK_ScalarNearlyZero;

View File

@ -115,7 +115,7 @@ void SkRRect::setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad
// miss the fact that a scale is required.
static double compute_min_scale(double rad1, double rad2, double limit, double curMin) {
if ((rad1 + rad2) > limit) {
return SkTMin(curMin, limit / (rad1 + rad2));
return std::min(curMin, limit / (rad1 + rad2));
}
return curMin;
}

View File

@ -11,6 +11,7 @@
#include "include/private/SkMalloc.h"
#include "include/private/SkTo.h"
#include <algorithm>
#include <atomic>
#include <new>
@ -40,7 +41,7 @@ struct SkBufferBlock {
//
size_t append(const void* src, size_t length) {
this->validate();
size_t amount = SkTMin(this->avail(), length);
size_t amount = std::min(this->avail(), length);
memcpy(this->availData(), src, amount);
fUsed += amount;
this->validate();
@ -59,7 +60,7 @@ struct SkBufferBlock {
private:
static size_t LengthToCapacity(size_t length) {
const size_t minSize = kMinAllocSize - sizeof(SkBufferBlock);
return SkTMax(length, minSize);
return std::max(length, minSize);
}
};
@ -71,7 +72,7 @@ struct SkBufferHead {
static size_t LengthToCapacity(size_t length) {
const size_t minSize = kMinAllocSize - sizeof(SkBufferHead);
return SkTMax(length, minSize);
return std::max(length, minSize);
}
static SkBufferHead* Alloc(size_t length) {
@ -171,7 +172,7 @@ size_t SkROBuffer::Iter::size() const {
if (!fBlock) {
return 0;
}
return SkTMin(fBlock->fCapacity, fRemaining);
return std::min(fBlock->fCapacity, fRemaining);
}
bool SkROBuffer::Iter::next() {
@ -290,7 +291,7 @@ public:
for (;;) {
size_t size = fIter.size();
SkASSERT(fLocalOffset <= size);
size_t avail = SkTMin(size - fLocalOffset, request - bytesRead);
size_t avail = std::min(size - fLocalOffset, request - bytesRead);
if (dst) {
memcpy(dst, (const char*)fIter.data() + fLocalOffset, avail);
dst = (char*)dst + avail;

View File

@ -61,7 +61,7 @@ void SkRecordPartialDraw(const SkRecord& record, SkCanvas* canvas,
const SkMatrix& initialCTM) {
SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
stop = SkTMin(stop, record.count());
stop = std::min(stop, record.count());
SkRecords::Draw draw(canvas, drawablePicts, nullptr, drawableCount, &initialCTM);
for (int i = start; i < stop; i++) {
record.visit(i, draw);

View File

@ -85,8 +85,8 @@ bool SkRect::setBoundsCheck(const SkPoint pts[], int count) {
bool all_finite = (accum * 0 == 0).allTrue();
if (all_finite) {
this->setLTRB(SkTMin(min[0], min[2]), SkTMin(min[1], min[3]),
SkTMax(max[0], max[2]), SkTMax(max[1], max[3]));
this->setLTRB(std::min(min[0], min[2]), std::min(min[1], min[3]),
std::max(max[0], max[2]), std::max(max[1], max[3]));
} else {
this->setEmpty();
}

View File

@ -434,7 +434,7 @@ size_t SkResourceCache::getEffectiveSingleAllocationByteLimit() const {
if (0 == limit) {
limit = fTotalByteLimit;
} else {
limit = SkTMin(limit, fTotalByteLimit);
limit = std::min(limit, fTotalByteLimit);
}
}
return limit;

View File

@ -95,7 +95,7 @@ static void add_alpha(SkAlpha* alpha, SkAlpha delta) {
}
static void safely_add_alpha(SkAlpha* alpha, SkAlpha delta) {
*alpha = SkTMin(0xFF, *alpha + delta);
*alpha = std::min(0xFF, *alpha + delta);
}
class AdditiveBlitter : public SkBlitter {
@ -415,7 +415,7 @@ void RunBasedAdditiveBlitter::blitAntiH(int x, int y, const SkAlpha antialias[],
antialias -= x;
x = 0;
}
len = SkTMin(len, fWidth - x);
len = std::min(len, fWidth - x);
SkASSERT(check(x, len));
if (x < fOffsetX) {
@ -485,7 +485,7 @@ void SafeRLEAdditiveBlitter::blitAntiH(int x, int y, const SkAlpha antialias[],
antialias -= x;
x = 0;
}
len = SkTMin(len, fWidth - x);
len = std::min(len, fWidth - x);
SkASSERT(check(x, len));
if (x < fOffsetX) {
@ -589,7 +589,7 @@ static SkFixed approximate_intersection(SkFixed l1, SkFixed r1, SkFixed l2, SkFi
if (l2 > r2) {
std::swap(l2, r2);
}
return (SkTMax(l1, l2) + SkTMin(r1, r2)) / 2;
return (std::max(l1, l2) + std::min(r1, r2)) / 2;
}
// Here we always send in l < SK_Fixed1, and the first alpha we want to compute is alphas[0]
@ -1107,7 +1107,7 @@ static void aaa_walk_convex_edges(SkAnalyticEdge* prevHead,
SkAnalyticEdge* riteE = (SkAnalyticEdge*)leftE->fNext;
SkAnalyticEdge* currE = (SkAnalyticEdge*)riteE->fNext;
SkFixed y = SkTMax(leftE->fUpperY, riteE->fUpperY);
SkFixed y = std::max(leftE->fUpperY, riteE->fUpperY);
for (;;) {
// We have to check fLowerY first because some edges might be alone (e.g., there's only
@ -1155,9 +1155,9 @@ static void aaa_walk_convex_edges(SkAnalyticEdge* prevHead,
}
local_bot_fixed = std::min(local_bot_fixed, SkIntToFixed(stop_y));
SkFixed left = SkTMax(leftBound, leftE->fX);
SkFixed left = std::max(leftBound, leftE->fX);
SkFixed dLeft = leftE->fDX;
SkFixed rite = SkTMin(riteBound, riteE->fX);
SkFixed rite = std::min(riteBound, riteE->fX);
SkFixed dRite = riteE->fDX;
if (0 == (dLeft | dRite)) {
int fullLeft = SkFixedCeilToInt(left);
@ -1326,8 +1326,8 @@ static void aaa_walk_convex_edges(SkAnalyticEdge* prevHead,
// Smooth jumping to integer y may make the last nextLeft/nextRite out of bound.
// Take them back into the bound here.
// Note that we substract kSnapHalf later so we have to add them to leftBound/riteBound
SkFixed nextLeft = SkTMax(left + SkFixedMul(dLeft, dY), leftBound + kSnapHalf);
SkFixed nextRite = SkTMin(rite + SkFixedMul(dRite, dY), riteBound + kSnapHalf);
SkFixed nextLeft = std::max(left + SkFixedMul(dLeft, dY), leftBound + kSnapHalf);
SkFixed nextRite = std::min(rite + SkFixedMul(dRite, dY), riteBound + kSnapHalf);
SkASSERT((left & kSnapMask) >= leftBound && (rite & kSnapMask) <= riteBound &&
(nextLeft & kSnapMask) >= leftBound && (nextRite & kSnapMask) <= riteBound);
blit_trapezoid_row(blitter,
@ -1472,10 +1472,10 @@ static void blit_saved_trapezoid(SkAnalyticEdge* leftE,
blit_trapezoid_row(
blitter,
y,
SkTMax(leftE->fSavedX, leftClip),
SkTMin(riteE->fSavedX, rightClip),
SkTMax(lowerLeft, leftClip),
SkTMin(lowerRite, rightClip),
std::max(leftE->fSavedX, leftClip),
std::min(riteE->fSavedX, rightClip),
std::max(lowerLeft, leftClip),
std::min(lowerRite, rightClip),
leftE->fSavedDY,
riteE->fSavedDY,
fullAlpha,
@ -1557,7 +1557,7 @@ static void aaa_walk_edges(SkAnalyticEdge* prevHead,
bool skipIntersect) {
prevHead->fX = prevHead->fUpperX = leftClip;
nextTail->fX = nextTail->fUpperX = rightClip;
SkFixed y = SkTMax(prevHead->fNext->fUpperY, SkIntToFixed(start_y));
SkFixed y = std::max(prevHead->fNext->fUpperY, SkIntToFixed(start_y));
SkFixed nextNextY = SK_MaxS32;
{
@ -1596,7 +1596,7 @@ static void aaa_walk_edges(SkAnalyticEdge* prevHead,
int w = 0;
bool in_interval = isInverse;
SkFixed prevX = prevHead->fX;
SkFixed nextY = SkTMin(nextNextY, SkFixedCeilToFixed(y + 1));
SkFixed nextY = std::min(nextNextY, SkFixedCeilToFixed(y + 1));
bool isIntegralNextY = (nextY & (SK_Fixed1 - 1)) == 0;
SkAnalyticEdge* currE = prevHead->fNext;
SkAnalyticEdge* leftE = prevHead;
@ -1699,9 +1699,9 @@ static void aaa_walk_edges(SkAnalyticEdge* prevHead,
} else {
SkFixed rite = currE->fX;
currE->goY(nextY, yShift);
SkFixed nextLeft = SkTMax(leftClip, leftE->fX);
rite = SkTMin(rightClip, rite);
SkFixed nextRite = SkTMin(rightClip, currE->fX);
SkFixed nextLeft = std::max(leftClip, leftE->fX);
rite = std::min(rightClip, rite);
SkFixed nextRite = std::min(rightClip, currE->fX);
blit_trapezoid_row(
blitter,
y >> 16,
@ -1718,11 +1718,11 @@ static void aaa_walk_edges(SkAnalyticEdge* prevHead,
(edges_too_close(prevRite, left, leftE->fX) ||
edges_too_close(currE, currE->fNext, nextY))),
true);
prevRite = SkFixedCeilToInt(SkTMax(rite, currE->fX));
prevRite = SkFixedCeilToInt(std::max(rite, currE->fX));
}
} else {
if (isLeft) {
left = SkTMax(currE->fX, leftClip);
left = std::max(currE->fX, leftClip);
leftDY = currE->fDY;
leftE = currE;
leftEnds = leftE->fLowerY == nextY;
@ -1810,7 +1810,7 @@ static void aaa_walk_edges(SkAnalyticEdge* prevHead,
y >> 16,
left,
rightClip,
SkTMax(leftClip, leftE->fX),
std::max(leftClip, leftE->fX),
rightClip,
leftDY,
0,
@ -1915,8 +1915,8 @@ static SK_ALWAYS_INLINE void aaa_fill_path(
// Otherwise, the edge drift may access an invalid address inside the mask.
SkIRect ir;
path.getBounds().roundOut(&ir);
leftBound = SkTMax(leftBound, SkIntToFixed(ir.fLeft));
rightBound = SkTMin(rightBound, SkIntToFixed(ir.fRight));
leftBound = std::max(leftBound, SkIntToFixed(ir.fLeft));
rightBound = std::min(rightBound, SkIntToFixed(ir.fRight));
}
if (!path.isInverseFillType() && path.isConvex() && count >= 2) {

View File

@ -658,7 +658,7 @@ static bool ShouldUseAAA(const SkPath& path, SkScalar avgLength, SkScalar comple
// every pixel row/column is significantly greater than zero. Hence
// Aanlytic AA is not likely to produce visible quality improvements,
// and Analytic AA might be slower than supersampling.
return path.countPoints() < SkTMax(bounds.width(), bounds.height()) / 2 - 10;
return path.countPoints() < std::max(bounds.width(), bounds.height()) / 2 - 10;
#else
if (path.countPoints() >= path.getBounds().height()) {
// SAA is faster than AAA in this case even if there are no

View File

@ -310,7 +310,7 @@ static inline Sk2s abs(const Sk2s& value) {
static inline SkScalar max_component(const Sk2s& value) {
SkScalar components[2];
value.store(components);
return SkTMax(components[0], components[1]);
return std::max(components[0], components[1]);
}
static inline int compute_cubic_segs(const SkPoint pts[4]) {

Some files were not shown because too many files have changed in this diff Show More