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

#include <StrokeIterator.h>

Public Types

enum class  Verb {
  kLine = (int)SkPathVerb::kLine , kQuad = (int)SkPathVerb::kQuad , kConic = (int)SkPathVerb::kConic , kCubic = (int)SkPathVerb::kCubic ,
  kCircle , kMoveWithinContour , kContourFinished
}
 

Public Member Functions

 StrokeIterator (const SkPath &path, const SkStrokeRec *stroke, const SkMatrix *viewMatrix)
 
bool next ()
 
Verb prevVerb () const
 
const SkPointprevPts () const
 
Verb verb () const
 
const SkPointpts () const
 
float w () const
 
Verb firstVerbInContour () const
 
const SkPointfirstPtsInContour () const
 

Static Public Member Functions

static constexpr bool IsVerbGeometric (Verb verb)
 

Detailed Description

Definition at line 39 of file StrokeIterator.h.

Member Enumeration Documentation

◆ Verb

Enumerator
kLine 
kQuad 
kConic 
kCubic 
kCircle 
kMoveWithinContour 
kContourFinished 

Definition at line 48 of file StrokeIterator.h.

48 {
49 // Verbs that describe stroke geometry.
54 kCircle, // A stroke-width circle drawn as a 180-degree point stroke.
55
56 // Helper verbs that notify callers to update their own iteration state.
59 };
@ kCubic
SkPath::RawIter returns 4 points.
@ kConic
SkPath::RawIter returns 3 points + 1 weight.
@ kQuad
SkPath::RawIter returns 3 points.
@ kLine
SkPath::RawIter returns 2 points.
Type::kYUV Type::kRGBA() int(0.7 *637)

Constructor & Destructor Documentation

◆ StrokeIterator()

skgpu::tess::StrokeIterator::StrokeIterator ( const SkPath path,
const SkStrokeRec stroke,
const SkMatrix viewMatrix 
)
inline

Definition at line 41 of file StrokeIterator.h.

42 : fViewMatrix(viewMatrix), fStroke(stroke) {
43 SkPathPriv::Iterate it(path);
44 fIter = it.begin();
45 fEnd = it.end();
46 }

Member Function Documentation

◆ firstPtsInContour()

const SkPoint * skgpu::tess::StrokeIterator::firstPtsInContour ( ) const
inline

Definition at line 138 of file StrokeIterator.h.

138 {
139 SkASSERT(fQueueCount > 0);
140 return fFirstPtsInContour;
141 }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ firstVerbInContour()

Verb skgpu::tess::StrokeIterator::firstVerbInContour ( ) const
inline

Definition at line 137 of file StrokeIterator.h.

137{ SkASSERT(fQueueCount > 0); return fFirstVerbInContour; }

◆ IsVerbGeometric()

static constexpr bool skgpu::tess::StrokeIterator::IsVerbGeometric ( Verb  verb)
inlinestaticconstexpr

Definition at line 60 of file StrokeIterator.h.

◆ next()

bool skgpu::tess::StrokeIterator::next ( )
inline

Definition at line 64 of file StrokeIterator.h.

64 {
65 if (fQueueCount) {
66 SkASSERT(fQueueCount >= 2);
67 this->popFront();
68 if (fQueueCount >= 2) {
69 return true;
70 }
71 SkASSERT(fQueueCount == 1);
72 if (this->atVerb(0) == Verb::kContourFinished) {
73 // Don't let "kContourFinished" be prevVerb at the start of the next contour.
74 fQueueCount = 0;
75 }
76 }
77 for (; fIter != fEnd; ++fIter) {
78 SkASSERT(fQueueCount == 0 || fQueueCount == 1);
79 auto [verb, pts, w] = *fIter;
80 switch (verb) {
82 if (!this->finishOpenContour()) {
83 continue;
84 }
85 break;
87 if (pts[3] == pts[2]) {
88 [[fallthrough]]; // i.e., "if (p3 == p2 && p2 == p1 && p1 == p0)"
91 if (pts[2] == pts[1]) {
92 [[fallthrough]]; // i.e., "if (p2 == p1 && p1 == p0)"
94 if (pts[1] == pts[0]) {
95 fLastDegenerateStrokePt = pts;
96 continue;
97 }}}
98 this->enqueue((Verb)verb, pts, w);
99 if (fQueueCount == 1) {
100 // Defer the first verb until the end when we know what it's joined to.
101 fFirstVerbInContour = (Verb)verb;
102 fFirstPtsInContour = pts;
103 fFirstWInContour = w;
104 continue;
105 }
106 break;
108 if (!fQueueCount) {
109 fLastDegenerateStrokePt = pts;
110 continue;
111 }
112 if (pts[0] != fFirstPtsInContour[0]) {
113 // Draw a line back to the contour's starting point.
114 fClosePts = {pts[0], fFirstPtsInContour[0]};
115 this->enqueue(Verb::kLine, fClosePts.data(), nullptr);
116 }
117 // Repeat the first verb, this time as the "current" stroke instead of the prev.
118 this->enqueue(fFirstVerbInContour, fFirstPtsInContour, fFirstWInContour);
119 this->enqueue(Verb::kContourFinished, nullptr, nullptr);
120 fLastDegenerateStrokePt = nullptr;
121 break;
122 }
123 SkASSERT(fQueueCount >= 2);
124 ++fIter;
125 return true;
126 }
127 return this->finishOpenContour();
128 }
@ kClose
SkPath::RawIter returns 0 points.
@ kMove
SkPath::RawIter returns 1 point.
const SkPoint * pts() const

◆ prevPts()

const SkPoint * skgpu::tess::StrokeIterator::prevPts ( ) const
inline

Definition at line 131 of file StrokeIterator.h.

131{ return this->atPts(0); }

◆ prevVerb()

Verb skgpu::tess::StrokeIterator::prevVerb ( ) const
inline

Definition at line 130 of file StrokeIterator.h.

130{ return this->atVerb(0); }

◆ pts()

const SkPoint * skgpu::tess::StrokeIterator::pts ( ) const
inline

Definition at line 134 of file StrokeIterator.h.

134{ return this->atPts(1); }

◆ verb()

Verb skgpu::tess::StrokeIterator::verb ( ) const
inline

Definition at line 133 of file StrokeIterator.h.

133{ return this->atVerb(1); }

◆ w()

float skgpu::tess::StrokeIterator::w ( ) const
inline

Definition at line 135 of file StrokeIterator.h.

135{ return this->atW(1); }

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