aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-11-30 13:45:06 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-30 20:16:49 +0000
commitc789b61167dd98efc3c3bfcf9673eef24c2e57f4 (patch)
treeba3a28f33c7d3c5e8c323cacc40125def20c80b2
parentc5d0147717e50acba106b76c6c345192274ddc06 (diff)
Bring back SkRasterPipeline::run() for one-off uses.
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I308b6d75f2987a667eead9a55760a2ff6aec2984 Reviewed-on: https://skia-review.googlesource.com/5353 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
-rw-r--r--src/core/SkColorSpaceXform_A2B.cpp5
-rw-r--r--src/core/SkOpts.cpp1
-rw-r--r--src/core/SkOpts.h1
-rw-r--r--src/core/SkPM4fPriv.h2
-rw-r--r--src/core/SkRasterPipeline.cpp4
-rw-r--r--src/core/SkRasterPipeline.h3
-rw-r--r--src/core/SkRasterPipelineBlitter.cpp2
-rw-r--r--src/opts/SkOpts_hsw.cpp1
-rw-r--r--src/opts/SkOpts_sse41.cpp1
-rw-r--r--src/opts/SkRasterPipeline_opts.h5
-rw-r--r--tests/SkRasterPipelineTest.cpp6
11 files changed, 22 insertions, 9 deletions
diff --git a/src/core/SkColorSpaceXform_A2B.cpp b/src/core/SkColorSpaceXform_A2B.cpp
index d10453cb67..f2f694349f 100644
--- a/src/core/SkColorSpaceXform_A2B.cpp
+++ b/src/core/SkColorSpaceXform_A2B.cpp
@@ -64,10 +64,7 @@ bool SkColorSpaceXform_A2B::onApply(ColorFormat dstFormat, void* dst, ColorForma
pipeline.append(SkRasterPipeline::store_f32, &dst);
break;
}
-
- auto p = pipeline.compile();
-
- p(0,0, count);
+ pipeline.run(0,0, count);
return true;
}
diff --git a/src/core/SkOpts.cpp b/src/core/SkOpts.cpp
index 6c13dd05e1..45fb2890f2 100644
--- a/src/core/SkOpts.cpp
+++ b/src/core/SkOpts.cpp
@@ -90,6 +90,7 @@ namespace SkOpts {
DEFINE_DEFAULT(hash_fn);
+ DEFINE_DEFAULT(run_pipeline);
DEFINE_DEFAULT(compile_pipeline);
DEFINE_DEFAULT(convolve_vertically);
diff --git a/src/core/SkOpts.h b/src/core/SkOpts.h
index 22be97c332..b09d8cfd9f 100644
--- a/src/core/SkOpts.h
+++ b/src/core/SkOpts.h
@@ -75,6 +75,7 @@ namespace SkOpts {
return hash_fn(data, bytes, seed);
}
+ extern void (*run_pipeline)(size_t, size_t, size_t, const SkRasterPipeline::Stage*, int);
extern std::function<void(size_t, size_t, size_t)>
(*compile_pipeline)(const SkRasterPipeline::Stage*, int);
diff --git a/src/core/SkPM4fPriv.h b/src/core/SkPM4fPriv.h
index 13c1fd9ab7..db8d478f13 100644
--- a/src/core/SkPM4fPriv.h
+++ b/src/core/SkPM4fPriv.h
@@ -126,7 +126,7 @@ static inline SkColor4f SkColor4f_from_SkColor(SkColor color, SkColorSpace* dst)
SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).get(), dst);
p.append(SkRasterPipeline::store_f32, &color4f_ptr);
- p.compile()(0,0,1);
+ p.run(0,0,1);
} else {
// Linear gamma, dst gamut.
swizzle_rb(SkNx_cast<float>(Sk4b::Load(&color)) * (1/255.0f)).store(&color4f);
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp
index 7c4c95f480..27856fd576 100644
--- a/src/core/SkRasterPipeline.cpp
+++ b/src/core/SkRasterPipeline.cpp
@@ -27,6 +27,10 @@ void SkRasterPipeline::extend(const SkRasterPipeline& src) {
}
}
+void SkRasterPipeline::run(size_t x, size_t y, size_t n) const {
+ SkOpts::run_pipeline(x,y,n, fStages, fNum);
+}
+
std::function<void(size_t, 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 0495ebc3e7..01b581f3bb 100644
--- a/src/core/SkRasterPipeline.h
+++ b/src/core/SkRasterPipeline.h
@@ -104,6 +104,9 @@ public:
void extend(const SkRasterPipeline&);
// Runs the pipeline walking x through [x,x+n), holding y constant.
+ void run(size_t x, size_t y, size_t n) const;
+
+ // If you're going to run() the pipeline more than once, it's best to compile it.
std::function<void(size_t x, size_t y, size_t n)> compile() const;
void dump() const;
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index d1796f5766..075da1a754 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -140,7 +140,7 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
if (is_constant) {
pipeline->append(SkRasterPipeline::store_f32, &paintColor);
- pipeline->compile()(0,0, 1);
+ pipeline->run(0,0, 1);
*pipeline = SkRasterPipeline();
pipeline->append(SkRasterPipeline::constant_color, paintColor);
diff --git a/src/opts/SkOpts_hsw.cpp b/src/opts/SkOpts_hsw.cpp
index 96465b8a07..12bc49444f 100644
--- a/src/opts/SkOpts_hsw.cpp
+++ b/src/opts/SkOpts_hsw.cpp
@@ -17,6 +17,7 @@
namespace SkOpts {
void Init_hsw() {
+ run_pipeline = hsw::run_pipeline;
compile_pipeline = hsw::compile_pipeline;
}
}
diff --git a/src/opts/SkOpts_sse41.cpp b/src/opts/SkOpts_sse41.cpp
index 0d771bdbef..e29fcde722 100644
--- a/src/opts/SkOpts_sse41.cpp
+++ b/src/opts/SkOpts_sse41.cpp
@@ -20,6 +20,7 @@ namespace SkOpts {
box_blur_yx = sse41::box_blur_yx;
srcover_srgb_srgb = sse41::srcover_srgb_srgb;
blit_row_s32a_opaque = sse41::blit_row_s32a_opaque;
+ run_pipeline = sse41::run_pipeline;
compile_pipeline = sse41::compile_pipeline;
}
}
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h
index 163b9ebbf0..5be1b0c309 100644
--- a/src/opts/SkRasterPipeline_opts.h
+++ b/src/opts/SkRasterPipeline_opts.h
@@ -960,6 +960,11 @@ namespace SK_OPTS_NS {
return fn;
}
+ SI void run_pipeline(size_t x, size_t y, size_t n,
+ const SkRasterPipeline::Stage* stages, int nstages) {
+ compile_pipeline(stages, nstages)(x,y,n);
+ }
+
} // namespace SK_OPTS_NS
#undef SI
diff --git a/tests/SkRasterPipelineTest.cpp b/tests/SkRasterPipelineTest.cpp
index 427bc93015..50c417f5f0 100644
--- a/tests/SkRasterPipelineTest.cpp
+++ b/tests/SkRasterPipelineTest.cpp
@@ -25,7 +25,7 @@ DEF_TEST(SkRasterPipeline, r) {
p.append(SkRasterPipeline::load_f16_d, &load_d_ctx);
p.append(SkRasterPipeline::srcover);
p.append(SkRasterPipeline::store_f16, &store_ctx);
- p.compile()(0,0, 1);
+ p.run(0,0, 1);
// We should see half-intensity magenta.
REPORTER_ASSERT(r, ((result >> 0) & 0xffff) == 0x3800);
@@ -37,7 +37,7 @@ DEF_TEST(SkRasterPipeline, r) {
DEF_TEST(SkRasterPipeline_empty, r) {
// No asserts... just a test that this is safe to run.
SkRasterPipeline p;
- p.compile()(0,0, 20);
+ p.run(0,0, 20);
}
DEF_TEST(SkRasterPipeline_nonsense, r) {
@@ -45,5 +45,5 @@ DEF_TEST(SkRasterPipeline_nonsense, r) {
// srcover() calls st->next(); this makes sure we've always got something there to call.
SkRasterPipeline p;
p.append(SkRasterPipeline::srcover);
- p.compile()(0,0, 20);
+ p.run(0,0, 20);
}