diff options
author | 2017-06-01 14:43:51 -0400 | |
---|---|---|
committer | 2017-06-01 19:23:10 +0000 | |
commit | 5df94d508ecfb62d54b757961dba611a00ff563c (patch) | |
tree | 3c1d188883c341bc22f712ed5e1508fb52e85224 | |
parent | e0f7e164eed88912ee708de57da25ad05933366f (diff) |
have shaders that need seed_shader call it themselves
This ought to make compose shader and our sprite blitter a bit more
efficient. Compose shader can simply re-seed instead of saving the
xy values off to a buffer. The sprite blitter doesn't need xy at all.
Change-Id: Ib4b3509288810f74a4c8e2978ce2ca14d8644980
Reviewed-on: https://skia-review.googlesource.com/18405
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
-rw-r--r-- | src/core/SkDraw_vertices.cpp | 9 | ||||
-rw-r--r-- | src/core/SkRasterPipelineBlitter.cpp | 4 | ||||
-rw-r--r-- | src/shaders/SkComposeShader.cpp | 8 | ||||
-rw-r--r-- | src/shaders/SkImageShader.cpp | 1 | ||||
-rw-r--r-- | src/shaders/gradients/SkGradientShader.cpp | 2 |
5 files changed, 9 insertions, 15 deletions
diff --git a/src/core/SkDraw_vertices.cpp b/src/core/SkDraw_vertices.cpp index 6b6ba9c555..662a6ff187 100644 --- a/src/core/SkDraw_vertices.cpp +++ b/src/core/SkDraw_vertices.cpp @@ -86,15 +86,16 @@ protected: Context* onMakeContext(const ContextRec& rec, SkArenaAlloc* alloc) const override { return nullptr; } - bool onAppendStages(SkRasterPipeline* pipeine, SkColorSpace* dstCS, SkArenaAlloc* alloc, + bool onAppendStages(SkRasterPipeline* pipeline, SkColorSpace* dstCS, SkArenaAlloc* alloc, const SkMatrix&, const SkPaint&, const SkMatrix*) const override { - pipeine->append(SkRasterPipeline::matrix_4x3, &fM43); + pipeline->append(SkRasterPipeline::seed_shader); + pipeline->append(SkRasterPipeline::matrix_4x3, &fM43); // In theory we should never need to clamp. However, either due to imprecision in our // matrix43, or the scan converter passing us pixel centers that in fact are not within // the triangle, we do see occasional (slightly) out-of-range values, so we add these // clamp stages. It would be nice to find a way to detect when these are not needed. - pipeine->append(SkRasterPipeline::clamp_0); - pipeine->append(SkRasterPipeline::clamp_a); + pipeline->append(SkRasterPipeline::clamp_0); + pipeline->append(SkRasterPipeline::clamp_a); return true; } diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp index 59fb172170..2925fe3455 100644 --- a/src/core/SkRasterPipelineBlitter.cpp +++ b/src/core/SkRasterPipelineBlitter.cpp @@ -177,10 +177,6 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst, if (shaderCtx) { colorPipeline->append(SkRasterPipeline::load_f32, &blitter->fShaderOutput); } else { - // If the shader's not constant, it'll need seeding with x,y. - if (!is_constant) { - colorPipeline->append(SkRasterPipeline::seed_shader); - } colorPipeline->extend(shaderPipeline); } diff --git a/src/shaders/SkComposeShader.cpp b/src/shaders/SkComposeShader.cpp index 7735494291..be2388f4ec 100644 --- a/src/shaders/SkComposeShader.cpp +++ b/src/shaders/SkComposeShader.cpp @@ -128,24 +128,18 @@ bool SkComposeShader::onAppendStages(SkRasterPipeline* pipeline, SkColorSpace* d SkArenaAlloc* alloc, const SkMatrix& ctm, const SkPaint& paint, const SkMatrix* localM) const { struct Storage { - float fXY[4 * SkJumper_kMaxStride]; float fRGBA[4 * SkJumper_kMaxStride]; float fAlpha; }; auto storage = alloc->make<Storage>(); - // We need to save off device x,y (inputs to shader), since after calling fShaderA they - // will be smashed, and I'll need them again for fShaderB. store_rgba saves off 4 registers - // even though we only need to save r,g. - pipeline->append(SkRasterPipeline::store_rgba, storage->fXY); if (!as_SB(fShaderB)->appendStages(pipeline, dstCS, alloc, ctm, paint, localM)) { // SRC return false; } // This outputs r,g,b,a, which we'll need later when we apply the mode, but we save it off now // since fShaderB will overwrite them. pipeline->append(SkRasterPipeline::store_rgba, storage->fRGBA); - // Now we restore the device x,y for the next shader - pipeline->append(SkRasterPipeline::load_rgba, storage->fXY); + if (!as_SB(fShaderA)->appendStages(pipeline, dstCS, alloc, ctm, paint, localM)) { // DST return false; } diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp index d46d2558e8..bdbd382638 100644 --- a/src/shaders/SkImageShader.cpp +++ b/src/shaders/SkImageShader.cpp @@ -258,6 +258,7 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dstCS, SkA } } + p->append(SkRasterPipeline::seed_shader); struct MiscCtx { std::unique_ptr<SkBitmapController::State> state; diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp index 137da84d0c..d98c8c6c7e 100644 --- a/src/shaders/gradients/SkGradientShader.cpp +++ b/src/shaders/gradients/SkGradientShader.cpp @@ -422,6 +422,8 @@ bool SkGradientShaderBase::onAppendStages(SkRasterPipeline* p, return false; } + p->append(SkRasterPipeline::seed_shader); + auto* m = alloc->makeArrayDefault<float>(9); if (matrix.asAffine(m)) { p->append(SkRasterPipeline::matrix_2x3, m); |