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

Public Member Functions

 PathIterBench (PathIterType t)
 
bool isSuitableFor (Backend backend) override
 
- 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 *) 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 38 of file PathIterBench.cpp.

Constructor & Destructor Documentation

◆ PathIterBench()

PathIterBench::PathIterBench ( PathIterType  t)
inline

Definition at line 47 of file PathIterBench.cpp.

47 : fType(t) {
48 fName.printf("pathiter_%s", gPathIterNames[static_cast<unsigned>(t)]);
49
50 SkRandom rand;
51 for (int i = 0; i < 1000; ++i) {
52 SkPoint pts[4];
53 int n = rand_pts(rand, pts);
54 switch (n) {
55 case 1:
56 fPath.moveTo(pts[0]);
57 break;
58 case 2:
59 fPath.lineTo(pts[1]);
60 break;
61 case 3:
62 fPath.quadTo(pts[1], pts[2]);
63 break;
64 case 4:
65 fPath.cubicTo(pts[1], pts[2], pts[3]);
66 break;
67 }
68 }
69 }
static int rand_pts(SkRandom &rand, SkPoint pts[4])
const char * gPathIterNames[]
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
Definition: SkPath.cpp:746
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
Definition: SkPath.cpp:799
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

Member Function Documentation

◆ isSuitableFor()

bool PathIterBench::isSuitableFor ( Backend  backend)
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 71 of file PathIterBench.cpp.

71 {
73 }
const char * backend

◆ onDraw()

void PathIterBench::onDraw ( int  loops,
SkCanvas  
)
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 80 of file PathIterBench.cpp.

80 {
81 // Need to do *something* with the results, so the compile doesn't elide
82 // away the code we want to time.
83 auto handle = [this](int verb, const SkPoint pts[]) {
84 fVerbInc += verb;
85 fXInc += pts[0].fX;
86 fYInc += pts[0].fY;
87 };
88
89 switch (fType) {
91 for (int i = 0; i < loops; ++i) {
92 SkPath::Iter iter(fPath, true);
93 SkPath::Verb verb;
94 SkPoint pts[4];
95 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
96 handle(verb, pts);
97 }
98 }
99 break;
101 for (int i = 0; i < loops; ++i) {
102 for (auto [verb, pts, w] : SkPathPriv::Iterate(fPath)) {
103 handle((SkPath::Verb)verb, pts);
104 }
105 }
106 break;
108 for (int i = 0; i < loops; ++i) {
109 SkPathEdgeIter iter(fPath);
110 while (auto r = iter.next()) {
111 handle((int)r.fEdge, r.fPts);
112 }
113 }
114 break;
115 }
116 }
@ kDone_Verb
Definition: SkPath.h:1472
SkScalar w

◆ onGetName()

const char * PathIterBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 76 of file PathIterBench.cpp.

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

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