From a07e4302cfefc282d8d235edfbc20a54c75afa88 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Wed, 9 Aug 2017 13:51:35 -0400 Subject: add gamma stage Until now we've been using 3 separate parametric stages to apply gamma to r,g,b. That works fine, but is kind of unnecessarily slow, and again less clear in a stack trace than seeing "gamma". The new bench runs in about 60% of the time the old one does on my Trashcan. BUG=skia:6939 Change-Id: I079698d3009b081f1c23a2e27fc26e373b439610 Reviewed-on: https://skia-review.googlesource.com/32721 Reviewed-by: Mike Reed Commit-Queue: Mike Klein --- bench/SkRasterPipelineBench.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'bench/SkRasterPipelineBench.cpp') diff --git a/bench/SkRasterPipelineBench.cpp b/bench/SkRasterPipelineBench.cpp index 818ab2b447..baff258409 100644 --- a/bench/SkRasterPipelineBench.cpp +++ b/bench/SkRasterPipelineBench.cpp @@ -113,9 +113,12 @@ static SkColorSpaceTransferFn gamma(float g) { class SkRasterPipeline_2dot2 : public Benchmark { public: + SkRasterPipeline_2dot2(bool parametric) : fParametric(parametric) {} + bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; } const char* onGetName() override { - return "SkRasterPipeline_2dot2"; + return fParametric ? "SkRasterPipeline_2dot2_parametric" + : "SkRasterPipeline_2dot2_gamma"; } void onDraw(int loops, SkCanvas*) override { @@ -126,19 +129,27 @@ public: SkSTArenaAlloc<256> alloc; SkRasterPipeline p(&alloc); p.append_constant_color(&alloc, c); - p.append(SkRasterPipeline::parametric_r, &from_2dot2); - p.append(SkRasterPipeline::parametric_g, &from_2dot2); - p.append(SkRasterPipeline::parametric_b, &from_2dot2); - p.append(SkRasterPipeline::parametric_r, & to_2dot2); - p.append(SkRasterPipeline::parametric_g, & to_2dot2); - p.append(SkRasterPipeline::parametric_b, & to_2dot2); + if (fParametric) { + p.append(SkRasterPipeline::parametric_r, &from_2dot2); + p.append(SkRasterPipeline::parametric_g, &from_2dot2); + p.append(SkRasterPipeline::parametric_b, &from_2dot2); + p.append(SkRasterPipeline::parametric_r, & to_2dot2); + p.append(SkRasterPipeline::parametric_g, & to_2dot2); + p.append(SkRasterPipeline::parametric_b, & to_2dot2); + } else { + p.append(SkRasterPipeline::gamma, &from_2dot2.fG); + p.append(SkRasterPipeline::gamma, & to_2dot2.fG); + } while (loops --> 0) { p.run(0,0,N,1); } } +private: + bool fParametric; }; -DEF_BENCH( return (new SkRasterPipeline_2dot2); ) +DEF_BENCH( return (new SkRasterPipeline_2dot2( true)); ) +DEF_BENCH( return (new SkRasterPipeline_2dot2(false)); ) class SkRasterPipelineToSRGB : public Benchmark { public: -- cgit v1.2.3