OLD | NEW |
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 "Timer.h" | 8 #include "Timer.h" |
9 #include "PictureBenchmark.h" | 9 #include "PictureBenchmark.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkPicture.h" | 11 #include "SkPicture.h" |
12 #include "SkString.h" | 12 #include "SkString.h" |
13 #include "picture_utils.h" | 13 #include "picture_utils.h" |
14 | 14 |
15 namespace sk_tools { | 15 namespace sk_tools { |
16 | 16 |
17 PictureBenchmark::PictureBenchmark() | 17 PictureBenchmark::PictureBenchmark() |
18 : fRepeats(1) | 18 : fRepeats(1) |
19 , fRenderer(NULL) | 19 , fRenderer(NULL) |
20 , fTimerResult(TimerData::kAvg_Result) | 20 , fTimerResult(TimerData::kAvg_Result) |
21 , fTimerTypes(0) | 21 , fTimerTypes(0) |
22 , fTimeIndividualTiles(false) | 22 , fTimeIndividualTiles(false) |
23 , fPurgeDecodedTex(false) | 23 , fPurgeDecodedTex(false) |
24 , fPreprocess(false) | 24 , fWriter(NULL) { |
25 , fWriter(NULL) | 25 } |
26 {} | |
27 | 26 |
28 PictureBenchmark::~PictureBenchmark() { | 27 PictureBenchmark::~PictureBenchmark() { |
29 SkSafeUnref(fRenderer); | 28 SkSafeUnref(fRenderer); |
30 } | 29 } |
31 | 30 |
32 void PictureBenchmark::setTimersToShow(bool wall, | 31 void PictureBenchmark::setTimersToShow(bool wall, |
33 bool truncatedWall, | 32 bool truncatedWall, |
34 bool cpu, | 33 bool cpu, |
35 bool truncatedCpu, | 34 bool truncatedCpu, |
36 bool gpu) { | 35 bool gpu) { |
(...skipping 12 matching lines...) Expand all Loading... |
49 } | 48 } |
50 #endif | 49 #endif |
51 return SkNEW_ARGS(Timer, (NULL)); | 50 return SkNEW_ARGS(Timer, (NULL)); |
52 } | 51 } |
53 | 52 |
54 PictureRenderer* PictureBenchmark::setRenderer(sk_tools::PictureRenderer* render
er) { | 53 PictureRenderer* PictureBenchmark::setRenderer(sk_tools::PictureRenderer* render
er) { |
55 SkRefCnt_SafeAssign(fRenderer, renderer); | 54 SkRefCnt_SafeAssign(fRenderer, renderer); |
56 return renderer; | 55 return renderer; |
57 } | 56 } |
58 | 57 |
59 void PictureBenchmark::run(SkPicture* pict) { | 58 void PictureBenchmark::run(SkPicture* pict, bool useMultiPictureDraw) { |
60 SkASSERT(pict); | 59 SkASSERT(pict); |
61 if (NULL == pict) { | 60 if (NULL == pict) { |
62 return; | 61 return; |
63 } | 62 } |
64 | 63 |
65 SkASSERT(fRenderer != NULL); | 64 SkASSERT(fRenderer != NULL); |
66 if (NULL == fRenderer) { | 65 if (NULL == fRenderer) { |
67 return; | 66 return; |
68 } | 67 } |
69 | 68 |
70 fRenderer->init(pict, NULL, NULL, NULL, false); | 69 fRenderer->init(pict, NULL, NULL, NULL, false, useMultiPictureDraw); |
71 | 70 |
72 // We throw this away to remove first time effects (such as paging in this p
rogram) | 71 // We throw this away to remove first time effects (such as paging in this p
rogram) |
73 fRenderer->setup(); | 72 fRenderer->setup(); |
74 | 73 |
75 if (fPreprocess) { | |
76 if (fRenderer->getCanvas()) { | |
77 fRenderer->getCanvas()->EXPERIMENTAL_optimize(fRenderer->getPicture(
)); | |
78 } | |
79 } | |
80 | |
81 fRenderer->render(NULL); | 74 fRenderer->render(NULL); |
82 fRenderer->resetState(true); // flush, swapBuffers and Finish | 75 fRenderer->resetState(true); // flush, swapBuffers and Finish |
83 | 76 |
84 if (fPurgeDecodedTex) { | 77 if (fPurgeDecodedTex) { |
85 fRenderer->purgeTextures(); | 78 fRenderer->purgeTextures(); |
86 } | 79 } |
87 | 80 |
88 bool usingGpu = false; | 81 bool usingGpu = false; |
89 #if SK_SUPPORT_GPU | 82 #if SK_SUPPORT_GPU |
90 usingGpu = fRenderer->isUsingGpuDevice(); | 83 usingGpu = fRenderer->isUsingGpuDevice(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 fTimerResult, | 237 fTimerResult, |
245 timerTypes, | 238 timerTypes, |
246 numInnerLoops); | 239 numInnerLoops); |
247 #endif | 240 #endif |
248 } | 241 } |
249 | 242 |
250 fRenderer->end(); | 243 fRenderer->end(); |
251 } | 244 } |
252 | 245 |
253 } | 246 } |
OLD | NEW |