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

Public Member Functions

 FilteringBench (SkFilterMode fm, SkMipmapMode mm)
 
- 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 17 of file FilteringBench.cpp.

Constructor & Destructor Documentation

◆ FilteringBench()

FilteringBench::FilteringBench ( SkFilterMode  fm,
SkMipmapMode  mm 
)
inline

Definition at line 19 of file FilteringBench.cpp.

19 : fSampling(fm, mm) {
20 fName.printf("samplingoptions_filter_%d_mipmap_%d", (int)fm, (int)mm);
21 }
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

Member Function Documentation

◆ onDelayedSetup()

void FilteringBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 28 of file FilteringBench.cpp.

28 {
29 auto img = ToolUtils::GetResourceAsImage("images/ship.png");
30 // need to force raster since lazy doesn't support filteroptions yet
31 img = img->makeRasterImage();
32
33 fRect = SkRect::MakeIWH(img->width(), img->height());
34 fShader = img->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, fSampling);
35 }
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition: DecodeUtils.h:25
static SkRect MakeIWH(int w, int h)
Definition: SkRect.h:623

◆ onDraw()

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

Implements Benchmark.

Definition at line 37 of file FilteringBench.cpp.

37 {
38 // scale so we will trigger lerping between levels if we mipmapping
39 canvas->scale(0.75f, 0.75f);
40
42 paint.setShader(fShader);
43 for (int i = 0; i < loops; ++i) {
44 for (int j = 0; j < 10; ++j) {
45 canvas->drawRect(fRect, paint);
46 }
47 }
48 }
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
const Paint & paint
Definition: color_source.cc:38

◆ onGetName()

const char * FilteringBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 24 of file FilteringBench.cpp.

24 {
25 return fName.c_str();
26 }
const char * c_str() const
Definition: SkString.h:133

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