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

Side by Side Diff: tools/VisualBench/VisualInteractiveModule.cpp

Issue 1379853003: Fix for nexus 5 crashing in GL benches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 2 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
« no previous file with comments | « bench/nanobench.cpp ('k') | tools/VisualBench/VisualLightweightBenchModule.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 8
9 #include "VisualInteractiveModule.h" 9 #include "VisualInteractiveModule.h"
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 fBenchmark.reset(fBenchmarkStream->next()); 93 fBenchmark.reset(fBenchmarkStream->next());
94 if (!fBenchmark) { 94 if (!fBenchmark) {
95 return false; 95 return false;
96 } 96 }
97 97
98 // clear both buffers 98 // clear both buffers
99 fOwner->clear(canvas, SK_ColorWHITE, 2); 99 fOwner->clear(canvas, SK_ColorWHITE, 2);
100 100
101 fBenchmark->preDraw(); 101 fBenchmark->delayedSetup();
102 102
103 return true; 103 return true;
104 } 104 }
105 105
106 void VisualInteractiveModule::draw(SkCanvas* canvas) { 106 void VisualInteractiveModule::draw(SkCanvas* canvas) {
107 if (!this->advanceRecordIfNecessary(canvas)) { 107 if (!this->advanceRecordIfNecessary(canvas)) {
108 SkDebugf("Exiting VisualBench successfully\n"); 108 SkDebugf("Exiting VisualBench successfully\n");
109 fOwner->closeWindow(); 109 fOwner->closeWindow();
110 return; 110 return;
111 } 111 }
112 this->renderFrame(canvas); 112 this->renderFrame(canvas);
113 switch (fState) { 113 switch (fState) {
114 case kPreWarmLoopsPerCanvasPreDraw_State: { 114 case kPreWarmLoopsPerCanvasPreDraw_State: {
115 this->perCanvasPreDraw(canvas, kPreWarmLoops_State); 115 this->perCanvasPreDraw(canvas, kPreWarmLoops_State);
116 break; 116 break;
117 } 117 }
118 case kPreWarmLoops_State: { 118 case kPreWarmLoops_State: {
119 this->preWarm(kTuneLoops_State); 119 this->preWarm(kTuneLoops_State);
120 break; 120 break;
121 } 121 }
122 case kTuneLoops_State: { 122 case kTuneLoops_State: {
123 this->tuneLoops(canvas); 123 this->tuneLoops(canvas);
124 break; 124 break;
125 } 125 }
126 case kPreTiming_State: { 126 case kPreTiming_State: {
127 fBenchmark->perCanvasPreDraw(canvas); 127 fBenchmark->perCanvasPreDraw(canvas);
128 fBenchmark->preDraw(canvas);
128 fCurrentFrame = 0; 129 fCurrentFrame = 0;
129 fTimer.start(); 130 fTimer.start();
130 fState = kTiming_State; 131 fState = kTiming_State;
131 // fall to next state 132 // fall to next state
132 } 133 }
133 case kTiming_State: { 134 case kTiming_State: {
134 this->timing(canvas); 135 this->timing(canvas);
135 break; 136 break;
136 } 137 }
137 case kAdvance_State: { 138 case kAdvance_State: {
138 this->postDraw(canvas); 139 this->postDraw(canvas);
139 this->nextState(kPreWarmLoopsPerCanvasPreDraw_State); 140 this->nextState(kPreWarmLoopsPerCanvasPreDraw_State);
140 break; 141 break;
141 } 142 }
142 } 143 }
143 } 144 }
144 145
145 inline void VisualInteractiveModule::nextState(State nextState) { 146 inline void VisualInteractiveModule::nextState(State nextState) {
146 fState = nextState; 147 fState = nextState;
147 } 148 }
148 149
149 void VisualInteractiveModule::perCanvasPreDraw(SkCanvas* canvas, State nextState ) { 150 void VisualInteractiveModule::perCanvasPreDraw(SkCanvas* canvas, State nextState ) {
150 fBenchmark->perCanvasPreDraw(canvas); 151 fBenchmark->perCanvasPreDraw(canvas);
152 fBenchmark->preDraw(canvas);
151 fCurrentFrame = 0; 153 fCurrentFrame = 0;
152 this->nextState(nextState); 154 this->nextState(nextState);
153 } 155 }
154 156
155 void VisualInteractiveModule::preWarm(State nextState) { 157 void VisualInteractiveModule::preWarm(State nextState) {
156 if (fCurrentFrame >= kGpuFrameLag) { 158 if (fCurrentFrame >= kGpuFrameLag) {
157 // we currently time across all frames to make sure we capture all GPU w ork 159 // we currently time across all frames to make sure we capture all GPU w ork
158 this->nextState(nextState); 160 this->nextState(nextState);
159 fCurrentFrame = 0; 161 fCurrentFrame = 0;
160 fTimer.start(); 162 fTimer.start();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 201 }
200 202
201 void VisualInteractiveModule::recordMeasurement() { 203 void VisualInteractiveModule::recordMeasurement() {
202 double measurement = this->elapsed() / (kFrames * fLoops); 204 double measurement = this->elapsed() / (kFrames * fLoops);
203 fMeasurements[fCurrentMeasurement++] = measurement; 205 fMeasurements[fCurrentMeasurement++] = measurement;
204 fCurrentMeasurement &= (kMeasurementCount-1); // fast mod 206 fCurrentMeasurement &= (kMeasurementCount-1); // fast mod
205 SkASSERT(fCurrentMeasurement < kMeasurementCount); 207 SkASSERT(fCurrentMeasurement < kMeasurementCount);
206 } 208 }
207 209
208 void VisualInteractiveModule::postDraw(SkCanvas* canvas) { 210 void VisualInteractiveModule::postDraw(SkCanvas* canvas) {
211 fBenchmark->postDraw(canvas);
209 fBenchmark->perCanvasPostDraw(canvas); 212 fBenchmark->perCanvasPostDraw(canvas);
210 fBenchmark.reset(nullptr); 213 fBenchmark.reset(nullptr);
211 fLoops = 1; 214 fLoops = 1;
212 } 215 }
213 216
214 inline void VisualInteractiveModule::timing(SkCanvas* canvas) { 217 inline void VisualInteractiveModule::timing(SkCanvas* canvas) {
215 if (fCurrentFrame >= kFrames) { 218 if (fCurrentFrame >= kFrames) {
216 this->recordMeasurement(); 219 this->recordMeasurement();
217 fTimer.start(); 220 fTimer.start();
218 fCurrentFrame = 0; 221 fCurrentFrame = 0;
219 } else { 222 } else {
220 fCurrentFrame++; 223 fCurrentFrame++;
221 } 224 }
222 } 225 }
223 226
224 bool VisualInteractiveModule::onHandleChar(SkUnichar c) { 227 bool VisualInteractiveModule::onHandleChar(SkUnichar c) {
225 if (' ' == c) { 228 if (' ' == c) {
226 this->nextState(kAdvance_State); 229 this->nextState(kAdvance_State);
227 } 230 }
228 231
229 return true; 232 return true;
230 } 233 }
OLDNEW
« no previous file with comments | « bench/nanobench.cpp ('k') | tools/VisualBench/VisualLightweightBenchModule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698