Lines Matching refs:SkPath

26 /** \class SkPath
27 SkPath contain geometry. SkPath may be empty, or contain one or more verbs that
28 outline a figure. SkPath always starts with a move verb to a Cartesian coordinate,
31 SkPath may contain any number of contours, each beginning with a move verb.
33 SkPath contours may contain only a move verb, or may also contain lines,
34 quadratic beziers, conics, and cubic beziers. SkPath contours may be open or
37 When used to draw a filled area, SkPath describes whether the fill is inside or
38 outside the geometry. SkPath also describes the winding rule used to fill
41 Internally, SkPath lazily computes metrics likes bounds and convexity. Call
42 SkPath::updateBoundsCache to make SkPath thread safe.
44 class SK_API SkPath {
65 static SkPath Make(const SkPoint[], int pointCount,
70 static SkPath Rect(const SkRect&, SkPathDirection = SkPathDirection::kCW,
72 static SkPath Oval(const SkRect&, SkPathDirection = SkPathDirection::kCW);
73 static SkPath Oval(const SkRect&, SkPathDirection, unsigned startIndex);
74 static SkPath Circle(SkScalar center_x, SkScalar center_y, SkScalar radius,
76 static SkPath RRect(const SkRRect&, SkPathDirection dir = SkPathDirection::kCW);
77 static SkPath RRect(const SkRRect&, SkPathDirection, unsigned startIndex);
78 static SkPath RRect(const SkRect& bounds, SkScalar rx, SkScalar ry,
81 static SkPath Polygon(const SkPoint pts[], int count, bool isClosed,
85 static SkPath Polygon(const std::initializer_list<SkPoint>& list, bool isClosed,
91 static SkPath Line(const SkPoint a, const SkPoint b) {
95 /** Constructs an empty SkPath. By default, SkPath has no verbs, no SkPoint, and no weights.
98 @return empty SkPath
102 SkPath();
109 Creating a SkPath copy is very efficient and never allocates memory.
110 SkPath are always copied by value from the interface; the underlying shared
113 @param path SkPath to copy by value
114 @return copy of SkPath
118 SkPath(const SkPath& path);
120 /** Releases ownership of any shared data and deletes data if SkPath is sole owner.
124 ~SkPath();
127 SkPath assignment makes two paths identical by value. Internally, assignment
131 Copying SkPath by assignment is very efficient and never allocates memory.
132 SkPath are always copied by value from the interface; the underlying shared
135 @param path verb array, SkPoint array, weights, and SkPath::FillType to copy
136 @return SkPath copied by value
140 SkPath& operator=(const SkPath& path);
142 /** Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights
145 @param a SkPath to compare
146 @param b SkPath to compare
147 @return true if SkPath pair are equivalent
149 friend SK_API bool operator==(const SkPath& a, const SkPath& b);
151 /** Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights
154 @param a SkPath to compare
155 @param b SkPath to compare
156 @return true if SkPath pair are not equivalent
158 friend bool operator!=(const SkPath& a, const SkPath& b) {
162 /** Returns true if SkPath contain equal verbs and equal weights.
163 If SkPath contain one or more conics, the weights must match.
166 trivial to interpolate a pair of SkPath containing conics with different
169 @param compare SkPath to compare
170 @return true if SkPath verb array and weights are equivalent
174 bool isInterpolatable(const SkPath& compare) const;
176 /** Interpolates between SkPath with SkPoint array of equal size.
186 the same size as ending SkPoint array. Call isInterpolatable() to check SkPath
192 @param out SkPath replaced by interpolated averages
193 @return true if SkPath contain same number of SkPoint
197 bool interpolate(const SkPath& ending, SkScalar weight, SkPath* out) const;
199 /** Returns SkPathFillType, the rule used to fill SkPath.
205 /** Sets FillType, the rule used to fill SkPath. While there is no check
212 /** Returns if FillType describes area outside SkPath geometry. The inverse fill area
239 @return true if SkPath is recognized as an oval or circle
253 @return true if SkPath contains only SkRRect
259 /** Sets SkPath to its initial state.
261 Internal storage associated with SkPath is released.
263 @return reference to SkPath
267 SkPath& reset();
269 /** Sets SkPath to its initial state, preserving internal storage.
271 Internal storage associated with SkPath is retained.
273 Use rewind() instead of reset() if SkPath storage will be reused and performance
276 @return reference to SkPath
280 SkPath& rewind();
282 /** Returns if SkPath is empty.
283 Empty SkPath may have FillType but has no SkPoint, SkPath::Verb, or conic weight.
284 SkPath() constructs empty SkPath; reset() and rewind() make SkPath empty.
286 @return true if the path contains no SkPath::Verb array
294 Contour is closed if SkPath SkPath::Verb array was last modified by close(). When stroked,
315 by the caller after it is drawn. SkPath by default have volatile set false, allowing
319 @return true if caller will alter SkPath after drawing
325 /** Specifies whether SkPath is volatile; whether it will be altered or discarded
326 by the caller after it is drawn. SkPath by default have volatile set false, allowing
332 Mark animating SkPath volatile to improve performance.
333 Mark unchanging SkPath non-volatile to improve repeated rendering.
335 raster surface SkPath draws are affected by volatile for some shadows.
336 GPU surface SkPath draws are affected by volatile for some shadows and concave geometries.
338 @param isVolatile true if caller will alter SkPath after drawing
339 @return reference to SkPath
341 SkPath& setIsVolatile(bool isVolatile) {
391 /** Returns true if SkPath contains only one line;
392 SkPath::Verb array has two entries: kMove_Verb, kLine_Verb.
393 If SkPath contains one line and line is not nullptr, line is set to
395 Returns false if SkPath is not one line; line is unaltered.
398 @return true if SkPath contains exactly one line
404 /** Returns the number of points in SkPath.
407 @return SkPath SkPoint array length
424 /** Returns number of points in SkPath. Up to max points are copied.
428 @param points storage for SkPath SkPoint array. May be nullptr
430 @return SkPath SkPoint array length
437 kCubic_Verb, and kClose_Verb; added to SkPath.
456 /** Returns the approximate byte size of the SkPath in memory.
462 /** Exchanges the verb array, SkPoint array, weights, and SkPath::FillType with other.
466 swap() usage has largely been replaced by operator=(const SkPath& path).
467 SkPath do not copy their content on assignment until they are written to,
470 @param other SkPath exchanged by value
474 void swap(SkPath& other);
477 Returns (0, 0, 0, 0) if SkPath contains no points. Returned bounds width and height may
478 be larger or smaller than area affected when SkPath is drawn.
480 SkRect returned includes all SkPoint added to SkPath, including SkPoint associated with
490 Unaltered copies of SkPath may also access cached bounds through getBounds().
494 Call to prepare SkPath subsequently drawn from multiple threads,
502 /** Returns minimum and maximum axes values of the lines and curves in SkPath.
503 Returns (0, 0, 0, 0) if SkPath contains no points.
505 when SkPath is drawn.
510 Behaves identically to getBounds() when SkPath contains
511 only lines. If SkPath contains curves, computed bounds includes
515 @return tight bounds of curves in SkPath
521 /** Returns true if rect is contained by SkPath.
522 May return false when rect is contained by SkPath.
524 For now, only returns true if SkPath has one contour and is convex.
525 rect may share points and edges with SkPath and be contained.
527 the SkPoint or line described by rect is contained by SkPath.
536 /** Grows SkPath verb array and SkPoint array to contain extraPtCount additional SkPoint.
538 reducing the number and size of allocations when creating SkPath.
554 @return reference to SkPath
558 SkPath& moveTo(SkScalar x, SkScalar y);
563 @return reference to SkPath
565 SkPath& moveTo(const SkPoint& p) {
570 If SkPath is empty, starts contour at (dx, dy).
576 @return reference to SkPath
580 SkPath& rMoveTo(SkScalar dx, SkScalar dy);
582 /** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is
590 @return reference to SkPath
594 SkPath& lineTo(SkScalar x, SkScalar y);
596 /** Adds line from last point to SkPoint p. If SkPath is empty, or last SkPath::Verb is
603 @return reference to SkPath
605 SkPath& lineTo(const SkPoint& p) {
609 /** Adds line from last point to vector (dx, dy). If SkPath is empty, or last SkPath::Verb is
619 @return reference to SkPath
625 SkPath& rLineTo(SkScalar dx, SkScalar dy);
628 If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
639 @return reference to SkPath
643 SkPath& quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
646 If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
655 @return reference to SkPath
657 SkPath& quadTo(const SkPoint& p1, const SkPoint& p2) {
662 If SkPath is empty, or last SkPath::Verb
676 @return reference to SkPath
683 SkPath& rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2);
686 If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
705 @return reference to SkPath
707 SkPath& conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
711 If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
728 @return reference to SkPath
730 SkPath& conicTo(const SkPoint& p1, const SkPoint& p2, SkScalar w) {
735 weighted by w. If SkPath is empty, or last SkPath::Verb
757 @return reference to SkPath
759 SkPath& rConicTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2,
763 (x3, y3). If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to
776 @return reference to SkPath
778 SkPath& cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
782 SkPoint p3. If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to
792 @return reference to SkPath
794 SkPath& cubicTo(const SkPoint& p1, const SkPoint& p2, const SkPoint& p3) {
800 If SkPath is empty, or last SkPath::Verb
816 @return reference to SkPath
818 SkPath& rCubicTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2,
821 /** Appends arc to SkPath. Arc added is part of ellipse
826 arcTo() adds line connecting SkPath last SkPoint to initial arc SkPoint if forceMoveTo
827 is false and SkPath is not empty. Otherwise, added contour begins with first point
834 @return reference to SkPath
838 SkPath& arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo);
840 /** Appends arc to SkPath, after appending line if needed. Arc is implemented by conic
842 last SkPath point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc
859 @return reference to SkPath
865 SkPath& arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius);
867 /** Appends arc to SkPath, after appending line if needed. Arc is implemented by conic
869 last SkPath point to p1, and tangent from p1 to p2. Arc
872 If last SkPath SkPoint does not start arc, arcTo() appends connecting line to SkPath.
876 tangents are nearly parallel, arcTo() appends line from last SkPath SkPoint to p1.
884 @return reference to SkPath
886 SkPath& arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) {
890 /** \enum SkPath::ArcSize
891 Four oval parts with radii (rx, ry) start at last SkPath SkPoint and ends at (x, y).
899 /** Appends arc to SkPath. Arc is implemented by one or more conics weighted to
901 curves from last SkPath SkPoint to (x, y), choosing one of four possible routes:
905 either radii are zero, or if last SkPath SkPoint equals (x, y). arcTo() scales radii
906 (rx, ry) to fit last SkPath SkPoint and (x, y) if both are greater than zero but
921 @return reference to SkPath
923 SkPath& arcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
926 /** Appends arc to SkPath. Arc is implemented by one or more conic weighted to describe
928 from last SkPath SkPoint to (xy.fX, xy.fY), choosing one of four possible routes:
933 radii are zero, or if last SkPath SkPoint equals (xy.fX, xy.fY). arcTo() scales radii r to
934 fit last SkPath SkPoint and xy if both are greater than zero but too small to describe
947 @return reference to SkPath
949 SkPath& arcTo(const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep,
954 /** Appends arc to SkPath, relative to last SkPath SkPoint. Arc is implemented by one or
956 xAxisRotate degrees. Arc curves from last SkPath SkPoint to relative end SkPoint:
958 counterclockwise, and smaller or larger. If SkPath is empty, the start arc SkPoint
962 if either radii are zero, or if last SkPath SkPoint equals end SkPoint.
963 arcTo() scales radii (rx, ry) to fit last SkPath SkPoint and end SkPoint if both are
976 @param dx x-axis offset end of arc from last SkPath SkPoint
977 @param dy y-axis offset end of arc from last SkPath SkPoint
978 @return reference to SkPath
980 SkPath& rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
983 /** Appends kClose_Verb to SkPath. A closed contour connects the first and last SkPoint
989 close() has no effect if SkPath is empty or last SkPath SkPath::Verb is kClose_Verb.
991 @return reference to SkPath
995 SkPath& close();
1030 /** Returns true if SkPath is equivalent to SkRect when filled.
1034 rect may be smaller than the SkPath bounds. SkPath bounds may include kMove_Verb points
1038 @param isClosed storage set to true if SkPath is closed; may be nullptr
1040 @return true if SkPath contains SkRect
1069 @param dir SkPath::Direction to orient the new contour
1071 @return reference to SkPath
1075 SkPath& addRect(const SkRect& rect, SkPathDirection dir, unsigned start);
1077 SkPath& addRect(const SkRect& rect, SkPathDirection dir = SkPathDirection::kCW) {
1081 SkPath& addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
1092 @param dir SkPath::Direction to wind ellipse
1093 @return reference to SkPath
1097 SkPath& addOval(const SkRect& oval, SkPathDirection dir = SkPathDirection::kCW);
1099 /** Adds oval to SkPath, appending kMove_Verb, four kConic_Verb, and kClose_Verb.
1105 @param dir SkPath::Direction to wind ellipse
1107 @return reference to SkPath
1111 SkPath& addOval(const SkRect& oval, SkPathDirection dir, unsigned start);
1113 /** Adds circle centered at (x, y) of size radius to SkPath, appending kMove_Verb,
1122 @param dir SkPath::Direction to wind circle
1123 @return reference to SkPath
1125 SkPath& addCircle(SkScalar x, SkScalar y, SkScalar radius,
1128 /** Appends arc to SkPath, as the start of new contour. Arc added is part of ellipse
1140 @return reference to SkPath
1144 SkPath& addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle);
1146 /** Appends SkRRect to SkPath, creating a new closed contour. SkRRect has bounds
1154 SkRect rect to SkPath.
1156 After appending, SkPath may be empty, or may contain: SkRect, oval, or SkRRect.
1161 @param dir SkPath::Direction to wind SkRRect
1162 @return reference to SkPath
1164 SkPath& addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
1167 /** Appends SkRRect to SkPath, creating a new closed contour. SkRRect has bounds
1173 @param dir SkPath::Direction to wind SkRRect
1174 @return reference to SkPath
1176 SkPath& addRoundRect(const SkRect& rect, const SkScalar radii[],
1179 /** Adds rrect to SkPath, creating a new closed contour. If
1184 After appending, SkPath may be empty, or may contain: SkRect, oval, or SkRRect.
1187 @param dir SkPath::Direction to wind SkRRect
1188 @return reference to SkPath
1192 SkPath& addRRect(const SkRRect& rrect, SkPathDirection dir = SkPathDirection::kCW);
1194 /** Adds rrect to SkPath, creating a new closed contour. If dir is kCW_Direction, rrect
1199 @param dir SkPath::Direction to wind SkRRect
1201 @return reference to SkPath
1205 SkPath& addRRect(const SkRRect& rrect, SkPathDirection dir, unsigned start);
1209 in pts array. If close is true, appends kClose_Verb to SkPath, connecting
1218 @return reference to SkPath
1222 SkPath& addPoly(const SkPoint pts[], int count, bool close);
1225 for every additional SkPoint in list. If close is true, appends kClose_Verb to SkPath,
1232 @return reference to SkPath
1234 SkPath& addPoly(const std::initializer_list<SkPoint>& list, bool close) {
1242 /** \enum SkPath::AddPathMode
1243 AddPathMode chooses how addPath() appends. Adding one SkPath to another can extend
1251 /** Appends src to SkPath, offset by (dx, dy).
1257 @param src SkPath verbs, SkPoint, and conic weights to add
1261 @return reference to SkPath
1263 SkPath& addPath(const SkPath& src, SkScalar dx, SkScalar dy,
1266 /** Appends src to SkPath.
1272 @param src SkPath verbs, SkPoint, and conic weights to add
1274 @return reference to SkPath
1276 SkPath& addPath(const SkPath& src, AddPathMode mode = kAppend_AddPathMode) {
1282 /** Appends src to SkPath, transformed by matrix. Transformed curves may have different
1289 @param src SkPath verbs, SkPoint, and conic weights to add
1292 @return reference to SkPath
1294 SkPath& addPath(const SkPath& src, const SkMatrix& matrix,
1297 /** Appends src to SkPath, from back to front.
1298 Reversed src always appends a new contour to SkPath.
1300 @param src SkPath verbs, SkPoint, and conic weights to add
1301 @return reference to SkPath
1305 SkPath& reverseAddPath(const SkPath& src);
1307 /** Offsets SkPoint array by (dx, dy). Offset SkPath replaces dst.
1308 If dst is nullptr, SkPath is replaced by offset data.
1312 @param dst overwritten, translated copy of SkPath; may be nullptr
1316 void offset(SkScalar dx, SkScalar dy, SkPath* dst) const;
1318 /** Offsets SkPoint array by (dx, dy). SkPath is replaced by offset data.
1329 Transformed SkPath replaces dst; if dst is nullptr, original data
1332 @param matrix SkMatrix to apply to SkPath
1333 @param dst overwritten, transformed copy of SkPath; may be nullptr
1338 void transform(const SkMatrix& matrix, SkPath* dst,
1343 SkPath is replaced by transformed data.
1345 @param matrix SkMatrix to apply to SkPath
1353 SkPath makeTransform(const SkMatrix& m,
1355 SkPath dst;
1360 SkPath makeScale(SkScalar sx, SkScalar sy) {
1364 /** Returns last point on SkPath in lastPt. Returns false if SkPoint array is empty,
1393 /** \enum SkPath::SegmentMask
1394 SegmentMask constants correspond to each drawing Verb type in SkPath; for
1395 instance, if SkPath only contains lines, only the kLine_SegmentMask bit is set.
1405 if SkPath contains one or more verbs of that type.
1406 Returns zero if SkPath contains no lines, or curves: quads, conics, or cubics.
1414 /** \enum SkPath::Verb
1415 Verb instructs SkPath how to interpret one or more SkPoint and optional conic weight;
1416 manage contour, and terminate SkPath.
1428 /** \class SkPath::Iter
1436 /** Initializes SkPath::Iter with an empty SkPath. next() on SkPath::Iter returns
1438 Call setPath to initialize SkPath::Iter at a later time.
1440 @return SkPath::Iter of empty SkPath
1446 /** Sets SkPath::Iter to return elements of verb array, SkPoint array, and conic weight in
1447 path. If forceClose is true, SkPath::Iter will add kLine_Verb and kClose_Verb after each
1450 @param path SkPath to iterate
1452 @return SkPath::Iter of path
1456 Iter(const SkPath& path, bool forceClose);
1458 /** Sets SkPath::Iter to return elements of verb array, SkPoint array, and conic weight in
1459 path. If forceClose is true, SkPath::Iter will add kLine_Verb and kClose_Verb after each
1462 @param path SkPath to iterate
1467 void setPath(const SkPath& path, bool forceClose);
1469 /** Returns next SkPath::Verb in verb array, and advances SkPath::Iter.
1472 Zero to four SkPoint are stored in pts, depending on the returned SkPath::Verb.
1474 @param pts storage for SkPoint data describing returned SkPath::Verb
1475 @return next SkPath::Verb from verb array
1502 kMove_Verb. if true, contour SkPath::Iter is processing may end with kClose_Verb, or
1503 SkPath::Iter may have been initialized with force close set to true.
1526 /** \class SkPath::RangeIter
1565 // (SkPath::injectMoveToIfNeeded should have guaranteed this to be the case.)
1600 /** \class SkPath::RawIter
1606 /** Initializes RawIter with an empty SkPath. next() on RawIter returns kDone_Verb.
1607 Call setPath to initialize SkPath::Iter at a later time.
1609 @return RawIter of empty SkPath
1615 @param path SkPath to iterate
1618 RawIter(const SkPath& path) {
1622 /** Sets SkPath::Iter to return elements of verb array, SkPoint array, and conic weight in
1625 @param path SkPath to iterate
1627 void setPath(const SkPath&);
1629 /** Returns next SkPath::Verb in verb array, and advances RawIter.
1631 Zero to four SkPoint are stored in pts, depending on the returned SkPath::Verb.
1633 @param pts storage for SkPoint data describing returned SkPath::Verb
1634 @return next SkPath::Verb from verb array
1638 /** Returns next SkPath::Verb, but does not advance RawIter.
1640 @return next SkPath::Verb from verb array
1661 friend class SkPath;
1665 /** Returns true if the point (x, y) is contained by SkPath, taking into
1670 @return true if SkPoint is in SkPath
1676 /** Writes text representation of SkPath to stream. If stream is nullptr, writes to
1680 @param stream writable SkWStream receiving SkPath text representation; may be nullptr
1687 /** Writes text representation of SkPath to string.
1697 // Like dump(), but outputs for the SkPath::Make() factory
1701 /** Writes SkPath to buffer, returning the number of bytes written.
1704 Writes SkPath::FillType, verb array, SkPoint array, conic weight, and
1705 additionally writes computed information like SkPath::Convexity and bounds.
1708 the format used for SkPath in memory is not guaranteed.
1710 @param buffer storage for SkPath; may be nullptr
1711 @return size of storage required for SkPath; always a multiple of 4
1717 /** Writes SkPath to buffer, returning the buffer written to, wrapped in SkData.
1719 serialize() writes SkPath::FillType, verb array, SkPoint array, conic weight, and
1720 additionally writes computed information like SkPath::Convexity and bounds.
1723 The format used for SkPath in memory is not guaranteed.
1725 @return SkPath data wrapped in SkData buffer
1731 /** Initializes SkPath from buffer of size length. Returns zero if the buffer is
1734 Reads SkPath::FillType, verb array, SkPoint array, conic weight, and
1735 additionally reads computed information like SkPath::Convexity and bounds.
1738 the format used for SkPath in memory is not guaranteed.
1740 @param buffer storage for SkPath
1752 Setting SkPath::FillType does not change generation identifier.
1755 SkPath::FillType does affect generation identifier on Android framework.
1763 /** Returns if SkPath data is consistent. Corrupt SkPath data is detected if
1767 @return true if SkPath data is consistent
1772 SkPath(sk_sp<SkPathRef>, SkPathFillType, bool isVolatile, SkPathConvexity,
1792 void copyFields(const SkPath& that);
1806 SkPath& reversePathTo(const SkPath&);
1811 // SkPath path; path.lineTo(...); <--- need a leading moveTo(0, 0)
1812 // SkPath path; ... path.close(); path.lineTo(...) <-- need a moveTo(previous moveTo)
1820 /** Asserts if SkPath data is inconsistent.
1848 SkPath& dirtyAfterEdit();
1877 /** Shrinks SkPath verb array and SkPoint array storage to discard unused capacity.
1878 * May reduce the heap overhead for SkPath known to be fully constructed.