Basic CPU support for VisualBench.

BUG=skia:

Review URL: https://codereview.chromium.org/1378393002
diff --git a/tools/VisualBench/CpuWrappedBenchmark.h b/tools/VisualBench/CpuWrappedBenchmark.h
new file mode 100644
index 0000000..e63187c
--- /dev/null
+++ b/tools/VisualBench/CpuWrappedBenchmark.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ */
+
+#ifndef CpuWrappedBenchmark_DEFINED
+#define CpuWrappedBenchmark_DEFINED
+
+#include "Benchmark.h"
+#include "SkSurface.h"
+
+class CpuWrappedBenchmark : public Benchmark {
+public:
+    // Takes ownership of caller's ref on `bench`.
+    explicit CpuWrappedBenchmark(Benchmark* bench) : fBench(bench) {}
+
+    const char* onGetName()       override { return fBench->getName(); }
+    const char* onGetUniqueName() override { return fBench->getUniqueName(); }
+
+    void onDraw(int loops, SkCanvas* canvas) override {
+        // TODO: use onPreDraw() to move offscreen allocation/deallocation out of timing.
+        SkAutoTUnref<SkSurface> offscreen(SkSurface::NewRaster(canvas->imageInfo()));
+
+        fBench->draw(loops, offscreen->getCanvas());
+        SkAutoTUnref<SkImage> image(offscreen->newImageSnapshot());
+        canvas->drawImage(image, 0,0);
+    }
+
+private:
+    SkAutoTUnref<Benchmark> fBench;
+};
+
+#endif//CpuWrappedBenchmark_DEFINED
diff --git a/tools/VisualBench/VisualBenchmarkStream.cpp b/tools/VisualBench/VisualBenchmarkStream.cpp
index 4cc819d..9e1ce36 100644
--- a/tools/VisualBench/VisualBenchmarkStream.cpp
+++ b/tools/VisualBench/VisualBenchmarkStream.cpp
@@ -7,12 +7,14 @@
  */
 
 #include <VisualBench/VisualBenchmarkStream.h>
+#include "CpuWrappedBenchmark.h"
 #include "GMBench.h"
 #include "SkOSFile.h"
 #include "SkPictureRecorder.h"
 #include "SkStream.h"
 #include "VisualSKPBench.h"
 
+DEFINE_bool(cpu, false, "Run in CPU mode?");
 DEFINE_string2(match, m, nullptr,
                "[~][^]substring[$] [...] of bench name to run.\n"
                "Multiple matches may be separated by spaces.\n"
@@ -72,6 +74,9 @@
             !bench->isSuitableFor(Benchmark::kGPU_Backend))) {
         bench->unref();
     }
+    if (FLAGS_cpu) {
+        return new CpuWrappedBenchmark(bench);
+    }
     return bench;
 }