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

Public Member Functions

 RotRectBench (bool aa, ColorType ct, SkBlendMode mode, bool perspective=false)
 
- 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 72 of file RotatedRectBench.cpp.

Constructor & Destructor Documentation

◆ RotRectBench()

RotRectBench::RotRectBench ( bool  aa,
ColorType  ct,
SkBlendMode  mode,
bool  perspective = false 
)
inline

Definition at line 74 of file RotatedRectBench.cpp.

75 : fAA(aa)
76 , fPerspective(perspective)
77 , fColorType(ct)
78 , fMode(mode) {
79 this->makeName();
80 }
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

Member Function Documentation

◆ onDraw()

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

Implements Benchmark.

Definition at line 85 of file RotatedRectBench.cpp.

85 {
87 paint.setAntiAlias(fAA);
88 paint.setBlendMode(fMode);
89 SkColor color = start_color(fColorType);
90
91 int w = this->getSize().width();
92 int h = this->getSize().height();
93
94 static const SkScalar kRectW = 25.1f;
95 static const SkScalar kRectH = 25.9f;
96
97 if (fColorType == kShaderOpaque_ColorType) {
98 // The only requirement for the shader is that it requires local coordinates
99 SkPoint pts[2] = { {0.0f, 0.0f}, {kRectW, kRectH} };
101 paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2,
103 }
104
106 // This value was chosen so that we frequently hit the axis-aligned case.
107 rotate.setRotate(30.f, kRectW / 2, kRectH / 2);
108 SkMatrix m = rotate;
109
110 SkScalar tx = 0, ty = 0;
111
112 if (fPerspective) {
113 // Apply some fixed perspective to change how ops may draw the rects
114 SkMatrix perspective;
115 perspective.setIdentity();
116 perspective.setPerspX(1e-4f);
117 perspective.setPerspY(1e-3f);
118 perspective.setSkewX(0.1f);
119 canvas->concat(perspective);
120 }
121
122 for (int i = 0; i < loops; ++i) {
123 canvas->save();
124 canvas->translate(tx, ty);
125 canvas->concat(m);
126 paint.setColor(color);
127 color = advance_color(color, fColorType, i);
128
129 canvas->drawRect(SkRect::MakeWH(kRectW, kRectH), paint);
130 canvas->restore();
131
132 tx += kRectW + 2;
133 if (tx > w) {
134 tx = 0;
135 ty += kRectH + 2;
136 if (ty > h) {
137 ty = 0;
138 }
139 }
140
141 m.postConcat(rotate);
142 }
143 }
@ kShaderOpaque_ColorType
static SkColor start_color(ColorType ct)
static SkColor advance_color(SkColor old, ColorType ct, int step)
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
static bool rotate(const SkDCubic &cubic, int zero, int index, SkDCubic &rotPath)
SkISize getSize()
Definition: Benchmark.cpp:26
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
SkMatrix & setSkewX(SkScalar v)
Definition: SkMatrix.h:518
SkMatrix & setPerspX(SkScalar v)
Definition: SkMatrix.h:537
SkMatrix & setPerspY(SkScalar v)
Definition: SkMatrix.h:544
SkMatrix & setIdentity()
Definition: SkMatrix.h:626
const Paint & paint
Definition: color_source.cc:38
DlColor color
float SkScalar
Definition: extension.cpp:12
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkScalar w
SkScalar h
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onGetName()

const char * RotRectBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 83 of file RotatedRectBench.cpp.

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

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