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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « tools/VisualBench/VisualStreamTimingModule.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "VisualStreamTimingModule.h"
9
10 #include "SkCanvas.h"
11
12 VisualStreamTimingModule::VisualStreamTimingModule(VisualBench* owner, bool preW armBeforeSample)
13 : fReinitializeBenchmark(false)
14 , fPreWarmBeforeSample(preWarmBeforeSample)
15 , fOwner(owner) {
16 fBenchmarkStream.reset(new VisualBenchmarkStream);
17 }
18
19 bool VisualStreamTimingModule::nextBenchmarkIfNecessary(SkCanvas* canvas) {
20 if (fBenchmark) {
21 return true;
22 }
23
24 fBenchmark.reset(fBenchmarkStream->next());
25 if (!fBenchmark) {
26 return false;
27 }
28
29 fOwner->clear(canvas, SK_ColorWHITE, 2);
30
31 fBenchmark->delayedSetup();
32 fBenchmark->preTimingHooks(canvas);
33 return true;
34 }
35
36 void VisualStreamTimingModule::draw(SkCanvas* canvas) {
37 if (!this->nextBenchmarkIfNecessary(canvas)) {
38 SkDebugf("Exiting VisualBench successfully\n");
39 fOwner->closeWindow();
40 return;
41 }
42
43 if (fReinitializeBenchmark) {
44 fReinitializeBenchmark = false;
45 fBenchmark->preTimingHooks(canvas);
46 }
47
48 this->renderFrame(canvas, fBenchmark, fTSM.loops());
49 fOwner->present();
50 TimingStateMachine::ParentEvents event = fTSM.nextFrame(fPreWarmBeforeSample );
51 switch (event) {
52 case TimingStateMachine::kReset_ParentEvents:
53 fBenchmark->postTimingHooks(canvas);
54 fOwner->reset();
55 fReinitializeBenchmark = true;
56 break;
57 case TimingStateMachine::kTiming_ParentEvents:
58 break;
59 case TimingStateMachine::kTimingFinished_ParentEvents:
60 fBenchmark->postTimingHooks(canvas);
61 fOwner->reset();
62 if (this->timingFinished(fBenchmark, fTSM.loops(), fTSM.lastMeasurem ent())) {
63 fTSM.nextBenchmark(canvas, fBenchmark);
64 fBenchmark.reset(nullptr);
65 } else {
66 fReinitializeBenchmark = true;
67 }
68 break;
69 }
70 }
OLDNEW
« 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