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

#include <GMBench.h>

Inheritance diagram for GMBench:
Benchmark SkRefCnt SkRefCntBase

Public Member Functions

 GMBench (std::unique_ptr< skiagm::GM > gm)
 
void modifyGrContextOptions (GrContextOptions *options) 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

const char * onGetName () override
 
bool isSuitableFor (Backend backend) override
 
void onPerCanvasPreDraw (SkCanvas *) override
 
void onPerCanvasPostDraw (SkCanvas *) override
 
void onDraw (int loops, SkCanvas *) override
 
SkISize onGetSize () 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

Runs a GM as a benchmark by repeatedly drawing the GM.

Definition at line 17 of file GMBench.h.

Constructor & Destructor Documentation

◆ GMBench()

GMBench::GMBench ( std::unique_ptr< skiagm::GM gm)

Definition at line 13 of file GMBench.cpp.

13 : fGM(std::move(gm)) {
14 fGM->setMode(skiagm::GM::kBench_Mode);
15
16 fName.printf("GM_%s", fGM->getName().c_str());
17}
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
@ kBench_Mode
Definition: gm.h:121

Member Function Documentation

◆ isSuitableFor()

bool GMBench::isSuitableFor ( Backend  backend)
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 23 of file GMBench.cpp.

23 {
25}
const char * backend

◆ modifyGrContextOptions()

void GMBench::modifyGrContextOptions ( GrContextOptions options)
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 21 of file GMBench.h.

21 {
22 return fGM->modifyGrContextOptions(options);
23 }
const char * options

◆ onDraw()

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

Implements Benchmark.

Definition at line 44 of file GMBench.cpp.

44 {
45 if (fGpuSetupFailed) {
46 return;
47 }
48
49 fGM->drawBackground(canvas);
50 for (int i = 0; i < loops; ++i) {
51 fGM->drawContent(canvas);
52 }
53}

◆ onGetName()

const char * GMBench::onGetName ( )
overrideprotectedvirtual

Implements Benchmark.

Definition at line 19 of file GMBench.cpp.

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

◆ onGetSize()

SkISize GMBench::onGetSize ( )
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 55 of file GMBench.cpp.

55 {
56 return fGM->getISize();
57}

◆ onPerCanvasPostDraw()

void GMBench::onPerCanvasPostDraw ( SkCanvas )
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 36 of file GMBench.cpp.

36 {
37 fGM->gpuTeardown();
38
39 // The same GM will be reused with multiple GrContexts. Let the next GrContext start
40 // afresh.
41 fGpuSetupFailed = false;
42}

◆ onPerCanvasPreDraw()

void GMBench::onPerCanvasPreDraw ( SkCanvas canvas)
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 27 of file GMBench.cpp.

27 {
28 SkString msg;
29 if (fGM->gpuSetup(canvas, &msg) != skiagm::DrawResult::kOk) {
30 fGpuSetupFailed = true;
31 }
32
33 fGM->onceBeforeDraw();
34}

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