8#ifndef SkColorPriv_DEFINED
9#define SkColorPriv_DEFINED
34#define SkAlphaMul(value, alpha256) (((value) * (alpha256)) >> 8)
37 return static_cast<U8CPU>(
SkTPin(
x, 0.0f, 1.0f) * 255 + 0.5);
45#define SK_A32_MASK ((1 << SK_A32_BITS) - 1)
46#define SK_R32_MASK ((1 << SK_R32_BITS) - 1)
47#define SK_G32_MASK ((1 << SK_G32_BITS) - 1)
48#define SK_B32_MASK ((1 << SK_B32_BITS) - 1)
62#define SK_RGBA_R32_SHIFT 0
63#define SK_RGBA_G32_SHIFT 8
64#define SK_RGBA_B32_SHIFT 16
65#define SK_RGBA_A32_SHIFT 24
67#define SK_BGRA_B32_SHIFT 0
68#define SK_BGRA_G32_SHIFT 8
69#define SK_BGRA_R32_SHIFT 16
70#define SK_BGRA_A32_SHIFT 24
72#if defined(SK_PMCOLOR_IS_RGBA) || defined(SK_PMCOLOR_IS_BGRA)
73 #error "Configure PMCOLOR by setting SK_R32_SHIFT."
78#if (SK_A32_SHIFT == SK_RGBA_A32_SHIFT && \
79 SK_R32_SHIFT == SK_RGBA_R32_SHIFT && \
80 SK_G32_SHIFT == SK_RGBA_G32_SHIFT && \
81 SK_B32_SHIFT == SK_RGBA_B32_SHIFT)
82 #define SK_PMCOLOR_IS_RGBA
83#elif (SK_A32_SHIFT == SK_BGRA_A32_SHIFT && \
84 SK_R32_SHIFT == SK_BGRA_R32_SHIFT && \
85 SK_G32_SHIFT == SK_BGRA_G32_SHIFT && \
86 SK_B32_SHIFT == SK_BGRA_B32_SHIFT)
87 #define SK_PMCOLOR_IS_BGRA
89 #error "need 32bit packing to be either RGBA or BGRA"
92#define SkGetPackedA32(packed) ((uint32_t)((packed) << (24 - SK_A32_SHIFT)) >> 24)
93#define SkGetPackedR32(packed) ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24)
94#define SkGetPackedG32(packed) ((uint32_t)((packed) << (24 - SK_G32_SHIFT)) >> 24)
95#define SkGetPackedB32(packed) ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24)
97#define SkA32Assert(a) SkASSERT((unsigned)(a) <= SK_A32_MASK)
98#define SkR32Assert(r) SkASSERT((unsigned)(r) <= SK_R32_MASK)
99#define SkG32Assert(g) SkASSERT((unsigned)(g) <= SK_G32_MASK)
100#define SkB32Assert(b) SkASSERT((unsigned)(b) <= SK_B32_MASK)
143 uint32_t mask = 0xFF00FF;
145 uint32_t rb = ((c & mask) *
scale) >> 8;
146 uint32_t ag = ((c >> 8) & mask) *
scale;
147 return (rb & mask) | (ag & ~mask);
153 uint32_t mask = 0xFF00FF;
154 uint32_t rb = (((
dst & mask) *
scale) >> 8) & mask;
155 uint32_t ag = (((
dst >> 8) & mask) *
scale) & ~mask;
161 return std::min(rb & 0x000001FF, 0x000000FFU) |
162 std::min(ag & 0x0001FF00, 0x0000FF00U) |
163 std::min(rb & 0x01FF0000, 0x00FF0000U) |
static SkPMColor SkPMSrcOver(SkPMColor src, SkPMColor dst)
static SK_ALWAYS_INLINE uint32_t SkAlphaMulQ(uint32_t c, unsigned scale)
static SkPMColor SkPremultiplyARGBInline(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define SkGetPackedA32(packed)
static U8CPU SkUnitScalarClampToByte(SkScalar x)
static unsigned SkAlpha255To256(U8CPU alpha)
static SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
static SkPMColor SkPackARGB32NoCheck(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
static U8CPU SkMulDiv255Round(U16CPU a, U16CPU b)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
constexpr uint8_t SkToU8(S x)
static float min(float r, float g, float b)