Remove SkScalarClampMax and SkScalarPin
Change-Id: Ic96a0ea2cd1bfd59ee3f236543e1d6dd102544ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269142
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 4c9aaeb..1162770 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -7,6 +7,7 @@
Milestone 82
<Insert new notes here- top is most recent.>
+ * Removed SkScalarClampMax and SkScalarPin.
* Removed SkMax32 and SkMin32.
* Removed SkMaxScalar and SkMinScalar.
diff --git a/gm/wacky_yuv_formats.cpp b/gm/wacky_yuv_formats.cpp
index 6b613ee..3fe6990 100644
--- a/gm/wacky_yuv_formats.cpp
+++ b/gm/wacky_yuv_formats.cpp
@@ -413,17 +413,17 @@
const uint8_t g = SkColorGetG(col);
const uint8_t b = SkColorGetB(col);
- yuv[0] = SkScalarPin(SkScalarRoundToInt(mtx[ 0]*r + mtx[ 1]*g + mtx[ 2]*b + mtx[ 4]*255), 0, 255);
- yuv[1] = SkScalarPin(SkScalarRoundToInt(mtx[ 5]*r + mtx[ 6]*g + mtx[ 7]*b + mtx[ 9]*255), 0, 255);
- yuv[2] = SkScalarPin(SkScalarRoundToInt(mtx[10]*r + mtx[11]*g + mtx[12]*b + mtx[14]*255), 0, 255);
+ yuv[0] = SkTPin(SkScalarRoundToInt(mtx[ 0]*r + mtx[ 1]*g + mtx[ 2]*b + mtx[ 4]*255), 0, 255);
+ yuv[1] = SkTPin(SkScalarRoundToInt(mtx[ 5]*r + mtx[ 6]*g + mtx[ 7]*b + mtx[ 9]*255), 0, 255);
+ yuv[2] = SkTPin(SkScalarRoundToInt(mtx[10]*r + mtx[11]*g + mtx[12]*b + mtx[14]*255), 0, 255);
yuv[3] = SkColorGetA(col);
}
static SkPMColor convert_yuva_to_rgba(const float mtx[20],
uint8_t y, uint8_t u, uint8_t v, uint8_t a) {
- uint8_t r = SkScalarPin(SkScalarRoundToInt(mtx[ 0]*y + mtx[ 1]*u + mtx[ 2]*v + mtx[ 4]*255), 0, 255);
- uint8_t g = SkScalarPin(SkScalarRoundToInt(mtx[ 5]*y + mtx[ 6]*u + mtx[ 7]*v + mtx[ 9]*255), 0, 255);
- uint8_t b = SkScalarPin(SkScalarRoundToInt(mtx[10]*y + mtx[11]*u + mtx[12]*v + mtx[14]*255), 0, 255);
+ uint8_t r = SkTPin(SkScalarRoundToInt(mtx[ 0]*y + mtx[ 1]*u + mtx[ 2]*v + mtx[ 4]*255), 0, 255);
+ uint8_t g = SkTPin(SkScalarRoundToInt(mtx[ 5]*y + mtx[ 6]*u + mtx[ 7]*v + mtx[ 9]*255), 0, 255);
+ uint8_t b = SkTPin(SkScalarRoundToInt(mtx[10]*y + mtx[11]*u + mtx[12]*v + mtx[14]*255), 0, 255);
return SkPremultiplyARGBInline(a, r, g, b);
}
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h
index 7078d92..19b74bc 100644
--- a/include/core/SkColorPriv.h
+++ b/include/core/SkColorPriv.h
@@ -31,7 +31,7 @@
#define SkAlphaMul(value, alpha256) (((value) * (alpha256)) >> 8)
static inline U8CPU SkUnitScalarClampToByte(SkScalar x) {
- return static_cast<U8CPU>(SkScalarPin(x, 0, 1) * 255 + 0.5);
+ return static_cast<U8CPU>(SkTPin(x, 0.0f, 1.0f) * 255 + 0.5);
}
#define SK_A32_BITS 8
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index 789b17b..2937162 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -103,16 +103,6 @@
return x - SkScalarTruncToScalar(x);
}
-static inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) {
- x = SkTMin(x, max);
- x = SkTMax<SkScalar>(x, 0);
- return x;
-}
-
-static inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) {
- return SkTPin(x, min, max);
-}
-
static inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
#define SkScalarInvert(x) sk_ieee_float_divide_TODO_IS_DIVIDE_BY_ZERO_SAFE_HERE(SK_Scalar1, (x))
diff --git a/samplecode/SampleDegenerateQuads.cpp b/samplecode/SampleDegenerateQuads.cpp
index d29c5d5..60db744 100644
--- a/samplecode/SampleDegenerateQuads.cpp
+++ b/samplecode/SampleDegenerateQuads.cpp
@@ -216,10 +216,10 @@
SkScalar coverage = bary[0] * c0 + bary[1] * c1 + bary[2] * c2;
if (coverage < 0.5f) {
// Check distances to domain
- SkScalar l = SkScalarPin(point.fX - geomDomain.fLeft, 0.f, 1.f);
- SkScalar t = SkScalarPin(point.fY - geomDomain.fTop, 0.f, 1.f);
- SkScalar r = SkScalarPin(geomDomain.fRight - point.fX, 0.f, 1.f);
- SkScalar b = SkScalarPin(geomDomain.fBottom - point.fY, 0.f, 1.f);
+ SkScalar l = SkTPin(point.fX - geomDomain.fLeft, 0.f, 1.f);
+ SkScalar t = SkTPin(point.fY - geomDomain.fTop, 0.f, 1.f);
+ SkScalar r = SkTPin(geomDomain.fRight - point.fX, 0.f, 1.f);
+ SkScalar b = SkTPin(geomDomain.fBottom - point.fY, 0.f, 1.f);
coverage = std::min(coverage, l * t * r * b);
}
return coverage;
diff --git a/src/core/SkColor.cpp b/src/core/SkColor.cpp
index 27c81b7..0303624 100644
--- a/src/core/SkColor.cpp
+++ b/src/core/SkColor.cpp
@@ -73,8 +73,8 @@
SkColor SkHSVToColor(U8CPU a, const SkScalar hsv[3]) {
SkASSERT(hsv);
- SkScalar s = SkScalarPin(hsv[1], 0, 1);
- SkScalar v = SkScalarPin(hsv[2], 0, 1);
+ SkScalar s = SkTPin(hsv[1], 0.0f, 1.0f);
+ SkScalar v = SkTPin(hsv[2], 0.0f, 1.0f);
U8CPU v_byte = SkScalarRoundToInt(v * 255);
diff --git a/src/core/SkCubicMap.cpp b/src/core/SkCubicMap.cpp
index 30cd3b4..f5285e0 100644
--- a/src/core/SkCubicMap.cpp
+++ b/src/core/SkCubicMap.cpp
@@ -52,7 +52,7 @@
}
float SkCubicMap::computeYFromX(float x) const {
- x = SkScalarPin(x, 0, 1);
+ x = SkTPin(x, 0.0f, 1.0f);
if (nearly_zero(x) || nearly_zero(1 - x)) {
return x;
diff --git a/src/core/SkDistanceFieldGen.cpp b/src/core/SkDistanceFieldGen.cpp
index 9471e1c..ffdbdc6 100644
--- a/src/core/SkDistanceFieldGen.cpp
+++ b/src/core/SkDistanceFieldGen.cpp
@@ -327,7 +327,7 @@
// The distance field is constructed as unsigned char values, so that the zero value is at 128,
// Beside 128, we have 128 values in range [0, 128), but only 127 values in range (128, 255].
// So we multiply distanceMagnitude by 127/128 at the latter range to avoid overflow.
- dist = SkScalarPin(-dist, -distanceMagnitude, distanceMagnitude * 127.0f / 128.0f);
+ dist = SkTPin<float>(-dist, -distanceMagnitude, distanceMagnitude * 127.0f / 128.0f);
// Scale into the positive range for unsigned distance.
dist += distanceMagnitude;
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index f437ab0..14ad33e 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -769,12 +769,12 @@
if (R2MinusQ3 < 0) { // we have 3 real roots
// the divide/root can, due to finite precisions, be slightly outside of -1...1
- SkScalar theta = SkScalarACos(SkScalarPin(R / SkScalarSqrt(Q3), -1, 1));
+ SkScalar theta = SkScalarACos(SkTPin(R / SkScalarSqrt(Q3), -1.0f, 1.0f));
SkScalar neg2RootQ = -2 * SkScalarSqrt(Q);
- tValues[0] = SkScalarPin(neg2RootQ * SkScalarCos(theta/3) - adiv3, 0, 1);
- tValues[1] = SkScalarPin(neg2RootQ * SkScalarCos((theta + 2*SK_ScalarPI)/3) - adiv3, 0, 1);
- tValues[2] = SkScalarPin(neg2RootQ * SkScalarCos((theta - 2*SK_ScalarPI)/3) - adiv3, 0, 1);
+ tValues[0] = SkTPin(neg2RootQ * SkScalarCos(theta/3) - adiv3, 0.0f, 1.0f);
+ tValues[1] = SkTPin(neg2RootQ * SkScalarCos((theta + 2*SK_ScalarPI)/3) - adiv3, 0.0f, 1.0f);
+ tValues[2] = SkTPin(neg2RootQ * SkScalarCos((theta - 2*SK_ScalarPI)/3) - adiv3, 0.0f, 1.0f);
SkDEBUGCODE(test_collaps_duplicates();)
// now sort the roots
@@ -789,7 +789,7 @@
if (A != 0) {
A += Q / A;
}
- tValues[0] = SkScalarPin(A - adiv3, 0, 1);
+ tValues[0] = SkTPin(A - adiv3, 0.0f, 1.0f);
return 1;
}
}
diff --git a/src/effects/SkEmbossMaskFilter.cpp b/src/effects/SkEmbossMaskFilter.cpp
index 5592fc7..2dcce2b 100644
--- a/src/effects/SkEmbossMaskFilter.cpp
+++ b/src/effects/SkEmbossMaskFilter.cpp
@@ -51,7 +51,7 @@
light.fAmbient = SkUnitScalarClampToByte(ambient);
// specular should be 0..15.99 as a scalar
static const SkScalar kSpecularMultiplier = SkIntToScalar(255) / 16;
- light.fSpecular = static_cast<U8CPU>(SkScalarPin(specular, 0, 16) * kSpecularMultiplier + 0.5);
+ light.fSpecular = static_cast<U8CPU>(SkTPin(specular, 0.0f, 16.0f) * kSpecularMultiplier + 0.5);
return SkEmbossMaskFilter::Make(blurSigma, light);
}
diff --git a/src/effects/SkHighContrastFilter.cpp b/src/effects/SkHighContrastFilter.cpp
index 4fbbf48..5922cf5 100644
--- a/src/effects/SkHighContrastFilter.cpp
+++ b/src/effects/SkHighContrastFilter.cpp
@@ -28,9 +28,9 @@
SkHighContrast_Filter(const SkHighContrastConfig& config) {
fConfig = config;
// Clamp contrast to just inside -1 to 1 to avoid division by zero.
- fConfig.fContrast = SkScalarPin(fConfig.fContrast,
- -1.0f + FLT_EPSILON,
- 1.0f - FLT_EPSILON);
+ fConfig.fContrast = SkTPin(fConfig.fContrast,
+ -1.0f + FLT_EPSILON,
+ 1.0f - FLT_EPSILON);
}
~SkHighContrast_Filter() override {}
diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
index ad40a11..86ab478 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
@@ -67,8 +67,8 @@
SkScalar outerThreshold,
sk_sp<SkImageFilter> input,
const SkImageFilter::CropRect* cropRect) {
- innerThreshold = SkScalarPin(innerThreshold, 0.f, 1.f);
- outerThreshold = SkScalarPin(outerThreshold, 0.f, 1.f);
+ innerThreshold = SkTPin(innerThreshold, 0.f, 1.f);
+ outerThreshold = SkTPin(outerThreshold, 0.f, 1.f);
if (!SkScalarIsFinite(innerThreshold) || !SkScalarIsFinite(outerThreshold)) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp
index 7281d21..e17daf1 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -164,7 +164,7 @@
SkPMColor light(const SkPoint3& normal, const SkPoint3& surfaceTolight,
const SkPoint3& lightColor) const override {
SkScalar colorScale = fKD * normal.dot(surfaceTolight);
- colorScale = SkScalarClampMax(colorScale, SK_Scalar1);
+ colorScale = SkTPin(colorScale, 0.0f, SK_Scalar1);
SkPoint3 color = lightColor.makeScale(colorScale);
return SkPackARGB32(255,
SkClampMax(SkScalarRoundToInt(color.fX), 255),
@@ -189,7 +189,7 @@
halfDir.fZ += SK_Scalar1; // eye position is always (0, 0, 1)
fast_normalize(&halfDir);
SkScalar colorScale = fKS * SkScalarPow(normal.dot(halfDir), fShininess);
- colorScale = SkScalarClampMax(colorScale, SK_Scalar1);
+ colorScale = SkTPin(colorScale, 0.0f, SK_Scalar1);
SkPoint3 color = lightColor.makeScale(colorScale);
return SkPackARGB32(SkClampMax(SkScalarRoundToInt(max_component(color)), 255),
SkClampMax(SkScalarRoundToInt(color.fX), 255),
@@ -967,7 +967,7 @@
: INHERITED(color),
fLocation(location),
fTarget(target),
- fSpecularExponent(SkScalarPin(specularExponent, kSpecularExponentMin, kSpecularExponentMax))
+ fSpecularExponent(SkTPin(specularExponent, kSpecularExponentMin, kSpecularExponentMax))
{
fS = target - location;
fast_normalize(&fS);
diff --git a/src/gpu/GrDistanceFieldGenFromVector.cpp b/src/gpu/GrDistanceFieldGenFromVector.cpp
index 988f3b9..b91cb35 100644
--- a/src/gpu/GrDistanceFieldGenFromVector.cpp
+++ b/src/gpu/GrDistanceFieldGenFromVector.cpp
@@ -242,8 +242,8 @@
SkPoint t = _P1mP0 - fPts[2] + fPts[1];
t.fX = _P1mP0.fX / t.fX;
t.fY = _P1mP0.fY / t.fY;
- t.fX = SkScalarClampMax(t.fX, 1.0);
- t.fY = SkScalarClampMax(t.fY, 1.0);
+ t.fX = SkTPin(t.fX, 0.0f, 1.0f);
+ t.fY = SkTPin(t.fY, 0.0f, 1.0f);
t.fX = _P1mP0.fX * t.fX;
t.fY = _P1mP0.fY * t.fY;
const SkPoint m = fPts[0] + t;
@@ -695,7 +695,7 @@
// The distance field is constructed as unsigned char values, so that the zero value is at 128,
// Beside 128, we have 128 values in range [0, 128), but only 127 values in range (128, 255].
// So we multiply distanceMagnitude by 127/128 at the latter range to avoid overflow.
- dist = SkScalarPin(-dist, -distanceMagnitude, distanceMagnitude * 127.0f / 128.0f);
+ dist = SkTPin<float>(-dist, -distanceMagnitude, distanceMagnitude * 127.0f / 128.0f);
// Scale into the positive range for unsigned distance.
dist += distanceMagnitude;
diff --git a/src/gpu/ccpr/GrOctoBounds.cpp b/src/gpu/ccpr/GrOctoBounds.cpp
index 72aa6f0..61e67c4 100644
--- a/src/gpu/ccpr/GrOctoBounds.cpp
+++ b/src/gpu/ccpr/GrOctoBounds.cpp
@@ -35,62 +35,62 @@
// y = x + (y0 - x0)
// Substitute: l45 = x0 - y0
// y = x - l45
- b = SkScalarPin(r - l45, t, b);
+ b = SkTPin(r - l45, t, b);
} else if (r45 < Get_x45(r,b)) {
// Slide the right side leftward until it crosses the r45 diagonal at y=b.
// x = y + (x0 - y0)
// Substitute: r45 = x0 - y0
// x = y + r45
- r = SkScalarPin(b + r45, l, r);
+ r = SkTPin(b + r45, l, r);
}
if (l45 > Get_x45(l,t)) {
// Slide the left side rightward until it crosses the l45 diagonal at y=t.
// x = y + (x0 - y0)
// Substitute: l45 = x0 - y0
// x = y + l45
- l = SkScalarPin(t + l45, l, r);
+ l = SkTPin(t + l45, l, r);
} else if (r45 < Get_x45(l,t)) {
// Slide the top downward until it crosses the r45 diagonal at x=l.
// y = x + (y0 - x0)
// Substitute: r45 = x0 - y0
// y = x - r45
- t = SkScalarPin(l - r45, t, b);
+ t = SkTPin(l - r45, t, b);
}
if (t45 > Get_y45(l,b)) {
// Slide the left side rightward until it crosses the t45 diagonal at y=b.
// x = -y + (x0 + y0)
// Substitute: t45 = x0 + y0
// x = -y + t45
- l = SkScalarPin(t45 - b, l, r);
+ l = SkTPin(t45 - b, l, r);
} else if (b45 < Get_y45(l,b)) {
// Slide the bottom upward until it crosses the b45 diagonal at x=l.
// y = -x + (y0 + x0)
// Substitute: b45 = x0 + y0
// y = -x + b45
- b = SkScalarPin(b45 - l, t, b);
+ b = SkTPin(b45 - l, t, b);
}
if (t45 > Get_y45(r,t)) {
// Slide the top downward until it crosses the t45 diagonal at x=r.
// y = -x + (y0 + x0)
// Substitute: t45 = x0 + y0
// y = -x + t45
- t = SkScalarPin(t45 - r, t, b);
+ t = SkTPin(t45 - r, t, b);
} else if (b45 < Get_y45(r,t)) {
// Slide the right side leftward until it crosses the b45 diagonal at y=t.
// x = -y + (x0 + y0)
// Substitute: b45 = x0 + y0
// x = -y + b45
- r = SkScalarPin(b45 - t, l, r);
+ r = SkTPin(b45 - t, l, r);
}
// Tighten the 45-degree bounding box. Since the dev bounds are now fully tightened, we only
// have to clamp the diagonals to outer corners.
// NOTE: This will not cause l,t,r,b to need more insetting. We only ever change a diagonal by
// pinning it to a FAR corner, which, by definition, is still outside the other corners.
- l45 = SkScalarPin(Get_x45(l,b), l45, r45);
- t45 = SkScalarPin(Get_y45(l,t), t45, b45);
- r45 = SkScalarPin(Get_x45(r,t), l45, r45);
- b45 = SkScalarPin(Get_y45(r,b), t45, b45);
+ l45 = SkTPin(Get_x45(l,b), l45, r45);
+ t45 = SkTPin(Get_y45(l,t), t45, b45);
+ r45 = SkTPin(Get_x45(r,t), l45, r45);
+ b45 = SkTPin(Get_y45(r,b), t45, b45);
// Make one final check for empty or NaN bounds. If the dev bounds were clipped completely
// outside one of the diagonals, they will have been pinned to empty. It's also possible that
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index bb89148..4713526 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -38,10 +38,10 @@
// It is OK if the domain rect is a line or point, but it should not be inverted. We do not
// handle rects that do not intersect the [0..1]x[0..1] rect.
SkASSERT(domain.isSorted());
- fDomain.fLeft = SkScalarPin(domain.fLeft, 0.0f, kFullRect.fRight);
- fDomain.fRight = SkScalarPin(domain.fRight, fDomain.fLeft, kFullRect.fRight);
- fDomain.fTop = SkScalarPin(domain.fTop, 0.0f, kFullRect.fBottom);
- fDomain.fBottom = SkScalarPin(domain.fBottom, fDomain.fTop, kFullRect.fBottom);
+ fDomain.fLeft = SkTPin(domain.fLeft, 0.0f, kFullRect.fRight);
+ fDomain.fRight = SkTPin(domain.fRight, fDomain.fLeft, kFullRect.fRight);
+ fDomain.fTop = SkTPin(domain.fTop, 0.0f, kFullRect.fBottom);
+ fDomain.fBottom = SkTPin(domain.fBottom, fDomain.fTop, kFullRect.fBottom);
SkASSERT(fDomain.fLeft <= fDomain.fRight);
SkASSERT(fDomain.fTop <= fDomain.fBottom);
}
diff --git a/src/gpu/ops/GrAAConvexTessellator.cpp b/src/gpu/ops/GrAAConvexTessellator.cpp
index 417d700..e5b84ec 100644
--- a/src/gpu/ops/GrAAConvexTessellator.cpp
+++ b/src/gpu/ops/GrAAConvexTessellator.cpp
@@ -665,7 +665,7 @@
}
SkScalar result = (depth - initialDepth) / (targetDepth - initialDepth) *
(targetCoverage - initialCoverage) + initialCoverage;
- return SkScalarClampMax(result, 1.0f);
+ return SkTPin(result, 0.0f, 1.0f);
}
// return true when processing is complete
diff --git a/src/shaders/SkPerlinNoiseShader.cpp b/src/shaders/SkPerlinNoiseShader.cpp
index 6351c11..901fa6a 100644
--- a/src/shaders/SkPerlinNoiseShader.cpp
+++ b/src/shaders/SkPerlinNoiseShader.cpp
@@ -563,7 +563,7 @@
}
// Clamp result
- return SkScalarPin(turbulenceFunctionResult, 0, SK_Scalar1);
+ return SkTPin(turbulenceFunctionResult, 0.0f, SK_Scalar1);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -623,7 +623,7 @@
y *= 2;
ratio *= 2;
}
- result = SkScalarClampMax((result + 1.0f) / 2.0f, 1.0f);
+ result = SkTPin((result + 1.0f) / 2.0f, 0.0f, 1.0f);
return result;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp
index 533a2a0..b25da38 100644
--- a/src/shaders/gradients/SkGradientShader.cpp
+++ b/src/shaders/gradients/SkGradientShader.cpp
@@ -187,7 +187,7 @@
const SkScalar uniformStep = desc.fPos[startIndex] - prev;
for (int i = startIndex; i < count; i++) {
// Pin the last value to 1.0, and make sure pos is monotonic.
- auto curr = (i == desc.fCount) ? 1 : SkScalarPin(desc.fPos[i], prev, 1);
+ auto curr = (i == desc.fCount) ? 1 : SkTPin(desc.fPos[i], prev, 1.0f);
uniformStops &= SkScalarNearlyEqual(uniformStep, curr - prev);
*origPosPtr++ = prev = curr;
diff --git a/src/utils/SkPatchUtils.cpp b/src/utils/SkPatchUtils.cpp
index e905bf7..1c6c2ac 100644
--- a/src/utils/SkPatchUtils.cpp
+++ b/src/utils/SkPatchUtils.cpp
@@ -357,9 +357,9 @@
indices[i + 4] = indices[i + 2];
indices[i + 5] = (x + 1) * stride + y;
}
- v = SkScalarClampMax(v + 1.f / lodY, 1);
+ v = SkTPin(v + 1.f / lodY, 0.0f, 1.0f);
}
- u = SkScalarClampMax(u + 1.f / lodX, 1);
+ u = SkTPin(u + 1.f / lodX, 0.0f, 1.0f);
}
if (tmpColors) {
diff --git a/src/utils/SkShadowTessellator.cpp b/src/utils/SkShadowTessellator.cpp
index 3e237b0..943567f 100644
--- a/src/utils/SkShadowTessellator.cpp
+++ b/src/utils/SkShadowTessellator.cpp
@@ -913,8 +913,8 @@
// umbraColor is the interior value, penumbraColor the exterior value.
auto outset = SkDrawShadowMetrics::AmbientBlurRadius(baseZ);
auto inset = outset * SkDrawShadowMetrics::AmbientRecipAlpha(baseZ) - outset;
- inset = SkScalarPin(inset, 0, SkTMin(path.getBounds().width(),
- path.getBounds().height()));
+ inset = SkTPin(inset, 0.0f, SkTMin(path.getBounds().width(),
+ path.getBounds().height()));
if (!this->computePathPolygon(path, ctm)) {
return;
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index a964555..1792244 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -1036,12 +1036,12 @@
}
}
-#define MAX_ZOOM_LEVEL 8
-#define MIN_ZOOM_LEVEL -8
+#define MAX_ZOOM_LEVEL 8.0f
+#define MIN_ZOOM_LEVEL -8.0f
void Viewer::changeZoomLevel(float delta) {
fZoomLevel += delta;
- fZoomLevel = SkScalarPin(fZoomLevel, MIN_ZOOM_LEVEL, MAX_ZOOM_LEVEL);
+ fZoomLevel = SkTPin(fZoomLevel, MIN_ZOOM_LEVEL, MAX_ZOOM_LEVEL);
this->preTouchMatrixChanged();
}