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

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

Issue 1442643007: Add visualbench option to not reset between samples (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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
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 DEFINE_bool(reset, true, "Reset the GL context between samples.");
13
14 VisualStreamTimingModule::VisualStreamTimingModule(VisualBench* owner)
13 : fInitState(kReset_InitState) 15 : fInitState(kReset_InitState)
14 , fPreWarmBeforeSample(preWarmBeforeSample)
15 , fOwner(owner) { 16 , fOwner(owner) {
16 fBenchmarkStream.reset(new VisualBenchmarkStream(owner->getSurfaceProps())); 17 fBenchmarkStream.reset(new VisualBenchmarkStream(owner->getSurfaceProps()));
17 } 18 }
18 19
19 inline void VisualStreamTimingModule::handleInitState(SkCanvas* canvas) { 20 inline void VisualStreamTimingModule::handleInitState(SkCanvas* canvas) {
20 switch (fInitState) { 21 switch (fInitState) {
21 case kNewBenchmark_InitState: 22 case kNewBenchmark_InitState:
22 fBenchmarkStream->current()->delayedSetup(); 23 fBenchmarkStream->current()->delayedSetup();
23 // fallthrough 24 // fallthrough
24 case kReset_InitState: 25 case kReset_InitState:
25 // This will flicker unfortunately, but as we are reseting the GLCon text each bench, 26 // This will flicker unfortunately, but as we are reseting the GLCon text each bench,
26 // we unfortunately don't have a choice 27 // we unfortunately don't have a choice
27 fOwner->clear(canvas, SK_ColorWHITE, 2); 28 fOwner->clear(canvas, SK_ColorWHITE, 2);
28 fBenchmarkStream->current()->preTimingHooks(canvas); 29 fBenchmarkStream->current()->preTimingHooks(canvas);
29 break; 30 break;
30 case kNone_InitState: 31 case kNone_InitState:
31 break; 32 break;
32 } 33 }
33 fInitState = kNone_InitState; 34 fInitState = kNone_InitState;
34 } 35 }
35 36
36 inline void VisualStreamTimingModule::handleTimingEvent(SkCanvas* canvas, 37 inline void VisualStreamTimingModule::handleTimingEvent(SkCanvas* canvas,
37 TimingStateMachine::Pare ntEvents event) { 38 TimingStateMachine::Pare ntEvents event) {
38 switch (event) { 39 switch (event) {
39 case TimingStateMachine::kReset_ParentEvents:
40 fBenchmarkStream->current()->postTimingHooks(canvas);
41 fOwner->reset();
42 fInitState = kReset_InitState;
43 break;
44 case TimingStateMachine::kTiming_ParentEvents: 40 case TimingStateMachine::kTiming_ParentEvents:
45 break; 41 break;
46 case TimingStateMachine::kTimingFinished_ParentEvents: 42 case TimingStateMachine::kTimingFinished_ParentEvents:
47 fBenchmarkStream->current()->postTimingHooks(canvas);
48 fOwner->reset();
49 if (this->timingFinished(fBenchmarkStream->current(), fTSM.loops(), 43 if (this->timingFinished(fBenchmarkStream->current(), fTSM.loops(),
50 fTSM.lastMeasurement())) { 44 fTSM.lastMeasurement())) {
45 fBenchmarkStream->current()->postTimingHooks(canvas);
46 fOwner->reset();
51 fTSM.nextBenchmark(); 47 fTSM.nextBenchmark();
52 if (!fBenchmarkStream->next()) { 48 if (!fBenchmarkStream->next()) {
53 SkDebugf("Exiting VisualBench successfully\n"); 49 SkDebugf("Exiting VisualBench successfully\n");
54 fOwner->closeWindow(); 50 fOwner->closeWindow();
55 } else { 51 } else {
56 fInitState = kNewBenchmark_InitState; 52 fInitState = kNewBenchmark_InitState;
57 } 53 }
58 } else { 54 break;
55 }
56 // fallthrough
57 case TimingStateMachine::kReset_ParentEvents:
58 if (FLAGS_reset) {
59 fBenchmarkStream->current()->postTimingHooks(canvas);
60 fOwner->reset();
59 fInitState = kReset_InitState; 61 fInitState = kReset_InitState;
60 } 62 }
61 break; 63 break;
62 } 64 }
63 } 65 }
64 66
65 void VisualStreamTimingModule::draw(SkCanvas* canvas) { 67 void VisualStreamTimingModule::draw(SkCanvas* canvas) {
66 if (!fBenchmarkStream->current()) { 68 if (!fBenchmarkStream->current()) {
67 // this should never happen but just to be safe 69 // this should never happen but just to be safe
68 // TODO research why this does happen on mac 70 // TODO research why this does happen on mac
69 return; 71 return;
70 } 72 }
71 73
72 this->handleInitState(canvas); 74 this->handleInitState(canvas);
73 this->renderFrame(canvas, fBenchmarkStream->current(), fTSM.loops()); 75 this->renderFrame(canvas, fBenchmarkStream->current(), fTSM.loops());
74 fOwner->present(); 76 fOwner->present();
75 TimingStateMachine::ParentEvents event = fTSM.nextFrame(fPreWarmBeforeSample ); 77 TimingStateMachine::ParentEvents event = fTSM.nextFrame(FLAGS_reset);
76 this->handleTimingEvent(canvas, event); 78 this->handleTimingEvent(canvas, event);
77 } 79 }
OLDNEW
« tools/VisualBench/VisualInteractiveModule.cpp ('K') | « tools/VisualBench/VisualStreamTimingModule.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698