static SkPMColor mult_modeproc(SkPMColor src, SkPMColor dst) { int a = SkAlphaMulAlpha(SkGetPackedA32(src), SkGetPackedA32(dst)); int r = SkAlphaMulAlpha(SkGetPackedR32(src), SkGetPackedR32(dst)); int g = SkAlphaMulAlpha(SkGetPackedG32(src), SkGetPackedG32(dst)); int b = SkAlphaMulAlpha(SkGetPackedB32(src), SkGetPackedB32(dst)); return SkPackARGB32(a, r, g, b); }
static uint16_t srcatop_modeproc16(SkPMColor src, uint16_t dst) { unsigned isa = 255 - SkGetPackedA32(src); return SkPackRGB16( SkPacked32ToR16(src) + SkAlphaMulAlpha(SkGetPackedR16(dst), isa), SkPacked32ToG16(src) + SkAlphaMulAlpha(SkGetPackedG16(dst), isa), SkPacked32ToB16(src) + SkAlphaMulAlpha(SkGetPackedB16(dst), isa)); }
// kColorBurn_Mode static inline int colorburn_byte(int sc, int dc, int sa, int da) { int rc; if (dc == da) { rc = sa * da + sc * (255 - da) + dc * (255 - sa); } else if (0 == sc) { return SkAlphaMulAlpha(dc, 255 - sa); } else { int tmp = (da - dc) * sa / sc; rc = sa * (da - ((da < tmp) ? da : tmp)) + sc * (255 - da) + dc * (255 - sa); } return clamp_div255round(rc); }
// kColorDodge_Mode static inline int colordodge_byte(int sc, int dc, int sa, int da) { int diff = sa - sc; int rc; if (0 == dc) { return SkAlphaMulAlpha(sc, 255 - da); } else if (0 == diff) { rc = sa * da + sc * (255 - da) + dc * (255 - sa); } else { diff = dc * sa / diff; rc = sa * ((da < diff) ? da : diff) + sc * (255 - da) + dc * (255 - sa); } return clamp_div255round(rc); }
// kXor_Mode [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc] static SkPMColor xor_modeproc(SkPMColor src, SkPMColor dst) { unsigned sa = SkGetPackedA32(src); unsigned da = SkGetPackedA32(dst); unsigned isa = 255 - sa; unsigned ida = 255 - da; return SkPackARGB32(sa + da - (SkAlphaMulAlpha(sa, da) << 1), SkAlphaMulAlpha(ida, SkGetPackedR32(src)) + SkAlphaMulAlpha(isa, SkGetPackedR32(dst)), SkAlphaMulAlpha(ida, SkGetPackedG32(src)) + SkAlphaMulAlpha(isa, SkGetPackedG32(dst)), SkAlphaMulAlpha(ida, SkGetPackedB32(src)) + SkAlphaMulAlpha(isa, SkGetPackedB32(dst))); }
static SkPMColor lighten_modeproc(SkPMColor src, SkPMColor dst) { unsigned sa = SkGetPackedA32(src); unsigned da = SkGetPackedA32(dst); unsigned src_scale = SkAlpha255To256(255 - sa); unsigned dst_scale = SkAlpha255To256(255 - da); unsigned ra = sa + da - SkAlphaMulAlpha(sa, da); unsigned rr = lighten_p(SkGetPackedR32(src), SkGetPackedR32(dst), src_scale, dst_scale); unsigned rg = lighten_p(SkGetPackedG32(src), SkGetPackedG32(dst), src_scale, dst_scale); unsigned rb = lighten_p(SkGetPackedB32(src), SkGetPackedB32(dst), src_scale, dst_scale); return SkPackARGB32(ra, SkFastMin32(rr, ra), SkFastMin32(rg, ra), SkFastMin32(rb, ra)); }
virtual void xferA8(SK_RESTRICT SkAlpha dst[], const SK_RESTRICT SkPMColor[], int count, const SK_RESTRICT SkAlpha aa[]) { SkASSERT(dst && count >= 0); if (NULL == aa) { memset(dst, 0, count); } else { for (int i = count - 1; i >= 0; --i) { unsigned a = aa[i]; if (0xFF == a) { dst[i] = 0; } else if (0 != a) { dst[i] = SkAlphaMulAlpha(dst[i], 255 - a); } } } }
// kSrcATop_Mode, //!< [Da, Sc * Da + (1 - Sa) * Dc] static SkPMColor srcatop_modeproc(SkPMColor src, SkPMColor dst) { unsigned sa = SkGetPackedA32(src); unsigned da = SkGetPackedA32(dst); unsigned isa = 255 - sa; return SkPackARGB32(da, SkAlphaMulAlpha(da, SkGetPackedR32(src)) + SkAlphaMulAlpha(isa, SkGetPackedR32(dst)), SkAlphaMulAlpha(da, SkGetPackedG32(src)) + SkAlphaMulAlpha(isa, SkGetPackedG32(dst)), SkAlphaMulAlpha(da, SkGetPackedB32(src)) + SkAlphaMulAlpha(isa, SkGetPackedB32(dst))); }
static inline int screen_byte(int a, int b) { return a + b - SkAlphaMulAlpha(a, b); }
static inline int srcover_byte(int a, int b) { return a + b - SkAlphaMulAlpha(a, b); }