Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
MorphologyBench Class Reference
Inheritance diagram for MorphologyBench:
Benchmark SkRefCnt SkRefCntBase

Public Member Functions

 MorphologyBench (SkScalar rad, MorphologyType style)
 
- 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
 
void onDraw (int loops, SkCanvas *canvas) 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 30 of file MorphologyBench.cpp.

Constructor & Destructor Documentation

◆ MorphologyBench()

MorphologyBench::MorphologyBench ( SkScalar  rad,
MorphologyType  style 
)
inline

Definition at line 36 of file MorphologyBench.cpp.

36 {
37 fRadius = rad;
38 fStyle = style;
39 const char* name = rad > 0 ? gStyleName[style] : "none";
40 if (SkScalarFraction(rad) != 0) {
41 fName.printf("morph_%.2f_%s", rad, name);
42 } else {
43 fName.printf("morph_%d_%s", SkScalarRoundToInt(rad), name);
44 }
45 }
static const char * gStyleName[]
#define SkScalarRoundToInt(x)
Definition: SkScalar.h:37
static SkScalar SkScalarFraction(SkScalar x)
Definition: SkScalar.h:67
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

◆ onDraw()

void MorphologyBench::onDraw ( int  loops,
SkCanvas canvas 
)
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 52 of file MorphologyBench.cpp.

52 {
54 this->setupPaint(&paint);
55
56 paint.setAntiAlias(true);
57
58 SkRandom rand;
59 for (int i = 0; i < loops; i++) {
60 SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400,
61 rand.nextUScalar1() * 400);
62 r.offset(fRadius, fRadius);
63
64 if (fRadius > 0) {
66 switch (fStyle) {
67 case kDilate_MT:
69 SkScalarFloorToInt(fRadius), SkScalarFloorToInt(fRadius), nullptr);
70 break;
71 case kErode_MT:
73 SkScalarFloorToInt(fRadius), SkScalarFloorToInt(fRadius), nullptr);
74 break;
75 }
76 paint.setImageFilter(std::move(mf));
77 }
78 canvas->drawOval(r, paint);
79 }
80 }
@ kErode_MT
@ kDilate_MT
#define SkScalarFloorToInt(x)
Definition: SkScalar.h:35
virtual void setupPaint(SkPaint *paint)
Definition: Benchmark.cpp:55
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
static sk_sp< SkImageFilter > Erode(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
SkScalar nextUScalar1()
Definition: SkRandom.h:101
const Paint & paint
Definition: color_source.cc:38
void offset(float dx, float dy)
Definition: SkRect.h:1016
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onGetName()

const char * MorphologyBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 48 of file MorphologyBench.cpp.

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

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