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

Unified Diff: include/core/SkScalar.h

Issue 977623002: Glyph positions maintain 32 bit integer part. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Branchless (on Clang). Created 5 years, 10 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 | src/core/SkTextMapStateProc.h » ('j') | src/core/SkTextMapStateProc.h » ('J')
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..9c51cf9980ae42b86d3d914704a05cc1a210a0d3 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(x, 0);
+ return x;
}
static inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) {
bungeman-skia 2015/03/04 21:38:05 With clang 3.5 this code turns into branch-less ma
mtklein 2015/03/04 21:45:30 Ah, that explains it. Thanks! This bit LGTM.
- 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 | src/core/SkTextMapStateProc.h » ('j') | src/core/SkTextMapStateProc.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698