aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkColorPriv.h
diff options
context:
space:
mode:
authorGravatar benjaminwagner <benjaminwagner@google.com>2016-02-24 10:07:52 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-24 10:07:52 -0800
commitf156ea3c3edf4208ebfcb7761135768a840185d0 (patch)
treebe4d3aa275cb9576e8f851516de9adbc64ce1ce5 /include/core/SkColorPriv.h
parent37198864158b176dcc74b573f204db95a6a4fd2a (diff)
Change SkUnitScalarClampToByte to more accurate implementation.
The previous implementation was likely more efficient when SkScalar was SkFixed. BUG=skia:4632 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1691403002 Review URL: https://codereview.chromium.org/1691403002
Diffstat (limited to 'include/core/SkColorPriv.h')
-rw-r--r--include/core/SkColorPriv.h8
1 files changed, 1 insertions, 7 deletions
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h
index bd0e040566..40e6e15dc8 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