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

Unified Diff: bench/SKPBench.cpp

Issue 425393004: SKPs-as-benches in nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more %.2g Created 6 years, 5 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/SKPBench.h ('k') | bench/nanobench.cpp » ('j') | bench/nanobench.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/SKPBench.cpp
diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ff4ed113702ab87a24892db5c46ff3fdd573d8ff
--- /dev/null
+++ b/bench/SKPBench.cpp
@@ -0,0 +1,41 @@
+/*
+ * 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 "SKPBench.h"
+
+SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip, SkScalar scale)
+ : fPic(SkRef(pic))
+ , fClip(clip)
+ , fScale(scale) {
+ fName.printf("%s_%.2g", name, scale);
+}
+
+const char* SKPBench::onGetName() {
+ return fName.c_str();
+}
+
+bool SKPBench::isSuitableFor(Backend backend) {
+ return backend != kNonRendering_Backend;
+}
+
+SkIPoint SKPBench::onGetSize() {
+ return SkIPoint::Make(fClip.fRight - fClip.fLeft, fClip.fBottom - fClip.fTop);
bsalomon 2014/08/01 13:23:24 fClip.width(), fClip.height()?
mtklein 2014/08/01 13:55:34 Done.
+}
+
+void SKPBench::onDraw(const int loops, SkCanvas* canvas) {
+ canvas->save();
+ SkRegion deviceClip;
bsalomon 2014/08/01 13:23:24 No regions, please! The GPU doesn't like them and
mtklein 2014/08/01 13:55:34 Done. Writing output SGTM. Let's follow up.
+ deviceClip.setRect(fClip);
+ canvas->clipRegion(deviceClip);
+
+ canvas->scale(fScale, fScale);
+
+ for (int i = 0; i < loops; i++) {
+ fPic->draw(canvas);
bsalomon 2014/08/01 13:23:24 I'm not sure whether we should have a canvas flush
mtklein 2014/08/01 13:55:34 Good question. Looks like bench_pictures does, so
+ }
+ canvas->restore();
+}
« no previous file with comments | « bench/SKPBench.h ('k') | bench/nanobench.cpp » ('j') | bench/nanobench.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698