aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/VisualBench/VisualBench.h
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-09-08 07:08:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-08 07:08:11 -0700
commit189aef7834e20a01c062817b54a49b76ad4a0b4b (patch)
treeceb8d007617cd2661cb18f82d08a930290c28d40 /tools/VisualBench/VisualBench.h
parent8fd97eab1d9c17c662e08f6b3dbd7be49ec0a838 (diff)
Create module system for VisualBench
The newly created VisualLightweightBenchModule is just the old VisualBench.cpp, but gutted to only include timing code. Future CLs will harden this abstraction, but for this CL the module owns a backpointer to VisualBench.cpp for a couple of calls. BUG=skia: Review URL: https://codereview.chromium.org/1304083007
Diffstat (limited to 'tools/VisualBench/VisualBench.h')
-rw-r--r--tools/VisualBench/VisualBench.h63
1 files changed, 5 insertions, 58 deletions
diff --git a/tools/VisualBench/VisualBench.h b/tools/VisualBench/VisualBench.h
index 61002fc9e9..75615f0735 100644
--- a/tools/VisualBench/VisualBench.h
+++ b/tools/VisualBench/VisualBench.h
@@ -11,12 +11,11 @@
#include "SkWindow.h"
-#include "ResultsWriter.h"
#include "SkPicture.h"
#include "SkString.h"
#include "SkSurface.h"
-#include "Timer.h"
-#include "VisualBenchmarkStream.h"
+#include "VisualFlags.h"
+#include "VisualModule.h"
#include "gl/SkGLContext.h"
class GrContext;
@@ -32,6 +31,8 @@ public:
VisualBench(void* hwnd, int argc, char** argv);
~VisualBench() override;
+ void reset() { this->resetContext(); }
+
protected:
SkSurface* createSurface() override;
@@ -40,73 +41,19 @@ protected:
void onSizeChange() override;
private:
- /*
- * The heart of visual bench is an event driven timing loop.
- * kPreWarmLoopsPerCanvasPreDraw_State: Before we begin timing, Benchmarks have a hook to
- * access the canvas. Then we prewarm before the autotune
- * loops step.
- * kPreWarmLoops_State: We prewarm the gpu before auto tuning to enter a steady
- * work state
- * kTuneLoops_State: Then we tune the loops of the benchmark to ensure we
- * are doing a measurable amount of work
- * kPreWarmTimingPerCanvasPreDraw_State: Because reset the context after tuning loops to ensure
- * coherent state, we need to give the benchmark
- * another hook
- * kPreWarmTiming_State: We prewarm the gpu again to enter a steady state
- * kTiming_State: Finally we time the benchmark. When finished timing
- * if we have enough samples then we'll start the next
- * benchmark in the kPreWarmLoopsPerCanvasPreDraw_State.
- * otherwise, we enter the
- * kPreWarmTimingPerCanvasPreDraw_State for another sample
- * In either case we reset the context.
- */
- enum State {
- kPreWarmLoopsPerCanvasPreDraw_State,
- kPreWarmLoops_State,
- kTuneLoops_State,
- kPreWarmTimingPerCanvasPreDraw_State,
- kPreWarmTiming_State,
- kTiming_State,
- };
void setTitle();
bool setupBackend();
void resetContext();
void setupRenderTarget();
bool onHandleChar(SkUnichar unichar) override;
- void printStats();
- bool advanceRecordIfNecessary(SkCanvas*);
- inline void renderFrame(SkCanvas*);
- inline void nextState(State);
- void perCanvasPreDraw(SkCanvas*, State);
- void preWarm(State nextState);
- void scaleLoops(double elapsedMs);
- inline void tuneLoops();
- inline void timing(SkCanvas*);
- inline double elapsed();
- void resetTimingState();
- void postDraw(SkCanvas*);
- void recordMeasurement();
-
- struct Record {
- SkTArray<double> fMeasurements;
- };
-
- int fCurrentSample;
- int fCurrentFrame;
- int fLoops;
- SkTArray<Record> fRecords;
- WallTimer fTimer;
- State fState;
- SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream;
- SkAutoTUnref<Benchmark> fBenchmark;
// support framework
+ SkAutoTDelete<VisualModule> fModule;
SkAutoTUnref<SkSurface> fSurface;
SkAutoTUnref<GrContext> fContext;
SkAutoTUnref<GrRenderTarget> fRenderTarget;
AttachmentInfo fAttachmentInfo;
SkAutoTUnref<const GrGLInterface> fInterface;
- SkAutoTDelete<ResultsWriter> fResults;
typedef SkOSWindow INHERITED;
};