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

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

Issue 1413713006: Wire up configurations properly in VisualBench (Closed) Base URL: https://skia.googlesource.com/skia.git@detachattach
Patch Set: Created 5 years, 1 month 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
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 #include "VisualStreamTimingModule.h" 8 #include "VisualStreamTimingModule.h"
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 11
12 VisualStreamTimingModule::VisualStreamTimingModule(VisualBench* owner, bool preW armBeforeSample) 12 VisualStreamTimingModule::VisualStreamTimingModule(VisualBench* owner, bool preW armBeforeSample)
13 : fInitState(kReset_InitState) 13 : fInitState(kInitial_InitState)
14 , fPreWarmBeforeSample(preWarmBeforeSample) 14 , fPreWarmBeforeSample(preWarmBeforeSample)
15 , fOwner(owner) { 15 , fOwner(owner) {
16 fBenchmarkStream.reset(new VisualBenchmarkStream); 16 fBenchmarkStream.reset(new VisualBenchmarkStream);
17 } 17 }
18 18
19 inline void VisualStreamTimingModule::handleInitState(SkCanvas* canvas) { 19 inline void VisualStreamTimingModule::handleInitState(SkCanvas* canvas) {
20 switch (fInitState) { 20 switch (fInitState) {
21 case kInitial_InitState:
22 SkDebugf("1\n");
23 fBenchmarkStream->next(fOwner->currentConfig());
24 // fall through
21 case kNewBenchmark_InitState: 25 case kNewBenchmark_InitState:
26 SkDebugf("2\n");
22 fBenchmarkStream->current()->delayedSetup(); 27 fBenchmarkStream->current()->delayedSetup();
23 // fallthrough 28 // fallthrough
24 case kReset_InitState: 29 case kReset_InitState:
30 SkDebugf("3\n");
25 // This will flicker unfortunately, but as we are reseting the GLCon text each bench, 31 // This will flicker unfortunately, but as we are reseting the GLCon text each bench,
26 // we unfortunately don't have a choice 32 // we unfortunately don't have a choice
27 fOwner->clear(canvas, SK_ColorWHITE, 2); 33 fOwner->clear(canvas, SK_ColorWHITE, 2);
28 fBenchmarkStream->current()->preTimingHooks(canvas); 34 fBenchmarkStream->current()->preTimingHooks(canvas);
29 break; 35 break;
30 case kNone_InitState: 36 case kNone_InitState:
31 break; 37 break;
32 } 38 }
33 fInitState = kNone_InitState; 39 fInitState = kNone_InitState;
34 } 40 }
35 41
36 inline void VisualStreamTimingModule::handleTimingEvent(SkCanvas* canvas, 42 inline void VisualStreamTimingModule::handleTimingEvent(SkCanvas* canvas,
37 TimingStateMachine::Pare ntEvents event) { 43 TimingStateMachine::Pare ntEvents event) {
38 switch (event) { 44 switch (event) {
39 case TimingStateMachine::kReset_ParentEvents: 45 case TimingStateMachine::kReset_ParentEvents:
40 fBenchmarkStream->current()->postTimingHooks(canvas); 46 fBenchmarkStream->current()->postTimingHooks(canvas);
41 fOwner->reset(); 47 fOwner->reset();
42 fInitState = kReset_InitState; 48 fInitState = kReset_InitState;
43 break; 49 break;
44 case TimingStateMachine::kTiming_ParentEvents: 50 case TimingStateMachine::kTiming_ParentEvents:
45 break; 51 break;
46 case TimingStateMachine::kTimingFinished_ParentEvents: 52 case TimingStateMachine::kTimingFinished_ParentEvents:
47 fBenchmarkStream->current()->postTimingHooks(canvas); 53 fBenchmarkStream->current()->postTimingHooks(canvas);
48 fOwner->reset(); 54 fOwner->reset();
49 if (this->timingFinished(fBenchmarkStream->current(), fTSM.loops(), 55 if (this->timingFinished(fBenchmarkStream->current(), fTSM.loops(),
50 fTSM.lastMeasurement())) { 56 fTSM.lastMeasurement())) {
51 fTSM.nextBenchmark(); 57 fTSM.nextBenchmark();
52 if (!fBenchmarkStream->next()) { 58 if (!fBenchmarkStream->next(fOwner->currentConfig())) {
53 SkDebugf("Exiting VisualBench successfully\n"); 59 if (!fOwner->nextConfig()) {
54 fOwner->closeWindow(); 60 SkDebugf("Exiting VisualBench successfully\n");
61 fOwner->closeWindow();
62 } else {
63 fBenchmarkStream.reset(new VisualBenchmarkStream);
64 }
55 } else { 65 } else {
56 fInitState = kNewBenchmark_InitState; 66 fInitState = kNewBenchmark_InitState;
57 } 67 }
58 } else { 68 } else {
59 fInitState = kReset_InitState; 69 fInitState = kReset_InitState;
60 } 70 }
61 break; 71 break;
62 } 72 }
63 } 73 }
64 74
65 void VisualStreamTimingModule::draw(SkCanvas* canvas) { 75 void VisualStreamTimingModule::draw(SkCanvas* canvas) {
66 if (!fBenchmarkStream->current()) { 76 if (!fBenchmarkStream->current()) {
67 // this should never happen but just to be safe 77 // this should never happen but just to be safe
68 // TODO research why this does happen on mac 78 // TODO research why this does happen on mac
69 return; 79 return;
70 } 80 }
71 81
72 this->handleInitState(canvas); 82 this->handleInitState(canvas);
73 this->renderFrame(canvas, fBenchmarkStream->current(), fTSM.loops()); 83 this->renderFrame(canvas, fBenchmarkStream->current(), fTSM.loops());
74 fOwner->present(); 84 fOwner->present();
75 TimingStateMachine::ParentEvents event = fTSM.nextFrame(fPreWarmBeforeSample ); 85 TimingStateMachine::ParentEvents event = fTSM.nextFrame(fPreWarmBeforeSample );
76 this->handleTimingEvent(canvas, event); 86 this->handleTimingEvent(canvas, event);
77 } 87 }
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