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 "SkSurface.h" | 15 #include "SkSurface.h" |
| 16 #include "Timer.h" |
16 #include "gl/SkGLContext.h" | 17 #include "gl/SkGLContext.h" |
17 | 18 |
18 class GrContext; | 19 class GrContext; |
19 struct GrGLInterface; | 20 struct GrGLInterface; |
20 class GrRenderTarget; | 21 class GrRenderTarget; |
21 class SkCanvas; | 22 class SkCanvas; |
22 | 23 |
23 /* | 24 /* |
24 * A Visual benchmarking tool for gpu benchmarking | 25 * A Visual benchmarking tool for gpu benchmarking |
25 */ | 26 */ |
26 class VisualBench : public SkOSWindow { | 27 class VisualBench : public SkOSWindow { |
27 public: | 28 public: |
28 VisualBench(void* hwnd, int argc, char** argv); | 29 VisualBench(void* hwnd, int argc, char** argv); |
29 ~VisualBench() override; | 30 ~VisualBench() override; |
30 | 31 |
31 protected: | 32 protected: |
32 SkSurface* createSurface() override; | 33 SkSurface* createSurface() override; |
33 | 34 |
34 void draw(SkCanvas* canvas) override; | 35 void draw(SkCanvas* canvas) override; |
35 | 36 |
36 void onSizeChange() override; | 37 void onSizeChange() override; |
37 | 38 |
38 private: | 39 private: |
39 void setTitle(); | 40 void setTitle(); |
40 bool setupBackend(); | 41 bool setupBackend(); |
| 42 void resetContext(); |
41 void setupRenderTarget(); | 43 void setupRenderTarget(); |
42 bool onHandleChar(SkUnichar unichar) override; | 44 bool onHandleChar(SkUnichar unichar) override; |
| 45 void timeFrame(SkCanvas*); |
| 46 void printStats(); |
| 47 inline void timePicture(SkCanvas*); |
| 48 inline void renderFrame(SkCanvas*); |
43 | 49 |
44 int fCurrentLoops; | 50 struct Timing { |
| 51 SkString fName; |
| 52 SkTArray<double> fMeasurements; |
| 53 }; |
| 54 |
| 55 enum State { |
| 56 kPreWarm_State, |
| 57 kTiming_State, |
| 58 }; |
| 59 |
| 60 int fLoop; |
45 int fCurrentPicture; | 61 int fCurrentPicture; |
46 int fCurrentFrame; | 62 int fCurrentSample; |
| 63 SkTArray<Timing> fTimings; |
47 SkTArray<SkPicture*> fPictures; | 64 SkTArray<SkPicture*> fPictures; |
| 65 WallTimer fTimer; |
| 66 State fState; |
48 | 67 |
49 // support framework | 68 // support framework |
50 SkAutoTUnref<SkSurface> fSurface; | 69 SkAutoTUnref<SkSurface> fSurface; |
51 SkAutoTUnref<GrContext> fContext; | 70 SkAutoTUnref<GrContext> fContext; |
52 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 71 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
53 AttachmentInfo fAttachmentInfo; | 72 AttachmentInfo fAttachmentInfo; |
54 SkAutoTUnref<const GrGLInterface> fInterface; | 73 SkAutoTUnref<const GrGLInterface> fInterface; |
55 | 74 |
56 typedef SkOSWindow INHERITED; | 75 typedef SkOSWindow INHERITED; |
57 }; | 76 }; |
58 | 77 |
59 #endif | 78 #endif |
OLD | NEW |