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

Side by Side Diff: bench/SKPBench.cpp

Issue 776273002: Fix SKPBench tiling so MPD and non-MPD match (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SKPBench.h" 8 #include "SKPBench.h"
9 #include "SkCommandLineFlags.h" 9 #include "SkCommandLineFlags.h"
10 #include "SkMultiPictureDraw.h" 10 #include "SkMultiPictureDraw.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 int xTiles = SkScalarCeilToInt(bounds.width() / SkIntToScalar(FLAGS_benchTi le)); 50 int xTiles = SkScalarCeilToInt(bounds.width() / SkIntToScalar(FLAGS_benchTi le));
51 int yTiles = SkScalarCeilToInt(bounds.height() / SkIntToScalar(FLAGS_benchTi le)); 51 int yTiles = SkScalarCeilToInt(bounds.height() / SkIntToScalar(FLAGS_benchTi le));
52 52
53 fSurfaces.setReserve(xTiles * yTiles); 53 fSurfaces.setReserve(xTiles * yTiles);
54 fTileRects.setReserve(xTiles * yTiles); 54 fTileRects.setReserve(xTiles * yTiles);
55 55
56 SkImageInfo ii = canvas->imageInfo().makeWH(FLAGS_benchTile, FLAGS_benchTile ); 56 SkImageInfo ii = canvas->imageInfo().makeWH(FLAGS_benchTile, FLAGS_benchTile );
57 57
58 for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) { 58 for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) {
59 for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTile) { 59 for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTile) {
60 *fTileRects.append() = SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAG S_benchTile); 60 const SkIRect tileRect = SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FL AGS_benchTile);
61 *fTileRects.append() = tileRect;
61 *fSurfaces.push() = canvas->newSurface(ii); 62 *fSurfaces.push() = canvas->newSurface(ii);
63
64 // Never want the contents of a tile to include stuff the parent
65 // canvas clips out
66 SkRect clip = SkRect::Make(bounds);
67 clip.offset(-SkIntToScalar(tileRect.fLeft), -SkIntToScalar(tileRect. fTop));
68 fSurfaces.top()->getCanvas()->clipRect(clip);
69
62 fSurfaces.top()->getCanvas()->setMatrix(canvas->getTotalMatrix()); 70 fSurfaces.top()->getCanvas()->setMatrix(canvas->getTotalMatrix());
63 fSurfaces.top()->getCanvas()->scale(fScale, fScale); 71 fSurfaces.top()->getCanvas()->scale(fScale, fScale);
64 } 72 }
65 } 73 }
66 } 74 }
67 75
68 void SKPBench::onPerCanvasPostDraw(SkCanvas* canvas) { 76 void SKPBench::onPerCanvasPostDraw(SkCanvas* canvas) {
69 if (!fUseMultiPictureDraw) { 77 if (!fUseMultiPictureDraw) {
70 return; 78 return;
71 } 79 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 SkIRect bounds; 121 SkIRect bounds;
114 SkAssertResult(canvas->getClipDeviceBounds(&bounds)); 122 SkAssertResult(canvas->getClipDeviceBounds(&bounds));
115 123
116 SkAutoCanvasRestore overall(canvas, true/*save now*/); 124 SkAutoCanvasRestore overall(canvas, true/*save now*/);
117 canvas->scale(fScale, fScale); 125 canvas->scale(fScale, fScale);
118 126
119 for (int i = 0; i < loops; i++) { 127 for (int i = 0; i < loops; i++) {
120 for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) { 128 for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) {
121 for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTi le) { 129 for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTi le) {
122 SkAutoCanvasRestore perTile(canvas, true/*save now*/); 130 SkAutoCanvasRestore perTile(canvas, true/*save now*/);
123 canvas->clipRect(SkRect::Make( 131 canvas->clipRect(SkRect::MakeXYWH(x/fScale, y/fScale,
124 SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAGS_b enchTile))); 132 FLAGS_benchTile/fScale,
133 FLAGS_benchTile/fScale));
125 fPic->playback(canvas); 134 fPic->playback(canvas);
126 } 135 }
127 } 136 }
128 137
129 canvas->flush(); 138 canvas->flush();
130 } 139 }
131 } 140 }
132 } 141 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698