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

Public Member Functions

 VertBench (unsigned flags)
 
- 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 33 of file VertBench.cpp.

Constructor & Destructor Documentation

◆ VertBench()

VertBench::VertBench ( unsigned  flags)
inline

Definition at line 67 of file VertBench.cpp.

67 : fFlags(flags) {
68 const SkScalar dx = SkIntToScalar(W) / COL;
69 const SkScalar dy = SkIntToScalar(H) / COL;
70
71 SkPoint* pts = fPts;
72 uint16_t* idx = fIdx;
73
74 SkScalar yy = 0;
75 for (int y = 0; y <= ROW; y++) {
76 SkScalar xx = 0;
77 for (int x = 0; x <= COL; ++x) {
78 pts->set(xx, yy);
79 pts += 1;
80 xx += dx;
81
82 if (x < COL && y < ROW) {
83 load_2_tris(idx, x, y, COL + 1);
84 for (int i = 0; i < 6; i++) {
85 SkASSERT(idx[i] < PTS);
86 }
87 idx += 6;
88 }
89 }
90 yy += dy;
91 }
92 SkASSERT(PTS == pts - fPts);
93 SkASSERT(IDX == idx - fIdx);
94
95 // We want to store texs in a separate array, so the blitters don't "cheat" and
96 // skip the (normal) step of computing the new local-matrix. This is the common case
97 // we think in the wild (where the texture coordinates are different from the positions.
98 memcpy(fTex, fPts, sizeof(fPts));
99
100 SkRandom rand;
101 for (int i = 0; i < PTS; ++i) {
102 fColors[i] = rand.nextU() | (0xFF << 24);
103 }
104
105 fName.set("verts");
106 if (fFlags & kTexture_VertFlag) {
107 fName.append("_textures");
108 }
109 if (fFlags & kColors_VertFlag) {
110 fName.append("_colors");
111 }
112 if (fFlags & kPersp_VertFlag) {
113 fName.append("_persp");
114 }
115 if (fFlags & kBilerp_VertFlag) {
116 fName.append("_bilerp");
117 }
118 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkIntToScalar(x)
Definition: SkScalar.h:57
@ kColors_VertFlag
Definition: VertBench.cpp:27
@ kTexture_VertFlag
Definition: VertBench.cpp:28
@ kBilerp_VertFlag
Definition: VertBench.cpp:30
@ kPersp_VertFlag
Definition: VertBench.cpp:29
uint32_t nextU()
Definition: SkRandom.h:42
void set(const SkString &src)
Definition: SkString.h:186
void append(const char text[])
Definition: SkString.h:203
float SkScalar
Definition: extension.cpp:12
FlutterSemanticsFlag flags
double y
double x
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
Definition: SkMD5.cpp:130
void set(float x, float y)
Definition: SkPoint_impl.h:200

Member Function Documentation

◆ onDraw()

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

Implements Benchmark.

Definition at line 122 of file VertBench.cpp.

122 {
124 this->setupPaint(&paint);
125 paint.setShader(fShader);
126
127 if (fFlags & kPersp_VertFlag) {
128 tiny_persp_effect(canvas);
129 }
130
131 const SkPoint* texs = (fFlags & kTexture_VertFlag) ? fTex : nullptr;
132 const SkColor* cols = (fFlags & kColors_VertFlag) ? fColors : nullptr;
134 fPts, texs, cols, IDX, fIdx);
135 for (int i = 0; i < loops; i++) {
137 }
138 }
@ kModulate
r = s*d
uint32_t SkColor
Definition: SkColor.h:37
static void tiny_persp_effect(SkCanvas *canvas)
Definition: VertBench.cpp:19
virtual void setupPaint(SkPaint *paint)
Definition: Benchmark.cpp:55
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
Definition: SkCanvas.cpp:1720
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
Definition: SkVertices.cpp:200
@ kTriangles_VertexMode
Definition: SkVertices.h:31
const Paint & paint
Definition: color_source.cc:38
PODArray< SkRect > texs
Definition: SkRecords.h:333

◆ onGetName()

const char * VertBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 121 of file VertBench.cpp.

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

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