| 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(benchTileW, 1600, "Tile width used for SKP playback."); | 13 // These CPU tile sizes are not good per se, but they are similar to what Chrome
uses. |
| 14 DEFINE_int32(benchTileH, 512, "Tile height used for SKP playback."); | 14 DEFINE_int32(CPUbenchTileW, 256, "Tile width used for CPU SKP playback."); |
| 15 DEFINE_int32(CPUbenchTileH, 256, "Tile height used for CPU SKP playback."); |
| 16 |
| 17 DEFINE_int32(GPUbenchTileW, 1600, "Tile width used for GPU SKP playback."); |
| 18 DEFINE_int32(GPUbenchTileH, 512, "Tile height used for GPU SKP playback."); |
| 15 | 19 |
| 16 SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
SkScalar scale, | 20 SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
SkScalar scale, |
| 17 bool useMultiPictureDraw) | 21 bool useMultiPictureDraw) |
| 18 : fPic(SkRef(pic)) | 22 : fPic(SkRef(pic)) |
| 19 , fClip(clip) | 23 , fClip(clip) |
| 20 , fScale(scale) | 24 , fScale(scale) |
| 21 , fName(name) | 25 , fName(name) |
| 22 , fUseMultiPictureDraw(useMultiPictureDraw) { | 26 , fUseMultiPictureDraw(useMultiPictureDraw) { |
| 23 fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for
perf.skia.org traces. | 27 fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for
perf.skia.org traces. |
| 24 if (useMultiPictureDraw) { | 28 if (useMultiPictureDraw) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 } | 41 } |
| 38 | 42 |
| 39 const char* SKPBench::onGetUniqueName() { | 43 const char* SKPBench::onGetUniqueName() { |
| 40 return fUniqueName.c_str(); | 44 return fUniqueName.c_str(); |
| 41 } | 45 } |
| 42 | 46 |
| 43 void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) { | 47 void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) { |
| 44 SkIRect bounds; | 48 SkIRect bounds; |
| 45 SkAssertResult(canvas->getClipDeviceBounds(&bounds)); | 49 SkAssertResult(canvas->getClipDeviceBounds(&bounds)); |
| 46 | 50 |
| 47 int tileW = SkTMin(FLAGS_benchTileW, bounds.width()); | 51 const bool gpu = canvas->getGrContext() != nullptr; |
| 48 int tileH = SkTMin(FLAGS_benchTileH, bounds.height()); | 52 int tileW = gpu ? FLAGS_GPUbenchTileW : FLAGS_CPUbenchTileW, |
| 53 tileH = gpu ? FLAGS_GPUbenchTileH : FLAGS_CPUbenchTileH; |
| 54 |
| 55 tileW = SkTMin(tileW, bounds.width()); |
| 56 tileH = SkTMin(tileH, bounds.height()); |
| 49 | 57 |
| 50 int xTiles = SkScalarCeilToInt(bounds.width() / SkIntToScalar(tileW)); | 58 int xTiles = SkScalarCeilToInt(bounds.width() / SkIntToScalar(tileW)); |
| 51 int yTiles = SkScalarCeilToInt(bounds.height() / SkIntToScalar(tileH)); | 59 int yTiles = SkScalarCeilToInt(bounds.height() / SkIntToScalar(tileH)); |
| 52 | 60 |
| 53 fSurfaces.setReserve(xTiles * yTiles); | 61 fSurfaces.setReserve(xTiles * yTiles); |
| 54 fTileRects.setReserve(xTiles * yTiles); | 62 fTileRects.setReserve(xTiles * yTiles); |
| 55 | 63 |
| 56 SkImageInfo ii = canvas->imageInfo().makeWH(tileW, tileH); | 64 SkImageInfo ii = canvas->imageInfo().makeWH(tileW, tileH); |
| 57 | 65 |
| 58 for (int y = bounds.fTop; y < bounds.fBottom; y += tileH) { | 66 for (int y = bounds.fTop; y < bounds.fBottom; y += tileH) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 for (int j = 0; j < fTileRects.count(); ++j) { | 136 for (int j = 0; j < fTileRects.count(); ++j) { |
| 129 const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale
, | 137 const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale
, |
| 130 -fTileRects[j].fTop / fScale)
; | 138 -fTileRects[j].fTop / fScale)
; |
| 131 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, NULL); | 139 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, NULL); |
| 132 } | 140 } |
| 133 | 141 |
| 134 for (int j = 0; j < fTileRects.count(); ++j) { | 142 for (int j = 0; j < fTileRects.count(); ++j) { |
| 135 fSurfaces[j]->getCanvas()->flush(); | 143 fSurfaces[j]->getCanvas()->flush(); |
| 136 } | 144 } |
| 137 } | 145 } |
| OLD | NEW |