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

Side by Side Diff: tools/VisualBench/VisualInteractiveModule.h

Issue 1382883003: move visual bench interactive module to timing state machine (Closed) Base URL: https://skia.googlesource.com/skia.git@vb
Patch Set: 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/TimingStateMachine.cpp ('k') | tools/VisualBench/VisualInteractiveModule.cpp » ('j') | 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 8
9 #ifndef VisualInteractiveModule_DEFINED 9 #ifndef VisualInteractiveModule_DEFINED
10 #define VisualInteractiveModule_DEFINED 10 #define VisualInteractiveModule_DEFINED
11 11
12 #include "VisualModule.h" 12 #include "VisualModule.h"
13 13
14 #include "ResultsWriter.h" 14 #include "ResultsWriter.h"
15 #include "SkPicture.h" 15 #include "SkPicture.h"
16 #include "Timer.h" 16 #include "Timer.h"
17 #include "TimingStateMachine.h"
17 #include "VisualBench.h" 18 #include "VisualBench.h"
18 #include "VisualBenchmarkStream.h" 19 #include "VisualBenchmarkStream.h"
19 20
20 class SkCanvas; 21 class SkCanvas;
21 22
22 /* 23 /*
23 * This module for VisualBench is designed to display stats data dynamically 24 * This module for VisualBench is designed to display stats data dynamically
24 */ 25 */
25 class VisualInteractiveModule : public VisualModule { 26 class VisualInteractiveModule : public VisualModule {
26 public: 27 public:
27 // TODO get rid of backpointer 28 // TODO get rid of backpointer
28 VisualInteractiveModule(VisualBench* owner); 29 VisualInteractiveModule(VisualBench* owner);
29 30
30 void draw(SkCanvas* canvas) override; 31 void draw(SkCanvas* canvas) override;
31 bool onHandleChar(SkUnichar unichar) override; 32 bool onHandleChar(SkUnichar unichar) override;
32 33
33 private: 34 private:
34 /*
35 * The heart of visual bench is an event driven timing loop.
36 * kPreWarmLoopsPerCanvasPreDraw_State: Before we begin timing, Benchmarks have a hook to
37 * access the canvas. Then we prewarm before the autotune
38 * loops step.
39 * kPreWarmLoops_State: We prewarm the gpu before auto tuni ng to enter a steady
40 * work state
41 * kTuneLoops_State: Then we tune the loops of the bench mark to ensure we
42 * are doing a measurable amount of wo rk
43 * kPreTiming_State: Because reset the context after tun ing loops to ensure
44 * coherent state, we need to restart before timing
45 * kTiming_State: Finally we time the benchmark. In this case we
46 * continue running and displaying ben chmark data
47 * until we quit or switch to another benchmark
48 * kAdvance_State: Advance to the next benchmark in th e stream
49 */
50 enum State {
51 kPreWarmLoopsPerCanvasPreDraw_State,
52 kPreWarmLoops_State,
53 kTuneLoops_State,
54 kPreTiming_State,
55 kTiming_State,
56 kAdvance_State,
57 };
58 void setTitle(); 35 void setTitle();
59 bool setupBackend(); 36 bool setupBackend();
60 void setupRenderTarget(); 37 void setupRenderTarget();
61 void drawStats(SkCanvas*); 38 void drawStats(SkCanvas*);
62 bool advanceRecordIfNecessary(SkCanvas*); 39 bool advanceRecordIfNecessary(SkCanvas*);
63 inline void renderFrame(SkCanvas*); 40 inline void renderFrame(SkCanvas*);
64 inline void nextState(State);
65 void perCanvasPreDraw(SkCanvas*, State);
66 void preWarm(State nextState);
67 void scaleLoops(double elapsedMs);
68 inline void tuneLoops(SkCanvas*);
69 inline void timing(SkCanvas*);
70 inline double elapsed();
71 void resetTimingState();
72 void postDraw(SkCanvas*);
73 void recordMeasurement();
74 41
75 static const int kMeasurementCount = 64; // should be power of 2 for fast m od 42 static const int kMeasurementCount = 64; // should be power of 2 for fast m od
76 double fMeasurements[kMeasurementCount]; 43 double fMeasurements[kMeasurementCount];
77 int fCurrentMeasurement; 44 int fCurrentMeasurement;
78 45
79 int fCurrentFrame;
80 int fLoops;
81 WallTimer fTimer;
82 State fState;
83 SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream; 46 SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream;
84 SkAutoTUnref<Benchmark> fBenchmark; 47 SkAutoTUnref<Benchmark> fBenchmark;
48 TimingStateMachine fTSM;
49 bool fAdvance;
85 50
86 // support framework 51 // support framework
87 SkAutoTUnref<VisualBench> fOwner; 52 SkAutoTUnref<VisualBench> fOwner;
88 53
89 typedef VisualModule INHERITED; 54 typedef VisualModule INHERITED;
90 }; 55 };
91 56
92 #endif 57 #endif
OLDNEW
« no previous file with comments | « tools/VisualBench/TimingStateMachine.cpp ('k') | tools/VisualBench/VisualInteractiveModule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698