12 #include "SkPathRef.h"
17 class SkAutoPathBoundsUpdate;
41 friend SK_API
bool operator==(
const SkPath&,
const SkPath&);
42 friend bool operator!=(
const SkPath& a,
const SkPath& b) {
54 bool isInterpolatable(
const SkPath& compare)
const;
65 bool interpolate(
const SkPath& ending, SkScalar weight,
SkPath* out)
const;
67 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
69 bool unique()
const {
return fPathRef->unique(); }
86 kInverseEvenOdd_FillType
102 fFillType = SkToU8(ft);
127 if (kUnknown_Convexity != fConvexity) {
128 return static_cast<Convexity
>(fConvexity);
130 return this->internalGetConvexity();
151 void setConvexity(Convexity);
158 return kConvex_Convexity == this->getConvexity();
167 SK_ATTR_DEPRECATED(
"use setConvexity")
168 void setIsConvex(
bool isConvex) {
169 this->setConvexity(isConvex ? kConvex_Convexity : kConcave_Convexity);
185 unsigned* start =
nullptr)
const {
187 bool result = fPathRef->isOval(rect, &isCCW, start);
189 *dir = isCCW ? kCCW_Direction : kCW_Direction;
207 unsigned* start =
nullptr)
const {
209 bool result = fPathRef->isRRect(rrect, &isCCW, start);
211 *dir = isCCW ? kCCW_Direction : kCW_Direction;
234 SkDEBUGCODE(this->validate();)
235 return 0 == fPathRef->countVerbs();
240 bool isLastContourClosed()
const;
247 SkDEBUGCODE(this->validate();)
248 return fPathRef->isFinite();
265 fIsVolatile = isVolatile;
281 const SkPoint& p3,
bool exact) {
283 p2.equalsWithinTolerance(p3);
293 p2.equalsWithinTolerance(p3) &&
294 p3.equalsWithinTolerance(p4);
303 bool isLine(
SkPoint line[2])
const;
307 int countPoints()
const;
313 SkPoint getPoint(
int index)
const;
321 int getPoints(
SkPoint points[],
int max)
const;
325 int countVerbs()
const;
334 int getVerbs(uint8_t verbs[],
int max)
const;
347 return fPathRef->getBounds();
366 bool conservativelyContainsRect(
const SkRect& rect)
const;
376 void incReserve(
unsigned extraPtCount);
383 void moveTo(SkScalar x, SkScalar y);
390 this->moveTo(p.fX, p.fY);
402 void rMoveTo(SkScalar dx, SkScalar dy);
411 void lineTo(SkScalar x, SkScalar y);
420 this->lineTo(p.fX, p.fY);
432 void rLineTo(SkScalar dx, SkScalar dy);
443 void quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
453 this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY);
469 void rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2);
471 void conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
474 this->conicTo(p1.fX, p1.fY, p2.fX, p2.fY, w);
476 void rConicTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2,
490 void cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
491 SkScalar x3, SkScalar y3);
502 this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY);
522 void rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
523 SkScalar x3, SkScalar y3);
536 void arcTo(
const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
bool forceMoveTo);
541 void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius);
547 this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius);
570 void arcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
571 Direction sweep, SkScalar x, SkScalar y);
573 void arcTo(
const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep,
575 this->arcTo(r.fX, r.fY, xAxisRotate, largeArc, sweep, xy.fX, xy.fY);
591 void rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
592 Direction sweep, SkScalar dx, SkScalar dy);
608 static_assert(0 == kWinding_FillType,
"fill_type_mismatch");
609 static_assert(1 == kEvenOdd_FillType,
"fill_type_mismatch");
610 static_assert(2 == kInverseWinding_FillType,
"fill_type_mismatch");
611 static_assert(3 == kInverseEvenOdd_FillType,
"fill_type_mismatch");
612 return (fill & 2) != 0;
624 static_assert(0 == kWinding_FillType,
"fill_type_mismatch");
625 static_assert(1 == kEvenOdd_FillType,
"fill_type_mismatch");
626 static_assert(2 == kInverseWinding_FillType,
"fill_type_mismatch");
627 static_assert(3 == kInverseEvenOdd_FillType,
"fill_type_mismatch");
636 SkScalar w,
SkPoint pts[],
int pow2);
653 bool isRect(
SkRect* rect,
bool* isClosed = NULL, Direction* direction = NULL)
const;
667 bool isNestedFillRects(
SkRect rect[2], Direction dirs[2] = NULL)
const;
676 void addRect(
const SkRect& rect, Direction dir = kCW_Direction);
691 void addRect(
const SkRect& rect, Direction dir,
unsigned start);
708 void addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
709 Direction dir = kCW_Direction);
719 void addOval(
const SkRect& oval, Direction dir = kCW_Direction);
738 void addOval(
const SkRect& oval, Direction dir,
unsigned start);
752 void addCircle(SkScalar x, SkScalar y, SkScalar radius,
753 Direction dir = kCW_Direction);
761 void addArc(
const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle);
770 void addRoundRect(
const SkRect& rect, SkScalar rx, SkScalar ry,
771 Direction dir = kCW_Direction);
784 void addRoundRect(
const SkRect& rect,
const SkScalar radii[],
785 Direction dir = kCW_Direction);
796 void addRRect(
const SkRRect& rrect, Direction dir = kCW_Direction);
813 void addRRect(
const SkRRect& rrect, Direction dir,
unsigned start);
826 void addPoly(
const SkPoint pts[],
int count,
bool close);
846 void addPath(
const SkPath& src, SkScalar dx, SkScalar dy,
847 AddPathMode mode = kAppend_AddPathMode);
854 this->addPath(src, m, mode);
862 void addPath(
const SkPath& src,
const SkMatrix& matrix, AddPathMode mode = kAppend_AddPathMode);
867 void reverseAddPath(
const SkPath& src);
875 void offset(SkScalar dx, SkScalar dy,
SkPath* dst)
const;
883 this->offset(dx, dy,
this);
899 this->transform(matrix,
this);
908 bool getLastPt(
SkPoint* lastPt)
const;
916 void setLastPt(SkScalar x, SkScalar y);
924 this->setLastPt(p.fX, p.fY);
928 kLine_SegmentMask = 1 << 0,
929 kQuad_SegmentMask = 1 << 1,
930 kConic_SegmentMask = 1 << 2,
931 kCubic_SegmentMask = 1 << 3,
965 void setPath(
const SkPath&,
bool forceClose);
980 if (doConsumeDegerates) {
981 this->consumeDegenerateSegments(exact);
983 return this->doNext(pts);
1005 bool isClosedContour()
const;
1009 const uint8_t* fVerbs;
1010 const uint8_t* fVerbStop;
1011 const SkScalar* fConicWeights;
1019 inline const SkPoint& cons_moveTo();
1021 void consumeDegenerateSegments(
bool exact);
1034 void setPath(
const SkPath& path) {
1035 fRawIter.setPathRef(*path.fPathRef.get());
1046 return (
Verb) fRawIter.next(pts);
1054 return (
Verb) fRawIter.peek();
1057 SkScalar conicWeight()
const {
1058 return fRawIter.conicWeight();
1070 bool contains(SkScalar x, SkScalar y)
const;
1072 void dump(
SkWStream* ,
bool forceClose,
bool dumpAsHex)
const;
1074 void dumpHex()
const;
1097 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
1098 static const int kPathRefGenIDBitCnt = 30;
1100 static const int kPathRefGenIDBitCnt = 32;
1103 SkDEBUGCODE(
void validate()
const;)
1104 SkDEBUGCODE(
void experimentalValidateRef()
const { fPathRef->validate(); } )
1107 enum SerializationOffsets {
1109 kUnused1_SerializationShift = 28,
1110 kDirection_SerializationShift = 26,
1111 kIsVolatile_SerializationShift = 25,
1113 kConvexity_SerializationShift = 16,
1114 kFillType_SerializationShift = 8,
1118 enum SerializationVersions {
1119 kPathPrivFirstDirection_Version = 1,
1120 kPathPrivLastMoveToIndex_Version = 2,
1121 kCurrent_Version = 2
1125 int fLastMoveToIndex;
1127 mutable uint8_t fConvexity;
1128 mutable SkAtomic<uint8_t, sk_memory_order_relaxed> fFirstDirection;
1144 friend class SkPathPriv;
1145 friend class SkPathStroker;
1151 void reversePathTo(
const SkPath&);
1159 inline void injectMoveToIfNeeded();
1161 inline bool hasOnlyMoveTos()
const;
1163 Convexity internalGetConvexity()
const;
1165 bool isRectContour(
bool allowPartial,
int* currVerb,
const SkPoint** pts,
1166 bool* isClosed, Direction* direction)
const;
1170 bool isZeroLength()
const;
1176 SkDEBUGCODE(this->validate();)
1177 return fPathRef->hasComputedBounds();
1182 void setBounds(
const SkRect& rect) {
1188 void setPt(
int index, SkScalar x, SkScalar y);
1190 friend class SkAutoPathBoundsUpdate;
1191 friend class SkAutoDisableOvalCheck;
1192 friend class SkAutoDisableDirectionCheck;
1193 friend class SkBench_AddPathTest;
1194 friend class PathTest_Private;
1195 friend class ForceIsRRect_Private;
iter.next returns 3 points + iter.conicWeight()
Definition: SkPath.h:945
static bool IsQuadDegenerate(const SkPoint &p1, const SkPoint &p2, const SkPoint &p3, bool exact)
Test a quad for zero length.
Definition: SkPath.h:280
Verb next(SkPoint pts[4])
Return the next verb in this iteration of the path.
Definition: SkPath.h:1045
void setFillType(FillType ft)
Set the path's fill type.
Definition: SkPath.h:101
bool contains(SkScalar x, SkScalar y) const
Returns true if the point { x, y } is contained by the path, taking into account the FillType...
static bool IsCubicDegenerate(const SkPoint &p1, const SkPoint &p2, const SkPoint &p3, const SkPoint &p4, bool exact)
Test a cubic curve for zero length.
Definition: SkPath.h:290
Specifies that "inside" is computed by an odd number of edge crossings.
Definition: SkPath.h:80
The SkRRect class represents a rounded rect with a potentially different radii for each corner...
Definition: SkRRect.h:48
The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line...
Definition: SkPath.h:27
Definition: SkPathRef.h:41
void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius)
Append a line and arc to the current path.
Definition: SkPath.h:546
Convexity getConvexity() const
Return the path's convexity, as stored in the path.
Definition: SkPath.h:126
bool hasComputedBounds() const
Returns if the path can return a bound at no cost (true) or will have to perform some computation (fa...
Definition: SkPath.h:1175
static FillType ConvertToNonInverseFillType(FillType fill)
Returns the equivalent non-inverted fill type to the given fill type.
Definition: SkPath.h:623
const SkRect & getBounds() const
Returns the bounds of the path's points.
Definition: SkPath.h:346
void cubicTo(const SkPoint &p1, const SkPoint &p2, const SkPoint &p3)
Add a cubic bezier from the last point, approaching control points p1 and p2, and ending at p3...
Definition: SkPath.h:501
void offset(SkScalar dx, SkScalar dy)
Offset the path by (dx,dy), returning true on success.
Definition: SkPath.h:882
Definition: SkPoint.h:156
bool isOval(SkRect *rect, Direction *dir=nullptr, unsigned *start=nullptr) const
Returns true if the path is an oval.
Definition: SkPath.h:184
Convexity getConvexityOrUnknown() const
Return the currently cached value for convexity, even if that is set to kUnknown_Convexity.
Definition: SkPath.h:140
iter.next returns 3 points
Definition: SkPath.h:944
SkScalar conicWeight() const
Return the weight for the current conic.
Definition: SkPath.h:990
FillType getFillType() const
Return the path's fill type.
Definition: SkPath.h:94
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:26
Verb peek() const
Return what the next verb will be, but do not visit the next segment.
Definition: SkPath.h:1053
uint32_t getGenerationID() const
Returns a non-zero, globally unique value corresponding to the set of verbs and points in the path (b...
bool isCloseLine() const
If next() returns kLine_Verb, then this query returns true if the line was the result of a close() co...
Definition: SkPath.h:1000
Definition: SkWriter32.h:25
ArcSize
Definition: SkPath.h:550
iter.next returns 0 points
Definition: SkPath.h:947
void setIsVolatile(bool isVolatile)
Specify whether this path is volatile.
Definition: SkPath.h:264
uint8_t SkBool8
Meant to be a small version of bool, for storage purposes.
Definition: SkTypes.h:268
void transform(const SkMatrix &matrix)
Transform the points in this path by matrix.
Definition: SkPath.h:898
void setLastPt(const SkPoint &p)
Set the last point on the path.
Definition: SkPath.h:923
Direction
Definition: SkPath.h:29
void toggleInverseFillType()
Toggle between inverse and normal filltypes.
Definition: SkPath.h:112
void updateBoundsCache() const
Calling this will, if the internal cache of the bounds is out of date, update it so that subsequent c...
Definition: SkPath.h:355
iter.next returns 2 points
Definition: SkPath.h:943
#define SkToBool(cond)
Returns 0 or 1 based on the condition.
Definition: SkTypes.h:287
iter.next returns 1 point
Definition: SkPath.h:942
static bool IsInverseFillType(FillType fill)
Returns whether or not a fill type is inverted.
Definition: SkPath.h:607
size_t writeToMemory(void *buffer) const
Write the path to the buffer, and return the number of bytes written.
Specifies that "inside" is computed by a non-zero sum of signed edge crossings.
Definition: SkPath.h:76
the larger of the two possible SVG arcs.
Definition: SkPath.h:554
uint32_t getSegmentMasks() const
Returns a mask, where each bit corresponding to a SegmentMask is set if the path contains 1 or more s...
Definition: SkPath.h:939
the smaller of the two possible SVG arcs.
Definition: SkPath.h:552
size_t readFromMemory(const void *buffer, size_t length)
Initializes the path from the buffer.
void quadTo(const SkPoint &p1, const SkPoint &p2)
Add a quadratic bezier from the last point, approaching control point p1, and ending at p2...
Definition: SkPath.h:452
void addPath(const SkPath &src, AddPathMode mode=kAppend_AddPathMode)
Add a copy of src to the path.
Definition: SkPath.h:851
iter.next returns 4 points
Definition: SkPath.h:946
bool isEmpty() const
Returns true if the path is empty (contains no lines or curves)
Definition: SkPath.h:233
Source path contours are added as new contours.
Definition: SkPath.h:831
void copyFields(const SkPath &that)
Sets all fields other than fPathRef to the values in 'that'.
void reset()
Set the matrix to identity.
bool isRRect(SkRRect *rrect, Direction *dir=nullptr, unsigned *start=nullptr) const
Returns true if the path is a round rect.
Definition: SkPath.h:206
bool isFinite() const
Returns true if all of the points in this path are finite, meaning there are no infinities and no NaN...
Definition: SkPath.h:246
FillType
Definition: SkPath.h:72
Iterate through the verbs in the path, providing the associated points.
Definition: SkPath.h:1027
bool isVolatile() const
Returns true if the path is volatile (i.e.
Definition: SkPath.h:253
Definition: SkPathRef.h:117
Definition: SkStream.h:182
Verb next(SkPoint pts[4], bool doConsumeDegerates=true, bool exact=false)
Return the next verb in this iteration of the path.
Definition: SkPath.h:979
counter-clockwise direction for adding closed contours
Definition: SkPath.h:33
bool isConvex() const
Returns true if the path is flagged as being convex.
Definition: SkPath.h:157
void lineTo(const SkPoint &p)
Add a line from the last point to the specified point.
Definition: SkPath.h:419
AddPathMode
Definition: SkPath.h:828
clockwise direction for adding closed contours
Definition: SkPath.h:31
iter.next returns 0 points
Definition: SkPath.h:948
bool equalsWithinTolerance(const SkPoint &p) const
Return true if this point and the given point are far enough apart such that a vector between them wo...
Definition: SkPoint.h:401
void resetFields()
Resets all fields other than fPathRef to their initial 'empty' values.
Iterate through all of the segments (lines, quadratics, cubics) of each contours in a path...
Definition: SkPath.h:960
bool isInverseFillType() const
Returns true if the filltype is one of the Inverse variants.
Definition: SkPath.h:106
Verb
Definition: SkPath.h:941
Light weight class for managing strings.
Definition: SkString.h:121
void moveTo(const SkPoint &p)
Set the beginning of the next contour to the point.
Definition: SkPath.h:389
static bool IsLineDegenerate(const SkPoint &p1, const SkPoint &p2, bool exact)
Test a line for zero length.
Definition: SkPath.h:272
Same as Winding, but draws outside of the path, rather than inside.
Definition: SkPath.h:83