Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Convexicator Struct Reference

Public Member Functions

SkPathFirstDirection getFirstDirection () const
 
void setMovePt (const SkPoint &pt)
 
bool addPt (const SkPoint &pt)
 
bool close ()
 
bool isFinite () const
 
int reversals () const
 

Static Public Member Functions

static SkPathConvexity BySign (const SkPoint points[], int count)
 

Detailed Description

Definition at line 2154 of file SkPath.cpp.

Member Function Documentation

◆ addPt()

bool Convexicator::addPt ( const SkPoint pt)
inline

Definition at line 2164 of file SkPath.cpp.

2164 {
2165 if (fLastPt == pt) {
2166 return true;
2167 }
2168 // should only be true for first non-zero vector after setMovePt was called. It is possible
2169 // we doubled backed at the start so need to check if fLastVec is zero or not.
2170 if (fFirstPt == fLastPt && fExpectedDir == kInvalid_DirChange && fLastVec.equals(0,0)) {
2171 fLastVec = pt - fLastPt;
2172 fFirstVec = fLastVec;
2173 } else if (!this->addVec(pt - fLastPt)) {
2174 return false;
2175 }
2176 fLastPt = pt;
2177 return true;
2178 }
@ kInvalid_DirChange
Definition SkPath.cpp:2150
bool equals(float x, float y) const

◆ BySign()

static SkPathConvexity Convexicator::BySign ( const SkPoint  points[],
int  count 
)
inlinestatic

Definition at line 2180 of file SkPath.cpp.

2180 {
2181 if (count <= 3) {
2182 // point, line, or triangle are always convex
2184 }
2185
2186 const SkPoint* last = points + count;
2187 SkPoint currPt = *points++;
2188 SkPoint firstPt = currPt;
2189 int dxes = 0;
2190 int dyes = 0;
2191 int lastSx = kValueNeverReturnedBySign;
2192 int lastSy = kValueNeverReturnedBySign;
2193 for (int outerLoop = 0; outerLoop < 2; ++outerLoop ) {
2194 while (points != last) {
2195 SkVector vec = *points - currPt;
2196 if (!vec.isZero()) {
2197 // give up if vector construction failed
2198 if (!vec.isFinite()) {
2200 }
2201 int sx = sign(vec.fX);
2202 int sy = sign(vec.fY);
2203 dxes += (sx != lastSx);
2204 dyes += (sy != lastSy);
2205 if (dxes > 3 || dyes > 3) {
2207 }
2208 lastSx = sx;
2209 lastSy = sy;
2210 }
2211 currPt = *points++;
2212 if (outerLoop) {
2213 break;
2214 }
2215 }
2216 points = &firstPt;
2217 }
2218 return SkPathConvexity::kConvex; // that is, it may be convex, don't know yet
2219 }
int count
static const int points[]
#define kValueNeverReturnedBySign
Definition SkPath.cpp:2142
static int sign(SkScalar x)
Definition SkPath.cpp:2141
bool isZero() const
float fX
x-axis value
bool isFinite() const
float fY
y-axis value

◆ close()

bool Convexicator::close ( )
inline

Definition at line 2221 of file SkPath.cpp.

2221 {
2222 // If this was an explicit close, there was already a lineTo to fFirstPoint, so this
2223 // addPt() is a no-op. Otherwise, the addPt implicitly closes the contour. In either case,
2224 // we have to check the direction change along the first vector in case it is concave.
2225 return this->addPt(fFirstPt) && this->addVec(fFirstVec);
2226 }
bool addPt(const SkPoint &pt)
Definition SkPath.cpp:2164

◆ getFirstDirection()

SkPathFirstDirection Convexicator::getFirstDirection ( ) const
inline

The direction returned is only valid if the path is determined convex

Definition at line 2157 of file SkPath.cpp.

2157{ return fFirstDirection; }

◆ isFinite()

bool Convexicator::isFinite ( ) const
inline

Definition at line 2228 of file SkPath.cpp.

2228 {
2229 return fIsFinite;
2230 }

◆ reversals()

int Convexicator::reversals ( ) const
inline

Definition at line 2232 of file SkPath.cpp.

2232 {
2233 return fReversals;
2234 }

◆ setMovePt()

void Convexicator::setMovePt ( const SkPoint pt)
inline

Definition at line 2159 of file SkPath.cpp.

2159 {
2160 fFirstPt = fLastPt = pt;
2161 fExpectedDir = kInvalid_DirChange;
2162 }

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