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

Unified Diff: bench/RecordingBench.cpp

Issue 559153002: Measure picture recording speed in nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 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 | « bench/RecordingBench.h ('k') | bench/nanobench.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/RecordingBench.cpp
diff --git a/bench/RecordingBench.cpp b/bench/RecordingBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ee626bc52cdde3ff5a62478fc7f5bebdb01dc536
--- /dev/null
+++ b/bench/RecordingBench.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "RecordingBench.h"
+
+#include "SkBBHFactory.h"
+#include "SkPictureRecorder.h"
+
+static const int kTileSize = 256;
+
+RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useBBH)
+ : fSrc(SkRef(pic))
+ , fName(name)
+ , fUseBBH(useBBH) {}
+
+const char* RecordingBench::onGetName() {
+ return fName.c_str();
+}
+
+bool RecordingBench::isSuitableFor(Backend backend) {
+ return backend == kNonRendering_Backend;
+}
+
+SkIPoint RecordingBench::onGetSize() {
+ return SkIPoint::Make(SkScalarCeilToInt(fSrc->cullRect().width()),
+ SkScalarCeilToInt(fSrc->cullRect().height()));
+}
+
+void RecordingBench::onDraw(const int loops, SkCanvas*) {
+ SkTileGridFactory::TileGridInfo info;
+ info.fTileInterval.set(kTileSize, kTileSize);
+ info.fMargin.setEmpty();
+ info.fOffset.setZero();
+ SkTileGridFactory factory(info);
+
+ const SkScalar w = fSrc->cullRect().width(),
+ h = fSrc->cullRect().height();
+
+ for (int i = 0; i < loops; i++) {
+ SkPictureRecorder recorder;
+ fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : NULL));
+ SkDELETE(recorder.endRecording());
+ }
+}
« no previous file with comments | « bench/RecordingBench.h ('k') | bench/nanobench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698