diff options
author | 2017-05-25 16:43:43 -0400 | |
---|---|---|
committer | 2017-05-25 21:11:19 +0000 | |
commit | 9b868f7b405b3739dcb634342a6c9569277afd6c (patch) | |
tree | 0d4f5495622ec97495f48c0326f7b252c1dddceb /src | |
parent | e7ba8b05d2a98c43f8d37890d36d6d31538459a1 (diff) |
Remove unused PM4f blitters
Change-Id: I19106b70ba19bffb04ae0517225fce2169ab5f33
Reviewed-on: https://skia-review.googlesource.com/17990
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBlitter.cpp | 37 | ||||
-rw-r--r-- | src/core/SkBlitter_PM4f.cpp | 440 | ||||
-rw-r--r-- | src/core/SkCoreBlitters.h | 6 |
3 files changed, 12 insertions, 471 deletions
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index ba79abd3f0..f4e43541a9 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -20,9 +20,6 @@ #include "SkUtils.h" #include "SkXfermodeInterpretation.h" -// define this for testing srgb blits -//#define SK_FORCE_PM4f_FOR_L32_BLITS - SkBlitter::~SkBlitter() {} bool SkBlitter::isNullBlitter() const { return false; } @@ -774,13 +771,9 @@ private: #include "SkCoreBlitters.h" SkShaderBase::ContextRec::DstType SkBlitter::PreferredShaderDest(const SkImageInfo& dstInfo) { -#ifdef SK_FORCE_PM4f_FOR_L32_BLITS - return SkShader::ContextRec::kPM4f_DstType; -#else return (dstInfo.gammaCloseToSRGB() || dstInfo.colorType() == kRGBA_F16_SkColorType) ? SkShaderBase::ContextRec::kPM4f_DstType : SkShaderBase::ContextRec::kPMColor_DstType; -#endif } bool SkBlitter::UseRasterPipelineBlitter(const SkPixmap& device, const SkPaint& paint) { @@ -928,29 +921,23 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device, break; case kN32_SkColorType: -#ifdef SK_FORCE_PM4f_FOR_L32_BLITS - if (true) -#else - if (device.info().gammaCloseToSRGB()) -#endif - { - blitter = SkBlitter_ARGB32_Create(device, *paint, shaderContext, alloc); + // sRGB and general color spaces are handled via raster pipeline. + SkASSERT(!device.colorSpace()); + + if (shader) { + blitter = alloc->make<SkARGB32_Shader_Blitter>(device, *paint, shaderContext); + } else if (paint->getColor() == SK_ColorBLACK) { + blitter = alloc->make<SkARGB32_Black_Blitter>(device, *paint); + } else if (paint->getAlpha() == 0xFF) { + blitter = alloc->make<SkARGB32_Opaque_Blitter>(device, *paint); } else { - if (shader) { - blitter = alloc->make<SkARGB32_Shader_Blitter>( - device, *paint, shaderContext); - } else if (paint->getColor() == SK_ColorBLACK) { - blitter = alloc->make<SkARGB32_Black_Blitter>(device, *paint); - } else if (paint->getAlpha() == 0xFF) { - blitter = alloc->make<SkARGB32_Opaque_Blitter>(device, *paint); - } else { - blitter = alloc->make<SkARGB32_Blitter>(device, *paint); - } + blitter = alloc->make<SkARGB32_Blitter>(device, *paint); } break; case kRGBA_F16_SkColorType: - blitter = SkBlitter_F16_Create(device, *paint, shaderContext, alloc); + // F16 is handled via raster pipeline. + SkASSERT(false); break; default: diff --git a/src/core/SkBlitter_PM4f.cpp b/src/core/SkBlitter_PM4f.cpp deleted file mode 100644 index f83e0c214e..0000000000 --- a/src/core/SkBlitter_PM4f.cpp +++ /dev/null @@ -1,440 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "SkCoreBlitters.h" - -#include "SkArenaAlloc.h" -#include "SkColorPriv.h" -#include "SkShader.h" -#include "SkUtils.h" -#include "SkXfermodePriv.h" -#include "SkBlitMask.h" -#include "SkTemplates.h" -#include "SkPM4f.h" - -template <typename State> class SkState_Blitter : public SkRasterBlitter { - typedef SkRasterBlitter INHERITED; - State fState; - -public: - SkState_Blitter(const SkPixmap& device, const SkPaint& paint) - : INHERITED(device) - , fState(device.info(), paint, nullptr) - {} - - void blitH(int x, int y, int width) override { - SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); - - fState.fProc1(fState.fMode, State::WritableAddr(fDevice, x, y), - &fState.fPM4f, width, nullptr); - } - - void blitV(int x, int y, int height, SkAlpha alpha) override { - SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height()); - - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - size_t deviceRB = fDevice.rowBytes(); - - for (int i = 0; i < height; ++i) { - fState.fProc1(fState.fMode, device, &fState.fPM4f, 1, &alpha); - device = (typename State::DstType*)((char*)device + deviceRB); - } - } - - void blitRect(int x, int y, int width, int height) override { - SkASSERT(x >= 0 && y >= 0 && - x + width <= fDevice.width() && y + height <= fDevice.height()); - - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - size_t deviceRB = fDevice.rowBytes(); - - do { - fState.fProc1(fState.fMode, device, &fState.fPM4f, width, nullptr); - y += 1; - device = (typename State::DstType*)((char*)device + deviceRB); - } while (--height > 0); - } - - void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override { - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - - for (;;) { - int count = *runs; - if (count <= 0) { - break; - } - int aa = *antialias; - if (aa) { - if (aa == 255) { - fState.fProc1(fState.fMode, device, &fState.fPM4f, count, nullptr); - } else { - for (int i = 0; i < count; ++i) { - fState.fProc1(fState.fMode, &device[i], &fState.fPM4f, 1, antialias); - } - } - } - device += count; - runs += count; - antialias += count; - x += count; - } - } - - void blitLCDMask(const SkMask& mask, const SkIRect& clip) { - auto proc = fState.getLCDProc(SkXfermode::kSrcIsSingle_LCDFlag); - - const int x = clip.fLeft; - const int width = clip.width(); - const int y = clip.fTop; - const int height = clip.height(); - - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - const size_t dstRB = fDevice.rowBytes(); - const uint16_t* maskRow = (const uint16_t*)mask.getAddr(x, y); - const size_t maskRB = mask.fRowBytes; - - for (int i = 0; i < height; ++i) { - proc(device, &fState.fPM4f, width, maskRow); - device = (typename State::DstType*)((char*)device + dstRB); - maskRow = (const uint16_t*)((const char*)maskRow + maskRB); - } - } - - void blitMask(const SkMask& mask, const SkIRect& clip) override { - if (SkMask::kLCD16_Format == mask.fFormat) { - this->blitLCDMask(mask, clip); - return; - } - if (SkMask::kA8_Format != mask.fFormat) { - this->INHERITED::blitMask(mask, clip); - return; - } - - SkASSERT(mask.fBounds.contains(clip)); - - const int x = clip.fLeft; - const int width = clip.width(); - const int y = clip.fTop; - const int height = clip.height(); - - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - const size_t dstRB = fDevice.rowBytes(); - const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y); - const size_t maskRB = mask.fRowBytes; - - for (int i = 0; i < height; ++i) { - fState.fProc1(fState.fMode, device, &fState.fPM4f, width, maskRow); - device = (typename State::DstType*)((char*)device + dstRB); - maskRow += maskRB; - } - } -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////// - -template <typename State> class SkState_Shader_Blitter : public SkShaderBlitter { -public: - SkState_Shader_Blitter(const SkPixmap& device, const SkPaint& paint, - const SkShaderBase::Context::BlitState& bstate) - : INHERITED(device, paint, bstate.fCtx) - , fState(device.info(), paint, bstate.fCtx) - , fBState(bstate) - , fBlitBW(bstate.fBlitBW) - , fBlitAA(bstate.fBlitAA) - {} - - void blitH(int x, int y, int width) override { - SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width()); - - if (fBlitBW) { - fBlitBW(&fBState, x, y, fDevice, width); - return; - } - - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width); - fState.fProcN(fState.fMode, device, fState.fBuffer, width, nullptr); - } - - void blitV(int x, int y, int height, SkAlpha alpha) override { - SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height()); - - if (fBlitAA) { - for (const int bottom = y + height; y < bottom; ++y) { - fBlitAA(&fBState, x, y, fDevice, 1, &alpha); - } - return; - } - - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - size_t deviceRB = fDevice.rowBytes(); - - if (fConstInY) { - fShaderContext->shadeSpan4f(x, y, fState.fBuffer, 1); - } - for (const int bottom = y + height; y < bottom; ++y) { - if (!fConstInY) { - fShaderContext->shadeSpan4f(x, y, fState.fBuffer, 1); - } - fState.fProcN(fState.fMode, device, fState.fBuffer, 1, &alpha); - device = (typename State::DstType*)((char*)device + deviceRB); - } - } - - void blitRect(int x, int y, int width, int height) override { - SkASSERT(x >= 0 && y >= 0 && - x + width <= fDevice.width() && y + height <= fDevice.height()); - - if (fBlitBW) { - for (const int bottom = y + height; y < bottom; ++y) { - fBlitBW(&fBState, x, y, fDevice, width); - } - return; - } - - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - size_t deviceRB = fDevice.rowBytes(); - - if (fConstInY) { - fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width); - } - for (const int bottom = y + height; y < bottom; ++y) { - if (!fConstInY) { - fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width); - } - fState.fProcN(fState.fMode, device, fState.fBuffer, width, nullptr); - device = (typename State::DstType*)((char*)device + deviceRB); - } - } - - void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override { - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - - for (;;) { - int count = *runs; - if (count <= 0) { - break; - } - int aa = *antialias; - if (aa) { - if (fBlitBW && (aa == 255)) { - fBlitBW(&fBState, x, y, fDevice, count); - } else { - fShaderContext->shadeSpan4f(x, y, fState.fBuffer, count); - if (aa == 255) { - fState.fProcN(fState.fMode, device, fState.fBuffer, count, nullptr); - } else { - for (int i = 0; i < count; ++i) { - fState.fProcN(fState.fMode, &device[i], &fState.fBuffer[i], 1, antialias); - } - } - } - } - device += count; - runs += count; - antialias += count; - x += count; - } - } - - void blitLCDMask(const SkMask& mask, const SkIRect& clip) { - auto proc = fState.getLCDProc(0); - - const int x = clip.fLeft; - const int width = clip.width(); - int y = clip.fTop; - - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - const size_t deviceRB = fDevice.rowBytes(); - const uint16_t* maskRow = (const uint16_t*)mask.getAddr(x, y); - const size_t maskRB = mask.fRowBytes; - - if (fConstInY) { - fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width); - } - for (; y < clip.fBottom; ++y) { - if (!fConstInY) { - fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width); - } - proc(device, fState.fBuffer, width, maskRow); - device = (typename State::DstType*)((char*)device + deviceRB); - maskRow = (const uint16_t*)((const char*)maskRow + maskRB); - } - } - - void blitMask(const SkMask& mask, const SkIRect& clip) override { - if (SkMask::kLCD16_Format == mask.fFormat) { - this->blitLCDMask(mask, clip); - return; - } - if (SkMask::kA8_Format != mask.fFormat) { - this->INHERITED::blitMask(mask, clip); - return; - } - - SkASSERT(mask.fBounds.contains(clip)); - - const int x = clip.fLeft; - const int width = clip.width(); - int y = clip.fTop; - const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y); - const size_t maskRB = mask.fRowBytes; - - if (fBlitAA) { - for (; y < clip.fBottom; ++y) { - fBlitAA(&fBState, x, y, fDevice, width, maskRow); - maskRow += maskRB; - } - return; - } - - typename State::DstType* device = State::WritableAddr(fDevice, x, y); - const size_t deviceRB = fDevice.rowBytes(); - - if (fConstInY) { - fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width); - } - for (; y < clip.fBottom; ++y) { - if (!fConstInY) { - fShaderContext->shadeSpan4f(x, y, fState.fBuffer, width); - } - fState.fProcN(fState.fMode, device, fState.fBuffer, width, maskRow); - device = (typename State::DstType*)((char*)device + deviceRB); - maskRow += maskRB; - } - } - -protected: - State fState; - SkShaderBase::Context::BlitState fBState; - SkShaderBase::Context::BlitBW fBlitBW; - SkShaderBase::Context::BlitAA fBlitAA; - - typedef SkShaderBlitter INHERITED; -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -static bool is_opaque(const SkPaint& paint, const SkShaderBase::Context* shaderContext) { - return shaderContext ? SkToBool(shaderContext->getFlags() & SkShaderBase::kOpaqueAlpha_Flag) - : 0xFF == paint.getAlpha(); -} - -struct State4f { - State4f(const SkImageInfo& info, const SkPaint& paint, - const SkShaderBase::Context* shaderContext) { - fMode = paint.getBlendMode(); - if (shaderContext) { - fBuffer.reset(info.width()); - } else { - fPM4f = SkColor4f::FromColor(paint.getColor()).premul(); - } - fFlags = 0; - } - - SkPM4f fPM4f; - SkAutoTMalloc<SkPM4f> fBuffer; - uint32_t fFlags; - SkBlendMode fMode; - SkShaderBase::Context::BlitState fBState; -}; - -struct State32 : State4f { - typedef uint32_t DstType; - - SkXfermode::D32Proc fProc1; - SkXfermode::D32Proc fProcN; - - State32(const SkImageInfo& info, const SkPaint& paint, - const SkShaderBase::Context* shaderContext) - : State4f(info, paint, shaderContext) - { - if (is_opaque(paint, shaderContext)) { - fFlags |= SkXfermode::kSrcIsOpaque_D32Flag; - } - if (info.gammaCloseToSRGB()) { - fFlags |= SkXfermode::kDstIsSRGB_D32Flag; - } - fProc1 = SkXfermode::GetD32Proc(fMode, fFlags | SkXfermode::kSrcIsSingle_D32Flag); - fProcN = SkXfermode::GetD32Proc(fMode, fFlags); - } - - SkXfermode::LCD32Proc getLCDProc(uint32_t oneOrManyFlag) const { - uint32_t flags = fFlags & 1; - if (fFlags & SkXfermode::kDstIsSRGB_D32Flag) { - flags |= SkXfermode::kDstIsSRGB_LCDFlag; - } - return SkXfermode::GetLCD32Proc(flags | oneOrManyFlag); - } - - static DstType* WritableAddr(const SkPixmap& device, int x, int y) { - return device.writable_addr32(x, y); - } -}; - -struct StateF16 : State4f { - typedef uint64_t DstType; - - SkXfermode::F16Proc fProc1; - SkXfermode::F16Proc fProcN; - - StateF16(const SkImageInfo& info, const SkPaint& paint, - const SkShaderBase::Context* shaderContext) - : State4f(info, paint, shaderContext) - { - if (is_opaque(paint, shaderContext)) { - fFlags |= SkXfermode::kSrcIsOpaque_F16Flag; - } - SkASSERT(kRGBA_F16_SkColorType == info.colorType()); - fProc1 = SkXfermode::GetF16Proc(fMode, fFlags | SkXfermode::kSrcIsSingle_F16Flag); - fProcN = SkXfermode::GetF16Proc(fMode, fFlags); - } - - SkXfermode::LCDF16Proc getLCDProc(uint32_t oneOrManyFlag) const { - uint32_t flags = fFlags & 1; - return SkXfermode::GetLCDF16Proc(flags | oneOrManyFlag); - } - - static DstType* WritableAddr(const SkPixmap& device, int x, int y) { - return device.writable_addr64(x, y); - } -}; - -template <typename State> SkBlitter* create(const SkPixmap& device, const SkPaint& paint, - SkShaderBase::Context* shaderContext, - SkArenaAlloc* alloc) { - SkASSERT(alloc != nullptr); - - if (shaderContext) { - SkShaderBase::Context::BlitState bstate; - sk_bzero(&bstate, sizeof(bstate)); - bstate.fCtx = shaderContext; - bstate.fMode = paint.getBlendMode(); - - (void)shaderContext->chooseBlitProcs(device.info(), &bstate); - return alloc->make<SkState_Shader_Blitter<State>>(device, paint, bstate); - } else { - SkColor color = paint.getColor(); - if (0 == SkColorGetA(color)) { - return nullptr; - } - return alloc->make<SkState_Blitter<State>>(device, paint); - } -} - -SkBlitter* SkBlitter_ARGB32_Create(const SkPixmap& device, const SkPaint& paint, - SkShaderBase::Context* shaderContext, - SkArenaAlloc* alloc) { - return create<State32>(device, paint, shaderContext, alloc); -} - -SkBlitter* SkBlitter_F16_Create(const SkPixmap& device, const SkPaint& paint, - SkShaderBase::Context* shaderContext, - SkArenaAlloc* alloc) { - return create<StateF16>(device, paint, shaderContext, alloc); -} diff --git a/src/core/SkCoreBlitters.h b/src/core/SkCoreBlitters.h index 7f3de32ab1..bc25db935a 100644 --- a/src/core/SkCoreBlitters.h +++ b/src/core/SkCoreBlitters.h @@ -176,12 +176,6 @@ private: typedef SkShaderBlitter INHERITED; }; -SkBlitter* SkBlitter_ARGB32_Create(const SkPixmap& device, const SkPaint&, SkShaderBase::Context*, - SkArenaAlloc*); - -SkBlitter* SkBlitter_F16_Create(const SkPixmap& device, const SkPaint&, SkShaderBase::Context*, - SkArenaAlloc*); - /////////////////////////////////////////////////////////////////////////////// /* These return the correct subclass of blitter for their device config. |