aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/shaders/SkShader.cpp
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-04-04 13:46:35 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-04 18:13:48 +0000
commitaf2769d00b70ca456452e4e88bdf5abecd320f68 (patch)
tree83fef5b2e2a4d66ec9de911cfc33fdc2d5ffe6dd /src/shaders/SkShader.cpp
parentbf74a460814a7912ed3d2e1af000afd2c45cd318 (diff)
Banish SkShaderBase::isRasterPipelineOnly()
Keeping related heuristics in sync with actual shader capabilities is somewhat tricky, and overall fragile. So how about this: instead of an explicit opt-in mechanism, try to instantiate a legacy shader context and fall back to raster pipeline on failure (null Context => implicit opt-in for raster pipeline). Shaders can still choose not to draw by returning both a null Context and failing appendStages(). BUG=skia:7772 Change-Id: I2e76f51af7064853a6cb851b4c30c82eba3ee828 Reviewed-on: https://skia-review.googlesource.com/118383 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/shaders/SkShader.cpp')
-rw-r--r--src/shaders/SkShader.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/shaders/SkShader.cpp b/src/shaders/SkShader.cpp
index 2dcba94983..195ac29d15 100644
--- a/src/shaders/SkShader.cpp
+++ b/src/shaders/SkShader.cpp
@@ -91,9 +91,15 @@ bool SkShaderBase::asLuminanceColor(SkColor* colorPtr) const {
}
SkShaderBase::Context* SkShaderBase::makeContext(const ContextRec& rec, SkArenaAlloc* alloc) const {
- return this->computeTotalInverse(*rec.fMatrix, rec.fLocalMatrix, nullptr)
- ? this->onMakeContext(rec, alloc)
- : nullptr;
+ // We always fall back to raster pipeline when perspective is present.
+ if (rec.fMatrix->hasPerspective() ||
+ fLocalMatrix.hasPerspective() ||
+ (rec.fLocalMatrix && rec.fLocalMatrix->hasPerspective()) ||
+ !this->computeTotalInverse(*rec.fMatrix, rec.fLocalMatrix, nullptr)) {
+ return nullptr;
+ }
+
+ return this->onMakeContext(rec, alloc);
}
SkShaderBase::Context* SkShaderBase::makeBurstPipelineContext(const ContextRec& rec,
@@ -114,11 +120,10 @@ SkShaderBase::Context* SkShaderBase::makeBurstPipelineContext(const ContextRec&
SkShaderBase::Context::Context(const SkShaderBase& shader, const ContextRec& rec)
: fShader(shader), fCTM(*rec.fMatrix)
{
- // We should never use a context for RP-only shaders.
- SkASSERT(!shader.isRasterPipelineOnly(*rec.fMatrix));
- // ... or for perspective.
+ // We should never use a context with perspective.
SkASSERT(!rec.fMatrix->hasPerspective());
SkASSERT(!rec.fLocalMatrix || !rec.fLocalMatrix->hasPerspective());
+ SkASSERT(!shader.getLocalMatrix().hasPerspective());
// Because the context parameters must be valid at this point, we know that the matrix is
// invertible.