Replace SkPin32 with SkTPin and remove.

SkPin32 is already just forwarding to SkTPin, so convert existing
users and remove SkPin32.

Review URL: https://codereview.chromium.org/1314583003
This commit is contained in:
bungeman 2015-08-28 09:09:32 -07:00 committed by Commit bot
parent 7445cef42f
commit 62ce0303fb
8 changed files with 17 additions and 21 deletions

View File

@ -392,13 +392,9 @@ static inline int32_t SkFastMin32(int32_t value, int32_t max) {
return value;
}
template <typename T> static inline const T& SkTPin(const T& x, const T& min, const T& max) {
return SkTMax(SkTMin(x, max), min);
}
/** Returns signed 32 bit value pinned between min and max, inclusively. */
static inline int32_t SkPin32(int32_t value, int32_t min, int32_t max) {
return SkTPin(value, min, max);
/** Returns value pinned between min and max, inclusively. */
template <typename T> static inline const T& SkTPin(const T& value, const T& min, const T& max) {
return SkTMax(SkTMin(value, max), min);
}
static inline uint32_t SkSetClearShift(uint32_t bits, bool cond,

View File

@ -199,7 +199,7 @@ SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, int dx, int dy) {
if (pr) {
const SkImageInfo& info = pr->info();
fPixelRefOrigin.set(SkPin32(dx, 0, info.width()), SkPin32(dy, 0, info.height()));
fPixelRefOrigin.set(SkTPin(dx, 0, info.width()), SkTPin(dy, 0, info.height()));
} else {
// ignore dx,dy if there is no pixelref
fPixelRefOrigin.setZero();

View File

@ -18,9 +18,9 @@ SkFontStyle::SkFontStyle() {
SkFontStyle::SkFontStyle(int weight, int width, Slant slant) {
fUnion.fU32 = 0;
fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight);
fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width);
fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant);
fUnion.fR.fWeight = SkTPin<int>(weight, kThin_Weight, kBlack_Weight);
fUnion.fR.fWidth = SkTPin<int>(width, kUltraCondensed_Width, kUltaExpanded_Width);
fUnion.fR.fSlant = SkTPin<int>(slant, kUpright_Slant, kItalic_Slant);
}
SkFontStyle::SkFontStyle(unsigned oldStyle) {

View File

@ -509,7 +509,7 @@ void SkString::insertU64(size_t offset, uint64_t dec, int minDigits) {
}
void SkString::insertHex(size_t offset, uint32_t hex, int minDigits) {
minDigits = SkPin32(minDigits, 0, 8);
minDigits = SkTPin(minDigits, 0, 8);
static const char gHex[] = "0123456789ABCDEF";

View File

@ -361,8 +361,8 @@ bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src,
SkScalar y_interp = SkScalarMul(weight, (fSrcRect.y() + y * inv_y_zoom)) +
(SK_Scalar1 - weight) * y;
int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1);
int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1);
int x_val = SkTPin(SkScalarFloorToInt(x_interp), 0, width - 1);
int y_val = SkTPin(SkScalarFloorToInt(y_interp), 0, height - 1);
*dptr = sptr[y_val * width + x_val];
dptr++;

View File

@ -126,8 +126,8 @@ public:
class ClampPixelFetcher {
public:
static inline SkPMColor fetch(const SkBitmap& src, int x, int y, const SkIRect& bounds) {
x = SkPin32(x, bounds.fLeft, bounds.fRight - 1);
y = SkPin32(y, bounds.fTop, bounds.fBottom - 1);
x = SkTPin(x, bounds.fLeft, bounds.fRight - 1);
y = SkTPin(y, bounds.fTop, bounds.fBottom - 1);
return *src.getAddr32(x, y);
}
};

View File

@ -91,7 +91,7 @@ void SkTableMaskFilter::MakeGammaTable(uint8_t table[256], SkScalar gamma) {
float x = 0;
for (int i = 0; i < 256; i++) {
// float ee = powf(x, g) * 255;
table[i] = SkPin32(sk_float_round2int(powf(x, g) * 255), 0, 255);
table[i] = SkTPin(sk_float_round2int(powf(x, g) * 255), 0, 255);
x += dx;
}
}

View File

@ -92,10 +92,10 @@ void shadeSpan16_radial_clamp(SkScalar sfx, SkScalar sdx,
// might perform this check for the other modes,
// but the win will be a smaller % of the total
if (dy == 0) {
fy = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1);
fy = SkTPin(fy, -0xFFFF >> 1, 0xFFFF >> 1);
fy *= fy;
do {
unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1);
unsigned xx = SkTPin(fx, -0xFFFF >> 1, 0xFFFF >> 1);
unsigned fi = (xx * xx + fy) >> (14 + 16 - kSQRT_TABLE_BITS);
fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS));
fx += dx;
@ -105,8 +105,8 @@ void shadeSpan16_radial_clamp(SkScalar sfx, SkScalar sdx,
} while (--count != 0);
} else {
do {
unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1);
unsigned fi = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1);
unsigned xx = SkTPin(fx, -0xFFFF >> 1, 0xFFFF >> 1);
unsigned fi = SkTPin(fy, -0xFFFF >> 1, 0xFFFF >> 1);
fi = (xx * xx + fi * fi) >> (14 + 16 - kSQRT_TABLE_BITS);
fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS));
fx += dx;