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

Public Member Functions

 MatrixConvolutionBench (bool bigKernel, SkTileMode tileMode, bool convolveAlpha)
 
- 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 17 of file MatrixConvolutionBench.cpp.

Constructor & Destructor Documentation

◆ MatrixConvolutionBench()

MatrixConvolutionBench::MatrixConvolutionBench ( bool  bigKernel,
SkTileMode  tileMode,
bool  convolveAlpha 
)
inline

Definition at line 19 of file MatrixConvolutionBench.cpp.

20 : fName(SkStringPrintf("matrixconvolution_%s%s%s",
21 bigKernel ? "bigKernel_" : "",
23 convolveAlpha ? "" : "_noConvolveAlpha")) {
24 if (bigKernel) {
25 SkISize kernelSize = SkISize::Make(9, 9);
26 SkScalar kernel[81];
27 for (int i = 0; i < 81; i++) {
28 kernel[i] = SkIntToScalar(1);
29 }
30 kernel[40] = SkIntToScalar(-79);
31 SkScalar gain = 0.3f, bias = SkIntToScalar(100);
32 SkIPoint kernelOffset = SkIPoint::Make(4, 4);
33 fFilter = SkImageFilters::MatrixConvolution(kernelSize, kernel, gain, bias,
34 kernelOffset, tileMode, convolveAlpha,
35 nullptr);
36 } else {
37 SkISize kernelSize = SkISize::Make(3, 3);
38 SkScalar kernel[9] = {
42 };
43 SkScalar gain = 0.3f, bias = SkIntToScalar(100);
44 SkIPoint kernelOffset = SkIPoint::Make(1, 1);
45 fFilter = SkImageFilters::MatrixConvolution(kernelSize, kernel, gain, bias,
46 kernelOffset, tileMode, convolveAlpha,
47 nullptr);
48 }
49 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
static sk_sp< SkImageFilter > MatrixConvolution(const SkISize &kernelSize, const SkScalar kernel[], SkScalar gain, SkScalar bias, const SkIPoint &kernelOffset, SkTileMode tileMode, bool convolveAlpha, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
float SkScalar
Definition: extension.cpp:12
const char * tilemode_name(SkTileMode mode)
Definition: ToolUtils.cpp:129
static constexpr SkIPoint Make(int32_t x, int32_t y)
Definition: SkPoint_impl.h:38
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

Member Function Documentation

◆ onDraw()

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

Implements Benchmark.

Definition at line 56 of file MatrixConvolutionBench.cpp.

56 {
58 this->setupPaint(&paint);
59 paint.setImageFilter(fFilter);
60 paint.setAntiAlias(true);
61
62 SkRandom rand;
63 for (int i = 0; i < loops; i++) {
64 SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400,
65 rand.nextUScalar1() * 400);
66 canvas->drawOval(r, paint);
67 }
68 }
virtual void setupPaint(SkPaint *paint)
Definition: Benchmark.cpp:55
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
SkScalar nextUScalar1()
Definition: SkRandom.h:101
const Paint & paint
Definition: color_source.cc:38
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onGetName()

const char * MatrixConvolutionBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 52 of file MatrixConvolutionBench.cpp.

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

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