aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/SKPBench.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-12-04 08:31:02 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-04 08:31:03 -0800
commit63242d7d24917f836eace34ee20faeb49def5e67 (patch)
tree4f7f34959349dc41243fe1cdc477363592f2a16d /bench/SKPBench.cpp
parent89dee4298e79b69ef2f1ec045c90ffacff9cabec (diff)
Fix SKPBench tiling so MPD and non-MPD match
Two issues with the SKPBench tile computation were causing the MPD path to do more work: The clip from the parent canvas wasn't being used to trim content off the edges of the MPD tiles The non-MPD path was not taking the scale into account in its tile placement (resulting in it having fewer, larger active tiles when scaling). Review URL: https://codereview.chromium.org/776273002
Diffstat (limited to 'bench/SKPBench.cpp')
-rw-r--r--bench/SKPBench.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp
index 3e692171db..222a878950 100644
--- a/bench/SKPBench.cpp
+++ b/bench/SKPBench.cpp
@@ -57,8 +57,16 @@ void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) {
for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) {
for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTile) {
- *fTileRects.append() = SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAGS_benchTile);
+ const SkIRect tileRect = SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAGS_benchTile);
+ *fTileRects.append() = tileRect;
*fSurfaces.push() = canvas->newSurface(ii);
+
+ // Never want the contents of a tile to include stuff the parent
+ // canvas clips out
+ SkRect clip = SkRect::Make(bounds);
+ clip.offset(-SkIntToScalar(tileRect.fLeft), -SkIntToScalar(tileRect.fTop));
+ fSurfaces.top()->getCanvas()->clipRect(clip);
+
fSurfaces.top()->getCanvas()->setMatrix(canvas->getTotalMatrix());
fSurfaces.top()->getCanvas()->scale(fScale, fScale);
}
@@ -120,8 +128,9 @@ void SKPBench::onDraw(const int loops, SkCanvas* canvas) {
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)));
+ canvas->clipRect(SkRect::MakeXYWH(x/fScale, y/fScale,
+ FLAGS_benchTile/fScale,
+ FLAGS_benchTile/fScale));
fPic->playback(canvas);
}
}