Skia
2D Graphics Library
SkPath.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkPath_DEFINED
9 #define SkPath_DEFINED
10 
11 #include "include/core/SkMatrix.h"
13 #include "include/private/SkPathRef.h"
14 #include "include/private/SkTo.h"
15 
16 #include <initializer_list>
17 
18 class SkAutoPathBoundsUpdate;
19 class SkData;
20 class SkRRect;
21 class SkWStream;
22 
23 // WIP -- define this locally, and fix call-sites to use SkPathBuilder (skbug.com/9000)
24 //#define SK_HIDE_PATH_EDIT_METHODS
25 
44 class SK_API SkPath {
45 public:
65  static SkPath Make(const SkPoint[], int pointCount,
66  const uint8_t[], int verbCount,
67  const SkScalar[], int conicWeightCount,
68  SkPathFillType, bool isVolatile = false);
69 
70  static SkPath Rect(const SkRect&, SkPathDirection dir = SkPathDirection::kCW);
71  static SkPath Oval(const SkRect&, SkPathDirection dir = SkPathDirection::kCW);
72  static SkPath Circle(SkScalar center_x, SkScalar center_y, SkScalar radius,
74  static SkPath RRect(const SkRRect&, SkPathDirection dir = SkPathDirection::kCW);
75 
76  static SkPath Polygon(const SkPoint pts[], int count, bool isClosed,
78  bool isVolatile = false);
79 
80  static SkPath Polygon(const std::initializer_list<SkPoint>& list, bool isClosed,
82  bool isVolatile = false) {
83  return Polygon(list.begin(), SkToInt(list.size()), isClosed, fillType, isVolatile);
84  }
85 
86  static SkPath Line(const SkPoint a, const SkPoint b) {
87  return Polygon({a, b}, false);
88  }
89 
97  SkPath();
98 
113  SkPath(const SkPath& path);
114 
119  ~SkPath();
120 
135  SkPath& operator=(const SkPath& path);
136 
144  friend SK_API bool operator==(const SkPath& a, const SkPath& b);
145 
153  friend bool operator!=(const SkPath& a, const SkPath& b) {
154  return !(a == b);
155  }
156 
169  bool isInterpolatable(const SkPath& compare) const;
170 
192  bool interpolate(const SkPath& ending, SkScalar weight, SkPath* out) const;
193 
198  SkPathFillType getFillType() const { return (SkPathFillType)fFillType; }
199 
204  fFillType = SkToU8(ft);
205  }
206 
212  bool isInverseFillType() const { return SkPathFillType_IsInverse(this->getFillType()); }
213 
218  fFillType ^= 2;
219  }
220 
225  SkPathConvexityType convexity = this->getConvexityTypeOrUnknown();
226  if (convexity != SkPathConvexityType::kUnknown) {
227  return convexity;
228  }
229  return this->internalGetConvexity();
230  }
231 
239  return (SkPathConvexityType)fConvexity.load(std::memory_order_relaxed);
240  }
241 
248  void setConvexityType(SkPathConvexityType convexity);
249 
252  bool isConvex() const {
253  return SkPathConvexityType::kConvex == this->getConvexityType();
254  }
255 
267  bool isOval(SkRect* bounds) const;
268 
281  bool isRRect(SkRRect* rrect) const;
282 
291  SkPath& reset();
292 
304  SkPath& rewind();
305 
312  bool isEmpty() const {
313  SkDEBUGCODE(this->validate();)
314  return 0 == fPathRef->countVerbs();
315  }
316 
325  bool isLastContourClosed() const;
326 
333  bool isFinite() const {
334  SkDEBUGCODE(this->validate();)
335  return fPathRef->isFinite();
336  }
337 
345  bool isVolatile() const {
346  return SkToBool(fIsVolatile);
347  }
348 
364  void setIsVolatile(bool isVolatile) {
365  fIsVolatile = isVolatile;
366  }
367 
382  static bool IsLineDegenerate(const SkPoint& p1, const SkPoint& p2, bool exact);
383 
395  static bool IsQuadDegenerate(const SkPoint& p1, const SkPoint& p2,
396  const SkPoint& p3, bool exact);
397 
410  static bool IsCubicDegenerate(const SkPoint& p1, const SkPoint& p2,
411  const SkPoint& p3, const SkPoint& p4, bool exact);
412 
424  bool isLine(SkPoint line[2]) const;
425 
433  int countPoints() const;
434 
444  SkPoint getPoint(int index) const;
445 
456  int getPoints(SkPoint points[], int max) const;
457 
465  int countVerbs() const;
466 
476  int getVerbs(uint8_t verbs[], int max) const;
477 
482  size_t approximateBytesUsed() const;
483 
496  void swap(SkPath& other);
497 
507  const SkRect& getBounds() const {
508  return fPathRef->getBounds();
509  }
510 
519  void updateBoundsCache() const {
520  // for now, just calling getBounds() is sufficient
521  this->getBounds();
522  }
523 
541  SkRect computeTightBounds() const;
542 
556  bool conservativelyContainsRect(const SkRect& rect) const;
557 
566  void incReserve(int extraPtCount);
567 
571  void shrinkToFit();
572 
573 #ifdef SK_HIDE_PATH_EDIT_METHODS
574 private:
575 #endif
576 
585  SkPath& moveTo(SkScalar x, SkScalar y);
586 
592  SkPath& moveTo(const SkPoint& p) {
593  return this->moveTo(p.fX, p.fY);
594  }
595 
607  SkPath& rMoveTo(SkScalar dx, SkScalar dy);
608 
621  SkPath& lineTo(SkScalar x, SkScalar y);
622 
632  SkPath& lineTo(const SkPoint& p) {
633  return this->lineTo(p.fX, p.fY);
634  }
635 
652  SkPath& rLineTo(SkScalar dx, SkScalar dy);
653 
670  SkPath& quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
671 
684  SkPath& quadTo(const SkPoint& p1, const SkPoint& p2) {
685  return this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY);
686  }
687 
710  SkPath& rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2);
711 
734  SkPath& conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
735  SkScalar w);
736 
757  SkPath& conicTo(const SkPoint& p1, const SkPoint& p2, SkScalar w) {
758  return this->conicTo(p1.fX, p1.fY, p2.fX, p2.fY, w);
759  }
760 
786  SkPath& rConicTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2,
787  SkScalar w);
788 
805  SkPath& cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
806  SkScalar x3, SkScalar y3);
807 
821  SkPath& cubicTo(const SkPoint& p1, const SkPoint& p2, const SkPoint& p3) {
822  return this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY);
823  }
824 
845  SkPath& rCubicTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2,
846  SkScalar dx3, SkScalar dy3);
847 
865  SkPath& arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo);
866 
892  SkPath& arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius);
893 
913  SkPath& arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) {
914  return this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius);
915  }
916 
921  enum ArcSize {
924  };
925 
950  SkPath& arcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
951  SkPathDirection sweep, SkScalar x, SkScalar y);
952 
976  SkPath& arcTo(const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep,
977  const SkPoint xy) {
978  return this->arcTo(r.fX, r.fY, xAxisRotate, largeArc, sweep, xy.fX, xy.fY);
979  }
980 
1007  SkPath& rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
1008  SkPathDirection sweep, SkScalar dx, SkScalar dy);
1009 
1022  SkPath& close();
1023 
1024 #ifdef SK_HIDE_PATH_EDIT_METHODS
1025 public:
1026 #endif
1027 
1054  static int ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2,
1055  SkScalar w, SkPoint pts[], int pow2);
1056 
1071  bool isRect(SkRect* rect, bool* isClosed = nullptr, SkPathDirection* direction = nullptr) const;
1072 
1084  SkPath& addRect(const SkRect& rect, SkPathDirection dir = SkPathDirection::kCW);
1085 
1098  SkPath& addRect(const SkRect& rect, SkPathDirection dir, unsigned start);
1099 
1113  SkPath& addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
1115 
1127  SkPath& addOval(const SkRect& oval, SkPathDirection dir = SkPathDirection::kCW);
1128 
1141  SkPath& addOval(const SkRect& oval, SkPathDirection dir, unsigned start);
1142 
1155  SkPath& addCircle(SkScalar x, SkScalar y, SkScalar radius,
1157 
1174  SkPath& addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle);
1175 
1194  SkPath& addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
1196 
1206  SkPath& addRoundRect(const SkRect& rect, const SkScalar radii[],
1208 
1222  SkPath& addRRect(const SkRRect& rrect, SkPathDirection dir = SkPathDirection::kCW);
1223 
1235  SkPath& addRRect(const SkRRect& rrect, SkPathDirection dir, unsigned start);
1236 
1252  SkPath& addPoly(const SkPoint pts[], int count, bool close);
1253 
1264  SkPath& addPoly(const std::initializer_list<SkPoint>& list, bool close) {
1265  return this->addPoly(list.begin(), SkToInt(list.size()), close);
1266  }
1267 
1275  };
1276 
1289  SkPath& addPath(const SkPath& src, SkScalar dx, SkScalar dy,
1290  AddPathMode mode = kAppend_AddPathMode);
1291 
1302  SkPath& addPath(const SkPath& src, AddPathMode mode = kAppend_AddPathMode) {
1303  SkMatrix m;
1304  m.reset();
1305  return this->addPath(src, m, mode);
1306  }
1307 
1320  SkPath& addPath(const SkPath& src, const SkMatrix& matrix,
1321  AddPathMode mode = kAppend_AddPathMode);
1322 
1331  SkPath& reverseAddPath(const SkPath& src);
1332 
1342  void offset(SkScalar dx, SkScalar dy, SkPath* dst) const;
1343 
1349  void offset(SkScalar dx, SkScalar dy) {
1350  this->offset(dx, dy, this);
1351  }
1352 
1364  void transform(const SkMatrix& matrix, SkPath* dst,
1366 
1374  void transform(const SkMatrix& matrix,
1376  this->transform(matrix, this, pc);
1377  }
1378 
1379  SkPath makeTransform(const SkMatrix& m,
1381  SkPath dst;
1382  this->transform(m, &dst, pc);
1383  return dst;
1384  }
1385 
1386  SkPath makeScale(SkScalar sx, SkScalar sy) {
1387  return this->makeTransform(SkMatrix::Scale(sx, sy), SkApplyPerspectiveClip::kNo);
1388  }
1389 
1398  bool getLastPt(SkPoint* lastPt) const;
1399 
1408  void setLastPt(SkScalar x, SkScalar y);
1409 
1415  void setLastPt(const SkPoint& p) {
1416  this->setLastPt(p.fX, p.fY);
1417  }
1418 
1424  kLine_SegmentMask = kLine_SkPathSegmentMask,
1425  kQuad_SegmentMask = kQuad_SkPathSegmentMask,
1426  kConic_SegmentMask = kConic_SkPathSegmentMask,
1427  kCubic_SegmentMask = kCubic_SkPathSegmentMask,
1428  };
1429 
1438  uint32_t getSegmentMasks() const { return fPathRef->getSegmentMasks(); }
1439 
1444  enum Verb {
1445  kMove_Verb = static_cast<int>(SkPathVerb::kMove),
1446  kLine_Verb = static_cast<int>(SkPathVerb::kLine),
1447  kQuad_Verb = static_cast<int>(SkPathVerb::kQuad),
1448  kConic_Verb = static_cast<int>(SkPathVerb::kConic),
1449  kCubic_Verb = static_cast<int>(SkPathVerb::kCubic),
1450  kClose_Verb = static_cast<int>(SkPathVerb::kClose),
1451  kDone_Verb = kClose_Verb + 1
1452  };
1453 
1459  class SK_API Iter {
1460  public:
1461 
1470  Iter();
1471 
1482  Iter(const SkPath& path, bool forceClose);
1483 
1493  void setPath(const SkPath& path, bool forceClose);
1494 
1505  Verb next(SkPoint pts[4]);
1506 
1514  SkScalar conicWeight() const { return *fConicWeights; }
1515 
1525  bool isCloseLine() const { return SkToBool(fCloseLine); }
1526 
1535  bool isClosedContour() const;
1536 
1537  private:
1538  const SkPoint* fPts;
1539  const uint8_t* fVerbs;
1540  const uint8_t* fVerbStop;
1541  const SkScalar* fConicWeights;
1542  SkPoint fMoveTo;
1543  SkPoint fLastPt;
1544  bool fForceClose;
1545  bool fNeedClose;
1546  bool fCloseLine;
1547  enum SegmentState : uint8_t {
1549  kEmptyContour_SegmentState,
1551  kAfterMove_SegmentState,
1553  kAfterPrimitive_SegmentState
1554  };
1555  SegmentState fSegmentState;
1556 
1557  inline const SkPoint& cons_moveTo();
1558  Verb autoClose(SkPoint pts[2]);
1559  };
1560 
1561 private:
1568  class RangeIter {
1569  public:
1570  RangeIter() = default;
1571  RangeIter(const uint8_t* verbs, const SkPoint* points, const SkScalar* weights)
1572  : fVerb(verbs), fPoints(points), fWeights(weights) {
1573  SkDEBUGCODE(fInitialPoints = fPoints;)
1574  }
1575  bool operator!=(const RangeIter& that) const {
1576  return fVerb != that.fVerb;
1577  }
1578  bool operator==(const RangeIter& that) const {
1579  return fVerb == that.fVerb;
1580  }
1581  RangeIter& operator++() {
1582  auto verb = static_cast<SkPathVerb>(*fVerb++);
1583  fPoints += pts_advance_after_verb(verb);
1584  if (verb == SkPathVerb::kConic) {
1585  ++fWeights;
1586  }
1587  return *this;
1588  }
1589  RangeIter operator++(int) {
1590  RangeIter copy = *this;
1591  this->operator++();
1592  return copy;
1593  }
1594  SkPathVerb peekVerb() const {
1595  return static_cast<SkPathVerb>(*fVerb);
1596  }
1597  std::tuple<SkPathVerb, const SkPoint*, const SkScalar*> operator*() const {
1598  SkPathVerb verb = this->peekVerb();
1599  // We provide the starting point for beziers by peeking backwards from the current
1600  // point, which works fine as long as there is always a kMove before any geometry.
1601  // (SkPath::injectMoveToIfNeeded should have guaranteed this to be the case.)
1602  int backset = pts_backset_for_verb(verb);
1603  SkASSERT(fPoints + backset >= fInitialPoints);
1604  return {verb, fPoints + backset, fWeights};
1605  }
1606  private:
1607  constexpr static int pts_advance_after_verb(SkPathVerb verb) {
1608  switch (verb) {
1609  case SkPathVerb::kMove: return 1;
1610  case SkPathVerb::kLine: return 1;
1611  case SkPathVerb::kQuad: return 2;
1612  case SkPathVerb::kConic: return 2;
1613  case SkPathVerb::kCubic: return 3;
1614  case SkPathVerb::kClose: return 0;
1615  }
1616  SkUNREACHABLE;
1617  }
1618  constexpr static int pts_backset_for_verb(SkPathVerb verb) {
1619  switch (verb) {
1620  case SkPathVerb::kMove: return 0;
1621  case SkPathVerb::kLine: return -1;
1622  case SkPathVerb::kQuad: return -1;
1623  case SkPathVerb::kConic: return -1;
1624  case SkPathVerb::kCubic: return -1;
1625  case SkPathVerb::kClose: return 0;
1626  }
1627  SkUNREACHABLE;
1628  }
1629  const uint8_t* fVerb = nullptr;
1630  const SkPoint* fPoints = nullptr;
1631  const SkScalar* fWeights = nullptr;
1632  SkDEBUGCODE(const SkPoint* fInitialPoints = nullptr;)
1633  };
1634 public:
1635 
1639  class SK_API RawIter {
1640  public:
1641 
1647  RawIter() {}
1648 
1654  RawIter(const SkPath& path) {
1655  setPath(path);
1656  }
1657 
1663  void setPath(const SkPath&);
1664 
1672  Verb next(SkPoint[4]);
1673 
1678  Verb peek() const {
1679  return (fIter != fEnd) ? static_cast<Verb>(std::get<0>(*fIter)) : kDone_Verb;
1680  }
1681 
1690  return fConicWeight;
1691  }
1692 
1693  private:
1694  RangeIter fIter;
1695  RangeIter fEnd;
1696  SkScalar fConicWeight = 0;
1697  friend class SkPath;
1698 
1699  };
1700 
1710  bool contains(SkScalar x, SkScalar y) const;
1711 
1723  void dump(SkWStream* stream, bool forceClose, bool dumpAsHex) const;
1724 
1732  void dump() const;
1733 
1743  void dumpHex() const;
1744 
1759  size_t writeToMemory(void* buffer) const;
1760 
1773  sk_sp<SkData> serialize() const;
1774 
1790  size_t readFromMemory(const void* buffer, size_t length);
1791 
1805  uint32_t getGenerationID() const;
1806 
1813  bool isValid() const { return this->isValidImpl() && fPathRef->isValid(); }
1814 
1815 private:
1817 
1818  sk_sp<SkPathRef> fPathRef;
1819  int fLastMoveToIndex;
1820  mutable std::atomic<uint8_t> fConvexity; // SkPathConvexityType
1821  mutable std::atomic<uint8_t> fFirstDirection; // really an SkPathPriv::FirstDirection
1822  uint8_t fFillType : 2;
1823  uint8_t fIsVolatile : 1;
1824 
1829  void resetFields();
1830 
1835  void copyFields(const SkPath& that);
1836 
1837  size_t writeToMemoryAsRRect(void* buffer) const;
1838  size_t readAsRRect(const void*, size_t);
1839  size_t readFromMemory_EQ4Or5(const void*, size_t);
1840 
1841  friend class Iter;
1842  friend class SkPathPriv;
1843  friend class SkPathStroker;
1844 
1845  /* Append, in reverse order, the first contour of path, ignoring path's
1846  last point. If no moveTo() call has been made for this contour, the
1847  first point is automatically set to (0,0).
1848  */
1849  SkPath& reversePathTo(const SkPath&);
1850 
1851  // called before we add points for lineTo, quadTo, cubicTo, checking to see
1852  // if we need to inject a leading moveTo first
1853  //
1854  // SkPath path; path.lineTo(...); <--- need a leading moveTo(0, 0)
1855  // SkPath path; ... path.close(); path.lineTo(...) <-- need a moveTo(previous moveTo)
1856  //
1857  inline void injectMoveToIfNeeded();
1858 
1859  inline bool hasOnlyMoveTos() const;
1860 
1861  SkPathConvexityType internalGetConvexity() const;
1862 
1866  SkDEBUGCODE(void validate() const { SkASSERT(this->isValidImpl()); } )
1867  bool isValidImpl() const;
1868  SkDEBUGCODE(void validateRef() const { fPathRef->validate(); } )
1869 
1870  // called by stroker to see if all points (in the last contour) are equal and worthy of a cap
1871  bool isZeroLengthSincePoint(int startPtIndex) const;
1872 
1876  bool hasComputedBounds() const {
1877  SkDEBUGCODE(this->validate();)
1878  return fPathRef->hasComputedBounds();
1879  }
1880 
1881 
1882  // 'rect' needs to be sorted
1883  void setBounds(const SkRect& rect) {
1884  SkPathRef::Editor ed(&fPathRef);
1885 
1886  ed.setBounds(rect);
1887  }
1888 
1889  void setPt(int index, SkScalar x, SkScalar y);
1890 
1891  SkPath& dirtyAfterEdit();
1892 
1893  // Bottlenecks for working with fConvexity and fFirstDirection.
1894  // Notice the setters are const... these are mutable atomic fields.
1895  void setConvexityType(SkPathConvexityType) const;
1896  void setFirstDirection(uint8_t) const;
1897  uint8_t getFirstDirection() const;
1898 
1899  friend class SkAutoPathBoundsUpdate;
1900  friend class SkAutoDisableOvalCheck;
1901  friend class SkAutoDisableDirectionCheck;
1902  friend class SkPathBuilder;
1903  friend class SkPathEdgeIter;
1904  friend class SkPathWriter;
1905  friend class SkOpBuilder;
1906  friend class SkBench_AddPathTest; // perf test reversePathTo
1907  friend class PathTest_Private; // unit test reversePathTo
1908  friend class ForceIsRRect_Private; // unit test isRRect
1909  friend class FuzzPath; // for legacy access to validateRef
1910 };
1911 
1912 #endif
SkPathFillType getFillType() const
Returns SkPathFillType, the rule used to fill SkPath.
Definition: SkPath.h:198
SkPathConvexityType
Definition: SkPathTypes.h:36
Verb peek() const
Returns next SkPath::Verb, but does not advance RawIter.
Definition: SkPath.h:1678
sk_sp< SkData > serialize() const
Writes SkPath to buffer, returning the buffer written to, wrapped in SkData.
void setFillType(SkPathFillType ft)
Sets FillType, the rule used to fill SkPath.
Definition: SkPath.h:203
bool isEmpty() const
Returns if SkPath is empty.
Definition: SkPath.h:312
SkPathConvexityType getConvexityType() const
Returns the comvexity type, computing if needed.
Definition: SkPath.h:224
SkRRect describes a rounded rectangle with a bounds and a pair of radii for each corner.
Definition: SkRRect.h:30
SkPath contain geometry.
Definition: SkPath.h:44
SkPath::RawIter returns 0 points.
uint32_t getSegmentMasks() const
Returns a mask, where each set bit corresponds to a SegmentMask constant if SkPath contains one or mo...
Definition: SkPath.h:1438
void dumpHex() const
Writes text representation of SkPath to standard output.
bool isCloseLine() const
Returns true if last kLine_Verb returned by next() was generated by kClose_Verb.
Definition: SkPath.h:1525
Definition: SkPathTypes.h:52
SkPath::RawIter returns 3 points.
void offset(SkScalar dx, SkScalar dy)
Offsets SkPoint array by (dx, dy).
Definition: SkPath.h:1349
SkApplyPerspectiveClip
When we transform points through a matrix containing perspective (the bottom row is something other t...
Definition: SkMatrix.h:24
SkPath & arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius)
Appends arc to SkPath, after appending line if needed.
Definition: SkPath.h:913
SkPoint holds two 32-bit floating point coordinates.
Definition: SkPoint.h:160
Do pre-clip the geometry before applying the (perspective) matrix.
static SkMatrix SK_WARN_UNUSED_RESULT Scale(SkScalar sx, SkScalar sy)
Sets SkMatrix to scale by (sx, sy).
Definition: SkMatrix.h:66
#define SkDEBUGCODE(...)
Definition: SkTypes.h:456
#define SK_API
Definition: SkTypes.h:191
SkPath()
Constructs an empty SkPath.
SkPath & arcTo(const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep, const SkPoint xy)
Appends arc to SkPath.
Definition: SkPath.h:976
SkPath makeTransform(const SkMatrix &m, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkPath.h:1379
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:45
Definition: SkPathTypes.h:50
ArcSize
Definition: SkPath.h:921
add line if prior contour is not closed
Definition: SkPath.h:1274
SkPath & conicTo(const SkPoint &p1, const SkPoint &p2, SkScalar w)
Adds conic from last point towards SkPoint p1, to SkPoint p2, weighted by w.
Definition: SkPath.h:757
SkPath::RawIter returns 2 points.
void setIsVolatile(bool isVolatile)
Specifies whether SkPath is volatile; whether it will be altered or discarded by the caller after it ...
Definition: SkPath.h:364
Perform a series of path operations, optimized for unioning many paths together.
Definition: SkPathOps.h:86
RawIter()
Initializes RawIter with an empty SkPath.
Definition: SkPath.h:1647
uint32_t getGenerationID() const
(See Skia bug 1762.) Returns a non-zero, globally unique value.
SkPath & moveTo(const SkPoint &p)
Adds beginning of contour at SkPoint p.
Definition: SkPath.h:592
Definition: SkPathBuilder.h:16
void setLastPt(const SkPoint &p)
Sets the last point on the path.
Definition: SkPath.h:1415
bool isVolatile() const
Returns true if the path is volatile; it will not be altered or discarded by the caller after it is d...
Definition: SkPath.h:345
void toggleInverseFillType()
Replaces FillType with its inverse.
Definition: SkPath.h:217
SkPath::RawIter returns 3 points + 1 weight.
void updateBoundsCache() const
Updates internal bounds so that subsequent calls to getBounds() are instantaneous.
Definition: SkPath.h:519
SkData holds an immutable data buffer.
Definition: SkData.h:22
larger of arc pair
Definition: SkPath.h:923
SkPath & cubicTo(const SkPoint &p1, const SkPoint &p2, const SkPoint &p3)
Adds cubic from last point towards SkPoint p1, then towards SkPoint p2, ending at SkPoint p3...
Definition: SkPath.h:821
smaller of arc pair
Definition: SkPath.h:922
size_t readFromMemory(const void *buffer, size_t length)
Initializes SkPath from buffer of size length.
bool isFinite() const
Returns true for finite SkPoint array values between negative SK_ScalarMax and positive SK_ScalarMax...
Definition: SkPath.h:333
bool contains(SkScalar x, SkScalar y) const
Returns true if the point (x, y) is contained by SkPath, taking into account FillType.
friend bool operator!=(const SkPath &a, const SkPath &b)
Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights are not eq...
Definition: SkPath.h:153
SkPathVerb
Definition: SkPathTypes.h:56
Definition: SkPathTypes.h:51
void dump() const
Writes text representation of SkPath to standard output.
static constexpr bool SkToBool(const T &x)
Definition: SkTypes.h:486
Don&#39;t pre-clip the geometry before applying the (perspective) matrix.
#define SkASSERT(cond)
Definition: SkTypes.h:449
Specifies that "inside" is computed by a non-zero sum of signed edge crossings.
SkPathFillType
Definition: SkPathTypes.h:13
SkScalar conicWeight() const
Returns conic weight if next() returned kConic_Verb.
Definition: SkPath.h:1514
bool isConvex() const
Returns true if the path is convex.
Definition: SkPath.h:252
const SkRect & getBounds() const
Returns minimum and maximum axes values of SkPoint array.
Definition: SkPath.h:507
void transform(const SkMatrix &matrix, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes)
Transforms verb array, SkPoint array, and weight by matrix.
Definition: SkPath.h:1374
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:334
appended to destination unaltered
Definition: SkPath.h:1273
size_t writeToMemory(void *buffer) const
Writes SkPath to buffer, returning the number of bytes written.
#define SkUNREACHABLE
Definition: SkTypes.h:266
static SkPath Polygon(const std::initializer_list< SkPoint > &list, bool isClosed, SkPathFillType fillType=SkPathFillType::kWinding, bool isVolatile=false)
Definition: SkPath.h:80
SkMatrix & reset()
Sets SkMatrix to identity; which has no effect on mapped SkPoint.
clockwise direction for adding closed contours
Use Iter instead.
Definition: SkPath.h:1639
static SkPath Line(const SkPoint a, const SkPoint b)
Definition: SkPath.h:86
SkPath::RawIter returns 1 point.
SkScalar fX
x-axis value
Definition: SkPoint.h:161
Definition: SkStream.h:227
bool isInverseFillType() const
Returns if FillType describes area outside SkPath geometry.
Definition: SkPath.h:212
float SkScalar
Definition: SkScalar.h:16
SkRect holds four SkScalar coordinates describing the upper and lower bounds of a rectangle...
Definition: SkRect.h:560
static bool SkPathFillType_IsInverse(SkPathFillType ft)
Definition: SkPathTypes.h:28
SkPath & lineTo(const SkPoint &p)
Adds line from last point to SkPoint p.
Definition: SkPath.h:632
bool isValid() const
Returns if SkPath data is consistent.
Definition: SkPath.h:1813
Definition: SkPathTypes.h:53
SkPath & quadTo(const SkPoint &p1, const SkPoint &p2)
Adds quad from last point towards SkPoint p1, to SkPoint p2.
Definition: SkPath.h:684
AddPathMode
Definition: SkPath.h:1272
bool operator==(const sk_sp< T > &a, const sk_sp< U > &b)
Definition: SkRefCnt.h:338
SkPath::RawIter returns 4 points.
SkPathDirection
Definition: SkPathTypes.h:42
SkPathConvexityType getConvexityTypeOrUnknown() const
If the path&#39;s convexity is already known, return it, else return kUnknown.
Definition: SkPath.h:238
SkPath & addPoly(const std::initializer_list< SkPoint > &list, bool close)
Adds contour created from list.
Definition: SkPath.h:1264
sk_sp< SkDrawLooper > SK_API Make(SkColor4f color, SkColorSpace *cs, SkScalar sigma, SkScalar dx, SkScalar dy)
SegmentMask
Definition: SkPath.h:1423
SkScalar fY
y-axis value
Definition: SkPoint.h:162
SkScalar conicWeight() const
Returns conic weight if next() returned kConic_Verb.
Definition: SkPath.h:1689
Iterates through verb array, and associated SkPoint array and conic weight.
Definition: SkPath.h:1459
Verb
Definition: SkPath.h:1444
SkPath & addPath(const SkPath &src, AddPathMode mode=kAppend_AddPathMode)
Appends src to SkPath.
Definition: SkPath.h:1302
RawIter(const SkPath &path)
Sets RawIter to return elements of verb array, SkPoint array, and conic weight in path...
Definition: SkPath.h:1654
SkPath makeScale(SkScalar sx, SkScalar sy)
Definition: SkPath.h:1386