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

Public Member Functions

 BlurBench (SkScalar rad, SkBlurStyle bs)
 
- 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 32 of file BlurBench.cpp.

Constructor & Destructor Documentation

◆ BlurBench()

BlurBench::BlurBench ( SkScalar  rad,
SkBlurStyle  bs 
)
inline

Definition at line 38 of file BlurBench.cpp.

38 {
39 fRadius = rad;
40 fStyle = bs;
41 const char* name = rad > 0 ? gStyleName[bs] : "none";
42 const char* quality = "high_quality";
43 if (SkScalarFraction(rad) != 0) {
44 fName.printf("blur_%.2f_%s_%s", rad, name, quality);
45 } else {
46 fName.printf("blur_%d_%s_%s", SkScalarRoundToInt(rad), name, quality);
47 }
48 }
static const char * gStyleName[]
Definition: BlurBench.cpp:25
#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 BlurBench::onDraw ( int  loops,
SkCanvas canvas 
)
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 55 of file BlurBench.cpp.

55 {
57 this->setupPaint(&paint);
58
59 paint.setAntiAlias(true);
60
61 SkRandom rand;
62 for (int i = 0; i < loops; i++) {
63 SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400,
64 rand.nextUScalar1() * 400);
65 r.offset(fRadius, fRadius);
66
67 if (fRadius > 0) {
68 paint.setMaskFilter(SkMaskFilter::MakeBlur(fStyle,
70 }
71 canvas->drawOval(r, paint);
72 }
73 }
virtual void setupPaint(SkPaint *paint)
Definition: Benchmark.cpp:55
static SkScalar SK_SPI ConvertRadiusToSigma(SkScalar radius)
Definition: SkBlurMask.cpp:39
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
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 * BlurBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 51 of file BlurBench.cpp.

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

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