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