blob: 1920a52b2bebb832486e03bb1d7543551703eefc [file] [log] [blame]
joshualittda7b8432015-05-27 09:19:03 -07001/*
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"
bsalomon45171e22015-06-16 13:52:18 -070015#include "SkString.h"
joshualittda7b8432015-05-27 09:19:03 -070016#include "SkSurface.h"
Tom Hudson2880df22015-10-29 09:55:42 -040017#include "VisualFlags.h"
18#include "VisualModule.h"
joshualittda7b8432015-05-27 09:19:03 -070019#include "gl/SkGLContext.h"
20
21class GrContext;
22struct GrGLInterface;
23class GrRenderTarget;
24class SkCanvas;
25
26/*
27 * A Visual benchmarking tool for gpu benchmarking
28 */
29class VisualBench : public SkOSWindow {
30public:
31 VisualBench(void* hwnd, int argc, char** argv);
32 ~VisualBench() override;
33
Tom Hudson2880df22015-10-29 09:55:42 -040034 void reset() { this->resetContext(); }
35
36 void clear(SkCanvas* canvas, SkColor color, int frames);
37
joshualittda7b8432015-05-27 09:19:03 -070038protected:
39 SkSurface* createSurface() override;
40
41 void draw(SkCanvas* canvas) override;
42
43 void onSizeChange() override;
44
45private:
46 void setTitle();
47 bool setupBackend();
joshualitt7fe8ee42015-06-01 10:03:54 -070048 void resetContext();
joshualittda7b8432015-05-27 09:19:03 -070049 void setupRenderTarget();
50 bool onHandleChar(SkUnichar unichar) override;
Tom Hudson2880df22015-10-29 09:55:42 -040051 void tearDownContext();
52 void setupContext();
joshualittda7b8432015-05-27 09:19:03 -070053
54 // support framework
Tom Hudson2880df22015-10-29 09:55:42 -040055 SkAutoTDelete<VisualModule> fModule;
joshualittda7b8432015-05-27 09:19:03 -070056 SkAutoTUnref<SkSurface> fSurface;
57 SkAutoTUnref<GrContext> fContext;
58 SkAutoTUnref<GrRenderTarget> fRenderTarget;
59 AttachmentInfo fAttachmentInfo;
60 SkAutoTUnref<const GrGLInterface> fInterface;
joshualittda7b8432015-05-27 09:19:03 -070061
62 typedef SkOSWindow INHERITED;
63};
64
65#endif