remove upper limit on number of pipeline stages
Bicubic is going to blow right past 48. At this point the fixed preallocation strategy is starting to look naive... at 64 we'd allocate just over 1K for every pipeline (and every compiled pipeline).
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD
Change-Id: Ib2944ead1217123aba2b6347fd9d5315217540c9
Reviewed-on: https://skia-review.googlesource.com/5551
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp
index a9164d3..6d31a55 100644
--- a/src/core/SkRasterPipeline.cpp
+++ b/src/core/SkRasterPipeline.cpp
@@ -11,35 +11,27 @@
SkRasterPipeline::SkRasterPipeline() {}
void SkRasterPipeline::append(StockStage stage, void* ctx) {
-#ifdef SK_DEBUG
- if (fNum == (int)SK_ARRAY_COUNT(fStages)) {
- this->dump();
- }
-#endif
- SkASSERT(fNum < (int)SK_ARRAY_COUNT(fStages));
- fStages[fNum++] = { stage, ctx };
+ fStages.push_back({stage, ctx});
}
void SkRasterPipeline::extend(const SkRasterPipeline& src) {
- for (int i = 0; i < src.fNum; i++) {
- const Stage& s = src.fStages[i];
- this->append(s.stage, s.ctx);
- }
+ fStages.insert(fStages.end(),
+ src.fStages.begin(), src.fStages.end());
}
void SkRasterPipeline::run(size_t x, size_t y, size_t n) const {
- SkOpts::run_pipeline(x,y,n, fStages, fNum);
+ SkOpts::run_pipeline(x,y,n, fStages.data(), SkToInt(fStages.size()));
}
std::function<void(size_t, size_t, size_t)> SkRasterPipeline::compile() const {
- return SkOpts::compile_pipeline(fStages, fNum);
+ return SkOpts::compile_pipeline(fStages.data(), SkToInt(fStages.size()));
}
void SkRasterPipeline::dump() const {
- SkDebugf("SkRasterPipeline, %d stages\n", fNum);
- for (int i = 0; i < fNum; i++) {
+ SkDebugf("SkRasterPipeline, %d stages\n", SkToInt(fStages.size()));
+ for (auto&& st : fStages) {
const char* name = "";
- switch (fStages[i].stage) {
+ switch (st.stage) {
#define M(x) case x: name = #x; break;
SK_RASTER_PIPELINE_STAGES(M)
#undef M
diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h
index 8762386..179bfb5 100644
--- a/src/core/SkRasterPipeline.h
+++ b/src/core/SkRasterPipeline.h
@@ -12,6 +12,7 @@
#include "SkTArray.h"
#include "SkTypes.h"
#include <functional>
+#include <vector>
/**
* SkRasterPipeline provides a cheap way to chain together a pixel processing pipeline.
@@ -90,9 +91,6 @@
class SkRasterPipeline {
public:
- // No pipeline may be more than kMaxStages long.
- static const int kMaxStages = 48;
-
SkRasterPipeline();
enum StockStage {
@@ -120,8 +118,7 @@
};
private:
- int fNum = 0;
- Stage fStages[kMaxStages];
+ std::vector<Stage> fStages;
};
#endif//SkRasterPipeline_DEFINED
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h
index 07f6323..e73d56c 100644
--- a/src/opts/SkRasterPipeline_opts.h
+++ b/src/opts/SkRasterPipeline_opts.h
@@ -944,7 +944,7 @@
namespace {
struct Compiled {
- Compiled(const SkRasterPipeline::Stage* stages, int nstages) {
+ Compiled(const SkRasterPipeline::Stage* stages, int nstages) : fStages(nstages) {
if (nstages == 0) {
return;
}
@@ -965,18 +965,18 @@
_1 = SkNf(1);
while (n >= N) {
- fStart(fStages, x*N, X,Y,_1,_0, _0,_0,_0,_0);
+ fStart(fStages.data(), x*N, X,Y,_1,_0, _0,_0,_0,_0);
X += (float)N;
x += N;
n -= N;
}
if (n) {
- fStart(fStages, x*N+n, X,Y,_1,_0, _0,_0,_0,_0);
+ fStart(fStages.data(), x*N+n, X,Y,_1,_0, _0,_0,_0,_0);
}
}
Fn fStart = just_return;
- Stage fStages[SkRasterPipeline::kMaxStages];
+ std::vector<Stage> fStages;
};
}