use rasterpipeline for non-8888-clamp shaders (so we can delete more legacy code)

Definitely changes some GMs, but I think they're all more correct.

Bug: skia:
Change-Id: Ic30622f2c17325bce4c82b4d7997036d3cc026c2
Reviewed-on: https://skia-review.googlesource.com/20363
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2017-06-21 09:15:25 -07:00 committed by Skia Commit-Bot
parent 711450e948
commit 00b8ab61dd
5 changed files with 27 additions and 0 deletions

View File

@ -51,6 +51,9 @@ protected:
sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
bool onAppendStages(SkRasterPipeline*, SkColorSpace* dstCS, SkArenaAlloc*,
const SkMatrix&, const SkPaint&, const SkMatrix* localM) const override;
bool isRasterPipelineOnly() const override {
return as_SB(fShader)->isRasterPipelineOnly();
}
private:
sk_sp<SkShader> fShader;

View File

@ -48,6 +48,22 @@ bool SkImageShader::isOpaque() const {
return fImage->isOpaque();
}
bool SkImageShader::IsRasterPipelineOnly(SkColorType ct, SkShader::TileMode tx,
SkShader::TileMode ty) {
if (ct != kN32_SkColorType) {
return true;
}
if (tx != SkShader::kClamp_TileMode || ty != SkShader::kClamp_TileMode) {
return true;
}
return false;
}
bool SkImageShader::isRasterPipelineOnly() const {
SkBitmapProvider provider(fImage.get(), nullptr);
return IsRasterPipelineOnly(provider.info().colorType(), fTileModeX, fTileModeY);
}
SkShaderBase::Context* SkImageShader::onMakeContext(const ContextRec& rec,
SkArenaAlloc* alloc) const {
return SkBitmapProcLegacyShader::MakeContext(*this, fTileModeX, fTileModeY,

View File

@ -19,6 +19,7 @@ public:
const SkMatrix* localMatrix);
bool isOpaque() const override;
bool isRasterPipelineOnly() const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageShader)
@ -29,6 +30,8 @@ public:
SkImageShader(sk_sp<SkImage>, TileMode tx, TileMode ty, const SkMatrix* localMatrix);
static bool IsRasterPipelineOnly(SkColorType, SkShader::TileMode tx, SkShader::TileMode ty);
protected:
void flatten(SkWriteBuffer&) const override;
Context* onMakeContext(const ContextRec&, SkArenaAlloc* storage) const override;

View File

@ -265,6 +265,10 @@ sk_sp<SkShader> SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, con
return tileShader;
}
bool SkPictureShader::isRasterPipelineOnly() const {
return SkImageShader::IsRasterPipelineOnly(kN32_SkColorType, fTmx, fTmy);
}
bool SkPictureShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* cs, SkArenaAlloc* alloc,
const SkMatrix& ctm, const SkPaint& paint,
const SkMatrix* localMatrix) const {

View File

@ -39,6 +39,7 @@ protected:
const SkMatrix&, const SkPaint&, const SkMatrix*) const override;
Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override;
sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
bool isRasterPipelineOnly() const override;
private:
SkPictureShader(sk_sp<SkPicture>, TileMode, TileMode, const SkMatrix*, const SkRect*,