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

Public Member Functions

 ConstXTileBench (SkTileMode xTile, SkTileMode yTile, SkFilterMode fm, bool doTrans, bool doScale)
 
- 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 30 of file TileBench.cpp.

Constructor & Destructor Documentation

◆ ConstXTileBench()

ConstXTileBench::ConstXTileBench ( SkTileMode  xTile,
SkTileMode  yTile,
SkFilterMode  fm,
bool  doTrans,
bool  doScale 
)
inline

Definition at line 32 of file TileBench.cpp.

37 : fFilterMode{fm}
38 , fXTile{xTile}
39 , fYTile{yTile}
40 , fDoTrans{doTrans}
41 , fDoScale{doScale} {
42 fName.printf("constXTile_");
43
44 static const char* gTileModeStr[kSkTileModeCount] = { "C", "R", "M", "D" };
45 fName.append(gTileModeStr[(unsigned)xTile]);
46 fName.append(gTileModeStr[(unsigned)yTile]);
47
48 if (fm != SkFilterMode::kNearest) {
49 fName.append("_filter");
50 }
51
52 if (doTrans) {
53 fName.append("_trans");
54 }
55
56 if (doScale) {
57 fName.append("_scale");
58 }
59 }
static constexpr int kSkTileModeCount
Definition: SkTileMode.h:39
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
void append(const char text[])
Definition: SkString.h:203

Member Function Documentation

◆ onDelayedSetup()

void ConstXTileBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 66 of file TileBench.cpp.

66 {
67 SkBitmap bm;
68
69 bm.allocN32Pixels(kWidth, kHeight, true);
71
72 create_gradient(&bm);
73
74 fPaint.setShader(bm.makeShader(fXTile, fYTile, SkSamplingOptions(fFilterMode)));
75 }
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void create_gradient(SkBitmap *bm)
Definition: TileBench.cpp:15
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkBitmap.cpp:669
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
void eraseColor(SkColor4f) const
Definition: SkBitmap.cpp:442
void setShader(sk_sp< SkShader > shader)

◆ onDraw()

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

Implements Benchmark.

Definition at line 77 of file TileBench.cpp.

77 {
78 SkPaint paint(fPaint);
79 this->setupPaint(&paint);
80 if (fDoTrans) {
81 paint.setColor(SkColorSetARGB(0x80, 0xFF, 0xFF, 0xFF));
82 }
83
84 SkRect r;
85
86 if (fDoScale) {
87 r = SkRect::MakeWH(SkIntToScalar(2 * 640), SkIntToScalar(2 * 480));
89 } else {
91 }
92
93 SkPaint bgPaint;
94 bgPaint.setColor(SK_ColorWHITE);
95
96 for (int i = 0; i < loops; i++) {
97 if (fDoTrans) {
98 canvas->drawRect(r, bgPaint);
99 }
100
101 canvas->drawRect(r, paint);
102 }
103 }
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
#define SK_ScalarHalf
Definition: SkScalar.h:19
#define SkIntToScalar(x)
Definition: SkScalar.h:57
virtual void setupPaint(SkPaint *paint)
Definition: Benchmark.cpp:55
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void setColor(SkColor color)
Definition: SkPaint.cpp:119
const Paint & paint
Definition: color_source.cc:38
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onGetName()

const char * ConstXTileBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 62 of file TileBench.cpp.

62 {
63 return fName.c_str();
64 }
const char * c_str() const
Definition: SkString.h:133

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