From cc63173634e773eac5de0b92f05d117ed2bdca84 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Tue, 6 Dec 2016 09:17:55 -0500 Subject: 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 Commit-Queue: Mike Klein --- src/core/SkRasterPipeline.cpp | 24 ++++++++---------------- src/core/SkRasterPipeline.h | 7 ++----- src/opts/SkRasterPipeline_opts.h | 8 ++++---- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp index a9164d342d..6d31a55f28 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 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 8762386f58..179bfb531d 100644 --- a/src/core/SkRasterPipeline.h +++ b/src/core/SkRasterPipeline.h @@ -12,6 +12,7 @@ #include "SkTArray.h" #include "SkTypes.h" #include +#include /** * 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 @@ public: }; private: - int fNum = 0; - Stage fStages[kMaxStages]; + std::vector fStages; }; #endif//SkRasterPipeline_DEFINED diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h index 07f6323673..e73d56cc8b 100644 --- a/src/opts/SkRasterPipeline_opts.h +++ b/src/opts/SkRasterPipeline_opts.h @@ -944,7 +944,7 @@ SI Fn enum_to_Fn(SkRasterPipeline::StockStage st) { 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 @@ namespace { _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 fStages; }; } -- cgit v1.2.3