diff --git a/src/core/SkSpriteBlitter_ARGB32.cpp b/src/core/SkSpriteBlitter_ARGB32.cpp index 3ecfcf472b..27fc86d601 100644 --- a/src/core/SkSpriteBlitter_ARGB32.cpp +++ b/src/core/SkSpriteBlitter_ARGB32.cpp @@ -148,109 +148,6 @@ private: typedef Sprite_D32_XferFilter INHERITED; }; -static void fillbuffer(SkPMColor* SK_RESTRICT dst, - const SkPMColor16* SK_RESTRICT src, int count) { - SkASSERT(count > 0); - - do { - *dst++ = SkPixel4444ToPixel32(*src++); - } while (--count != 0); -} - -class Sprite_D32_S4444_XferFilter : public Sprite_D32_XferFilter { -public: - Sprite_D32_S4444_XferFilter(const SkPixmap& source, const SkPaint& paint) - : Sprite_D32_XferFilter(source, paint) {} - - void blitRect(int x, int y, int width, int height) override { - SkASSERT(width > 0 && height > 0); - SkPMColor* SK_RESTRICT dst = fDst.writable_addr32(x, y); - const SkPMColor16* SK_RESTRICT src = fSource.addr16(x - fLeft, y - fTop); - size_t dstRB = fDst.rowBytes(); - size_t srcRB = fSource.rowBytes(); - SkPMColor* SK_RESTRICT buffer = fBuffer; - SkColorFilter* colorFilter = fColorFilter; - SkXfermode* xfermode = fXfermode; - - do { - fillbuffer(buffer, src, width); - - if (colorFilter) { - colorFilter->filterSpan(buffer, width, buffer); - } - if (xfermode) { - xfermode->xfer32(dst, buffer, width, nullptr); - } else { - fProc32(dst, buffer, width, fAlpha); - } - - dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB); - src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB); - } while (--height != 0); - } - -private: - typedef Sprite_D32_XferFilter INHERITED; -}; - -/////////////////////////////////////////////////////////////////////////////// - -static void src_row(SkPMColor* SK_RESTRICT dst, - const SkPMColor16* SK_RESTRICT src, int count) { - do { - *dst = SkPixel4444ToPixel32(*src); - src += 1; - dst += 1; - } while (--count != 0); -} - -class Sprite_D32_S4444_Opaque : public SkSpriteBlitter { -public: - Sprite_D32_S4444_Opaque(const SkPixmap& source) : SkSpriteBlitter(source) {} - - void blitRect(int x, int y, int width, int height) override { - SkASSERT(width > 0 && height > 0); - SkPMColor* SK_RESTRICT dst = fDst.writable_addr32(x, y); - const SkPMColor16* SK_RESTRICT src = fSource.addr16(x - fLeft, y - fTop); - size_t dstRB = fDst.rowBytes(); - size_t srcRB = fSource.rowBytes(); - - do { - src_row(dst, src, width); - dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB); - src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB); - } while (--height != 0); - } -}; - -static void srcover_row(SkPMColor* SK_RESTRICT dst, - const SkPMColor16* SK_RESTRICT src, int count) { - do { - *dst = SkPMSrcOver(SkPixel4444ToPixel32(*src), *dst); - src += 1; - dst += 1; - } while (--count != 0); -} - -class Sprite_D32_S4444 : public SkSpriteBlitter { -public: - Sprite_D32_S4444(const SkPixmap& source) : SkSpriteBlitter(source) {} - - void blitRect(int x, int y, int width, int height) override { - SkASSERT(width > 0 && height > 0); - SkPMColor* SK_RESTRICT dst = fDst.writable_addr32(x, y); - const SkPMColor16* SK_RESTRICT src = fSource.addr16(x - fLeft, y - fTop); - size_t dstRB = fDst.rowBytes(); - size_t srcRB = fSource.rowBytes(); - - do { - srcover_row(dst, src, width); - dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB); - src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB); - } while (--height != 0); - } -}; - /////////////////////////////////////////////////////////////////////////////// SkSpriteBlitter* SkSpriteBlitter::ChooseL32(const SkPixmap& source, const SkPaint& paint, @@ -266,32 +163,16 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseL32(const SkPixmap& source, const SkPain SkColorFilter* filter = paint.getColorFilter(); SkSpriteBlitter* blitter = nullptr; - switch (source.colorType()) { - case kARGB_4444_SkColorType: - if (alpha != 0xFF) { - return nullptr; // we only have opaque sprites + if (source.colorType() == kN32_SkColorType) { + if (!isSrcOver || filter) { + if (255 == alpha) { + // this can handle xfermode or filter, but not alpha + blitter = allocator->make(source, paint); } - if (!isSrcOver || filter) { - blitter = allocator->make(source, paint); - } else if (source.isOpaque()) { - blitter = allocator->make(source); - } else { - blitter = allocator->make(source); - } - break; - case kN32_SkColorType: - if (!isSrcOver || filter) { - if (255 == alpha) { - // this can handle xfermode or filter, but not alpha - blitter = allocator->make(source, paint); - } - } else { - // this can handle alpha, but not xfermode or filter - blitter = allocator->make(source, alpha); - } - break; - default: - break; + } else { + // this can handle alpha, but not xfermode or filter + blitter = allocator->make(source, alpha); + } } return blitter; }