aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/VisualBench/VisualBench.h
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-06-30 06:50:10 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-30 06:50:10 -0700
commit91b6f32e07aa479fc634bfc6fc88fe949b933236 (patch)
tree7fb174f2ef43b67e9609518c9e022bf2190342e0 /tools/VisualBench/VisualBench.h
parent7b971f0152299ae9a924252a9bfd220318497bdd (diff)
Move visualbench to its own folder
Diffstat (limited to 'tools/VisualBench/VisualBench.h')
-rw-r--r--tools/VisualBench/VisualBench.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/tools/VisualBench/VisualBench.h b/tools/VisualBench/VisualBench.h
new file mode 100644
index 0000000000..332fe82eb4
--- /dev/null
+++ b/tools/VisualBench/VisualBench.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ */
+
+#ifndef VisualBench_DEFINED
+#define VisualBench_DEFINED
+
+#include "SkWindow.h"
+
+#include "SkPicture.h"
+#include "SkString.h"
+#include "SkSurface.h"
+#include "Timer.h"
+#include "gl/SkGLContext.h"
+
+class GrContext;
+struct GrGLInterface;
+class GrRenderTarget;
+class SkCanvas;
+
+/*
+ * A Visual benchmarking tool for gpu benchmarking
+ */
+class VisualBench : public SkOSWindow {
+public:
+ VisualBench(void* hwnd, int argc, char** argv);
+ ~VisualBench() override;
+
+protected:
+ SkSurface* createSurface() override;
+
+ void draw(SkCanvas* canvas) override;
+
+ void onSizeChange() override;
+
+private:
+ void setTitle();
+ bool setupBackend();
+ void resetContext();
+ void setupRenderTarget();
+ bool onHandleChar(SkUnichar unichar) override;
+ void printStats();
+ bool loadPicture();
+ bool advanceRecordIfNecessary();
+ inline void renderFrame(SkCanvas*);
+
+ struct Record {
+ SkString fFilename;
+ SkTArray<double> fMeasurements;
+ };
+
+ enum State {
+ kPreWarmLoops_State,
+ kTuneLoops_State,
+ kPreWarmTiming_State,
+ kTiming_State,
+ };
+ void preWarm(State nextState);
+
+ int fCurrentPictureIdx;
+ SkAutoTUnref<SkPicture> fPicture;
+ int fCurrentSample;
+ int fCurrentFrame;
+ int fFlushes;
+ int fLoops;
+ SkTArray<Record> fRecords;
+ WallTimer fTimer;
+ State fState;
+
+ // support framework
+ SkAutoTUnref<SkSurface> fSurface;
+ SkAutoTUnref<GrContext> fContext;
+ SkAutoTUnref<GrRenderTarget> fRenderTarget;
+ AttachmentInfo fAttachmentInfo;
+ SkAutoTUnref<const GrGLInterface> fInterface;
+
+ typedef SkOSWindow INHERITED;
+};
+
+#endif