Flutter Engine
The Flutter Engine
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 2218 of file SkPath.cpp.

Member Function Documentation

◆ addPt()

bool Convexicator::addPt ( const SkPoint pt)
inline

Definition at line 2228 of file SkPath.cpp.

2228 {
2229 if (fLastPt == pt) {
2230 return true;
2231 }
2232 // should only be true for first non-zero vector after setMovePt was called. It is possible
2233 // we doubled backed at the start so need to check if fLastVec is zero or not.
2234 if (fFirstPt == fLastPt && fExpectedDir == kInvalid_DirChange && fLastVec.equals(0,0)) {
2235 fLastVec = pt - fLastPt;
2236 fFirstVec = fLastVec;
2237 } else if (!this->addVec(pt - fLastPt)) {
2238 return false;
2239 }
2240 fLastPt = pt;
2241 return true;
2242 }
@ kInvalid_DirChange
Definition: SkPath.cpp:2214
bool equals(float x, float y) const
Definition: SkPoint_impl.h:422

◆ BySign()

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

Definition at line 2244 of file SkPath.cpp.

2244 {
2245 if (count <= 3) {
2246 // point, line, or triangle are always convex
2248 }
2249
2250 const SkPoint* last = points + count;
2251 SkPoint currPt = *points++;
2252 SkPoint firstPt = currPt;
2253 int dxes = 0;
2254 int dyes = 0;
2255 int lastSx = kValueNeverReturnedBySign;
2256 int lastSy = kValueNeverReturnedBySign;
2257 for (int outerLoop = 0; outerLoop < 2; ++outerLoop ) {
2258 while (points != last) {
2259 SkVector vec = *points - currPt;
2260 if (!vec.isZero()) {
2261 // give up if vector construction failed
2262 if (!vec.isFinite()) {
2264 }
2265 int sx = sign(vec.fX);
2266 int sy = sign(vec.fY);
2267 dxes += (sx != lastSx);
2268 dyes += (sy != lastSy);
2269 if (dxes > 3 || dyes > 3) {
2271 }
2272 lastSx = sx;
2273 lastSy = sy;
2274 }
2275 currPt = *points++;
2276 if (outerLoop) {
2277 break;
2278 }
2279 }
2280 points = &firstPt;
2281 }
2282 return SkPathConvexity::kConvex; // that is, it may be convex, don't know yet
2283 }
int count
Definition: FontMgrTest.cpp:50
static const int points[]
#define kValueNeverReturnedBySign
Definition: SkPath.cpp:2206
static int sign(SkScalar x)
Definition: SkPath.cpp:2205
bool isZero() const
Definition: SkPoint_impl.h:193
float fX
x-axis value
Definition: SkPoint_impl.h:164
bool isFinite() const
Definition: SkPoint_impl.h:412
float fY
y-axis value
Definition: SkPoint_impl.h:165

◆ close()

bool Convexicator::close ( )
inline

Definition at line 2285 of file SkPath.cpp.

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

◆ getFirstDirection()

SkPathFirstDirection Convexicator::getFirstDirection ( ) const
inline

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

Definition at line 2221 of file SkPath.cpp.

2221{ return fFirstDirection; }

◆ isFinite()

bool Convexicator::isFinite ( ) const
inline

Definition at line 2292 of file SkPath.cpp.

2292 {
2293 return fIsFinite;
2294 }

◆ reversals()

int Convexicator::reversals ( ) const
inline

Definition at line 2296 of file SkPath.cpp.

2296 {
2297 return fReversals;
2298 }

◆ setMovePt()

void Convexicator::setMovePt ( const SkPoint pt)
inline

Definition at line 2223 of file SkPath.cpp.

2223 {
2224 fFirstPt = fLastPt = pt;
2225 fExpectedDir = kInvalid_DirChange;
2226 }

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