Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Protected Member Functions | List of all members
PolyUtilsBench Class Referenceabstract
Inheritance diagram for PolyUtilsBench:
Benchmark SkRefCnt SkRefCntBase CirclePolyUtilsBench IceCreamPolyUtilsBench IntersectingPolyUtilsBench NotchPolyUtilsBench StarPolyUtilsBench

Public Types

enum class  Type {
  kConvexCheck , kSimpleCheck , kInsetConvex , kOffsetSimple ,
  kTessellateSimple
}
 
- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 

Public Member Functions

 PolyUtilsBench (Type type)
 
virtual void appendName (SkString *)=0
 
virtual void makePoly (SkTDArray< SkPoint > *poly)=0
 
virtual int complexity ()
 
- 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 ()
 

Detailed Description

Definition at line 19 of file PolyUtilsBench.cpp.

Member Enumeration Documentation

◆ Type

enum class PolyUtilsBench::Type
strong
Enumerator
kConvexCheck 
kSimpleCheck 
kInsetConvex 
kOffsetSimple 
kTessellateSimple 

Definition at line 23 of file PolyUtilsBench.cpp.

23{ kConvexCheck, kSimpleCheck, kInsetConvex, kOffsetSimple, kTessellateSimple };

Constructor & Destructor Documentation

◆ PolyUtilsBench()

PolyUtilsBench::PolyUtilsBench ( Type  type)
inline

Definition at line 25 of file PolyUtilsBench.cpp.

25: fType(type) {}
GLenum type

Member Function Documentation

◆ appendName()

virtual void PolyUtilsBench::appendName ( SkString )
pure virtual

◆ complexity()

virtual int PolyUtilsBench::complexity ( )
inlinevirtual

Definition at line 29 of file PolyUtilsBench.cpp.

29{ return 0; }

◆ makePoly()

virtual void PolyUtilsBench::makePoly ( SkTDArray< SkPoint > *  poly)
pure virtual

◆ onDraw()

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

Implements Benchmark.

Definition at line 55 of file PolyUtilsBench.cpp.

55 {
57 this->makePoly(&poly);
58 switch (fType) {
60 for (int i = 0; i < loops; i++) {
61 (void)SkIsConvexPolygon(poly.begin(), poly.size());
62 }
63 break;
65 for (int i = 0; i < loops; i++) {
66 (void)SkIsSimplePolygon(poly.begin(), poly.size());
67 }
68 break;
70 if (SkIsConvexPolygon(poly.begin(), poly.size())) {
72 for (int i = 0; i < loops; i++) {
73 (void)SkInsetConvexPolygon(poly.begin(), poly.size(), 10, &result);
74 (void)SkInsetConvexPolygon(poly.begin(), poly.size(), 40, &result);
75 }
76 }
77 break;
79 if (SkIsSimplePolygon(poly.begin(), poly.size())) {
82 bounds.setBounds(poly.begin(), poly.size());
83 for (int i = 0; i < loops; i++) {
84 (void)SkOffsetSimplePolygon(poly.begin(), poly.size(), bounds, 10,
85 &result);
86 (void)SkOffsetSimplePolygon(poly.begin(), poly.size(), bounds, -10,
87 &result);
88 }
89 }
90 break;
92 if (SkIsSimplePolygon(poly.begin(), poly.size())) {
93 AutoSTMalloc<64, uint16_t> indexMap(poly.size());
94 for (int i = 0; i < poly.size(); ++i) {
95 indexMap[i] = i;
96 }
97 SkTDArray<uint16_t> triangleIndices;
98 for (int i = 0; i < loops; i++) {
99 SkTriangulateSimplePolygon(poly.begin(), indexMap, poly.size(),
100 &triangleIndices);
101 }
102 }
103 break;
104 }
105 }
bool SkIsConvexPolygon(const SkPoint *polygonVerts, int polygonSize)
bool SkTriangulateSimplePolygon(const SkPoint *polygonVerts, uint16_t *indexMap, int polygonSize, SkTDArray< uint16_t > *triangleIndices)
bool SkOffsetSimplePolygon(const SkPoint *inputPolygonVerts, int inputPolygonSize, const SkRect &bounds, SkScalar offset, SkTDArray< SkPoint > *offsetPolygon, SkTDArray< int > *polygonIndices)
bool SkIsSimplePolygon(const SkPoint *polygon, int polygonSize)
bool SkInsetConvexPolygon(const SkPoint *inputPolygonVerts, int inputPolygonSize, SkScalar inset, SkTDArray< SkPoint > *insetPolygon)
virtual void makePoly(SkTDArray< SkPoint > *poly)=0
int size() const
Definition: SkTDArray.h:138
T * begin()
Definition: SkTDArray.h:150
GAsyncResult * result
Optional< SkRect > bounds
Definition: SkRecords.h:189

◆ onGetName()

const char * PolyUtilsBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 32 of file PolyUtilsBench.cpp.

32 {
33 fName = "poly_utils_";
34 this->appendName(&fName);
35 switch (fType) {
37 fName.append("_c");
38 break;
40 fName.append("_s");
41 break;
43 fName.append("_i");
44 break;
46 fName.append("_o");
47 break;
49 fName.append("_t");
50 break;
51 }
52 return fName.c_str();
53 }
virtual void appendName(SkString *)=0
void append(const char text[])
Definition: SkString.h:203
const char * c_str() const
Definition: SkString.h:133

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