From b24704d35f67f5b460be9c92794892e06adceb46 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Wed, 24 May 2017 07:53:00 -0400 Subject: SkRasterPipeline in SkArenaAlloc Bug: skia:6673 Change-Id: Ia2bae4f6a9039a007a10b6b45bcf2f0854bf6e5c Reviewed-on: https://skia-review.googlesource.com/17794 Reviewed-by: Mike Reed Commit-Queue: Mike Klein --- bench/SkRasterPipelineBench.cpp | 69 +++-------------------------------------- 1 file changed, 5 insertions(+), 64 deletions(-) (limited to 'bench/SkRasterPipelineBench.cpp') diff --git a/bench/SkRasterPipelineBench.cpp b/bench/SkRasterPipelineBench.cpp index bef80b3fca..df130183b8 100644 --- a/bench/SkRasterPipelineBench.cpp +++ b/bench/SkRasterPipelineBench.cpp @@ -39,7 +39,7 @@ public: void* src_ctx = src; void* dst_ctx = dst; - SkRasterPipeline p; + SkRasterPipeline_<256> p; p.append(SkRasterPipeline::load_8888, &src_ctx); p.append_from_srgb(kUnpremul_SkAlphaType); p.append(SkRasterPipeline::scale_u8, &mask_ctx); @@ -79,7 +79,7 @@ public: void* src_ctx = src; void* dst_ctx = dst; - SkRasterPipeline p; + SkRasterPipeline_<256> p; p.append(SkRasterPipeline::load_8888, &dst_ctx); p.append(SkRasterPipeline::move_src_dst); p.append(SkRasterPipeline::load_8888, &src_ctx); @@ -87,9 +87,7 @@ public: p.append(SkRasterPipeline::store_8888, &dst_ctx); if (fCompile) { - char buffer[1024]; - SkArenaAlloc alloc(buffer); - auto fn = p.compile(&alloc); + auto fn = p.compile(); while (loops --> 0) { fn(0,N); } @@ -124,7 +122,7 @@ public: SkColorSpaceTransferFn from_2dot2 = gamma( 2.2f), to_2dot2 = gamma(1/2.2f); - SkRasterPipeline p; + SkRasterPipeline_<256> p; p.append(SkRasterPipeline::constant_color, &c); p.append(SkRasterPipeline::parametric_r, &from_2dot2); p.append(SkRasterPipeline::parametric_g, &from_2dot2); @@ -148,7 +146,7 @@ public: } void onDraw(int loops, SkCanvas*) override { - SkRasterPipeline p; + SkRasterPipeline_<256> p; p.append(SkRasterPipeline::to_srgb); while (loops --> 0) { @@ -157,60 +155,3 @@ public: } }; DEF_BENCH( return (new SkRasterPipelineToSRGB); ) - -class SkRasterPipelineReuseBench : public Benchmark { -public: - enum Mode { None, Some, Full }; - - explicit SkRasterPipelineReuseBench(Mode mode) : fMode(mode), fName("SkRasterPipelineReuse") { - switch(mode) { - case None: fName.append("_none"); break; - case Some: fName.append("_some"); break; - case Full: fName.append("_full"); break; - } - } - const char* onGetName() override { return fName.c_str(); } - bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; } - - void onDraw(int loops, SkCanvas*) override { - const int kStages = 20; - const auto stage = SkRasterPipeline::to_srgb; // Any stage will do. We won't call it. - - switch(fMode) { - case None: - while (loops --> 0) { - SkRasterPipeline p; - for (int i = 0; i < kStages; i++) { - p.append(stage); - } - } - break; - - case Some: - while (loops --> 0) { - SkRasterPipeline p(kStages); - for (int i = 0; i < kStages; i++) { - p.append(stage); - } - } - break; - - case Full: - SkRasterPipeline p(kStages); - while (loops --> 0) { - p.rewind(); - for (int i = 0; i < kStages; i++) { - p.append(stage); - } - } - break; - } - } - -private: - Mode fMode; - SkString fName; -}; -DEF_BENCH( return (new SkRasterPipelineReuseBench(SkRasterPipelineReuseBench::None)); ) -DEF_BENCH( return (new SkRasterPipelineReuseBench(SkRasterPipelineReuseBench::Some)); ) -DEF_BENCH( return (new SkRasterPipelineReuseBench(SkRasterPipelineReuseBench::Full)); ) -- cgit v1.2.3