aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-06-29 09:40:04 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-29 14:35:06 +0000
commite43fba1d649bbd40532320f1f2c8760434f28630 (patch)
tree335aa4474ddac81352ba9a87c75266b7bae0bbc0
parent5f46e96757e9b914485cc6c819ed97b637503fcc (diff)
clean up colorfilter sprite blitters
Instead of rejecting all sprite blitters when there's a color filter, just remove the old legacy color filter sprite blitters. The SkRasterPipelineSpriteBlitter can still handle color filters... no need to fall back to the general shader (gather) blitter. Change-Id: Ib27f3e153612d0d904093da68223c2b862b17f63 Reviewed-on: https://skia-review.googlesource.com/21204 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Reed <reed@google.com>
-rw-r--r--src/core/SkBlitter_Sprite.cpp3
-rw-r--r--src/core/SkSpriteBlitter_ARGB32.cpp101
2 files changed, 20 insertions, 84 deletions
diff --git a/src/core/SkBlitter_Sprite.cpp b/src/core/SkBlitter_Sprite.cpp
index 8d841c2caf..99b185a1ad 100644
--- a/src/core/SkBlitter_Sprite.cpp
+++ b/src/core/SkBlitter_Sprite.cpp
@@ -185,9 +185,6 @@ SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint,
if (source.alphaType() == kUnpremul_SkAlphaType) {
return nullptr;
}
- if (paint.getColorFilter()) {
- return nullptr;
- }
SkSpriteBlitter* blitter = nullptr;
diff --git a/src/core/SkSpriteBlitter_ARGB32.cpp b/src/core/SkSpriteBlitter_ARGB32.cpp
index 27fc86d601..b39f79b969 100644
--- a/src/core/SkSpriteBlitter_ARGB32.cpp
+++ b/src/core/SkSpriteBlitter_ARGB32.cpp
@@ -58,94 +58,34 @@ private:
///////////////////////////////////////////////////////////////////////////////
-class Sprite_D32_XferFilter : public SkSpriteBlitter {
+class Sprite_D32_S32A_Xfer: public SkSpriteBlitter {
public:
- Sprite_D32_XferFilter(const SkPixmap& source, const SkPaint& paint) : SkSpriteBlitter(source) {
- fColorFilter = paint.getColorFilter();
- SkSafeRef(fColorFilter);
-
+ Sprite_D32_S32A_Xfer(const SkPixmap& source, const SkPaint& paint) : SkSpriteBlitter(source) {
fXfermode = SkXfermode::Peek(paint.getBlendMode());
-
- fBufferSize = 0;
- fBuffer = nullptr;
-
- unsigned flags32 = 0;
- if (255 != paint.getAlpha()) {
- flags32 |= SkBlitRow::kGlobalAlpha_Flag32;
- }
- if (!source.isOpaque()) {
- flags32 |= SkBlitRow::kSrcPixelAlpha_Flag32;
- }
-
- fProc32 = SkBlitRow::Factory32(flags32);
- fAlpha = paint.getAlpha();
- }
-
- ~Sprite_D32_XferFilter() override {
- delete[] fBuffer;
- SkSafeUnref(fColorFilter);
+ SkASSERT(fXfermode);
}
- void setup(const SkPixmap& dst, int left, int top, const SkPaint& paint) override {
- this->INHERITED::setup(dst, left, top, paint);
-
- int width = dst.width();
- if (width > fBufferSize) {
- fBufferSize = width;
- delete[] fBuffer;
- fBuffer = new SkPMColor[width];
- }
- }
-
-protected:
- SkColorFilter* fColorFilter;
- SkXfermode* fXfermode;
- int fBufferSize;
- SkPMColor* fBuffer;
- SkBlitRow::Proc32 fProc32;
- U8CPU fAlpha;
-
-private:
- typedef SkSpriteBlitter INHERITED;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-class Sprite_D32_S32A_XferFilter : public Sprite_D32_XferFilter {
-public:
- Sprite_D32_S32A_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);
uint32_t* SK_RESTRICT dst = fDst.writable_addr32(x, y);
const uint32_t* SK_RESTRICT src = fSource.addr32(x - fLeft, y - fTop);
size_t dstRB = fDst.rowBytes();
size_t srcRB = fSource.rowBytes();
- SkColorFilter* colorFilter = fColorFilter;
SkXfermode* xfermode = fXfermode;
do {
- const SkPMColor* tmp = src;
-
- if (colorFilter) {
- colorFilter->filterSpan(src, width, fBuffer);
- tmp = fBuffer;
- }
-
- if (xfermode) {
- xfermode->xfer32(dst, tmp, width, nullptr);
- } else {
- fProc32(dst, tmp, width, fAlpha);
- }
+ xfermode->xfer32(dst, src, width, nullptr);
dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB);
src = (const uint32_t* SK_RESTRICT)((const char*)src + srcRB);
} while (--height != 0);
}
+protected:
+ SkXfermode* fXfermode;
+
private:
- typedef Sprite_D32_XferFilter INHERITED;
+ typedef SkSpriteBlitter INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
@@ -154,25 +94,24 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseL32(const SkPixmap& source, const SkPain
SkArenaAlloc* allocator) {
SkASSERT(allocator != nullptr);
+ if (paint.getColorFilter() != nullptr) {
+ return nullptr;
+ }
if (paint.getMaskFilter() != nullptr) {
return nullptr;
}
- U8CPU alpha = paint.getAlpha();
- bool isSrcOver = paint.isSrcOver();
- SkColorFilter* filter = paint.getColorFilter();
- SkSpriteBlitter* blitter = nullptr;
+ U8CPU alpha = paint.getAlpha();
if (source.colorType() == kN32_SkColorType) {
- if (!isSrcOver || filter) {
- if (255 == alpha) {
- // this can handle xfermode or filter, but not alpha
- blitter = allocator->make<Sprite_D32_S32A_XferFilter>(source, paint);
- }
- } else {
- // this can handle alpha, but not xfermode or filter
- blitter = allocator->make<Sprite_D32_S32>(source, alpha);
+ if (paint.isSrcOver()) {
+ // this can handle alpha, but not xfermode
+ return allocator->make<Sprite_D32_S32>(source, alpha);
+ }
+ if (255 == alpha) {
+ // this can handle an xfermode, but not alpha
+ return allocator->make<Sprite_D32_S32A_Xfer>(source, paint);
}
}
- return blitter;
+ return nullptr;
}