aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-10-21 12:29:25 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-21 12:29:25 -0700
commitc7f7f467df07be73b22dbee38a59762997eb19bc (patch)
tree75f76fef6eb4694b074a98a2a24ffa5599ec689c /bench
parent9abf4f82a86af6e9f608f559905352264c850e18 (diff)
Draw SKPs in 256x256 tiles in nanobench.
(This CL will certainly trigger performance regression alerts. Tiled drawing is slower than non-tiled drawing.) BUG=skia: Review URL: https://codereview.chromium.org/669983002
Diffstat (limited to 'bench')
-rw-r--r--bench/SKPBench.cpp25
-rw-r--r--bench/nanobench.cpp8
2 files changed, 23 insertions, 10 deletions
diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp
index 9d822d9a25..9c96ef6f53 100644
--- a/bench/SKPBench.cpp
+++ b/bench/SKPBench.cpp
@@ -6,6 +6,9 @@
*/
#include "SKPBench.h"
+#include "SkCommandLineFlags.h"
+
+DECLARE_int32(benchTile);
SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip, SkScalar scale)
: fPic(SkRef(pic))
@@ -32,11 +35,21 @@ SkIPoint SKPBench::onGetSize() {
}
void SKPBench::onDraw(const int loops, SkCanvas* canvas) {
- canvas->save();
- canvas->scale(fScale, fScale);
- for (int i = 0; i < loops; i++) {
- fPic->playback(canvas);
- canvas->flush();
+ SkIRect bounds;
+ SkAssertResult(canvas->getClipDeviceBounds(&bounds));
+
+ SkAutoCanvasRestore overall(canvas, true/*save now*/);
+ canvas->scale(fScale, fScale);
+
+ for (int i = 0; i < loops; i++) {
+ for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) {
+ for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTile) {
+ SkAutoCanvasRestore perTile(canvas, true/*save now*/);
+ canvas->clipRect(SkRect::Make(
+ SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAGS_benchTile)));
+ fPic->playback(canvas);
+ }
}
- canvas->restore();
+ canvas->flush();
+ }
}
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 250f438d6a..2758528a96 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -70,6 +70,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_bool(bbh, true, "Build a BBH for SKPs?");
+DEFINE_int32(benchTile, 256, "Tile dimension used for SKP playback.");
DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run.");
static SkString humanize(double ms) {
@@ -514,11 +515,10 @@ public:
}
if (FLAGS_bbh) {
// The SKP we read off disk doesn't have a BBH. Re-record so it grows one.
- // Here we use an SkTileGrid with parameters optimized for FLAGS_clip.
const SkTileGridFactory::TileGridInfo info = {
- SkISize::Make(fClip.width(), fClip.height()), // tile interval
- SkISize::Make(0,0), // margin
- SkIPoint::Make(fClip.left(), fClip.top()), // offset
+ SkISize::Make(FLAGS_benchTile, FLAGS_benchTile), // tile interval
+ SkISize::Make(0,0), // margin
+ SkIPoint::Make(0,0), // offset
};
SkTileGridFactory factory(info);
SkPictureRecorder recorder;