diff options
author | mtklein <mtklein@chromium.org> | 2014-10-21 12:29:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-21 12:29:25 -0700 |
commit | c7f7f467df07be73b22dbee38a59762997eb19bc (patch) | |
tree | 75f76fef6eb4694b074a98a2a24ffa5599ec689c /bench/SKPBench.cpp | |
parent | 9abf4f82a86af6e9f608f559905352264c850e18 (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/SKPBench.cpp')
-rw-r--r-- | bench/SKPBench.cpp | 25 |
1 files changed, 19 insertions, 6 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(); + } } |