Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
SKPAnimationBench Class Reference

#include <SKPAnimationBench.h>

Inheritance diagram for SKPAnimationBench:
SKPBench Benchmark SkRefCnt SkRefCntBase

Classes

class  Animation
 

Public Member Functions

 SKPAnimationBench (const char *name, const SkPicture *, const SkIRect &devClip, sk_sp< Animation >, bool doLooping)
 
- Public Member Functions inherited from SKPBench
 SKPBench (const char *name, const SkPicture *, const SkIRect &devClip, SkScalar scale, bool doLooping)
 
 ~SKPBench () override
 
bool shouldLoop () const override
 
void getGpuStats (SkCanvas *, skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values) override
 
bool getDMSAAStats (GrRecordingContext *) 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
 

Static Public Member Functions

static sk_sp< AnimationMakeZoomAnimation (SkScalar zoomMax, double zoomPeriodMs)
 

Protected Member Functions

const char * onGetUniqueName () override
 
void onPerCanvasPreDraw (SkCanvas *canvas) override
 
void drawMPDPicture () override
 
void drawPicture () override
 
- Protected Member Functions inherited from SKPBench
const char * onGetName () override
 
const char * onGetUniqueName () override
 
void onPerCanvasPreDraw (SkCanvas *) override
 
void onPerCanvasPostDraw (SkCanvas *) override
 
bool isSuitableFor (Backend backend) override
 
void onDraw (int loops, SkCanvas *canvas) override
 
SkISize onGetSize () override
 
virtual void drawMPDPicture ()
 
virtual void drawPicture ()
 
const SkPicturepicture () const
 
const skia_private::TArray< sk_sp< SkSurface > > & surfaces () const
 
const SkTDArray< SkIRect > & tileRects () const
 
- 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 an SkPicture as a benchmark by repeatedly drawing it, first centering the picture and for each step it concats the passed in matrix

Definition at line 19 of file SKPAnimationBench.h.

Constructor & Destructor Documentation

◆ SKPAnimationBench()

SKPAnimationBench::SKPAnimationBench ( const char *  name,
const SkPicture pic,
const SkIRect devClip,
sk_sp< Animation animation,
bool  doLooping 
)

Definition at line 14 of file SKPAnimationBench.cpp.

16 : INHERITED(name, pic, clip, 1.0, doLooping)
17 , fAnimation(std::move(animation)) {
18 fUniqueName.printf("%s_%s", name, fAnimation->getTag());
19}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

Member Function Documentation

◆ drawMPDPicture()

void SKPAnimationBench::drawMPDPicture ( )
inlineoverrideprotectedvirtual

Reimplemented from SKPBench.

Definition at line 37 of file SKPAnimationBench.h.

37 {
38 SK_ABORT("MPD not supported\n");
39 }
#define SK_ABORT(message,...)
Definition: SkAssert.h:70

◆ drawPicture()

void SKPAnimationBench::drawPicture ( )
overrideprotectedvirtual

Reimplemented from SKPBench.

Definition at line 31 of file SKPAnimationBench.cpp.

31 {
32 for (int j = 0; j < this->tileRects().size(); ++j) {
33 SkMatrix trans = SkMatrix::Translate(-1.f * this->tileRects()[j].fLeft,
34 -1.f * this->tileRects()[j].fTop);
35 fAnimation->preConcatFrameMatrix(fAnimationTime.nextRangeF(0, 1000), fDevBounds, &trans);
36 this->surfaces()[j]->getCanvas()->drawPicture(this->picture(), &trans, nullptr);
37 }
38
39 for (int j = 0; j < this->tileRects().size(); ++j) {
40 skgpu::Flush(this->surfaces()[j].get());
41 }
42}
const skia_private::TArray< sk_sp< SkSurface > > & surfaces() const
Definition: SKPBench.h:49
const SkPicture * picture() const
Definition: SKPBench.h:48
const SkTDArray< SkIRect > & tileRects() const
Definition: SKPBench.h:50
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
float nextRangeF(float min, float max)
Definition: SkRandom.h:64
int size() const
Definition: SkTDArray.h:138
const myers::Point & get(const myers::Segment &)
void Flush(SkSurface *surface)
Definition: GpuTools.h:25

◆ MakeZoomAnimation()

sk_sp< SKPAnimationBench::Animation > SKPAnimationBench::MakeZoomAnimation ( SkScalar  zoomMax,
double  zoomPeriodMs 
)
static

Definition at line 71 of file SKPAnimationBench.cpp.

72 {
73 return sk_make_sp<ZoomAnimation>(zoomMax, zoomPeriodMs);
74}

◆ onGetUniqueName()

const char * SKPAnimationBench::onGetUniqueName ( )
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 21 of file SKPAnimationBench.cpp.

21 {
22 return fUniqueName.c_str();
23}
const char * c_str() const
Definition: SkString.h:133

◆ onPerCanvasPreDraw()

void SKPAnimationBench::onPerCanvasPreDraw ( SkCanvas canvas)
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 25 of file SKPAnimationBench.cpp.

25 {
27 fDevBounds = canvas->getDeviceClipBounds();
28 SkAssertResult(!fDevBounds.isEmpty());
29}
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
void onPerCanvasPreDraw(SkCanvas *) override
Definition: SKPBench.cpp:56
SkIRect getDeviceClipBounds() const
Definition: SkCanvas.cpp:1607
bool isEmpty() const
Definition: SkRect.h:202

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