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