allow SkRP color filters to fail

I think we decided at some point that we had implemented all existing
color filters with SkRasterPipeline, and then stopped checking for
appendStages() failure.  It's all still plumbed through, and I'd like to
start making some color filters fail to appendStage() and use
SkVMBlitter, at least some of the time.

Change-Id: I520151e7bfc01c4cf333a6ed515f27bee6cd55ee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308195
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2020-08-05 12:41:30 -05:00 committed by Skia Commit-Bot
parent 4c97814f3a
commit 6d00de3ca9
5 changed files with 19 additions and 5 deletions

View File

@ -326,14 +326,20 @@ public:
p->append(SkRasterPipeline::store_src, state->orig_rgba);
if (!fCF1) {
fCF0->appendStages(rec, shaderIsOpaque);
if (!fCF0->appendStages(rec, shaderIsOpaque)) {
return false;
}
p->append(SkRasterPipeline::move_src_dst);
p->append(SkRasterPipeline::load_src, state->orig_rgba);
} else {
fCF0->appendStages(rec, shaderIsOpaque);
if (!fCF0->appendStages(rec, shaderIsOpaque)) {
return false;
}
p->append(SkRasterPipeline::store_src, state->filtered_rgba);
p->append(SkRasterPipeline::load_src, state->orig_rgba);
fCF1->appendStages(rec, shaderIsOpaque);
if (!fCF1->appendStages(rec, shaderIsOpaque)) {
return false;
}
p->append(SkRasterPipeline::load_dst, state->filtered_rgba);
}
float* storage = rec.fAlloc->make<float>(fWeight);

View File

@ -28,8 +28,10 @@ namespace skvm {
class SkColorFilterBase : public SkColorFilter {
public:
SK_WARN_UNUSED_RESULT
bool appendStages(const SkStageRec& rec, bool shaderIsOpaque) const;
SK_WARN_UNUSED_RESULT
skvm::Color program(skvm::Builder*, skvm::Color,
SkColorSpace* dstCS, skvm::Uniforms*, SkArenaAlloc*) const;

View File

@ -184,7 +184,9 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
SkStageRec rec = {
colorPipeline, alloc, dst.colorType(), dst.colorSpace(), paint, nullptr, matrixProvider
};
as_CFB(colorFilter)->appendStages(rec, is_opaque);
if (!as_CFB(colorFilter)->appendStages(rec, is_opaque)) {
return nullptr;
}
is_opaque = is_opaque && as_CFB(colorFilter)->isAlphaUnchanged();
}

View File

@ -56,7 +56,9 @@ bool SkColorFilterShader::onAppendStages(const SkStageRec& rec) const {
if (fAlpha != 1.0f) {
rec.fPipeline->append(SkRasterPipeline::scale_1_float, rec.fAlloc->make<float>(fAlpha));
}
fFilter->appendStages(rec, fShader->isOpaque());
if (!fFilter->appendStages(rec, fShader->isOpaque())) {
return false;
}
return true;
}

View File

@ -173,6 +173,7 @@ public:
bool asLuminanceColor(SkColor*) const;
// If this returns false, then we draw nothing (do not fall back to shader context)
SK_WARN_UNUSED_RESULT
bool appendStages(const SkStageRec&) const;
bool SK_WARN_UNUSED_RESULT computeTotalInverse(const SkMatrix& ctm,
@ -211,6 +212,7 @@ public:
return this->onAppendUpdatableStages(rec);
}
SK_WARN_UNUSED_RESULT
skvm::Color program(skvm::Builder*, skvm::Coord device, skvm::Coord local, skvm::Color paint,
const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst,