aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-10-25 13:31:21 -0400
committerGravatar Mike Klein <mtklein@chromium.org>2016-10-25 18:04:16 +0000
commite9f74b89c09772dd5abae1c0709c711d7cdb6535 (patch)
tree96e72a059facdc06f0ea39f2037e77d08eac6453 /src/core
parentaebfb45104eeb6dab5dbbedda13c2eaa7b7f7868 (diff)
SkRasterPipeline::compile().
I'm not yet caching these in the blitter, and speed is essentially unchanged in the bench where I am now building and compiling the pipeline only once. This may not be able to stay a simple std::function after I figure out caching, but for now it's a nice fit. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3911 Change-Id: I9545af589f73baf9f17cb4e6ace9a814c2478fe9 Reviewed-on: https://skia-review.googlesource.com/3911 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkOpts.cpp2
-rw-r--r--src/core/SkOpts.h4
-rw-r--r--src/core/SkRasterPipeline.cpp4
-rw-r--r--src/core/SkRasterPipeline.h8
-rw-r--r--src/core/SkRasterPipelineBlitter.cpp8
5 files changed, 14 insertions, 12 deletions
diff --git a/src/core/SkOpts.cpp b/src/core/SkOpts.cpp
index c082b160ee..6648909d1a 100644
--- a/src/core/SkOpts.cpp
+++ b/src/core/SkOpts.cpp
@@ -89,7 +89,7 @@ namespace SkOpts {
DEFINE_DEFAULT(hash_fn);
- DEFINE_DEFAULT(run_pipeline);
+ DEFINE_DEFAULT(compile_pipeline);
#undef DEFINE_DEFAULT
// Each Init_foo() is defined in src/opts/SkOpts_foo.cpp.
diff --git a/src/core/SkOpts.h b/src/core/SkOpts.h
index 7283030068..8e1b7fec8a 100644
--- a/src/core/SkOpts.h
+++ b/src/core/SkOpts.h
@@ -12,6 +12,7 @@
#include "SkTextureCompressor.h"
#include "SkTypes.h"
#include "SkXfermode.h"
+#include <functional>
struct ProcCoeff;
@@ -73,7 +74,8 @@ namespace SkOpts {
return hash_fn(data, bytes, seed);
}
- extern void (*run_pipeline)(size_t, size_t, const SkRasterPipeline::Stage*, int);
+ extern
+ std::function<void(size_t, size_t)> (*compile_pipeline)(const SkRasterPipeline::Stage*, int);
}
#endif//SkOpts_DEFINED
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp
index 707a33ae6f..54de6793b0 100644
--- a/src/core/SkRasterPipeline.cpp
+++ b/src/core/SkRasterPipeline.cpp
@@ -22,6 +22,6 @@ void SkRasterPipeline::extend(const SkRasterPipeline& src) {
}
}
-void SkRasterPipeline::run(size_t x, size_t n) const {
- SkOpts::run_pipeline(x,n, fStages, fNum);
+std::function<void(size_t, size_t)> SkRasterPipeline::compile() const {
+ return SkOpts::compile_pipeline(fStages, fNum);
}
diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h
index 60279dd168..548e503c84 100644
--- a/src/core/SkRasterPipeline.h
+++ b/src/core/SkRasterPipeline.h
@@ -11,6 +11,7 @@
#include "SkNx.h"
#include "SkTArray.h"
#include "SkTypes.h"
+#include <functional>
/**
* SkRasterPipeline provides a cheap way to chain together a pixel processing pipeline.
@@ -85,11 +86,8 @@ public:
// Append all stages to this pipeline.
void extend(const SkRasterPipeline&);
- // Run the pipeline constructed with append(), walking x through [x,x+n),
- // generally in 4-pixel steps, with perhaps one jagged tail step.
- void run(size_t x, size_t n) const;
- void run(size_t n) const { this->run(0, n); }
-
+ // Runs the pipeline walking x through [x,x+n).
+ std::function<void(size_t x, size_t n)> compile() const;
struct Stage {
StockStage stage;
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index 91d60bee3a..ec634c8b98 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -149,6 +149,8 @@ void SkRasterPipelineBlitter::append_store(SkRasterPipeline* p, void* dst) const
}
}
+// TODO: Figure out how to cache some of the compiled pipelines.
+
void SkRasterPipelineBlitter::blitH(int x, int y, int w) {
auto dst = fDst.writable_addr(0,y);
@@ -159,7 +161,7 @@ void SkRasterPipelineBlitter::blitH(int x, int y, int w) {
p.extend(fXfermode);
this->append_store(&p, dst);
- p.run(x, w);
+ p.compile()(x,w);
}
void SkRasterPipelineBlitter::blitAntiH(int x, int y, const SkAlpha aa[], const int16_t runs[]) {
@@ -176,7 +178,7 @@ void SkRasterPipelineBlitter::blitAntiH(int x, int y, const SkAlpha aa[], const
for (int16_t run = *runs; run > 0; run = *runs) {
coverage = *aa * (1/255.0f);
- p.run(x, run);
+ p.compile()(x, run);
x += run;
runs += run;
@@ -210,6 +212,6 @@ void SkRasterPipelineBlitter::blitMask(const SkMask& mask, const SkIRect& clip)
}
this->append_store(&p, dst);
- p.run(x, clip.width());
+ p.compile()(x, clip.width());
}
}