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/SkColorPriv.h

Issue 1691403002: Change SkUnitScalarClampToByte to more accurate implementation. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Revert to Patch 2. Created 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkColorPriv.h
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h
index bd0e040566cb0408c8ea5697d4e7c2c20781de43..40e6e15dc8873d823ff863f33196f852190b39b8 100644
--- a/include/core/SkColorPriv.h
+++ b/include/core/SkColorPriv.h
@@ -224,13 +224,7 @@ static inline int SkAlphaBlend255(S16CPU src, S16CPU dst, U8CPU alpha) {
}
static inline U8CPU SkUnitScalarClampToByte(SkScalar x) {
- if (x < 0) {
- return 0;
- }
- if (x >= SK_Scalar1) {
- return 255;
- }
- return SkScalarToFixed(x) >> 8;
+ return static_cast<U8CPU>(SkScalarPin(x, 0, 1) * 255 + 0.5);
}
#define SK_R16_BITS 5
« 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