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 <reed@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/bench/SkRasterPipelineBench.cpp b/bench/SkRasterPipelineBench.cpp
index 818ab2b..baff258 100644
--- a/bench/SkRasterPipelineBench.cpp
+++ b/bench/SkRasterPipelineBench.cpp
@@ -113,9 +113,12 @@
 
 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 @@
         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: