Chromium Code Reviews| Index: src/core/SkBlitter_RGB16.cpp |
| diff --git a/src/core/SkBlitter_RGB16.cpp b/src/core/SkBlitter_RGB16.cpp |
| index d9193ecf8f1952202b29875426296ce253d14fc0..cff0066ab4a87f3cc0342e7b7cdb299107a28df7 100644 |
| --- a/src/core/SkBlitter_RGB16.cpp |
| +++ b/src/core/SkBlitter_RGB16.cpp |
| @@ -70,6 +70,7 @@ public: |
| protected: |
| SkPMColor fSrcColor32; |
| + SkPMColor fSrcColors32[8]; |
| uint32_t fExpandedRaw16; |
| unsigned fScale; |
| uint16_t fColor16; // already scaled by fScale |
| @@ -77,6 +78,8 @@ protected: |
| uint16_t fRawDither16; // unscaled |
| SkBool8 fDoDither; |
| + SkBlitRow::ColorProc16 fColorProc16; |
| + |
| // illegal |
| SkRGB16_Blitter& operator=(const SkRGB16_Blitter&); |
| @@ -527,6 +530,11 @@ SkRGB16_Blitter::SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint) |
| SkColor color = paint.getColor(); |
| fSrcColor32 = SkPreMultiplyColor(color); |
| + |
| + for (int count = 0; count < 8; count++) { |
|
djsollen
2015/01/14 14:57:54
We shouldn't need to do this here. You can just d
mlee
2015/01/15 08:12:36
On 2015/01/14 14:57:54, djsollen wrote:
Hi, djsol
mlee
2015/01/21 10:17:32
On 2015/01/14 14:57:54, djsollen wrote:
Done in pa
|
| + fSrcColors32[count] = fSrcColor32; |
| + } |
| + |
| fScale = SkAlpha255To256(SkColorGetA(color)); |
| int r = SkColorGetR(color); |
| @@ -544,6 +552,14 @@ SkRGB16_Blitter::SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint) |
| fColor16 = SkPackRGB16( SkAlphaMul(r, fScale) >> (8 - SK_R16_BITS), |
| SkAlphaMul(g, fScale) >> (8 - SK_G16_BITS), |
| SkAlphaMul(b, fScale) >> (8 - SK_B16_BITS)); |
| + |
| + // compute SkBlitRow::Procs |
| + unsigned flags = 0; |
| + |
| + // TODO: respect fDoDither |
| + flags |= SkBlitRow::kSrcPixelAlpha_Flag; |
| + |
| + fColorProc16 = SkBlitRow::PlatformColorFactory565(flags); |
| } |
| const SkBitmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) { |
| @@ -554,31 +570,12 @@ const SkBitmap* SkRGB16_Blitter::justAnOpaqueColor(uint32_t* value) { |
| return NULL; |
| } |
| -static uint32_t pmcolor_to_expand16(SkPMColor c) { |
| - unsigned r = SkGetPackedR32(c); |
| - unsigned g = SkGetPackedG32(c); |
| - unsigned b = SkGetPackedB32(c); |
| - return (g << 24) | (r << 13) | (b << 2); |
| -} |
| - |
| -static inline void blend32_16_row(SkPMColor src, uint16_t dst[], int count) { |
| - SkASSERT(count > 0); |
| - uint32_t src_expand = pmcolor_to_expand16(src); |
| - unsigned scale = SkAlpha255To256(0xFF - SkGetPackedA32(src)) >> 3; |
| - do { |
| - uint32_t dst_expand = SkExpand_rgb_16(*dst) * scale; |
| - *dst = SkCompact_rgb_16((src_expand + dst_expand) >> 5); |
| - dst += 1; |
| - } while (--count != 0); |
| -} |
| - |
| void SkRGB16_Blitter::blitH(int x, int y, int width) { |
| SkASSERT(width > 0); |
| SkASSERT(x + width <= fDevice.width()); |
| uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); |
| - // TODO: respect fDoDither |
| - blend32_16_row(fSrcColor32, device, width); |
| + fColorProc16(device, fSrcColors32, width, x, y); |
| } |
| void SkRGB16_Blitter::blitAntiH(int x, int y, |
| @@ -681,10 +678,9 @@ void SkRGB16_Blitter::blitRect(int x, int y, int width, int height) { |
| SkASSERT(x + width <= fDevice.width() && y + height <= fDevice.height()); |
| uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y); |
| size_t deviceRB = fDevice.rowBytes(); |
| - SkPMColor src32 = fSrcColor32; |
| while (--height >= 0) { |
| - blend32_16_row(src32, device, width); |
| + fColorProc16(device, fSrcColors32, width, x, y); |
| device = (uint16_t*)((char*)device + deviceRB); |
| } |
| } |