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

Unified Diff: bench/SKPBench.cpp

Issue 669983002: Draw SKPs in 256x256 tiles in nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: int -> float Created 6 years, 2 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 | bench/nanobench.cpp » ('j') | no next file with comments »
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
index 9d822d9a2516180982ac746743878cdf13a448ca..9c96ef6f5343be3ed6f2f3bc668211a9a3853e73 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();
+ }
}
« no previous file with comments | « no previous file | bench/nanobench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698