diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBlitRow_D16.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/core/SkBlitRow_D16.cpp b/src/core/SkBlitRow_D16.cpp index 07c42ceb0b..72c9d527dc 100644 --- a/src/core/SkBlitRow_D16.cpp +++ b/src/core/SkBlitRow_D16.cpp @@ -63,27 +63,16 @@ static void S32A_D565_Blend(uint16_t* SK_RESTRICT dst, SkASSERT(255 > alpha); if (count > 0) { - int src_scale = SkAlpha255To256(alpha); do { SkPMColor sc = *src++; SkPMColorAssert(sc); - if (sc) - { + if (sc) { uint16_t dc = *dst; - unsigned sa = SkGetPackedA32(sc); - unsigned dr, dg, db; - - if (sa == 255) { - dr = SkAlphaBlend(SkPacked32ToR16(sc), SkGetPackedR16(dc), src_scale); - dg = SkAlphaBlend(SkPacked32ToG16(sc), SkGetPackedG16(dc), src_scale); - db = SkAlphaBlend(SkPacked32ToB16(sc), SkGetPackedB16(dc), src_scale); - } else { - unsigned dst_scale = 255 - SkAlphaMul(sa, src_scale); - dr = (SkPacked32ToR16(sc) * src_scale + SkGetPackedR16(dc) * dst_scale) >> 8; - dg = (SkPacked32ToG16(sc) * src_scale + SkGetPackedG16(dc) * dst_scale) >> 8; - db = (SkPacked32ToB16(sc) * src_scale + SkGetPackedB16(dc) * dst_scale) >> 8; - } - *dst = SkPackRGB16(dr, dg, db); + unsigned dst_scale = 255 - SkMulDiv255Round(SkGetPackedA32(sc), alpha); + unsigned dr = SkMulS16(SkPacked32ToR16(sc), alpha) + SkMulS16(SkGetPackedR16(dc), dst_scale); + unsigned dg = SkMulS16(SkPacked32ToG16(sc), alpha) + SkMulS16(SkGetPackedG16(dc), dst_scale); + unsigned db = SkMulS16(SkPacked32ToB16(sc), alpha) + SkMulS16(SkGetPackedB16(dc), dst_scale); + *dst = SkPackRGB16(SkDiv255Round(dr), SkDiv255Round(dg), SkDiv255Round(db)); } dst += 1; } while (--count != 0); |