Use SkTMin and SkTMax for clamp/pin.
This changes SkScalarClampMax and SkScalarPin to use SkTMin and SkTMax. This change allows compilers to more easily transform these operations into fast max/min operarations as opposed to conditional branches. Review URL: https://codereview.chromium.org/993593002
This commit is contained in:
parent
a548593a65
commit
167eb17cd6
@ -169,11 +169,15 @@ static inline int SkDScalarRoundToInt(SkScalar x) {
|
||||
}
|
||||
|
||||
static inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) {
|
||||
return x < 0 ? 0 : x > max ? max : x;
|
||||
x = SkTMin(x, max);
|
||||
x = SkTMax<SkScalar>(x, 0);
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) {
|
||||
return x < min ? min : x > max ? max : x;
|
||||
x = SkTMin(x, max);
|
||||
x = SkTMax(x, min);
|
||||
return x;
|
||||
}
|
||||
|
||||
SkScalar SkScalarSinCos(SkScalar radians, SkScalar* cosValue);
|
||||
|
Loading…
Reference in New Issue
Block a user