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

Unified Diff: tools/VisualBench/VisualStreamTimingModule.cpp

Issue 1385073002: Create VisualStreamTimingModule (Closed) Base URL: https://skia.googlesource.com/skia.git@vb3a
Patch Set: feedback inc 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/VisualBench/VisualStreamTimingModule.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/VisualBench/VisualStreamTimingModule.cpp
diff --git a/tools/VisualBench/VisualStreamTimingModule.cpp b/tools/VisualBench/VisualStreamTimingModule.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..db75890d11ae499e1a74ff4c1084b716bf1b6575
--- /dev/null
+++ b/tools/VisualBench/VisualStreamTimingModule.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "VisualStreamTimingModule.h"
+
+#include "SkCanvas.h"
+
+VisualStreamTimingModule::VisualStreamTimingModule(VisualBench* owner, bool preWarmBeforeSample)
+ : fReinitializeBenchmark(false)
+ , fPreWarmBeforeSample(preWarmBeforeSample)
+ , fOwner(owner) {
+ 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 (!this->nextBenchmarkIfNecessary(canvas)) {
+ SkDebugf("Exiting VisualBench successfully\n");
+ fOwner->closeWindow();
+ return;
+ }
+
+ if (fReinitializeBenchmark) {
+ fReinitializeBenchmark = false;
+ fBenchmark->preTimingHooks(canvas);
+ }
+
+ this->renderFrame(canvas, fBenchmark, fTSM.loops());
+ fOwner->present();
+ TimingStateMachine::ParentEvents event = fTSM.nextFrame(fPreWarmBeforeSample);
+ switch (event) {
+ case TimingStateMachine::kReset_ParentEvents:
+ fBenchmark->postTimingHooks(canvas);
+ fOwner->reset();
+ fReinitializeBenchmark = true;
+ break;
+ case TimingStateMachine::kTiming_ParentEvents:
+ break;
+ case TimingStateMachine::kTimingFinished_ParentEvents:
+ fBenchmark->postTimingHooks(canvas);
+ fOwner->reset();
+ if (this->timingFinished(fBenchmark, fTSM.loops(), fTSM.lastMeasurement())) {
+ fTSM.nextBenchmark(canvas, fBenchmark);
+ fBenchmark.reset(nullptr);
+ } else {
+ fReinitializeBenchmark = true;
+ }
+ break;
+ }
+}
« no previous file with comments | « tools/VisualBench/VisualStreamTimingModule.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698