diff options
author | 2017-09-15 14:02:15 -0400 | |
---|---|---|
committer | 2017-09-15 18:28:33 +0000 | |
commit | dbdc57cb405134db7f2dc146aa4ee7ad62d3b029 (patch) | |
tree | 287a158e6df30238fde5cd5a7f2e1ddd1da878a7 /include/core/SkColorPriv.h | |
parent | 7c55726156a6b2bda10035188be0077848bd3ede (diff) |
fix google3 colorpriv use
older versions of webkit
use more of colorpriv than
contemporary chrome
TBR=reed@google.com
Bug: skia: 6898
Change-Id: I4adcc7d04e2cdd7bf3a85e7d591337144105ab48
Reviewed-on: https://skia-review.googlesource.com/47180
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'include/core/SkColorPriv.h')
-rw-r--r-- | include/core/SkColorPriv.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h index bc8d3004e7..545421e0e8 100644 --- a/include/core/SkColorPriv.h +++ b/include/core/SkColorPriv.h @@ -8,6 +8,8 @@ #ifndef SkColorPriv_DEFINED #define SkColorPriv_DEFINED +#include "SkMath.h" + /** Turn 0..255 into 0..256 by adding 1 at the half-way point. Used to turn a byte into a scale value, so that we can say scale * value >> 8 instead of alpha * value / 255. @@ -31,8 +33,14 @@ static inline U8CPU SkUnitScalarClampToByte(SkScalar x) { } #define SK_A32_BITS 8 +#define SK_R32_BITS 8 +#define SK_G32_BITS 8 +#define SK_B32_BITS 8 #define SK_A32_MASK ((1 << SK_A32_BITS) - 1) +#define SK_R32_MASK ((1 << SK_R32_BITS) - 1) +#define SK_G32_MASK ((1 << SK_G32_BITS) - 1) +#define SK_B32_MASK ((1 << SK_B32_BITS) - 1) #define SkGetPackedA32(packed) ((uint32_t)((packed) << (24 - SK_A32_SHIFT)) >> 24) #define SkGetPackedR32(packed) ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24) @@ -40,6 +48,9 @@ static inline U8CPU SkUnitScalarClampToByte(SkScalar x) { #define SkGetPackedB32(packed) ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24) #define SkA32Assert(a) SkASSERT((unsigned)(a) <= SK_A32_MASK) +#define SkR32Assert(r) SkASSERT((unsigned)(r) <= SK_R32_MASK) +#define SkG32Assert(g) SkASSERT((unsigned)(g) <= SK_G32_MASK) +#define SkB32Assert(b) SkASSERT((unsigned)(b) <= SK_B32_MASK) /** * Pack the components into a SkPMColor, checking (in the debug version) that @@ -64,6 +75,21 @@ static inline SkPMColor SkPackARGB32NoCheck(U8CPU a, U8CPU r, U8CPU g, U8CPU b) (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT); } +static inline +SkPMColor SkPremultiplyARGBInline(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { + SkA32Assert(a); + SkR32Assert(r); + SkG32Assert(g); + SkB32Assert(b); + + if (a != 255) { + r = SkMulDiv255Round(r, a); + g = SkMulDiv255Round(g, a); + b = SkMulDiv255Round(b, a); + } + return SkPackARGB32(a, r, g, b); +} + // When Android is compiled optimizing for size, SkAlphaMulQ doesn't get // inlined; forcing inlining significantly improves performance. static SK_ALWAYS_INLINE uint32_t SkAlphaMulQ(uint32_t c, unsigned scale) { |