Index: tools/VisualBench/VisualStreamTimingModule.cpp |
diff --git a/tools/VisualBench/VisualStreamTimingModule.cpp b/tools/VisualBench/VisualStreamTimingModule.cpp |
index 4148282ce672d6c2ae8d8428b9b882f00d053561..db75890d11ae499e1a74ff4c1084b716bf1b6575 100644 |
--- a/tools/VisualBench/VisualStreamTimingModule.cpp |
+++ b/tools/VisualBench/VisualStreamTimingModule.cpp |
@@ -16,43 +16,52 @@ |
fBenchmarkStream.reset(new VisualBenchmarkStream); |
} |
+bool VisualStreamTimingModule::nextBenchmarkIfNecessary(SkCanvas* canvas) { |
+ if (fBenchmark) { |
+ return true; |
+ } |
+ |
+ fBenchmark.reset(fBenchmarkStream->next()); |
+ if (!fBenchmark) { |
+ return false; |
+ } |
+ |
+ fOwner->clear(canvas, SK_ColorWHITE, 2); |
+ |
+ fBenchmark->delayedSetup(); |
+ fBenchmark->preTimingHooks(canvas); |
+ return true; |
+} |
+ |
void VisualStreamTimingModule::draw(SkCanvas* canvas) { |
- if (!fBenchmarkStream->current()) { |
- // this should never happen but just to be safe |
+ if (!this->nextBenchmarkIfNecessary(canvas)) { |
+ SkDebugf("Exiting VisualBench successfully\n"); |
+ fOwner->closeWindow(); |
return; |
} |
if (fReinitializeBenchmark) { |
fReinitializeBenchmark = false; |
- fBenchmarkStream->current()->preTimingHooks(canvas); |
+ fBenchmark->preTimingHooks(canvas); |
} |
- this->renderFrame(canvas, fBenchmarkStream->current(), fTSM.loops()); |
+ this->renderFrame(canvas, fBenchmark, fTSM.loops()); |
fOwner->present(); |
TimingStateMachine::ParentEvents event = fTSM.nextFrame(fPreWarmBeforeSample); |
switch (event) { |
case TimingStateMachine::kReset_ParentEvents: |
- fBenchmarkStream->current()->postTimingHooks(canvas); |
+ fBenchmark->postTimingHooks(canvas); |
fOwner->reset(); |
fReinitializeBenchmark = true; |
break; |
case TimingStateMachine::kTiming_ParentEvents: |
break; |
case TimingStateMachine::kTimingFinished_ParentEvents: |
- fBenchmarkStream->current()->postTimingHooks(canvas); |
+ fBenchmark->postTimingHooks(canvas); |
fOwner->reset(); |
- if (this->timingFinished(fBenchmarkStream->current(), fTSM.loops(), |
- fTSM.lastMeasurement())) { |
- fTSM.nextBenchmark(); |
- if (!fBenchmarkStream->next()) { |
- SkDebugf("Exiting VisualBench successfully\n"); |
- fOwner->closeWindow(); |
- } else { |
- fOwner->clear(canvas, SK_ColorWHITE, 2); |
- |
- fBenchmarkStream->current()->delayedSetup(); |
- fBenchmarkStream->current()->preTimingHooks(canvas); |
- } |
+ if (this->timingFinished(fBenchmark, fTSM.loops(), fTSM.lastMeasurement())) { |
+ fTSM.nextBenchmark(canvas, fBenchmark); |
+ fBenchmark.reset(nullptr); |
} else { |
fReinitializeBenchmark = true; |
} |