2015-10-14 14:49:28 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
2015-10-15 14:18:29 +00:00
|
|
|
class SkCanvas;
|
|
|
|
|
2015-10-14 14:49:28 +00:00
|
|
|
/*
|
|
|
|
* 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:
|
2015-11-13 16:28:49 +00:00
|
|
|
VisualStreamTimingModule(VisualBench* owner);
|
2015-10-14 14:49:28 +00:00
|
|
|
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;
|
|
|
|
|
2015-10-15 14:18:29 +00:00
|
|
|
inline void handleInitState(SkCanvas*);
|
|
|
|
inline void handleTimingEvent(SkCanvas*, TimingStateMachine::ParentEvents);
|
2015-10-14 21:45:07 +00:00
|
|
|
|
2015-10-14 14:49:28 +00:00
|
|
|
TimingStateMachine fTSM;
|
|
|
|
SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream;
|
2015-10-15 14:18:29 +00:00
|
|
|
enum InitState {
|
|
|
|
kNone_InitState,
|
|
|
|
kReset_InitState,
|
|
|
|
kNewBenchmark_InitState,
|
|
|
|
};
|
|
|
|
InitState fInitState;
|
2015-10-14 14:49:28 +00:00
|
|
|
|
|
|
|
// support framework
|
|
|
|
VisualBench* fOwner;
|
|
|
|
|
|
|
|
typedef VisualModule INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|