Change to add zoom animations to nanobench

BUG=skia:

Review URL: https://codereview.chromium.org/1061323003
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 0045d53..c33f2c7 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -18,6 +18,7 @@
 #include "ProcStats.h"
 #include "ResultsWriter.h"
 #include "RecordingBench.h"
+#include "SKPAnimationBench.h"
 #include "SKPBench.h"
 #include "Stats.h"
 #include "Timer.h"
@@ -82,6 +83,7 @@
 DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this.");
 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs.");
 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs.");
+DEFINE_string(zoom, "1.0,1", "Comma-separated scale,step zoom factors for SKPs.");
 DEFINE_bool(bbh, true, "Build a BBH for SKPs?");
 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?");
 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run.");
@@ -491,6 +493,7 @@
                       , fCurrentImage(0)
                       , fCurrentSubsetImage(0)
                       , fCurrentColorType(0)
+                      , fCurrentAnimSKP(0)
                       , fDivisor(2) {
         for (int i = 0; i < FLAGS_skps.count(); i++) {
             if (SkStrEndsWith(FLAGS_skps[i], ".skp")) {
@@ -517,6 +520,11 @@
             }
         }
 
+        if (2 != sscanf(FLAGS_zoom[0], "%f,%d", &fZoomScale, &fZoomSteps)) {
+            SkDebugf("Can't parse %s from --zoom as a scale,step.\n", FLAGS_zoom[0]);
+            exit(1);
+        }
+
         fUseMPDs.push_back() = false;
         if (FLAGS_mpd) {
             fUseMPDs.push_back() = true;
@@ -625,8 +633,9 @@
                     fSourceType = "skp";
                     fBenchType = "playback";
                     return SkNEW_ARGS(SKPBench,
-                            (name.c_str(), pic.get(), fClip,
-                             fScales[fCurrentScale], fUseMPDs[fCurrentUseMPD++]));
+                                      (name.c_str(), pic.get(), fClip,
+                                       fScales[fCurrentScale], fUseMPDs[fCurrentUseMPD++]));
+
                 }
                 fCurrentUseMPD = 0;
                 fCurrentSKP++;
@@ -635,6 +644,26 @@
             fCurrentScale++;
         }
 
+        // Now loop over each skp again if we have an animation
+        if (fZoomScale != 1.0f && fZoomSteps != 1) {
+            while (fCurrentAnimSKP < fSKPs.count()) {
+                const SkString& path = fSKPs[fCurrentAnimSKP];
+                SkAutoTUnref<SkPicture> pic;
+                if (!ReadPicture(path.c_str(), &pic)) {
+                    fCurrentAnimSKP++;
+                    continue;
+                }
+
+                fCurrentAnimSKP++;
+                SkString name = SkOSPath::Basename(path.c_str());
+                SkMatrix anim = SkMatrix::I();
+                anim.setScale(fZoomScale, fZoomScale);
+                return SkNEW_ARGS(SKPAnimationBench, (name.c_str(), pic.get(), fClip, anim,
+                                  fZoomSteps));
+            }
+        }
+
+
         for (; fCurrentCodec < fImages.count(); fCurrentCodec++) {
             const SkString& path = fImages[fCurrentCodec];
             SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
@@ -789,6 +818,8 @@
     SkTArray<bool>     fUseMPDs;
     SkTArray<SkString> fImages;
     SkTArray<SkColorType> fColorTypes;
+    SkScalar           fZoomScale;
+    int                fZoomSteps;
 
     double fSKPBytes, fSKPOps;
 
@@ -802,6 +833,7 @@
     int fCurrentImage;
     int fCurrentSubsetImage;
     int fCurrentColorType;
+    int fCurrentAnimSKP;
     const int fDivisor;
 };