aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'src/shaders')
-rw-r--r--src/shaders/SkColorFilterShader.h3
-rw-r--r--src/shaders/SkImageShader.cpp16
-rw-r--r--src/shaders/SkImageShader.h3
-rw-r--r--src/shaders/SkPictureShader.cpp4
-rw-r--r--src/shaders/SkPictureShader.h1
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*,