Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
skgpu::tess::MidpointContourParser Class Reference

#include <MidpointContourParser.h>

Public Member Functions

 MidpointContourParser (const SkPath &path)
 
bool parseNextContour ()
 
SkPathPriv::Iterate currentContour ()
 
SkPoint currentMidpoint ()
 

Detailed Description

Definition at line 29 of file MidpointContourParser.h.

Constructor & Destructor Documentation

◆ MidpointContourParser()

skgpu::tess::MidpointContourParser::MidpointContourParser ( const SkPath path)
inline

Definition at line 31 of file MidpointContourParser.h.

32 : fPath(path)
33 , fVerbs(SkPathPriv::VerbData(fPath))
34 , fNumRemainingVerbs(fPath.countVerbs())
35 , fPoints(SkPathPriv::PointData(fPath))
36 , fWeights(SkPathPriv::ConicWeightData(fPath)) {}
static const uint8_t * VerbData(const SkPath &path)
Definition SkPathPriv.h:198
static const SkScalar * ConicWeightData(const SkPath &path)
Definition SkPathPriv.h:213
static const SkPoint * PointData(const SkPath &path)
Definition SkPathPriv.h:203
int countVerbs() const
Definition SkPath.cpp:546

Member Function Documentation

◆ currentContour()

SkPathPriv::Iterate skgpu::tess::MidpointContourParser::currentContour ( )
inline

Definition at line 85 of file MidpointContourParser.h.

85 {
86 return SkPathPriv::Iterate(fVerbs, fVerbs + fVerbsIdx, fPoints, fWeights);
87 }

◆ currentMidpoint()

SkPoint skgpu::tess::MidpointContourParser::currentMidpoint ( )
inline

Definition at line 89 of file MidpointContourParser.h.

89{ return fMidpoint * (1.f / fMidpointWeight); }

◆ parseNextContour()

bool skgpu::tess::MidpointContourParser::parseNextContour ( )
inline

Definition at line 39 of file MidpointContourParser.h.

39 {
40 bool hasGeometry = false;
41 for (; fVerbsIdx < fNumRemainingVerbs; ++fVerbsIdx) {
42 switch (fVerbs[fVerbsIdx]) {
44 if (!hasGeometry) {
45 fMidpoint = {0,0};
46 fMidpointWeight = 0;
47 this->advance(); // Resets fPtsIdx to 0 and advances fPoints.
48 fPtsIdx = 1; // Increment fPtsIdx past the kMove.
49 continue;
50 }
51 if (fPoints[0] != fPoints[fPtsIdx - 1]) {
52 // There's an implicit close at the end. Add the start point to our mean.
53 fMidpoint += fPoints[0];
54 ++fMidpointWeight;
55 }
56 return true;
57 default:
58 continue;
60 ++fPtsIdx;
61 break;
63 ++fWtsIdx;
64 [[fallthrough]];
66 fPtsIdx += 2;
67 break;
69 fPtsIdx += 3;
70 break;
71 }
72 fMidpoint += fPoints[fPtsIdx - 1];
73 ++fMidpointWeight;
74 hasGeometry = true;
75 }
76 if (hasGeometry && fPoints[0] != fPoints[fPtsIdx - 1]) {
77 // There's an implicit close at the end. Add the start point to our mean.
78 fMidpoint += fPoints[0];
79 ++fMidpointWeight;
80 }
81 return hasGeometry;
82 }
@ kMove_Verb
Definition SkPath.h:1458
@ kConic_Verb
Definition SkPath.h:1461
@ kCubic_Verb
Definition SkPath.h:1462
@ kQuad_Verb
Definition SkPath.h:1460
@ kLine_Verb
Definition SkPath.h:1459

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