Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: include/core/SkScalar.h

Issue 993593002: Use SkTMin and SkTMax for clamp/pin. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: State type and auto convert constant. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkScalar.h
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index 3c1787ed2da5ead04788b16ba50cbb8e9116b127..fae23eb23a6c9a9b7862c215a41fb9f5ec4841d7 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698