| 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 #if SK_SUPPORT_GPU |
| 14 #include "GrContext.h" |
| 15 #endif |
| 16 |
| 13 // These CPU tile sizes are not good per se, but they are similar to what Chrome
uses. | 17 // These CPU tile sizes are not good per se, but they are similar to what Chrome
uses. |
| 14 DEFINE_int32(CPUbenchTileW, 256, "Tile width used for CPU SKP playback."); | 18 DEFINE_int32(CPUbenchTileW, 256, "Tile width used for CPU SKP playback."); |
| 15 DEFINE_int32(CPUbenchTileH, 256, "Tile height used for CPU SKP playback."); | 19 DEFINE_int32(CPUbenchTileH, 256, "Tile height used for CPU SKP playback."); |
| 16 | 20 |
| 17 DEFINE_int32(GPUbenchTileW, 1600, "Tile width used for GPU SKP playback."); | 21 DEFINE_int32(GPUbenchTileW, 1600, "Tile width used for GPU SKP playback."); |
| 18 DEFINE_int32(GPUbenchTileH, 512, "Tile height used for GPU SKP playback."); | 22 DEFINE_int32(GPUbenchTileH, 512, "Tile height used for GPU SKP playback."); |
| 19 | 23 |
| 20 SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
SkScalar scale, | 24 SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
SkScalar scale, |
| 21 bool useMultiPictureDraw, bool doLooping) | 25 bool useMultiPictureDraw, bool doLooping) |
| 22 : fPic(SkRef(pic)) | 26 : fPic(SkRef(pic)) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 SkASSERT(fDoLooping || 1 == loops); | 112 SkASSERT(fDoLooping || 1 == loops); |
| 109 if (fUseMultiPictureDraw) { | 113 if (fUseMultiPictureDraw) { |
| 110 for (int i = 0; i < loops; i++) { | 114 for (int i = 0; i < loops; i++) { |
| 111 this->drawMPDPicture(); | 115 this->drawMPDPicture(); |
| 112 } | 116 } |
| 113 } else { | 117 } else { |
| 114 for (int i = 0; i < loops; i++) { | 118 for (int i = 0; i < loops; i++) { |
| 115 this->drawPicture(); | 119 this->drawPicture(); |
| 116 } | 120 } |
| 117 } | 121 } |
| 122 #if SK_SUPPORT_GPU |
| 123 // Ensure the GrContext doesn't batch across draw loops. |
| 124 if (GrContext* context = canvas->getGrContext()) { |
| 125 context->flush(); |
| 126 } |
| 127 #endif |
| 118 } | 128 } |
| 119 | 129 |
| 120 void SKPBench::drawMPDPicture() { | 130 void SKPBench::drawMPDPicture() { |
| 121 SkMultiPictureDraw mpd; | 131 SkMultiPictureDraw mpd; |
| 122 | 132 |
| 123 for (int j = 0; j < fTileRects.count(); ++j) { | 133 for (int j = 0; j < fTileRects.count(); ++j) { |
| 124 SkMatrix trans; | 134 SkMatrix trans; |
| 125 trans.setTranslate(-fTileRects[j].fLeft/fScale, | 135 trans.setTranslate(-fTileRects[j].fLeft/fScale, |
| 126 -fTileRects[j].fTop/fScale); | 136 -fTileRects[j].fTop/fScale); |
| 127 mpd.add(fSurfaces[j]->getCanvas(), fPic, &trans); | 137 mpd.add(fSurfaces[j]->getCanvas(), fPic, &trans); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 138 for (int j = 0; j < fTileRects.count(); ++j) { | 148 for (int j = 0; j < fTileRects.count(); ++j) { |
| 139 const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale
, | 149 const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale
, |
| 140 -fTileRects[j].fTop / fScale)
; | 150 -fTileRects[j].fTop / fScale)
; |
| 141 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, nullptr); | 151 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, nullptr); |
| 142 } | 152 } |
| 143 | 153 |
| 144 for (int j = 0; j < fTileRects.count(); ++j) { | 154 for (int j = 0; j < fTileRects.count(); ++j) { |
| 145 fSurfaces[j]->getCanvas()->flush(); | 155 fSurfaces[j]->getCanvas()->flush(); |
| 146 } | 156 } |
| 147 } | 157 } |
| OLD | NEW |