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 // These CPU tile sizes are not good per se, but they are similar to what Chrome
uses. | 13 // 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."); | 14 DEFINE_int32(CPUbenchTileW, 256, "Tile width used for CPU SKP playback."); |
15 DEFINE_int32(CPUbenchTileH, 256, "Tile height used for CPU SKP playback."); | 15 DEFINE_int32(CPUbenchTileH, 256, "Tile height used for CPU SKP playback."); |
16 | 16 |
17 DEFINE_int32(GPUbenchTileW, 1600, "Tile width used for GPU SKP playback."); | 17 DEFINE_int32(GPUbenchTileW, 1600, "Tile width used for GPU SKP playback."); |
18 DEFINE_int32(GPUbenchTileH, 512, "Tile height used for GPU SKP playback."); | 18 DEFINE_int32(GPUbenchTileH, 512, "Tile height used for GPU SKP playback."); |
19 | 19 |
20 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, |
21 bool useMultiPictureDraw) | 21 bool useMultiPictureDraw, bool doLooping) |
22 : fPic(SkRef(pic)) | 22 : fPic(SkRef(pic)) |
23 , fClip(clip) | 23 , fClip(clip) |
24 , fScale(scale) | 24 , fScale(scale) |
25 , fName(name) | 25 , fName(name) |
26 , fUseMultiPictureDraw(useMultiPictureDraw) { | 26 , fUseMultiPictureDraw(useMultiPictureDraw) |
| 27 , fDoLooping(doLooping) { |
27 fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for
perf.skia.org traces. | 28 fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for
perf.skia.org traces. |
28 if (useMultiPictureDraw) { | 29 if (useMultiPictureDraw) { |
29 fUniqueName.append("_mpd"); | 30 fUniqueName.append("_mpd"); |
30 } | 31 } |
31 } | 32 } |
32 | 33 |
33 SKPBench::~SKPBench() { | 34 SKPBench::~SKPBench() { |
34 for (int i = 0; i < fSurfaces.count(); ++i) { | 35 for (int i = 0; i < fSurfaces.count(); ++i) { |
35 fSurfaces[i]->unref(); | 36 fSurfaces[i]->unref(); |
36 } | 37 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 98 |
98 bool SKPBench::isSuitableFor(Backend backend) { | 99 bool SKPBench::isSuitableFor(Backend backend) { |
99 return backend != kNonRendering_Backend; | 100 return backend != kNonRendering_Backend; |
100 } | 101 } |
101 | 102 |
102 SkIPoint SKPBench::onGetSize() { | 103 SkIPoint SKPBench::onGetSize() { |
103 return SkIPoint::Make(fClip.width(), fClip.height()); | 104 return SkIPoint::Make(fClip.width(), fClip.height()); |
104 } | 105 } |
105 | 106 |
106 void SKPBench::onDraw(const int loops, SkCanvas* canvas) { | 107 void SKPBench::onDraw(const int loops, SkCanvas* canvas) { |
| 108 SkASSERT(fDoLooping || 1 == loops); |
107 if (fUseMultiPictureDraw) { | 109 if (fUseMultiPictureDraw) { |
108 for (int i = 0; i < loops; i++) { | 110 for (int i = 0; i < loops; i++) { |
109 this->drawMPDPicture(); | 111 this->drawMPDPicture(); |
110 } | 112 } |
111 } else { | 113 } else { |
112 for (int i = 0; i < loops; i++) { | 114 for (int i = 0; i < loops; i++) { |
113 this->drawPicture(); | 115 this->drawPicture(); |
114 } | 116 } |
115 } | 117 } |
116 } | 118 } |
(...skipping 19 matching lines...) Expand all Loading... |
136 for (int j = 0; j < fTileRects.count(); ++j) { | 138 for (int j = 0; j < fTileRects.count(); ++j) { |
137 const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale
, | 139 const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale
, |
138 -fTileRects[j].fTop / fScale)
; | 140 -fTileRects[j].fTop / fScale)
; |
139 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, NULL); | 141 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, NULL); |
140 } | 142 } |
141 | 143 |
142 for (int j = 0; j < fTileRects.count(); ++j) { | 144 for (int j = 0; j < fTileRects.count(); ++j) { |
143 fSurfaces[j]->getCanvas()->flush(); | 145 fSurfaces[j]->getCanvas()->flush(); |
144 } | 146 } |
145 } | 147 } |
OLD | NEW |