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" |
11 #include "SkSurface.h" | 11 #include "SkSurface.h" |
12 | 12 |
13 DEFINE_int32(benchTile, 256, "Tile dimension used for SKP playback."); | 13 DEFINE_int32(benchTileW, 1600, "Tile width used for SKP playback."); |
| 14 DEFINE_int32(benchTileH, 512, "Tile height used for SKP playback."); |
14 | 15 |
15 SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
SkScalar scale, | 16 SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
SkScalar scale, |
16 bool useMultiPictureDraw) | 17 bool useMultiPictureDraw) |
17 : fPic(SkRef(pic)) | 18 : fPic(SkRef(pic)) |
18 , fClip(clip) | 19 , fClip(clip) |
19 , fScale(scale) | 20 , fScale(scale) |
20 , fName(name) | 21 , fName(name) |
21 , fUseMultiPictureDraw(useMultiPictureDraw) { | 22 , fUseMultiPictureDraw(useMultiPictureDraw) { |
22 fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for
perf.skia.org traces. | 23 fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for
perf.skia.org traces. |
23 if (useMultiPictureDraw) { | 24 if (useMultiPictureDraw) { |
(...skipping 12 matching lines...) Expand all Loading... |
36 } | 37 } |
37 | 38 |
38 const char* SKPBench::onGetUniqueName() { | 39 const char* SKPBench::onGetUniqueName() { |
39 return fUniqueName.c_str(); | 40 return fUniqueName.c_str(); |
40 } | 41 } |
41 | 42 |
42 void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) { | 43 void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) { |
43 SkIRect bounds; | 44 SkIRect bounds; |
44 SkAssertResult(canvas->getClipDeviceBounds(&bounds)); | 45 SkAssertResult(canvas->getClipDeviceBounds(&bounds)); |
45 | 46 |
46 int xTiles = SkScalarCeilToInt(bounds.width() / SkIntToScalar(FLAGS_benchTi
le)); | 47 int tileW = SkTMin(FLAGS_benchTileW, bounds.width()); |
47 int yTiles = SkScalarCeilToInt(bounds.height() / SkIntToScalar(FLAGS_benchTi
le)); | 48 int tileH = SkTMin(FLAGS_benchTileH, bounds.height()); |
| 49 |
| 50 int xTiles = SkScalarCeilToInt(bounds.width() / SkIntToScalar(tileW)); |
| 51 int yTiles = SkScalarCeilToInt(bounds.height() / SkIntToScalar(tileH)); |
48 | 52 |
49 fSurfaces.setReserve(xTiles * yTiles); | 53 fSurfaces.setReserve(xTiles * yTiles); |
50 fTileRects.setReserve(xTiles * yTiles); | 54 fTileRects.setReserve(xTiles * yTiles); |
51 | 55 |
52 SkImageInfo ii = canvas->imageInfo().makeWH(FLAGS_benchTile, FLAGS_benchTile
); | 56 SkImageInfo ii = canvas->imageInfo().makeWH(tileW, tileH); |
53 | 57 |
54 for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) { | 58 for (int y = bounds.fTop; y < bounds.fBottom; y += tileH) { |
55 for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTile) { | 59 for (int x = bounds.fLeft; x < bounds.fRight; x += tileW) { |
56 const SkIRect tileRect = SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FL
AGS_benchTile); | 60 const SkIRect tileRect = SkIRect::MakeXYWH(x, y, tileW, tileH); |
57 *fTileRects.append() = tileRect; | 61 *fTileRects.append() = tileRect; |
58 *fSurfaces.push() = canvas->newSurface(ii); | 62 *fSurfaces.push() = canvas->newSurface(ii); |
59 | 63 |
60 // Never want the contents of a tile to include stuff the parent | 64 // Never want the contents of a tile to include stuff the parent |
61 // canvas clips out | 65 // canvas clips out |
62 SkRect clip = SkRect::Make(bounds); | 66 SkRect clip = SkRect::Make(bounds); |
63 clip.offset(-SkIntToScalar(tileRect.fLeft), -SkIntToScalar(tileRect.
fTop)); | 67 clip.offset(-SkIntToScalar(tileRect.fLeft), -SkIntToScalar(tileRect.
fTop)); |
64 fSurfaces.top()->getCanvas()->clipRect(clip); | 68 fSurfaces.top()->getCanvas()->clipRect(clip); |
65 | 69 |
66 fSurfaces.top()->getCanvas()->setMatrix(canvas->getTotalMatrix()); | 70 fSurfaces.top()->getCanvas()->setMatrix(canvas->getTotalMatrix()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 -fTileRects[j].fTop / fScale); | 121 -fTileRects[j].fTop / fScale); |
118 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, NULL); | 122 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, NULL); |
119 } | 123 } |
120 | 124 |
121 for (int j = 0; j < fTileRects.count(); ++j) { | 125 for (int j = 0; j < fTileRects.count(); ++j) { |
122 fSurfaces[j]->getCanvas()->flush(); | 126 fSurfaces[j]->getCanvas()->flush(); |
123 } | 127 } |
124 } | 128 } |
125 } | 129 } |
126 } | 130 } |
OLD | NEW |