From f156ea3c3edf4208ebfcb7761135768a840185d0 Mon Sep 17 00:00:00 2001 From: benjaminwagner Date: Wed, 24 Feb 2016 10:07:52 -0800 Subject: [PATCH] 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 --- include/core/SkColorPriv.h | 8 +------- 1 file changed, 1 insertion(+), 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(SkScalarPin(x, 0, 1) * 255 + 0.5); } #define SK_R16_BITS 5