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

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

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

Powered by Google App Engine
This is Rietveld 408576698