OLD | NEW |
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 #ifndef VisualStreamTimingModule_DEFINED | 8 #ifndef VisualStreamTimingModule_DEFINED |
9 #define VisualStreamTimingModule_DEFINED | 9 #define VisualStreamTimingModule_DEFINED |
10 | 10 |
11 #include "VisualModule.h" | 11 #include "VisualModule.h" |
12 | 12 |
13 #include "TimingStateMachine.h" | 13 #include "TimingStateMachine.h" |
14 #include "VisualBench.h" | 14 #include "VisualBench.h" |
15 #include "VisualBenchmarkStream.h" | 15 #include "VisualBenchmarkStream.h" |
16 | 16 |
| 17 class SkCanvas; |
| 18 |
17 /* | 19 /* |
18 * VisualStreamTimingModule is the base class for modules which want to time a s
tream of Benchmarks. | 20 * VisualStreamTimingModule is the base class for modules which want to time a s
tream of Benchmarks. |
19 * | 21 * |
20 * Subclasses should implement renderFrame, which is called for each frame, and
timingFinished, | 22 * Subclasses should implement renderFrame, which is called for each frame, and
timingFinished, |
21 * which is called when a sample has finished timing. | 23 * which is called when a sample has finished timing. |
22 */ | 24 */ |
23 class VisualStreamTimingModule : public VisualModule { | 25 class VisualStreamTimingModule : public VisualModule { |
24 public: | 26 public: |
25 VisualStreamTimingModule(VisualBench* owner, bool preWarmBeforeSample); | 27 VisualStreamTimingModule(VisualBench* owner, bool preWarmBeforeSample); |
26 void draw(SkCanvas* canvas) override; | 28 void draw(SkCanvas* canvas) override; |
27 | 29 |
28 private: | 30 private: |
29 virtual void renderFrame(SkCanvas*, Benchmark*, int loops)=0; | 31 virtual void renderFrame(SkCanvas*, Benchmark*, int loops)=0; |
30 | 32 |
31 // subclasses should return true to advance the stream | 33 // subclasses should return true to advance the stream |
32 virtual bool timingFinished(Benchmark*, int loops, double measurement)=0; | 34 virtual bool timingFinished(Benchmark*, int loops, double measurement)=0; |
33 | 35 |
34 bool nextBenchmarkIfNecessary(SkCanvas*); | 36 inline void handleInitState(SkCanvas*); |
| 37 inline void handleTimingEvent(SkCanvas*, TimingStateMachine::ParentEvents); |
35 | 38 |
36 TimingStateMachine fTSM; | 39 TimingStateMachine fTSM; |
37 SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream; | 40 SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream; |
38 SkAutoTUnref<Benchmark> fBenchmark; | 41 enum InitState { |
39 bool fReinitializeBenchmark; | 42 kNone_InitState, |
| 43 kReset_InitState, |
| 44 kNewBenchmark_InitState, |
| 45 }; |
| 46 InitState fInitState; |
40 bool fPreWarmBeforeSample; | 47 bool fPreWarmBeforeSample; |
41 | 48 |
42 // support framework | 49 // support framework |
43 VisualBench* fOwner; | 50 VisualBench* fOwner; |
44 | 51 |
45 typedef VisualModule INHERITED; | 52 typedef VisualModule INHERITED; |
46 }; | 53 }; |
47 | 54 |
48 #endif | 55 #endif |
OLD | NEW |