Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tools/PictureBenchmark.cpp

Issue 233663002: Update bench to be able to preprocess skps (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add missing file Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "SkBenchLogger.h" 8 #include "SkBenchLogger.h"
9 #include "BenchTimer.h" 9 #include "BenchTimer.h"
10 #include "PictureBenchmark.h" 10 #include "PictureBenchmark.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkString.h" 13 #include "SkString.h"
14 #include "picture_utils.h" 14 #include "picture_utils.h"
15 15
16 namespace sk_tools { 16 namespace sk_tools {
17 17
18 PictureBenchmark::PictureBenchmark() 18 PictureBenchmark::PictureBenchmark()
19 : fRepeats(1) 19 : fRepeats(1)
20 , fLogger(NULL) 20 , fLogger(NULL)
21 , fRenderer(NULL) 21 , fRenderer(NULL)
22 , fTimerResult(TimerData::kAvg_Result) 22 , fTimerResult(TimerData::kAvg_Result)
23 , fTimerTypes(0) 23 , fTimerTypes(0)
24 , fTimeIndividualTiles(false) 24 , fTimeIndividualTiles(false)
25 , fPurgeDecodedTex(false) 25 , fPurgeDecodedTex(false)
26 , fPreprocess(false)
26 {} 27 {}
27 28
28 PictureBenchmark::~PictureBenchmark() { 29 PictureBenchmark::~PictureBenchmark() {
29 SkSafeUnref(fRenderer); 30 SkSafeUnref(fRenderer);
30 } 31 }
31 32
32 void PictureBenchmark::setTimersToShow(bool wall, 33 void PictureBenchmark::setTimersToShow(bool wall,
33 bool truncatedWall, 34 bool truncatedWall,
34 bool cpu, 35 bool cpu,
35 bool truncatedCpu, 36 bool truncatedCpu,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 71
71 SkASSERT(fRenderer != NULL); 72 SkASSERT(fRenderer != NULL);
72 if (NULL == fRenderer) { 73 if (NULL == fRenderer) {
73 return; 74 return;
74 } 75 }
75 76
76 fRenderer->init(pict, NULL, NULL, false); 77 fRenderer->init(pict, NULL, NULL, false);
77 78
78 // We throw this away to remove first time effects (such as paging in this p rogram) 79 // We throw this away to remove first time effects (such as paging in this p rogram)
79 fRenderer->setup(); 80 fRenderer->setup();
81
82 if (fPreprocess) {
83 if (NULL != fRenderer->getCanvas()) {
84 fRenderer->getCanvas()->EXPERIMENTAL_optimize(pict);
85 }
86 }
87
80 fRenderer->render(NULL); 88 fRenderer->render(NULL);
81 fRenderer->resetState(true); // flush, swapBuffers and Finish 89 fRenderer->resetState(true); // flush, swapBuffers and Finish
82 90
91 if (fPreprocess) {
92 if (NULL != fRenderer->getCanvas()) {
93 fRenderer->getCanvas()->EXPERIMENTAL_purge(pict);
94 }
95 }
96
83 if (fPurgeDecodedTex) { 97 if (fPurgeDecodedTex) {
84 fRenderer->purgeTextures(); 98 fRenderer->purgeTextures();
85 } 99 }
86 100
87 bool usingGpu = false; 101 bool usingGpu = false;
88 #if SK_SUPPORT_GPU 102 #if SK_SUPPORT_GPU
89 usingGpu = fRenderer->isUsingGpuDevice(); 103 usingGpu = fRenderer->isUsingGpuDevice();
90 #endif 104 #endif
91 105
92 uint32_t timerTypes = fTimerTypes; 106 uint32_t timerTypes = fTimerTypes;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 fRenderer->setup(); 223 fRenderer->setup();
210 224
211 perRunTimer->start(); 225 perRunTimer->start();
212 fRenderer->render(NULL); 226 fRenderer->render(NULL);
213 perRunTimer->truncatedEnd(); 227 perRunTimer->truncatedEnd();
214 fRenderer->resetState(false); // flush & swapBuffers, but don' t Finish 228 fRenderer->resetState(false); // flush & swapBuffers, but don' t Finish
215 perRunTimer->end(); 229 perRunTimer->end();
216 230
217 SkAssertResult(perRunTimerData.appendTimes(perRunTimer.get())); 231 SkAssertResult(perRunTimerData.appendTimes(perRunTimer.get()));
218 232
233 if (fPreprocess) {
234 if (NULL != fRenderer->getCanvas()) {
235 fRenderer->getCanvas()->EXPERIMENTAL_purge(pict);
236 }
237 }
238
219 if (fPurgeDecodedTex) { 239 if (fPurgeDecodedTex) {
220 fRenderer->purgeTextures(); 240 fRenderer->purgeTextures();
221 } 241 }
222 } 242 }
223 longRunningTimer->truncatedEnd(); 243 longRunningTimer->truncatedEnd();
224 fRenderer->resetState(true); // flush, swapBuffers and Finish 244 fRenderer->resetState(true); // flush, swapBuffers and Finish
225 longRunningTimer->end(); 245 longRunningTimer->end();
226 SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get ())); 246 SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get ()));
227 } 247 }
228 248
(...skipping 20 matching lines...) Expand all
249 numInnerLoops); 269 numInnerLoops);
250 result.append("\n"); 270 result.append("\n");
251 this->logProgress(result.c_str()); 271 this->logProgress(result.c_str());
252 #endif 272 #endif
253 } 273 }
254 274
255 fRenderer->end(); 275 fRenderer->end();
256 } 276 }
257 277
258 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698