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

Public Member Functions

 DashGridBench (int dashLength, int strokeWidth, bool doAA)
 
- 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 373 of file DashBench.cpp.

Constructor & Destructor Documentation

◆ DashGridBench()

DashGridBench::DashGridBench ( int  dashLength,
int  strokeWidth,
bool  doAA 
)
inline

Definition at line 381 of file DashBench.cpp.

381 {
382 fName.printf("dashgrid_%d_%d%s", dashLength, strokeWidth, doAA ? "_aa" : "_bw");
383 fStrokeWidth = strokeWidth;
384 fDoAA = doAA;
385
386 SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) };
387 fPathEffect = SkDashPathEffect::Make(vals, 2, SK_Scalar1);
388 }
static const int strokeWidth
Definition: BlurTest.cpp:60
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
float SkScalar
Definition: extension.cpp:12

Member Function Documentation

◆ onDraw()

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

Implements Benchmark.

Definition at line 395 of file DashBench.cpp.

395 {
396 SkPaint p;
397 this->setupPaint(&p);
398 p.setColor(SK_ColorBLACK);
399 p.setStyle(SkPaint::kStroke_Style);
400 p.setStrokeWidth(SkIntToScalar(fStrokeWidth));
401 p.setPathEffect(fPathEffect);
402 p.setAntiAlias(fDoAA);
403
404 SkPoint pts[4] = {
405 { SkIntToScalar(0), 20.5f },
406 { SkIntToScalar(20), 20.5f },
407 { 20.5f, SkIntToScalar(0) },
408 { 20.5f, SkIntToScalar(20) }
409 };
410
411 for (int i = 0; i < loops; ++i) {
412 for (int j = 0; j < 10; ++j) {
413 for (int k = 0; k < 10; ++k) {
414 // Horizontal line
415 SkPoint horPts[2];
416 horPts[0].fX = pts[0].fX + k * 22.f;
417 horPts[0].fY = pts[0].fY + j * 22.f;
418 horPts[1].fX = pts[1].fX + k * 22.f;
419 horPts[1].fY = pts[1].fY + j * 22.f;
420 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, horPts, p);
421
422 // Vertical line
423 SkPoint vertPts[2];
424 vertPts[0].fX = pts[2].fX + k * 22.f;
425 vertPts[0].fY = pts[2].fY + j * 22.f;
426 vertPts[1].fX = pts[3].fX + k * 22.f;
427 vertPts[1].fY = pts[3].fY + j * 22.f;
428 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, vertPts, p);
429 }
430 }
431 }
432 }
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
virtual void setupPaint(SkPaint *paint)
Definition: Benchmark.cpp:55
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Definition: SkCanvas.cpp:1710
@ kLines_PointMode
draw each pair of points as a line segment
Definition: SkCanvas.h:1242
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165

◆ onGetName()

const char * DashGridBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 391 of file DashBench.cpp.

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

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