Add SkTPin.
Currently there exist SkScalarPin and SkPin32, and in a future change another version is desired. This change introduces SkTPin and changes SkScalarPin and SkPin32 to use it. Review URL: https://codereview.chromium.org/1090003002
This commit is contained in:
parent
5b9f42c4d1
commit
fd0ecf46ce
@ -175,9 +175,7 @@ static inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) {
|
||||
}
|
||||
|
||||
static inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) {
|
||||
x = SkTMin(x, max);
|
||||
x = SkTMax(x, min);
|
||||
return x;
|
||||
return SkTPin(x, min, max);
|
||||
}
|
||||
|
||||
SkScalar SkScalarSinCos(SkScalar radians, SkScalar* cosValue);
|
||||
|
@ -400,16 +400,13 @@ static inline int32_t SkFastMin32(int32_t value, int32_t max) {
|
||||
return value;
|
||||
}
|
||||
|
||||
/** Returns signed 32 bit value pinned between min and max, inclusively
|
||||
*/
|
||||
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) {
|
||||
if (value < min) {
|
||||
value = min;
|
||||
}
|
||||
if (value > max) {
|
||||
value = max;
|
||||
}
|
||||
return value;
|
||||
return SkTPin(value, min, max);
|
||||
}
|
||||
|
||||
static inline uint32_t SkSetClearShift(uint32_t bits, bool cond,
|
||||
|
Loading…
Reference in New Issue
Block a user