blob: c1f61d95197432129129e879e5fdbacd65b8da1a [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"
joshualitt189aef72015-09-08 07:08:11 -070017#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
joshualitt189aef72015-09-08 07:08:11 -070034 void reset() { this->resetContext(); }
35
jvanverthf5d1b2d2015-09-15 07:40:56 -070036 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;
joshualittda7b8432015-05-27 09:19:03 -070051
52 // support framework
joshualitt189aef72015-09-08 07:08:11 -070053 SkAutoTDelete<VisualModule> fModule;
joshualittda7b8432015-05-27 09:19:03 -070054 SkAutoTUnref<SkSurface> fSurface;
55 SkAutoTUnref<GrContext> fContext;
56 SkAutoTUnref<GrRenderTarget> fRenderTarget;
57 AttachmentInfo fAttachmentInfo;
58 SkAutoTUnref<const GrGLInterface> fInterface;
joshualittda7b8432015-05-27 09:19:03 -070059
60 typedef SkOSWindow INHERITED;
61};
62
63#endif