aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkRasterPipeline.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-10-25 10:27:33 -0400
committerGravatar Mike Klein <mtklein@chromium.org>2016-10-25 17:30:38 +0000
commitaebfb45104eeb6dab5dbbedda13c2eaa7b7f7868 (patch)
tree7dcbf9bf86bd1b9fad0048dccbabb11e47a1d3fb /src/core/SkRasterPipeline.cpp
parentcc813ae9a0afe4259f12b655d9336662a6e2c100 (diff)
Move SkRasterPipeline further into SkOpts.
The portable code now becomes entirely focused on enum+ptr descriptions, leaving the concrete implementation of the pipeline to SkOpts::run_pipeline(). As implemented, the concrete implementation is basically the same, with a little more type safety. Speed is essentially unchanged on my laptop, and that's having run_pipeline() rebuild its concrete state every call. There's room for improvement there if we split this into a compile_pipeline() / run_pipeline() sort of thing, which is my next planned CL. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3920 CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Change-Id: Ie4c554f51040426de7c5c144afa5d9d9d8938012 Reviewed-on: https://skia-review.googlesource.com/3920 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkRasterPipeline.cpp')
-rw-r--r--src/core/SkRasterPipeline.cpp36
1 files changed, 8 insertions, 28 deletions
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp
index bc7feaccc7..707a33ae6f 100644
--- a/src/core/SkRasterPipeline.cpp
+++ b/src/core/SkRasterPipeline.cpp
@@ -8,40 +8,20 @@
#include "SkOpts.h"
#include "SkRasterPipeline.h"
-SkRasterPipeline::SkRasterPipeline() {
- fBodyStart = SkOpts::body[just_return];
- fTailStart = SkOpts::tail[just_return];
-}
-
-void SkRasterPipeline::append(void (*body)(), void (*tail)(), void* ctx) {
- // Each stage holds its own context and the next function to call.
- // So the pipeline itself has to hold onto the first function that starts the pipeline.
- (fBody.empty() ? fBodyStart : fBody.back().fNext) = body;
- (fTail.empty() ? fTailStart : fTail.back().fNext) = tail;
-
- // Each last stage starts with its next function set to JustReturn as a safety net.
- // It'll be overwritten by the next call to append().
- fBody.push_back({ SkOpts::body[just_return], ctx });
- fTail.push_back({ SkOpts::tail[just_return], ctx });
-}
+SkRasterPipeline::SkRasterPipeline() {}
void SkRasterPipeline::append(StockStage stage, void* ctx) {
- this->append(SkOpts::body[stage], SkOpts::tail[stage], ctx);
+ SkASSERT(fNum < (int)SK_ARRAY_COUNT(fStages));
+ fStages[fNum++] = { stage, ctx };
}
void SkRasterPipeline::extend(const SkRasterPipeline& src) {
- SkASSERT(src.fBody.count() == src.fTail.count());
-
- auto body = src.fBodyStart,
- tail = src.fTailStart;
- for (int i = 0; i < src.fBody.count(); i++) {
- SkASSERT(src.fBody[i].fCtx == src.fTail[i].fCtx);
- this->append(body, tail, src.fBody[i].fCtx);
- body = src.fBody[i].fNext;
- tail = src.fTail[i].fNext;
+ for (int i = 0; i < src.fNum; i++) {
+ const Stage& s = src.fStages[i];
+ this->append(s.stage, s.ctx);
}
}
-void SkRasterPipeline::run(size_t x, size_t n) {
- SkOpts::run_pipeline(x,n, fBodyStart,fBody.begin(), fTailStart,fTail.begin());
+void SkRasterPipeline::run(size_t x, size_t n) const {
+ SkOpts::run_pipeline(x,n, fStages, fNum);
}