Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
MSKPBench Class Reference

#include <MSKPBench.h>

Inheritance diagram for MSKPBench:
Benchmark SkRefCnt SkRefCntBase

Public Member Functions

 MSKPBench (SkString name, std::unique_ptr< MSKPPlayer > player)
 
 ~MSKPBench () override
 
- Public Member Functions inherited from Benchmark
 Benchmark ()
 
const char * getName ()
 
const char * getUniqueName ()
 
SkISize getSize ()
 
virtual bool isSuitableFor (Backend backend)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual bool shouldLoop () const
 
void delayedSetup ()
 
void perCanvasPreDraw (SkCanvas *)
 
void perCanvasPostDraw (SkCanvas *)
 
void preDraw (SkCanvas *)
 
void postDraw (SkCanvas *)
 
void draw (int loops, SkCanvas *)
 
virtual void getGpuStats (SkCanvas *, skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values)
 
virtual bool getDMSAAStats (GrRecordingContext *)
 
int getUnits () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

void onDraw (int loops, SkCanvas *) override
 
const char * onGetName () override
 
SkISize onGetSize () override
 
void onPreDraw (SkCanvas *) override
 
void onPostDraw (SkCanvas *) override
 
- Protected Member Functions inherited from Benchmark
void setUnits (int units)
 
virtual void setupPaint (SkPaint *paint)
 
virtual const char * onGetName ()=0
 
virtual const char * onGetUniqueName ()
 
virtual void onDelayedSetup ()
 
virtual void onPerCanvasPreDraw (SkCanvas *)
 
virtual void onPerCanvasPostDraw (SkCanvas *)
 
virtual void onPreDraw (SkCanvas *)
 
virtual void onPostDraw (SkCanvas *)
 
virtual void onDraw (int loops, SkCanvas *)=0
 
virtual SkISize onGetSize ()
 

Additional Inherited Members

- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 

Detailed Description

Definition at line 15 of file MSKPBench.h.

Constructor & Destructor Documentation

◆ MSKPBench()

MSKPBench::MSKPBench ( SkString  name,
std::unique_ptr< MSKPPlayer player 
)

Definition at line 14 of file MSKPBench.cpp.

15 : fName(name), fPlayer(std::move(player)) {}
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ ~MSKPBench()

MSKPBench::~MSKPBench ( )
overridedefault

Member Function Documentation

◆ onDraw()

void MSKPBench::onDraw ( int  loops,
SkCanvas canvas 
)
overrideprotectedvirtual

Implements Benchmark.

Definition at line 19 of file MSKPBench.cpp.

19 {
20 for (int i = 0; i < loops; ++i) {
21 for (int f = 0; f < fPlayer->numFrames(); ++f) {
22 canvas->save();
23 canvas->clipIRect(SkIRect::MakeSize(fPlayer->frameDimensions(f)));
24 fPlayer->playFrame(canvas, f);
25 canvas->restore();
26 if (auto dContext = GrAsDirectContext(canvas->recordingContext())) {
27 dContext->flushAndSubmit();
28 }
29 }
30 // Ensure each loop replays all offscreen layer draws from scratch.
31 fPlayer->rewindLayers();
32 }
33}
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
void restore()
Definition: SkCanvas.cpp:461
void clipIRect(const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect)
Definition: SkCanvas.h:991
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
int save()
Definition: SkCanvas.cpp:447
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66

◆ onGetName()

const char * MSKPBench::onGetName ( )
overrideprotectedvirtual

Implements Benchmark.

Definition at line 35 of file MSKPBench.cpp.

35{ return fName.c_str(); }
const char * c_str() const
Definition: SkString.h:133

◆ onGetSize()

SkISize MSKPBench::onGetSize ( )
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 37 of file MSKPBench.cpp.

37 {
38 auto dims = fPlayer->maxDimensions();
39 return {dims.width(), dims.height()};
40}

◆ onPostDraw()

void MSKPBench::onPostDraw ( SkCanvas )
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 47 of file MSKPBench.cpp.

47 {
48 // nanobench can tear down the 3D API context/device before destroying the benchmarks.
49 fPlayer->resetLayers();
50}

◆ onPreDraw()

void MSKPBench::onPreDraw ( SkCanvas canvas)
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 42 of file MSKPBench.cpp.

42 {
43 // We don't benchmark creation of the backing stores for layers so ensure they're all created.
44 fPlayer->allocateLayers(canvas);
45}

The documentation for this class was generated from the following files: