| Index: include/core/SkColorPriv.h
|
| diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h
|
| index 15c94ac68ca2f3fe289150dc08427d396cc64c87..f9c5d928a0b06b842741ca112fe395f269a6ca40 100644
|
| --- a/include/core/SkColorPriv.h
|
| +++ b/include/core/SkColorPriv.h
|
| @@ -369,6 +369,18 @@ static inline void SkBlendRGB16(const uint16_t src[], uint16_t dst[],
|
| #define SkPMColorAssert(c)
|
| #endif
|
|
|
| +static inline bool SkPMColorValid(SkPMColor c) {
|
| + auto a = SkGetPackedA32(c);
|
| + bool valid = a <= SK_A32_MASK
|
| + && SkGetPackedR32(c) <= a
|
| + && SkGetPackedG32(c) <= a
|
| + && SkGetPackedB32(c) <= a;
|
| + if (valid) {
|
| + SkPMColorAssert(c); // Make sure we're consistent when it counts.
|
| + }
|
| + return valid;
|
| +}
|
| +
|
| /**
|
| * Pack the components into a SkPMColor, checking (in the debug version) that
|
| * the components are 0..255, and are already premultiplied (i.e. alpha >= color)
|
|
|