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 | 8 |
9 #ifndef VisualBench_DEFINED | 9 #ifndef VisualBench_DEFINED |
10 #define VisualBench_DEFINED | 10 #define VisualBench_DEFINED |
11 | 11 |
12 #include "SkWindow.h" | 12 #include "SkWindow.h" |
13 | 13 |
14 #include "SkPicture.h" | 14 #include "SkPicture.h" |
15 #include "SkString.h" | 15 #include "SkString.h" |
16 #include "SkSurface.h" | 16 #include "SkSurface.h" |
17 #include "Timer.h" | 17 #include "Timer.h" |
| 18 #include "VisualBenchmarkStream.h" |
18 #include "gl/SkGLContext.h" | 19 #include "gl/SkGLContext.h" |
19 | 20 |
20 class GrContext; | 21 class GrContext; |
21 struct GrGLInterface; | 22 struct GrGLInterface; |
22 class GrRenderTarget; | 23 class GrRenderTarget; |
23 class SkCanvas; | 24 class SkCanvas; |
24 | 25 |
25 /* | 26 /* |
26 * A Visual benchmarking tool for gpu benchmarking | 27 * A Visual benchmarking tool for gpu benchmarking |
27 */ | 28 */ |
28 class VisualBench : public SkOSWindow { | 29 class VisualBench : public SkOSWindow { |
29 public: | 30 public: |
30 VisualBench(void* hwnd, int argc, char** argv); | 31 VisualBench(void* hwnd, int argc, char** argv); |
31 ~VisualBench() override; | 32 ~VisualBench() override; |
32 | 33 |
33 protected: | 34 protected: |
34 SkSurface* createSurface() override; | 35 SkSurface* createSurface() override; |
35 | 36 |
36 void draw(SkCanvas* canvas) override; | 37 void draw(SkCanvas* canvas) override; |
37 | 38 |
38 void onSizeChange() override; | 39 void onSizeChange() override; |
39 | 40 |
40 private: | 41 private: |
41 void setTitle(); | 42 void setTitle(); |
42 bool setupBackend(); | 43 bool setupBackend(); |
43 void resetContext(); | 44 void resetContext(); |
44 void setupRenderTarget(); | 45 void setupRenderTarget(); |
45 bool onHandleChar(SkUnichar unichar) override; | 46 bool onHandleChar(SkUnichar unichar) override; |
46 void printStats(); | 47 void printStats(); |
47 bool loadPicture(); | 48 bool advanceRecordIfNecessary(SkCanvas*); |
48 bool advanceRecordIfNecessary(); | |
49 inline void renderFrame(SkCanvas*); | 49 inline void renderFrame(SkCanvas*); |
50 | 50 |
51 struct Record { | 51 struct Record { |
52 SkString fFilename; | |
53 SkTArray<double> fMeasurements; | 52 SkTArray<double> fMeasurements; |
54 }; | 53 }; |
55 | 54 |
56 enum State { | 55 enum State { |
57 kPreWarmLoops_State, | 56 kPreWarmLoops_State, |
58 kTuneLoops_State, | 57 kTuneLoops_State, |
59 kPreWarmTiming_State, | 58 kPreWarmTiming_State, |
60 kTiming_State, | 59 kTiming_State, |
61 }; | 60 }; |
62 void preWarm(State nextState); | 61 void preWarm(State nextState); |
63 | 62 |
64 int fCurrentPictureIdx; | |
65 SkAutoTUnref<SkPicture> fPicture; | |
66 int fCurrentSample; | 63 int fCurrentSample; |
67 int fCurrentFrame; | 64 int fCurrentFrame; |
68 int fFlushes; | 65 int fFlushes; |
69 int fLoops; | 66 int fLoops; |
70 SkTArray<Record> fRecords; | 67 SkTArray<Record> fRecords; |
71 WallTimer fTimer; | 68 WallTimer fTimer; |
72 State fState; | 69 State fState; |
| 70 SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream; |
| 71 Benchmark* fBenchmark; |
73 | 72 |
74 // support framework | 73 // support framework |
75 SkAutoTUnref<SkSurface> fSurface; | 74 SkAutoTUnref<SkSurface> fSurface; |
76 SkAutoTUnref<GrContext> fContext; | 75 SkAutoTUnref<GrContext> fContext; |
77 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 76 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
78 AttachmentInfo fAttachmentInfo; | 77 AttachmentInfo fAttachmentInfo; |
79 SkAutoTUnref<const GrGLInterface> fInterface; | 78 SkAutoTUnref<const GrGLInterface> fInterface; |
80 | 79 |
81 typedef SkOSWindow INHERITED; | 80 typedef SkOSWindow INHERITED; |
82 }; | 81 }; |
83 | 82 |
84 #endif | 83 #endif |
OLD | NEW |