8#ifndef SkColorData_DEFINED
9#define SkColorData_DEFINED
22#define SK_R16_SHIFT (SK_B16_BITS + SK_G16_BITS)
23#define SK_G16_SHIFT (SK_B16_BITS)
26#define SK_R16_MASK ((1 << SK_R16_BITS) - 1)
27#define SK_G16_MASK ((1 << SK_G16_BITS) - 1)
28#define SK_B16_MASK ((1 << SK_B16_BITS) - 1)
30#define SkGetPackedR16(color) (((unsigned)(color) >> SK_R16_SHIFT) & SK_R16_MASK)
31#define SkGetPackedG16(color) (((unsigned)(color) >> SK_G16_SHIFT) & SK_G16_MASK)
32#define SkGetPackedB16(color) (((unsigned)(color) >> SK_B16_SHIFT) & SK_B16_MASK)
46#define SkPacked16ToR32(c) SkR16ToR32(SkGetPackedR16(c))
47#define SkPacked16ToG32(c) SkG16ToG32(SkGetPackedG16(c))
48#define SkPacked16ToB32(c) SkB16ToB32(SkGetPackedB16(c))
52#define SkASSERT_IS_BYTE(x) SkASSERT(0 == ((x) & ~0xFFu))
84#ifdef SK_PMCOLOR_IS_RGBA
92#ifdef SK_PMCOLOR_IS_BGRA
103#define SK_ITU_BT709_LUM_COEFF_R (0.2126f)
104#define SK_ITU_BT709_LUM_COEFF_G (0.7152f)
105#define SK_ITU_BT709_LUM_COEFF_B (0.0722f)
110#define SK_LUM_COEFF_R SK_ITU_BT709_LUM_COEFF_R
111#define SK_LUM_COEFF_G SK_ITU_BT709_LUM_COEFF_G
112#define SK_LUM_COEFF_B SK_ITU_BT709_LUM_COEFF_B
122 return (r * 54 + g * 183 +
b * 19) >> 8;
129 unsigned prod = 0xFFFF -
value * alpha256;
130 return (prod + (prod >> 8)) >> 8;
137 SkASSERT((
unsigned)scale256 <= 256);
141static inline uint16_t
SkPackRGB16(
unsigned r,
unsigned g,
unsigned b) {
149#define SK_R16_MASK_IN_PLACE (SK_R16_MASK << SK_R16_SHIFT)
150#define SK_G16_MASK_IN_PLACE (SK_G16_MASK << SK_G16_SHIFT)
151#define SK_B16_MASK_IN_PLACE (SK_B16_MASK << SK_B16_SHIFT)
185static inline void SkSplay(uint32_t
color, uint32_t* ag, uint32_t* rb) {
186 const uint32_t mask = 0x00FF00FF;
187 *ag = (
color >> 8) & mask;
196 const uint32_t mask = 0x00FF00FF;
197 uint64_t agrb = (
color >> 8) & mask;
199 agrb |=
color & mask;
206static inline uint32_t
SkUnsplay(uint32_t ag, uint32_t rb) {
207 const uint32_t mask = 0xFF00FF00;
208 return (ag & mask) | ((rb & mask) >> 8);
216 const uint32_t mask = 0xFF00FF00;
218 ((agrb & mask) >> 8) |
219 ((agrb >> 32) & mask));
226 uint32_t src_ag, src_rb, dst_ag, dst_rb;
230 const uint32_t ret_ag = src_ag *
scale + (256 -
scale) * dst_ag;
231 const uint32_t ret_rb = src_rb *
scale + (256 -
scale) * dst_rb;
249 if (
sizeof(
void*) == 4) {
280 const uint32_t mask = 0xFF00FF;
282 uint32_t src_rb = (
src & mask) * src_scale;
283 uint32_t src_ag = ((
src >> 8) & mask) * src_scale;
285 uint32_t dst_rb = (
dst & mask) * dst_scale;
286 uint32_t dst_ag = ((
dst >> 8) & mask) * dst_scale;
288 return (((src_rb + dst_rb) >> 8) & mask) | ((src_ag + dst_ag) & ~mask);
294#define SkR32ToR16_MACRO(r) ((unsigned)(r) >> (SK_R32_BITS - SK_R16_BITS))
295#define SkG32ToG16_MACRO(g) ((unsigned)(g) >> (SK_G32_BITS - SK_G16_BITS))
296#define SkB32ToB16_MACRO(b) ((unsigned)(b) >> (SK_B32_BITS - SK_B16_BITS))
299 static inline unsigned SkR32ToR16(
unsigned r) {
303 static inline unsigned SkG32ToG16(
unsigned g) {
312 #define SkR32ToR16(r) SkR32ToR16_MACRO(r)
313 #define SkG32ToG16(g) SkG32ToG16_MACRO(g)
314 #define SkB32ToB16(b) SkB32ToB16_MACRO(b)
351#define SK_A4444_SHIFT 0
352#define SK_R4444_SHIFT 12
353#define SK_G4444_SHIFT 8
354#define SK_B4444_SHIFT 4
358 return (nib << 4) | nib;
361#define SkGetPackedA4444(c) (((unsigned)(c) >> SK_A4444_SHIFT) & 0xF)
362#define SkGetPackedR4444(c) (((unsigned)(c) >> SK_R4444_SHIFT) & 0xF)
363#define SkGetPackedG4444(c) (((unsigned)(c) >> SK_G4444_SHIFT) & 0xF)
364#define SkGetPackedB4444(c) (((unsigned)(c) >> SK_B4444_SHIFT) & 0xF)
366#define SkPacked4444ToA32(c) SkReplicateNibble(SkGetPackedA4444(c))
static int SkAlphaBlend(int src, int dst, int scale256)
constexpr SkPMColor4f SK_PMColor4fILLEGAL
static SkPMColor SkPMLerp(SkPMColor src, SkPMColor dst, unsigned scale)
static unsigned SkB16ToB32(unsigned b)
static SkPMColor SkFastFourByteInterp256(SkPMColor src, SkPMColor dst, unsigned scale)
#define SkB32ToB16_MACRO(b)
static uint32_t SkPackARGB_as_RGBA(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define SkGetPackedR4444(c)
#define SkGetPackedB16(color)
#define SkGetPackedG16(color)
static void SkSplay(uint32_t color, uint32_t *ag, uint32_t *rb)
static U8CPU SkComputeLuminance(U8CPU r, U8CPU g, U8CPU b)
constexpr SkPMColor4f SK_PMColor4fWHITE
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
static SkPMColor SkFastFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight)
static uint32_t SkUnsplay(uint32_t ag, uint32_t rb)
static U16CPU SkPack888ToRGB16(U8CPU r, U8CPU g, U8CPU b)
#define SkR32ToR16_MACRO(r)
static U16CPU SkPixel32ToPixel16(SkPMColor c)
static U8CPU SkReplicateNibble(unsigned nib)
#define SkG32ToG16_MACRO(g)
static SkPMColor SkFastFourByteInterp256_64(SkPMColor src, SkPMColor dst, unsigned scale)
static SkPMColor SkPixel4444ToPixel32(U16CPU c)
static uint32_t SkSwizzle_RB(uint32_t c)
#define SkPacked16ToG32(c)
constexpr SkPMColor4f SK_PMColor4fBLACK
static uint32_t SkPackARGB_as_BGRA(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
static uint16_t SkPackRGB16(unsigned r, unsigned g, unsigned b)
static SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight)
#define SkGetPackedR16(color)
static SkColor SkPixel16ToColor(U16CPU src)
static SkPMColor SkFourByteInterp256(SkPMColor src, SkPMColor dst, int scale)
#define SkPacked16ToR32(c)
#define SkASSERT_IS_BYTE(x)
static U16CPU SkAlphaMulInv256(U16CPU value, U16CPU alpha256)
static SkPMColor SkSwizzle_RGBA_to_PMColor(uint32_t c)
#define SkGetPackedB4444(c)
static unsigned SkG16ToG32(unsigned g)
static SkPMColor SkSwizzle_BGRA_to_PMColor(uint32_t c)
static SkPMColor SkFastFourByteInterp256_32(SkPMColor src, SkPMColor dst, unsigned scale)
#define SkGetPackedG4444(c)
#define SkPacked16ToB32(c)
static SkPMColor SkBlendARGB32(SkPMColor src, SkPMColor dst, U8CPU aa)
static unsigned SkR16ToR32(unsigned r)
#define SkGetPackedA4444(c)
#define SK_BGRA_R32_SHIFT
#define SkGetPackedB32(packed)
#define SkGetPackedR32(packed)
#define SK_BGRA_B32_SHIFT
#define SK_BGRA_G32_SHIFT
#define SK_RGBA_A32_SHIFT
#define SkAlphaMul(value, alpha256)
#define SK_RGBA_G32_SHIFT
#define SkGetPackedA32(packed)
#define SkGetPackedG32(packed)
#define SK_RGBA_B32_SHIFT
#define SK_BGRA_A32_SHIFT
#define SK_RGBA_R32_SHIFT
static unsigned SkAlpha255To256(U8CPU alpha)
static SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define SkColorSetRGB(r, g, b)
constexpr float SK_FloatNegativeInfinity
constexpr uint16_t SkToU16(S x)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d