skia2/tools/VisualBench/VisualStreamTimingModule.h
cdalton 266e2024ec Add visualbench option to not reset between samples
Adds a --reset flag that controls whether we teardown the graphics
context between samples. Also modifies the timing algorithm to always/
only pre-warm after resetting the context.

BUG=skia:

Review URL: https://codereview.chromium.org/1442643007
2015-11-13 08:28:49 -08:00

55 lines
1.4 KiB
C++

/*
* 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 VisualStreamTimingModule_DEFINED
#define VisualStreamTimingModule_DEFINED
#include "VisualModule.h"
#include "TimingStateMachine.h"
#include "VisualBench.h"
#include "VisualBenchmarkStream.h"
class SkCanvas;
/*
* VisualStreamTimingModule is the base class for modules which want to time a stream of Benchmarks.
*
* Subclasses should implement renderFrame, which is called for each frame, and timingFinished,
* which is called when a sample has finished timing.
*/
class VisualStreamTimingModule : public VisualModule {
public:
VisualStreamTimingModule(VisualBench* owner);
void draw(SkCanvas* canvas) override;
private:
virtual void renderFrame(SkCanvas*, Benchmark*, int loops)=0;
// subclasses should return true to advance the stream
virtual bool timingFinished(Benchmark*, int loops, double measurement)=0;
inline void handleInitState(SkCanvas*);
inline void handleTimingEvent(SkCanvas*, TimingStateMachine::ParentEvents);
TimingStateMachine fTSM;
SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream;
enum InitState {
kNone_InitState,
kReset_InitState,
kNewBenchmark_InitState,
};
InitState fInitState;
// support framework
VisualBench* fOwner;
typedef VisualModule INHERITED;
};
#endif