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>
diff --git a/src/core/SkDraw_vertices.cpp b/src/core/SkDraw_vertices.cpp
index 6b6ba9c..662a6ff 100644
--- a/src/core/SkDraw_vertices.cpp
+++ b/src/core/SkDraw_vertices.cpp
@@ -86,15 +86,16 @@
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 59fb172..2925fe3 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -177,10 +177,6 @@
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 7735494..be2388f 100644
--- a/src/shaders/SkComposeShader.cpp
+++ b/src/shaders/SkComposeShader.cpp
@@ -128,24 +128,18 @@
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 d46d255..bdbd382 100644
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -258,6 +258,7 @@
}
}
+ 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 137da84..d98c8c6 100644
--- a/src/shaders/gradients/SkGradientShader.cpp
+++ b/src/shaders/gradients/SkGradientShader.cpp
@@ -422,6 +422,8 @@
return false;
}
+ p->append(SkRasterPipeline::seed_shader);
+
auto* m = alloc->makeArrayDefault<float>(9);
if (matrix.asAffine(m)) {
p->append(SkRasterPipeline::matrix_2x3, m);