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

Public Member Functions

 BlurImageFilterBench (SkScalar sigmaX, SkScalar sigmaY, bool small, bool cropped, bool expanded)
 
- 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 onDelayedSetup () 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 61 of file BlurImageFilterBench.cpp.

Constructor & Destructor Documentation

◆ BlurImageFilterBench()

BlurImageFilterBench::BlurImageFilterBench ( SkScalar  sigmaX,
SkScalar  sigmaY,
bool  small,
bool  cropped,
bool  expanded 
)
inline

Definition at line 63 of file BlurImageFilterBench.cpp.

65 : fIsSmall(small)
66 , fIsCropped(cropped)
67 , fIsExpanded(expanded)
68 , fInitialized(false)
69 , fSigmaX(sigmaX)
70 , fSigmaY(sigmaY) {
71 fName.printf("blur_image_filter_%s%s%s_%.2f_%.2f",
72 fIsSmall ? "small" : "large",
73 fIsCropped ? "_cropped" : "",
74 fIsExpanded ? "_expanded" : "",
75 sigmaX, sigmaY);
76 SkASSERT(!fIsExpanded || fIsCropped); // never want expansion w/o cropping
77 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

Member Function Documentation

◆ onDelayedSetup()

void BlurImageFilterBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 84 of file BlurImageFilterBench.cpp.

84 {
85 if (!fInitialized) {
86 fCheckerboard = make_checkerboard(fIsSmall ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE,
88 fInitialized = true;
89 }
90 }
#define FILTER_WIDTH_SMALL
static sk_sp< SkImage > make_checkerboard(int width, int height)
#define FILTER_WIDTH_LARGE
#define FILTER_HEIGHT_SMALL
#define FILTER_HEIGHT_LARGE

◆ onDraw()

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

Implements Benchmark.

Definition at line 92 of file BlurImageFilterBench.cpp.

92 {
93 static const int kX = 0;
94 static const int kY = 0;
95 const SkIRect bmpRect = SkIRect::MakeXYWH(kX, kY, fCheckerboard->width(),
96 fCheckerboard->height());
97 const SkIRect bmpRectInset = bmpRect.makeInset(10, 10);
98
99 sk_sp<SkImageFilter> input = fIsExpanded
100 ? SkImageFilters::Offset(0, 0, nullptr, &bmpRectInset)
101 : nullptr;
102
103 const SkIRect* crop =
104 fIsExpanded ? &bmpRect : fIsCropped ? &bmpRectInset : nullptr;
106 paint.setImageFilter(SkImageFilters::Blur(fSigmaX, fSigmaY, std::move(input), crop));
108
109 for (int i = 0; i < loops; i++) {
110 canvas->drawImage(fCheckerboard, kX, kY, sampling, &paint);
111 }
112 }
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Offset(SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
int width() const
Definition: SkImage.h:285
int height() const
Definition: SkImage.h:291
const Paint & paint
Definition: color_source.cc:38
SkSamplingOptions sampling
Definition: SkRecords.h:337
Definition: SkRect.h:32
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104
SkIRect makeInset(int32_t dx, int32_t dy) const
Definition: SkRect.h:332

◆ onGetName()

const char * BlurImageFilterBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 80 of file BlurImageFilterBench.cpp.

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

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