OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |