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 "VisualFlags.h" 18 #include "VisualModule.h" 19 #include "gl/SkGLContext.h" 20 21 class GrContext; 22 struct GrGLInterface; 23 class GrRenderTarget; 24 class SkCanvas; 25 26 /* 27 * A Visual benchmarking tool for gpu benchmarking 28 */ 29 class VisualBench : public SkOSWindow { 30 public: 31 VisualBench(void* hwnd, int argc, char** argv); 32 ~VisualBench() override; 33 reset()34 void reset() { this->resetContext(); } 35 36 void clear(SkCanvas* canvas, SkColor color, int frames); 37 38 protected: 39 SkSurface* createSurface() override; 40 41 void draw(SkCanvas* canvas) override; 42 43 void onSizeChange() override; 44 45 private: 46 void setTitle(); 47 bool setupBackend(); 48 void resetContext(); 49 void setupRenderTarget(); 50 bool onHandleChar(SkUnichar unichar) override; 51 void tearDownContext(); 52 void setupContext(); 53 54 // support framework 55 SkAutoTDelete<VisualModule> fModule; 56 SkAutoTUnref<SkSurface> fSurface; 57 SkAutoTUnref<GrContext> fContext; 58 SkAutoTUnref<GrRenderTarget> fRenderTarget; 59 AttachmentInfo fAttachmentInfo; 60 SkAutoTUnref<const GrGLInterface> fInterface; 61 62 typedef SkOSWindow INHERITED; 63 }; 64 65 #endif 66