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/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