Delete onChooseBlitProcs() and related code

All dead code now.

Change-Id: I3d88103fef90d9e2ceee8b13db143ac9704689f5
Reviewed-on: https://skia-review.googlesource.com/18034
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Florin Malita 2017-05-26 11:09:01 -04:00 committed by Skia Commit-Bot
parent a1fab3cec2
commit eb9f278e8c
9 changed files with 2 additions and 331 deletions

View File

@ -145,33 +145,10 @@ public:
}
}
bool onChooseBlitProcs(const SkImageInfo& dstInfo, BlitState* state) override {
if ((fBlitterPipeline = SkLinearBitmapPipeline::ClonePipelineForBlitting(
*fShaderPipeline,
fMatrixTypeMask,
fFilterQuality, fSrcPixmap,
fAlpha, state->fMode, dstInfo, fAllocator)))
{
state->fStorage[0] = fBlitterPipeline;
state->fBlitBW = &LinearPipelineContext::ForwardToPipeline;
return true;
}
return false;
}
static void ForwardToPipeline(BlitState* state, int x, int y, const SkPixmap& dst, int count) {
SkLinearBitmapPipeline* pipeline = static_cast<SkLinearBitmapPipeline*>(state->fStorage[0]);
void* addr = dst.writable_addr32(x, y);
pipeline->blitSpan(x, y, addr, count);
}
private:
// Store the allocator from the context creation incase we are asked to build a blitter.
SkArenaAlloc* fAllocator;
SkLinearBitmapPipeline* fShaderPipeline;
SkLinearBitmapPipeline* fBlitterPipeline;
SkXfermode::D32Proc fSrcModeProc;
SkPixmap fSrcPixmap;
float fAlpha;

View File

@ -250,71 +250,6 @@ sk_sp<SkShader> SkShader::MakeColorShader(const SkColor4f& color, sk_sp<SkColorS
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
static void D32_BlitBW(SkShaderBase::Context::BlitState* state, int x, int y, const SkPixmap& dst,
int count) {
SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0];
const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
proc(state->fMode, dst.writable_addr32(x, y), src, count, nullptr);
}
static void D32_BlitAA(SkShaderBase::Context::BlitState* state, int x, int y, const SkPixmap& dst,
int count, const SkAlpha aa[]) {
SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0];
const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
proc(state->fMode, dst.writable_addr32(x, y), src, count, aa);
}
static void F16_BlitBW(SkShaderBase::Context::BlitState* state, int x, int y, const SkPixmap& dst,
int count) {
SkXfermode::F16Proc proc = (SkXfermode::F16Proc)state->fStorage[0];
const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
proc(state->fMode, dst.writable_addr64(x, y), src, count, nullptr);
}
static void F16_BlitAA(SkShaderBase::Context::BlitState* state, int x, int y, const SkPixmap& dst,
int count, const SkAlpha aa[]) {
SkXfermode::F16Proc proc = (SkXfermode::F16Proc)state->fStorage[0];
const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
proc(state->fMode, dst.writable_addr64(x, y), src, count, aa);
}
static bool choose_blitprocs(const SkPM4f* pm4, const SkImageInfo& info,
SkShaderBase::Context::BlitState* state) {
uint32_t flags = SkXfermode::kSrcIsSingle_D32Flag;
if (pm4->a() == 1) {
flags |= SkXfermode::kSrcIsOpaque_D32Flag;
}
switch (info.colorType()) {
case kN32_SkColorType:
if (info.gammaCloseToSRGB()) {
flags |= SkXfermode::kDstIsSRGB_D32Flag;
}
state->fStorage[0] = (void*)SkXfermode::GetD32Proc(state->fMode, flags);
state->fStorage[1] = (void*)pm4;
state->fBlitBW = D32_BlitBW;
state->fBlitAA = D32_BlitAA;
return true;
case kRGBA_F16_SkColorType:
state->fStorage[0] = (void*)SkXfermode::GetF16Proc(state->fMode, flags);
state->fStorage[1] = (void*)pm4;
state->fBlitBW = F16_BlitBW;
state->fBlitAA = F16_BlitAA;
return true;
default:
return false;
}
}
bool SkColorShader::ColorShaderContext::onChooseBlitProcs(const SkImageInfo& info,
BlitState* state) {
return choose_blitprocs(&fPM4f, info, state);
}
bool SkColor4Shader::Color4Context::onChooseBlitProcs(const SkImageInfo& info, BlitState* state) {
return choose_blitprocs(&fPM4f, info, state);
}
bool SkColorShader::onAppendStages(SkRasterPipeline* p,
SkColorSpace* dst,

View File

@ -37,9 +37,6 @@ public:
void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) override;
void shadeSpan4f(int x, int y, SkPM4f[], int count) override;
protected:
bool onChooseBlitProcs(const SkImageInfo&, BlitState*) override;
private:
SkPM4f fPM4f;
SkPMColor fPMColor;
@ -98,9 +95,6 @@ public:
void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) override;
void shadeSpan4f(int x, int y, SkPM4f[], int count) override;
protected:
bool onChooseBlitProcs(const SkImageInfo&, BlitState*) override;
private:
SkPM4f fPM4f;
SkPMColor fPMColor;

View File

@ -417,38 +417,6 @@ SkLinearBitmapPipeline::SkLinearBitmapPipeline(
fFirstStage = matrixStage;
}
SkLinearBitmapPipeline* SkLinearBitmapPipeline::ClonePipelineForBlitting(
const SkLinearBitmapPipeline& pipeline,
SkMatrix::TypeMask matrixMask,
SkFilterQuality filterQuality,
const SkPixmap& srcPixmap,
float finalAlpha,
SkBlendMode blendMode,
const SkImageInfo& dstInfo,
SkArenaAlloc* allocator)
{
if (blendMode == SkBlendMode::kSrcOver && srcPixmap.info().alphaType() == kOpaque_SkAlphaType) {
blendMode = SkBlendMode::kSrc;
}
if (matrixMask & ~SkMatrix::kTranslate_Mask ) { return nullptr; }
if (filterQuality != SkFilterQuality::kNone_SkFilterQuality) { return nullptr; }
if (finalAlpha != 1.0f) { return nullptr; }
if (srcPixmap.info().colorType() != kRGBA_8888_SkColorType
|| dstInfo.colorType() != kRGBA_8888_SkColorType) { return nullptr; }
if (!srcPixmap.info().gammaCloseToSRGB() || !dstInfo.gammaCloseToSRGB()) {
return nullptr;
}
if (blendMode != SkBlendMode::kSrc && blendMode != SkBlendMode::kSrcOver) {
return nullptr;
}
return allocator->make<SkLinearBitmapPipeline>(
pipeline, srcPixmap, blendMode, dstInfo, allocator);
}
void SkLinearBitmapPipeline::shadeSpan4f(int x, int y, SkPM4f* dst, int count) {
SkASSERT(count > 0);
this->blitSpan(x, y, dst, count);

View File

@ -43,16 +43,6 @@ public:
const SkImageInfo& dstInfo,
SkArenaAlloc* allocator);
static SkLinearBitmapPipeline* ClonePipelineForBlitting(
const SkLinearBitmapPipeline& pipeline,
SkMatrix::TypeMask matrixMask,
SkFilterQuality filterQuality,
const SkPixmap& srcPixmap,
float finalAlpha,
SkBlendMode,
const SkImageInfo& dstInfo,
SkArenaAlloc* allocator);
~SkLinearBitmapPipeline();
void shadeSpan4f(int x, int y, SkPM4f* dst, int count);

View File

@ -100,35 +100,6 @@ public:
virtual void shadeSpan4f(int x, int y, SkPM4f[], int count);
struct BlitState;
typedef void (*BlitBW)(BlitState*,
int x, int y, const SkPixmap&, int count);
typedef void (*BlitAA)(BlitState*,
int x, int y, const SkPixmap&, int count, const SkAlpha[]);
struct BlitState {
// inputs
Context* fCtx;
SkBlendMode fMode;
// outputs
enum { N = 2 };
void* fStorage[N];
BlitBW fBlitBW;
BlitAA fBlitAA;
};
// Returns true if one or more of the blitprocs are set in the BlitState
bool chooseBlitProcs(const SkImageInfo& info, BlitState* state) {
state->fBlitBW = nullptr;
state->fBlitAA = nullptr;
if (this->onChooseBlitProcs(info, state)) {
SkASSERT(state->fBlitBW || state->fBlitAA);
return true;
}
return false;
}
/**
* The const void* ctx is only const because all the implementations are const.
* This can be changed to non-const if a new shade proc needs to change the ctx.
@ -163,8 +134,6 @@ public:
MatrixClass getInverseClass() const { return (MatrixClass)fTotalInverseClass; }
const SkMatrix& getCTM() const { return fCTM; }
virtual bool onChooseBlitProcs(const SkImageInfo&, BlitState*) { return false; }
private:
SkMatrix fCTM;
SkMatrix fTotalInverse;

View File

@ -23,10 +23,8 @@ namespace {
enum class ApplyPremul { True, False };
enum class DstType {
L32, // Linear 32bit. Used for both shader/blitter paths.
S32, // SRGB 32bit. Used for the blitter path only.
F16, // Linear half-float. Used for blitters only.
F32, // Linear float. Used for shaders only.
L32, // Linear 32bit.
F32, // Linear float.
};
template <ApplyPremul>
@ -102,63 +100,6 @@ struct DstTraits<DstType::L32, premul> {
}
};
template <ApplyPremul premul>
struct DstTraits<DstType::S32, premul> {
using PM = PremulTraits<premul>;
using Type = SkPMColor;
static Sk4f load(const SkPM4f& c) {
return c.to4f_pmorder();
}
static void store(const Sk4f& c, Type* dst) {
// FIXME: this assumes opaque colors. Handle unpremultiplication.
*dst = Sk4f_toS32(PM::apply(c));
}
static void store(const Sk4f& c, Type* dst, int n) {
sk_memset32(dst, Sk4f_toS32(PM::apply(c)), n);
}
static void store4x(const Sk4f& c0, const Sk4f& c1,
const Sk4f& c2, const Sk4f& c3,
Type* dst) {
store(c0, dst + 0);
store(c1, dst + 1);
store(c2, dst + 2);
store(c3, dst + 3);
}
};
template <ApplyPremul premul>
struct DstTraits<DstType::F16, premul> {
using PM = PremulTraits<premul>;
using Type = uint64_t;
static Sk4f load(const SkPM4f& c) {
return c.to4f();
}
static void store(const Sk4f& c, Type* dst) {
SkFloatToHalf_finite_ftz(PM::apply(c)).store(dst);
}
static void store(const Sk4f& c, Type* dst, int n) {
uint64_t color;
SkFloatToHalf_finite_ftz(PM::apply(c)).store(&color);
sk_memset64(dst, color, n);
}
static void store4x(const Sk4f& c0, const Sk4f& c1,
const Sk4f& c2, const Sk4f& c3,
Type* dst) {
store(c0, dst + 0);
store(c1, dst + 1);
store(c2, dst + 2);
store(c3, dst + 3);
}
};
template <ApplyPremul premul>
struct DstTraits<DstType::F32, premul> {
using PM = PremulTraits<premul>;

View File

@ -44,43 +44,6 @@ void ramp(const Sk4f& c, const Sk4f& dc, typename DstTraits<dstType, premul>::Ty
}
}
// Planar version of ramp (S32 no-premul only).
template<>
void ramp<DstType::S32, ApplyPremul::False>(const Sk4f& c, const Sk4f& dc, SkPMColor dst[], int n) {
SkASSERT(n > 0);
const Sk4f dc4 = dc * 4;
const Sk4x4f dc4x = { Sk4f(dc4[0]), Sk4f(dc4[1]), Sk4f(dc4[2]), Sk4f(dc4[3]) };
Sk4x4f c4x = Sk4x4f::Transpose(c, c + dc, c + dc * 2, c + dc * 3);
while (n >= 4) {
( sk_linear_to_srgb(c4x.r) << 0
| sk_linear_to_srgb(c4x.g) << 8
| sk_linear_to_srgb(c4x.b) << 16
| Sk4f_round(255.0f*c4x.a) << 24).store(dst);
c4x.r += dc4x.r;
c4x.g += dc4x.g;
c4x.b += dc4x.b;
c4x.a += dc4x.a;
dst += 4;
n -= 4;
}
if (n & 2) {
DstTraits<DstType::S32, ApplyPremul::False>
::store(Sk4f(c4x.r[0], c4x.g[0], c4x.b[0], c4x.a[0]), dst++);
DstTraits<DstType::S32, ApplyPremul::False>
::store(Sk4f(c4x.r[1], c4x.g[1], c4x.b[1], c4x.a[1]), dst++);
}
if (n & 1) {
DstTraits<DstType::S32, ApplyPremul::False>
::store(Sk4f(c4x.r[n & 2], c4x.g[n & 2], c4x.b[n & 2], c4x.a[n & 2]), dst);
}
}
template<SkShader::TileMode>
SkScalar pinFx(SkScalar);
@ -465,64 +428,3 @@ LinearGradient4fContext::mapTs(int x, int y, SkScalar ts[], int count) const {
}
}
}
bool SkLinearGradient::LinearGradient4fContext::onChooseBlitProcs(const SkImageInfo& info,
BlitState* state) {
if (state->fMode != SkBlendMode::kSrc &&
!(state->fMode == SkBlendMode::kSrcOver && (fFlags & kOpaqueAlpha_Flag))) {
return false;
}
switch (info.colorType()) {
case kN32_SkColorType:
state->fBlitBW = D32_BlitBW;
return true;
case kRGBA_F16_SkColorType:
state->fBlitBW = D64_BlitBW;
return true;
default:
return false;
}
}
void SkLinearGradient::
LinearGradient4fContext::D32_BlitBW(BlitState* state, int x, int y, const SkPixmap& dst,
int count) {
// FIXME: ignoring coverage for now
const LinearGradient4fContext* ctx =
static_cast<const LinearGradient4fContext*>(state->fCtx);
if (!dst.info().gammaCloseToSRGB()) {
if (ctx->fColorsArePremul) {
ctx->shadePremulSpan<DstType::L32, ApplyPremul::False>(
x, y, dst.writable_addr32(x, y), count);
} else {
ctx->shadePremulSpan<DstType::L32, ApplyPremul::True>(
x, y, dst.writable_addr32(x, y), count);
}
} else {
if (ctx->fColorsArePremul) {
ctx->shadePremulSpan<DstType::S32, ApplyPremul::False>(
x, y, dst.writable_addr32(x, y), count);
} else {
ctx->shadePremulSpan<DstType::S32, ApplyPremul::True>(
x, y, dst.writable_addr32(x, y), count);
}
}
}
void SkLinearGradient::
LinearGradient4fContext::D64_BlitBW(BlitState* state, int x, int y, const SkPixmap& dst,
int count) {
// FIXME: ignoring coverage for now
const LinearGradient4fContext* ctx =
static_cast<const LinearGradient4fContext*>(state->fCtx);
if (ctx->fColorsArePremul) {
ctx->shadePremulSpan<DstType::F16, ApplyPremul::False>(
x, y, dst.writable_addr64(x, y), count);
} else {
ctx->shadePremulSpan<DstType::F16, ApplyPremul::True>(
x, y, dst.writable_addr64(x, y), count);
}
}

View File

@ -22,8 +22,6 @@ public:
protected:
void mapTs(int x, int y, SkScalar ts[], int count) const override;
bool onChooseBlitProcs(const SkImageInfo&, BlitState*) override;
private:
using INHERITED = GradientShaderBase4fContext;
@ -42,9 +40,6 @@ private:
bool isFast() const { return fDstToPosClass == kLinear_MatrixClass; }
static void D32_BlitBW(BlitState*, int x, int y, const SkPixmap& dst, int count);
static void D64_BlitBW(BlitState*, int x, int y, const SkPixmap& dst, int count);
mutable const Sk4fGradientInterval* fCachedInterval;
};