add pipe to nanobench

BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3801

Change-Id: Ia0b90b1e2947a7b9ae7cb340ef5cd5b3251bbd23
Reviewed-on: https://skia-review.googlesource.com/3801
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index e929a80..6a0fb04 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -126,7 +126,7 @@
 DEFINE_string(sourceType, "",
         "Apply usual --match rules to source type: bench, gm, skp, image, etc.");
 DEFINE_string(benchType,  "",
-        "Apply usual --match rules to bench type: micro, recording, playback, skcodec, etc.");
+        "Apply usual --match rules to bench type: micro, recording, piping, playback, skcodec, etc.");
 
 static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
 
@@ -583,6 +583,7 @@
     BenchmarkStream() : fBenches(BenchRegistry::Head())
                       , fGMs(skiagm::GMRegistry::Head())
                       , fCurrentRecording(0)
+                      , fCurrentPiping(0)
                       , fCurrentScale(0)
                       , fCurrentSKP(0)
                       , fCurrentSVG(0)
@@ -727,6 +728,21 @@
             return new RecordingBench(name.c_str(), pic.get(), FLAGS_bbh, FLAGS_lite);
         }
 
+        // Add all .skps as PipeBenches.
+        while (fCurrentPiping < fSKPs.count()) {
+            const SkString& path = fSKPs[fCurrentPiping++];
+            sk_sp<SkPicture> pic = ReadPicture(path.c_str());
+            if (!pic) {
+                continue;
+            }
+            SkString name = SkOSPath::Basename(path.c_str());
+            fSourceType = "skp";
+            fBenchType  = "piping";
+            fSKPBytes = static_cast<double>(SkPictureUtils::ApproximateBytesUsed(pic.get()));
+            fSKPOps   = pic->approximateOpCount();
+            return new PipingBench(name.c_str(), pic.get());
+        }
+
         // Then once each for each scale as SKPBenches (playback).
         while (fCurrentScale < fScales.count()) {
             while (fCurrentSKP < fSKPs.count()) {
@@ -1057,6 +1073,7 @@
     const char* fSourceType;  // What we're benching: bench, GM, SKP, ...
     const char* fBenchType;   // How we bench it: micro, recording, playback, ...
     int fCurrentRecording;
+    int fCurrentPiping;
     int fCurrentScale;
     int fCurrentSKP;
     int fCurrentSVG;