Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: tools/VisualBench/CpuWrappedBenchmark.h

Issue 1378393002: Basic CPU support for VisualBench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/VisualBench/VisualBenchmarkStream.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/VisualBench/CpuWrappedBenchmark.h
diff --git a/tools/VisualBench/CpuWrappedBenchmark.h b/tools/VisualBench/CpuWrappedBenchmark.h
new file mode 100644
index 0000000000000000000000000000000000000000..e63187cca48ca450ded6fecdf565099ddb4b42d5
--- /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
« no previous file with comments | « no previous file | tools/VisualBench/VisualBenchmarkStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698