diff options
author | Mike Reed <reed@google.com> | 2017-06-21 09:15:25 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-21 18:45:50 +0000 |
commit | 00b8ab61ddf6723a593bfcc931bbabb957aa7b19 (patch) | |
tree | cd4de09244e00e087180aac9a88cce1ed1ade111 /src/shaders | |
parent | 711450e948b9900011dc0d474f82bf7bc9913259 (diff) |
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>
Diffstat (limited to 'src/shaders')
-rw-r--r-- | src/shaders/SkColorFilterShader.h | 3 | ||||
-rw-r--r-- | src/shaders/SkImageShader.cpp | 16 | ||||
-rw-r--r-- | src/shaders/SkImageShader.h | 3 | ||||
-rw-r--r-- | src/shaders/SkPictureShader.cpp | 4 | ||||
-rw-r--r-- | src/shaders/SkPictureShader.h | 1 |
5 files changed, 27 insertions, 0 deletions
diff --git a/src/shaders/SkColorFilterShader.h b/src/shaders/SkColorFilterShader.h index 6a3f65eade..662c267943 100644 --- a/src/shaders/SkColorFilterShader.h +++ b/src/shaders/SkColorFilterShader.h @@ -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; diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp index 808b856d8a..dbb433ae4e 100644 --- a/src/shaders/SkImageShader.cpp +++ b/src/shaders/SkImageShader.cpp @@ -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, diff --git a/src/shaders/SkImageShader.h b/src/shaders/SkImageShader.h index 7be982c5c6..e68abb5d5a 100644 --- a/src/shaders/SkImageShader.h +++ b/src/shaders/SkImageShader.h @@ -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; diff --git a/src/shaders/SkPictureShader.cpp b/src/shaders/SkPictureShader.cpp index 4bef53da75..d80a7da1f9 100644 --- a/src/shaders/SkPictureShader.cpp +++ b/src/shaders/SkPictureShader.cpp @@ -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 { diff --git a/src/shaders/SkPictureShader.h b/src/shaders/SkPictureShader.h index f7a509f181..6fd2a3a9f5 100644 --- a/src/shaders/SkPictureShader.h +++ b/src/shaders/SkPictureShader.h @@ -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*, |