Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkPath Class Reference

The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line segments, quadratic curves, and cubic curves. More...

#include <SkPath.h>

Classes

class  Iter
 Iterate through all of the segments (lines, quadratics, cubics) of each contours in a path. More...
 
class  RawIter
 Iterate through the verbs in the path, providing the associated points. More...
 

Public Types

enum  Direction { kCW_Direction, kCCW_Direction }
 
enum  FillType { kWinding_FillType, kEvenOdd_FillType, kInverseWinding_FillType, kInverseEvenOdd_FillType }
 
enum  Convexity { kUnknown_Convexity, kConvex_Convexity, kConcave_Convexity }
 
enum  ArcSize { kSmall_ArcSize, kLarge_ArcSize }
 
enum  AddPathMode { kAppend_AddPathMode, kExtend_AddPathMode }
 
enum  SegmentMask { kLine_SegmentMask = 1 << 0, kQuad_SegmentMask = 1 << 1, kConic_SegmentMask = 1 << 2, kCubic_SegmentMask = 1 << 3 }
 
enum  Verb {
  kMove_Verb, kLine_Verb, kQuad_Verb, kConic_Verb,
  kCubic_Verb, kClose_Verb, kDone_Verb
}
 

Public Member Functions

 SkPath (const SkPath &)
 
SkPathoperator= (const SkPath &)
 
bool isInterpolatable (const SkPath &compare) const
 Return true if the paths contain an equal array of verbs and weights. More...
 
bool interpolate (const SkPath &ending, SkScalar weight, SkPath *out) const
 Interpolate between two paths with same-sized point arrays. More...
 
FillType getFillType () const
 Return the path's fill type. More...
 
void setFillType (FillType ft)
 Set the path's fill type. More...
 
bool isInverseFillType () const
 Returns true if the filltype is one of the Inverse variants.
 
void toggleInverseFillType ()
 Toggle between inverse and normal filltypes. More...
 
Convexity getConvexity () const
 Return the path's convexity, as stored in the path. More...
 
Convexity getConvexityOrUnknown () const
 Return the currently cached value for convexity, even if that is set to kUnknown_Convexity. More...
 
void setConvexity (Convexity)
 Store a convexity setting in the path. More...
 
bool isConvex () const
 Returns true if the path is flagged as being convex. More...
 
void setIsConvex (bool isConvex)
 Set the isConvex flag to true or false. More...
 
bool isOval (SkRect *rect, Direction *dir=nullptr, unsigned *start=nullptr) const
 Returns true if the path is an oval. More...
 
bool isRRect (SkRRect *rrect, Direction *dir=nullptr, unsigned *start=nullptr) const
 Returns true if the path is a round rect. More...
 
void reset ()
 Clear any lines and curves from the path, making it empty. More...
 
void rewind ()
 Similar to reset(), in that all lines and curves are removed from the path. More...
 
bool isEmpty () const
 Returns true if the path is empty (contains no lines or curves) More...
 
bool isLastContourClosed () const
 Return true if the last contour of this path ends with a close verb.
 
bool isFinite () const
 Returns true if all of the points in this path are finite, meaning there are no infinities and no NaNs.
 
bool isVolatile () const
 Returns true if the path is volatile (i.e. More...
 
void setIsVolatile (bool isVolatile)
 Specify whether this path is volatile. More...
 
bool isLine (SkPoint line[2]) const
 Returns true if the path specifies a single line (i.e. More...
 
int countPoints () const
 Return the number of points in the path.
 
SkPoint getPoint (int index) const
 Return the point at the specified index. More...
 
int getPoints (SkPoint points[], int max) const
 Returns the number of points in the path. More...
 
int countVerbs () const
 Return the number of verbs in the path.
 
int getVerbs (uint8_t verbs[], int max) const
 Returns the number of verbs in the path. More...
 
void swap (SkPath &other)
 Swap contents of this and other. Guaranteed not to throw.
 
const SkRectgetBounds () const
 Returns the bounds of the path's points. More...
 
void updateBoundsCache () const
 Calling this will, if the internal cache of the bounds is out of date, update it so that subsequent calls to getBounds will be instantaneous. More...
 
bool conservativelyContainsRect (const SkRect &rect) const
 Does a conservative test to see whether a rectangle is inside a path. More...
 
void incReserve (unsigned extraPtCount)
 Hint to the path to prepare for adding more points. More...
 
void moveTo (SkScalar x, SkScalar y)
 Set the beginning of the next contour to the point (x,y). More...
 
void moveTo (const SkPoint &p)
 Set the beginning of the next contour to the point. More...
 
void rMoveTo (SkScalar dx, SkScalar dy)
 Set the beginning of the next contour relative to the last point on the previous contour. More...
 
void lineTo (SkScalar x, SkScalar y)
 Add a line from the last point to the specified point (x,y). More...
 
void lineTo (const SkPoint &p)
 Add a line from the last point to the specified point. More...
 
void rLineTo (SkScalar dx, SkScalar dy)
 Same as lineTo, but the coordinates are considered relative to the last point on this contour. More...
 
void quadTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
 Add a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2). More...
 
void quadTo (const SkPoint &p1, const SkPoint &p2)
 Add a quadratic bezier from the last point, approaching control point p1, and ending at p2. More...
 
void rQuadTo (SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2)
 Same as quadTo, but the coordinates are considered relative to the last point on this contour. More...
 
void conicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
 
void conicTo (const SkPoint &p1, const SkPoint &p2, SkScalar w)
 
void rConicTo (SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2, SkScalar w)
 
void cubicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
 Add a cubic bezier from the last point, approaching control points (x1,y1) and (x2,y2), and ending at (x3,y3). More...
 
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. More...
 
void rCubicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
 Same as cubicTo, but the coordinates are considered relative to the current point on this contour. More...
 
void arcTo (const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo)
 Append the specified arc to the path. More...
 
void arcTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius)
 Append a line and arc to the current path. More...
 
void arcTo (const SkPoint p1, const SkPoint p2, SkScalar radius)
 Append a line and arc to the current path. More...
 
void arcTo (SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep, SkScalar x, SkScalar y)
 Append an elliptical arc from the current point in the format used by SVG. More...
 
void arcTo (const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep, const SkPoint xy)
 
void rArcTo (SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep, SkScalar dx, SkScalar dy)
 Same as arcTo format used by SVG, but the destination coordinate is relative to the last point on this contour. More...
 
void close ()
 Close the current contour. More...
 
bool isRect (SkRect *rect, bool *isClosed=NULL, Direction *direction=NULL) const
 Returns true if the path specifies a rectangle. More...
 
bool isNestedFillRects (SkRect rect[2], Direction dirs[2]=NULL) const
 Returns true if the path specifies a pair of nested rectangles, or would draw a pair of nested rectangles when filled. More...
 
void addRect (const SkRect &rect, Direction dir=kCW_Direction)
 Add a closed rectangle contour to the path. More...
 
void addRect (const SkRect &rect, Direction dir, unsigned start)
 Add a closed rectangle contour to the path. More...
 
void addRect (SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, Direction dir=kCW_Direction)
 Add a closed rectangle contour to the path. More...
 
void addOval (const SkRect &oval, Direction dir=kCW_Direction)
 Add a closed oval contour to the path. More...
 
void addOval (const SkRect &oval, Direction dir, unsigned start)
 Add a closed oval contour to the path. More...
 
void addCircle (SkScalar x, SkScalar y, SkScalar radius, Direction dir=kCW_Direction)
 Add a closed circle contour to the path. More...
 
void addArc (const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle)
 Add the specified arc to the path as a new contour. More...
 
void addRoundRect (const SkRect &rect, SkScalar rx, SkScalar ry, Direction dir=kCW_Direction)
 Add a closed round-rectangle contour to the path. More...
 
void addRoundRect (const SkRect &rect, const SkScalar radii[], Direction dir=kCW_Direction)
 Add a closed round-rectangle contour to the path. More...
 
void addRRect (const SkRRect &rrect, Direction dir=kCW_Direction)
 Add an SkRRect contour to the path. More...
 
void addRRect (const SkRRect &rrect, Direction dir, unsigned start)
 Add an SkRRect contour to the path. More...
 
void addPoly (const SkPoint pts[], int count, bool close)
 Add a new contour made of just lines. More...
 
void addPath (const SkPath &src, SkScalar dx, SkScalar dy, AddPathMode mode=kAppend_AddPathMode)
 Add a copy of src to the path, offset by (dx,dy) More...
 
void addPath (const SkPath &src, AddPathMode mode=kAppend_AddPathMode)
 Add a copy of src to the path.
 
void addPath (const SkPath &src, const SkMatrix &matrix, AddPathMode mode=kAppend_AddPathMode)
 Add a copy of src to the path, transformed by matrix. More...
 
void reverseAddPath (const SkPath &src)
 Same as addPath(), but reverses the src input.
 
void offset (SkScalar dx, SkScalar dy, SkPath *dst) const
 Offset the path by (dx,dy), returning true on success. More...
 
void offset (SkScalar dx, SkScalar dy)
 Offset the path by (dx,dy), returning true on success. More...
 
void transform (const SkMatrix &matrix, SkPath *dst) const
 Transform the points in this path by matrix, and write the answer into dst. More...
 
void transform (const SkMatrix &matrix)
 Transform the points in this path by matrix. More...
 
bool getLastPt (SkPoint *lastPt) const
 Return the last point on the path. More...
 
void setLastPt (SkScalar x, SkScalar y)
 Set the last point on the path. More...
 
void setLastPt (const SkPoint &p)
 Set the last point on the path. More...
 
uint32_t getSegmentMasks () const
 Returns a mask, where each bit corresponding to a SegmentMask is set if the path contains 1 or more segments of that type. More...
 
bool contains (SkScalar x, SkScalar y) const
 Returns true if the point { x, y } is contained by the path, taking into account the FillType.
 
void dump (SkWStream *, bool forceClose, bool dumpAsHex) const
 
void dump () const
 
void dumpHex () const
 
size_t writeToMemory (void *buffer) const
 Write the path to the buffer, and return the number of bytes written. More...
 
size_t readFromMemory (const void *buffer, size_t length)
 Initializes the path from the buffer. More...
 
uint32_t getGenerationID () const
 Returns a non-zero, globally unique value corresponding to the set of verbs and points in the path (but not the fill type [except on Android skbug.com/1762]). More...
 
void validate () const
 
void experimentalValidateRef () const
 

Static Public Member Functions

static bool IsLineDegenerate (const SkPoint &p1, const SkPoint &p2, bool exact)
 Test a line for zero length. More...
 
static bool IsQuadDegenerate (const SkPoint &p1, const SkPoint &p2, const SkPoint &p3, bool exact)
 Test a quad for zero length. More...
 
static bool IsCubicDegenerate (const SkPoint &p1, const SkPoint &p2, const SkPoint &p3, const SkPoint &p4, bool exact)
 Test a cubic curve for zero length. More...
 
static bool IsInverseFillType (FillType fill)
 Returns whether or not a fill type is inverted. More...
 
static FillType ConvertToNonInverseFillType (FillType fill)
 Returns the equivalent non-inverted fill type to the given fill type. More...
 
static int ConvertConicToQuads (const SkPoint &p0, const SkPoint &p1, const SkPoint &p2, SkScalar w, SkPoint pts[], int pow2)
 Chop a conic into N quads, stored continguously in pts[], where N = 1 << pow2. More...
 

Static Public Attributes

static const int kPathRefGenIDBitCnt = 32
 

Private Types

enum  SerializationOffsets {
  kUnused1_SerializationShift = 28, kDirection_SerializationShift = 26, kIsVolatile_SerializationShift = 25, kConvexity_SerializationShift = 16,
  kFillType_SerializationShift = 8
}
 
enum  SerializationVersions { kPathPrivFirstDirection_Version = 1, kPathPrivLastMoveToIndex_Version = 2, kCurrent_Version = 2 }
 

Private Member Functions

void resetFields ()
 Resets all fields other than fPathRef to their initial 'empty' values. More...
 
void copyFields (const SkPath &that)
 Sets all fields other than fPathRef to the values in 'that'. More...
 
void reversePathTo (const SkPath &)
 
void injectMoveToIfNeeded ()
 
bool hasOnlyMoveTos () const
 
Convexity internalGetConvexity () const
 
bool isRectContour (bool allowPartial, int *currVerb, const SkPoint **pts, bool *isClosed, Direction *direction) const
 
bool isZeroLength () const
 
bool hasComputedBounds () const
 Returns if the path can return a bound at no cost (true) or will have to perform some computation (false).
 
void setBounds (const SkRect &rect)
 
void setPt (int index, SkScalar x, SkScalar y)
 

Private Attributes

SkAutoTUnref< SkPathReffPathRef
 
int fLastMoveToIndex
 
uint8_t fFillType
 
uint8_t fConvexity
 
SkAtomic< uint8_t,
sk_memory_order_relaxed > 
fFirstDirection
 
SkBool8 fIsVolatile
 

Friends

class Iter
 
class SkPathPriv
 
class SkPathStroker
 
class SkAutoPathBoundsUpdate
 
class SkAutoDisableOvalCheck
 
class SkAutoDisableDirectionCheck
 
class SkBench_AddPathTest
 
class PathTest_Private
 
class ForceIsRRect_Private
 
SK_API bool operator== (const SkPath &, const SkPath &)
 
bool operator!= (const SkPath &a, const SkPath &b)
 

Detailed Description

The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line segments, quadratic curves, and cubic curves.

Member Enumeration Documentation

Enumerator
kAppend_AddPathMode 

Source path contours are added as new contours.

kExtend_AddPathMode 

Path is added by extending the last contour of the destination path with the first contour of the source path.

If the last contour of the destination path is closed, then it will not be extended. Instead, the start of source path will be extended by a straight line to the end point of the destination path.

Enumerator
kSmall_ArcSize 

the smaller of the two possible SVG arcs.

kLarge_ArcSize 

the larger of the two possible SVG arcs.

Enumerator
kCW_Direction 

clockwise direction for adding closed contours

kCCW_Direction 

counter-clockwise direction for adding closed contours

Enumerator
kWinding_FillType 

Specifies that "inside" is computed by a non-zero sum of signed edge crossings.

kEvenOdd_FillType 

Specifies that "inside" is computed by an odd number of edge crossings.

kInverseWinding_FillType 

Same as Winding, but draws outside of the path, rather than inside.

kInverseEvenOdd_FillType 

Same as EvenOdd, but draws outside of the path, rather than inside.

Enumerator
kMove_Verb 

iter.next returns 1 point

kLine_Verb 

iter.next returns 2 points

kQuad_Verb 

iter.next returns 3 points

kConic_Verb 

iter.next returns 3 points + iter.conicWeight()

kCubic_Verb 

iter.next returns 4 points

kClose_Verb 

iter.next returns 0 points

kDone_Verb 

iter.next returns 0 points

Member Function Documentation

void SkPath::addArc ( const SkRect oval,
SkScalar  startAngle,
SkScalar  sweepAngle 
)

Add the specified arc to the path as a new contour.

Parameters
ovalThe bounds of oval used to define the size of the arc
startAngleStarting angle (in degrees) where the arc begins
sweepAngleSweep angle (in degrees) measured clockwise
void SkPath::addCircle ( SkScalar  x,
SkScalar  y,
SkScalar  radius,
Direction  dir = kCW_Direction 
)

Add a closed circle contour to the path.

The circle contour begins at the right-most point (as though 1 were passed to addOval's 'start' param).

Parameters
xThe x-coordinate of the center of a circle to add as a closed contour to the path
yThe y-coordinate of the center of a circle to add as a closed contour to the path
radiusThe radius of a circle to add as a closed contour to the path
dirThe direction to wind the circle's contour.
void SkPath::addOval ( const SkRect oval,
Direction  dir = kCW_Direction 
)

Add a closed oval contour to the path.

Parameters
ovalThe bounding oval to add as a closed contour to the path
dirThe direction to wind the oval's contour.

Note: the contour initial point index is 1 (as defined below).

void SkPath::addOval ( const SkRect oval,
Direction  dir,
unsigned  start 
)

Add a closed oval contour to the path.

Parameters
ovalThe bounding oval to add as a closed contour to the path
dirThe direction to wind the oval's contour.
startInitial point of the contour (initial moveTo), expressed as an ellipse vertex index, starting at the top, clock-wise (90/0/270/180deg order):

0 -*- | | 3 * * 1 | | -*- 2

void SkPath::addPath ( const SkPath src,
SkScalar  dx,
SkScalar  dy,
AddPathMode  mode = kAppend_AddPathMode 
)

Add a copy of src to the path, offset by (dx,dy)

Parameters
srcThe path to add as a new contour
dxThe amount to translate the path in X as it is added
dxThe amount to translate the path in Y as it is added
void SkPath::addPath ( const SkPath src,
const SkMatrix matrix,
AddPathMode  mode = kAppend_AddPathMode 
)

Add a copy of src to the path, transformed by matrix.

Parameters
srcThe path to add as a new contour
matrixTransform applied to src
modeDetermines how path is added
void SkPath::addPoly ( const SkPoint  pts[],
int  count,
bool  close 
)

Add a new contour made of just lines.

This is just a fast version of the following: this->moveTo(pts[0]); for (int i = 1; i < count; ++i) { this->lineTo(pts[i]); } if (close) { this->close(); }

void SkPath::addRect ( const SkRect rect,
Direction  dir = kCW_Direction 
)

Add a closed rectangle contour to the path.

Parameters
rectThe rectangle to add as a closed contour to the path
dirThe direction to wind the rectangle's contour.

Note: the contour initial point index is 0 (as defined below).

void SkPath::addRect ( const SkRect rect,
Direction  dir,
unsigned  start 
)

Add a closed rectangle contour to the path.

Parameters
rectThe rectangle to add as a closed contour to the path
dirThe direction to wind the rectangle's contour.
startInitial point of the contour (initial moveTo), expressed as a corner index, starting in the upper-left position, clock-wise:

0 1 *----—* | | *----—* 3 2

void SkPath::addRect ( SkScalar  left,
SkScalar  top,
SkScalar  right,
SkScalar  bottom,
Direction  dir = kCW_Direction 
)

Add a closed rectangle contour to the path.

Parameters
leftThe left side of a rectangle to add as a closed contour to the path
topThe top of a rectangle to add as a closed contour to the path
rightThe right side of a rectangle to add as a closed contour to the path
bottomThe bottom of a rectangle to add as a closed contour to the path
dirThe direction to wind the rectangle's contour.

Note: the contour initial point index is 0 (as defined above).

void SkPath::addRoundRect ( const SkRect rect,
SkScalar  rx,
SkScalar  ry,
Direction  dir = kCW_Direction 
)

Add a closed round-rectangle contour to the path.

Parameters
rectThe bounds of a round-rectangle to add as a closed contour
rxThe x-radius of the rounded corners on the round-rectangle
ryThe y-radius of the rounded corners on the round-rectangle
dirThe direction to wind the rectangle's contour.
void SkPath::addRoundRect ( const SkRect rect,
const SkScalar  radii[],
Direction  dir = kCW_Direction 
)

Add a closed round-rectangle contour to the path.

Each corner receives two radius values [X, Y]. The corners are ordered top-left, top-right, bottom-right, bottom-left.

Parameters
rectThe bounds of a round-rectangle to add as a closed contour
radiiArray of 8 scalars, 4 [X,Y] pairs for each corner
dirThe direction to wind the rectangle's contour. Note: The radii here now go through the same constraint handling as the SkRRect radii (i.e., either radii at a corner being 0 implies a sqaure corner and oversized radii are proportionally scaled down).
void SkPath::addRRect ( const SkRRect rrect,
Direction  dir = kCW_Direction 
)

Add an SkRRect contour to the path.

Parameters
rrectThe rounded rect to add as a closed contour
dirThe winding direction for the new contour.

Note: the contour initial point index is either 6 (for dir == kCW_Direction) or 7 (for dir == kCCW_Direction), as defined below.

void SkPath::addRRect ( const SkRRect rrect,
Direction  dir,
unsigned  start 
)

Add an SkRRect contour to the path.

Parameters
rrectThe rounded rect to add as a closed contour
dirThe winding direction for the new contour.
startInitial point of the contour (initial moveTo), expressed as an index of the radii minor/major points, ordered clock-wise:

0 1 *-—* 7 * * 2 | | 6 * * 3 *-—* 5 4

void SkPath::arcTo ( const SkRect oval,
SkScalar  startAngle,
SkScalar  sweepAngle,
bool  forceMoveTo 
)

Append the specified arc to the path.

If the start of the arc is different from the path's current last point, then an automatic lineTo() is added to connect the current contour to the start of the arc. However, if the path is empty, then we call moveTo() with the first point of the arc. The sweep angle is treated mod 360.

Parameters
ovalThe bounding oval defining the shape and size of the arc
startAngleStarting angle (in degrees) where the arc begins
sweepAngleSweep angle (in degrees) measured clockwise. This is treated mod 360.
forceMoveToIf true, always begin a new contour with the arc
void SkPath::arcTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  radius 
)

Append a line and arc to the current path.

This is the same as the PostScript call "arct".

void SkPath::arcTo ( const SkPoint  p1,
const SkPoint  p2,
SkScalar  radius 
)
inline

Append a line and arc to the current path.

This is the same as the PostScript call "arct".

void SkPath::arcTo ( SkScalar  rx,
SkScalar  ry,
SkScalar  xAxisRotate,
ArcSize  largeArc,
Direction  sweep,
SkScalar  x,
SkScalar  y 
)

Append an elliptical arc from the current point in the format used by SVG.

The center of the ellipse is computed to satisfy the constraints below.

Parameters
rx,ryThe radii in the x and y directions respectively.
xAxisRotateThe angle in degrees relative to the x-axis.
largeArcDetermines whether the smallest or largest arc possible is drawn.
sweepDetermines if the arc should be swept in an anti-clockwise or clockwise direction. Note that this enum value is opposite the SVG arc sweep value.
x,yThe destination coordinates.
void SkPath::close ( )

Close the current contour.

If the current point is not equal to the first point of the contour, a line segment is automatically added.

bool SkPath::conservativelyContainsRect ( const SkRect rect) const

Does a conservative test to see whether a rectangle is inside a path.

Currently it only will ever return true for single convex contour paths. The empty-status of the rect is not considered (e.g. a rect that is a point can be inside a path). Points or line segments where the rect edge touches the path border are not considered containment violations.

static int SkPath::ConvertConicToQuads ( const SkPoint p0,
const SkPoint p1,
const SkPoint p2,
SkScalar  w,
SkPoint  pts[],
int  pow2 
)
static

Chop a conic into N quads, stored continguously in pts[], where N = 1 << pow2.

The amount of storage needed is (1 + 2 * N)

static FillType SkPath::ConvertToNonInverseFillType ( FillType  fill)
inlinestatic

Returns the equivalent non-inverted fill type to the given fill type.

kWinding_FillType -> kWinding_FillType kEvenOdd_FillType -> kEvenOdd_FillType kInverseWinding_FillType -> kWinding_FillType kInverseEvenOdd_FillType -> kEvenOdd_FillType

void SkPath::copyFields ( const SkPath that)
private

Sets all fields other than fPathRef to the values in 'that'.

Assumes the caller has already set fPathRef. Doesn't change fGenerationID or fSourcePath on Android.

void SkPath::cubicTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  x3,
SkScalar  y3 
)

Add a cubic bezier from the last point, approaching control points (x1,y1) and (x2,y2), and ending at (x3,y3).

If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).

Parameters
x1The x-coordinate of the 1st control point on a cubic curve
y1The y-coordinate of the 1st control point on a cubic curve
x2The x-coordinate of the 2nd control point on a cubic curve
y2The y-coordinate of the 2nd control point on a cubic curve
x3The x-coordinate of the end point on a cubic curve
y3The y-coordinate of the end point on a cubic curve
void SkPath::cubicTo ( const SkPoint p1,
const SkPoint p2,
const SkPoint p3 
)
inline

Add a cubic bezier from the last point, approaching control points p1 and p2, and ending at p3.

If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).

Parameters
p1The 1st control point on a cubic curve
p2The 2nd control point on a cubic curve
p3The end point on a cubic curve
const SkRect& SkPath::getBounds ( ) const
inline

Returns the bounds of the path's points.

If the path contains zero points/verbs, this will return the "empty" rect [0, 0, 0, 0]. Note: this bounds may be larger than the actual shape, since curves do not extend as far as their control points. Additionally this bound encompases all points, even isolated moveTos either preceeding or following the last non-degenerate contour.

Convexity SkPath::getConvexity ( ) const
inline

Return the path's convexity, as stored in the path.

If it is currently unknown, then this function will attempt to compute the convexity (and cache the result).

Convexity SkPath::getConvexityOrUnknown ( ) const
inline

Return the currently cached value for convexity, even if that is set to kUnknown_Convexity.

Note: getConvexity() will automatically call ComputeConvexity and cache its return value if the current setting is kUnknown.

FillType SkPath::getFillType ( ) const
inline

Return the path's fill type.

This is used to define how "inside" is computed. The default value is kWinding_FillType.

Returns
the path's fill type
uint32_t SkPath::getGenerationID ( ) const

Returns a non-zero, globally unique value corresponding to the set of verbs and points in the path (but not the fill type [except on Android skbug.com/1762]).

Each time the path is modified, a different generation ID will be returned.

bool SkPath::getLastPt ( SkPoint lastPt) const

Return the last point on the path.

If no points have been added, (0,0) is returned. If there are no points, this returns false, otherwise it returns true.

Parameters
lastPtThe last point on the path is returned here
SkPoint SkPath::getPoint ( int  index) const

Return the point at the specified index.

If the index is out of range (i.e. is not 0 <= index < countPoints()) then the returned coordinates will be (0,0)

int SkPath::getPoints ( SkPoint  points[],
int  max 
) const

Returns the number of points in the path.

Up to max points are copied.

Parameters
pointsIf not null, receives up to max points
maxThe maximum number of points to copy into points
Returns
the actual number of points in the path
uint32_t SkPath::getSegmentMasks ( ) const
inline

Returns a mask, where each bit corresponding to a SegmentMask is set if the path contains 1 or more segments of that type.

Returns 0 for an empty path (no segments).

int SkPath::getVerbs ( uint8_t  verbs[],
int  max 
) const

Returns the number of verbs in the path.

Up to max verbs are copied. The verbs are copied as one byte per verb.

Parameters
verbsIf not null, receives up to max verbs
maxThe maximum number of verbs to copy into verbs
Returns
the actual number of verbs in the path
void SkPath::incReserve ( unsigned  extraPtCount)

Hint to the path to prepare for adding more points.

This can allow the path to more efficiently grow its storage.

Parameters
extraPtCountThe number of extra points the path should preallocate for.
bool SkPath::interpolate ( const SkPath ending,
SkScalar  weight,
SkPath out 
) const

Interpolate between two paths with same-sized point arrays.

The out path contains the verbs and weights of this path. The out points are a weighted average of this path and the ending path.

Parameters
endingThe path to interpolate between.
weightThe weight, from 0 to 1. The output points are set to (this->points * weight) + ending->points * (1 - weight).
Returns
true if the paths could be interpolated.
bool SkPath::isConvex ( ) const
inline

Returns true if the path is flagged as being convex.

This is not a confirmed by any analysis, it is just the value set earlier.

static bool SkPath::IsCubicDegenerate ( const SkPoint p1,
const SkPoint p2,
const SkPoint p3,
const SkPoint p4,
bool  exact 
)
inlinestatic

Test a cubic curve for zero length.

Returns
true if the cubic is of zero length; otherwise false.
bool SkPath::isEmpty ( ) const
inline

Returns true if the path is empty (contains no lines or curves)

Returns
true if the path is empty (contains no lines or curves)
bool SkPath::isInterpolatable ( const SkPath compare) const

Return true if the paths contain an equal array of verbs and weights.

Paths with equal verb counts can be readily interpolated. If the paths contain one or more conics, the conics' weights must also match.

Parameters
compareThe path to compare.
Returns
true if the paths have the same verbs and weights.
static bool SkPath::IsInverseFillType ( FillType  fill)
inlinestatic

Returns whether or not a fill type is inverted.

kWinding_FillType -> false kEvenOdd_FillType -> false kInverseWinding_FillType -> true kInverseEvenOdd_FillType -> true

bool SkPath::isLine ( SkPoint  line[2]) const

Returns true if the path specifies a single line (i.e.

it contains just a moveTo and a lineTo). If so, and line[] is not null, it sets the 2 points in line[] to the end-points of the line. If the path is not a line, returns false and ignores line[].

static bool SkPath::IsLineDegenerate ( const SkPoint p1,
const SkPoint p2,
bool  exact 
)
inlinestatic

Test a line for zero length.

Returns
true if the line is of zero length; otherwise false.
bool SkPath::isNestedFillRects ( SkRect  rect[2],
Direction  dirs[2] = NULL 
) const

Returns true if the path specifies a pair of nested rectangles, or would draw a pair of nested rectangles when filled.

If so, and if rect is not null, set rect[0] to the outer rectangle and rect[1] to the inner rectangle. If so, and dirs is not null, set dirs[0] to the direction of the outer rectangle and dirs[1] to the direction of the inner rectangle. If the path does not specify a pair of nested rectangles, return false and ignore rect and dirs.

Parameters
rectIf not null, returns the path as a pair of nested rectangles
dirsIf not null, returns the direction of the rects
Returns
true if the path describes a pair of nested rectangles
bool SkPath::isOval ( SkRect rect,
Direction dir = nullptr,
unsigned *  start = nullptr 
) const
inline

Returns true if the path is an oval.

Parameters
rectreturns the bounding rect of this oval. It's a circle if the height and width are the same.
diris the oval CCW (or CW if false).
startindicates where the contour starts on the oval (see SkPath::addOval for intepretation of the index).
Returns
true if this path is an oval. Tracking whether a path is an oval is considered an optimization for performance and so some paths that are in fact ovals can report false.
static bool SkPath::IsQuadDegenerate ( const SkPoint p1,
const SkPoint p2,
const SkPoint p3,
bool  exact 
)
inlinestatic

Test a quad for zero length.

Returns
true if the quad is of zero length; otherwise false.
bool SkPath::isRect ( SkRect rect,
bool *  isClosed = NULL,
Direction direction = NULL 
) const

Returns true if the path specifies a rectangle.

If this returns false, then all output parameters are ignored, and left unchanged. If this returns true, then each of the output parameters are checked for NULL. If they are not, they return their value.

Parameters
rectIf not null, set to the bounds of the rectangle. Note : this bounds may be smaller than the path's bounds, since it is just the bounds of the "drawable" parts of the path. e.g. a trailing MoveTo would be ignored in this rect, but not by the path's bounds
isClosedIf not null, set to true if the path is closed
directionIf not null, set to the rectangle's direction
Returns
true if the path specifies a rectangle
bool SkPath::isRRect ( SkRRect rrect,
Direction dir = nullptr,
unsigned *  start = nullptr 
) const
inline

Returns true if the path is a round rect.

Parameters
rrectReturns the bounding rect and radii of this round rect.
diris the rrect CCW (or CW if false).
startindicates where the contour starts on the rrect (see SkPath::addRRect for intepretation of the index).
Returns
true if this path is a round rect. Tracking whether a path is a round rect is considered an optimization for performance and so some paths that are in fact round rects can report false.
bool SkPath::isVolatile ( ) const
inline

Returns true if the path is volatile (i.e.

should not be cached by devices.)

void SkPath::lineTo ( SkScalar  x,
SkScalar  y 
)

Add a line from the last point to the specified point (x,y).

If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).

Parameters
xThe x-coordinate of the end of a line
yThe y-coordinate of the end of a line
void SkPath::lineTo ( const SkPoint p)
inline

Add a line from the last point to the specified point.

If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).

Parameters
pThe end of a line
void SkPath::moveTo ( SkScalar  x,
SkScalar  y 
)

Set the beginning of the next contour to the point (x,y).

Parameters
xThe x-coordinate of the start of a new contour
yThe y-coordinate of the start of a new contour
void SkPath::moveTo ( const SkPoint p)
inline

Set the beginning of the next contour to the point.

Parameters
pThe start of a new contour
void SkPath::offset ( SkScalar  dx,
SkScalar  dy,
SkPath dst 
) const

Offset the path by (dx,dy), returning true on success.

Parameters
dxThe amount in the X direction to offset the entire path
dyThe amount in the Y direction to offset the entire path
dstThe translated path is written here
void SkPath::offset ( SkScalar  dx,
SkScalar  dy 
)
inline

Offset the path by (dx,dy), returning true on success.

Parameters
dxThe amount in the X direction to offset the entire path
dyThe amount in the Y direction to offset the entire path
void SkPath::quadTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2 
)

Add a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2).

If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).

Parameters
x1The x-coordinate of the control point on a quadratic curve
y1The y-coordinate of the control point on a quadratic curve
x2The x-coordinate of the end point on a quadratic curve
y2The y-coordinate of the end point on a quadratic curve
void SkPath::quadTo ( const SkPoint p1,
const SkPoint p2 
)
inline

Add a quadratic bezier from the last point, approaching control point p1, and ending at p2.

If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).

Parameters
p1The control point on a quadratic curve
p2The end point on a quadratic curve
void SkPath::rArcTo ( SkScalar  rx,
SkScalar  ry,
SkScalar  xAxisRotate,
ArcSize  largeArc,
Direction  sweep,
SkScalar  dx,
SkScalar  dy 
)

Same as arcTo format used by SVG, but the destination coordinate is relative to the last point on this contour.

If there is no previous point, then a moveTo(0,0) is inserted automatically.

Parameters
rx,ryThe radii in the x and y directions respectively.
xAxisRotateThe angle in degrees relative to the x-axis.
largeArcDetermines whether the smallest or largest arc possible is drawn.
sweepDetermines if the arc should be swept in an anti-clockwise or clockwise direction. Note that this enum value is opposite the SVG arc sweep value.
dx,dyThe destination coordinates relative to the last point.
void SkPath::rCubicTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  x3,
SkScalar  y3 
)

Same as cubicTo, but the coordinates are considered relative to the current point on this contour.

If there is no previous point, then a moveTo(0,0) is inserted automatically.

Parameters
dx1The amount to add to the x-coordinate of the last point on this contour, to specify the 1st control point of a cubic curve
dy1The amount to add to the y-coordinate of the last point on this contour, to specify the 1st control point of a cubic curve
dx2The amount to add to the x-coordinate of the last point on this contour, to specify the 2nd control point of a cubic curve
dy2The amount to add to the y-coordinate of the last point on this contour, to specify the 2nd control point of a cubic curve
dx3The amount to add to the x-coordinate of the last point on this contour, to specify the end point of a cubic curve
dy3The amount to add to the y-coordinate of the last point on this contour, to specify the end point of a cubic curve
size_t SkPath::readFromMemory ( const void *  buffer,
size_t  length 
)

Initializes the path from the buffer.

Parameters
bufferMemory to read from
lengthAmount of memory available in the buffer
Returns
number of bytes read (must be a multiple of 4) or 0 if there was not enough memory available
void SkPath::reset ( )

Clear any lines and curves from the path, making it empty.

This frees up internal storage associated with those segments. On Android, does not change fSourcePath.

void SkPath::resetFields ( )
private

Resets all fields other than fPathRef to their initial 'empty' values.

Assumes the caller has already emptied fPathRef. On Android increments fGenerationID without reseting it.

void SkPath::rewind ( )

Similar to reset(), in that all lines and curves are removed from the path.

However, any internal storage for those lines/curves is retained, making reuse of the path potentially faster. On Android, does not change fSourcePath.

void SkPath::rLineTo ( SkScalar  dx,
SkScalar  dy 
)

Same as lineTo, but the coordinates are considered relative to the last point on this contour.

If there is no previous point, then a moveTo(0,0) is inserted automatically.

Parameters
dxThe amount to add to the x-coordinate of the previous point on this contour, to specify a line
dyThe amount to add to the y-coordinate of the previous point on this contour, to specify a line
void SkPath::rMoveTo ( SkScalar  dx,
SkScalar  dy 
)

Set the beginning of the next contour relative to the last point on the previous contour.

If there is no previous contour, this is treated the same as moveTo().

Parameters
dxThe amount to add to the x-coordinate of the end of the previous contour, to specify the start of a new contour
dyThe amount to add to the y-coordinate of the end of the previous contour, to specify the start of a new contour
void SkPath::rQuadTo ( SkScalar  dx1,
SkScalar  dy1,
SkScalar  dx2,
SkScalar  dy2 
)

Same as quadTo, but the coordinates are considered relative to the last point on this contour.

If there is no previous point, then a moveTo(0,0) is inserted automatically.

Parameters
dx1The amount to add to the x-coordinate of the last point on this contour, to specify the control point of a quadratic curve
dy1The amount to add to the y-coordinate of the last point on this contour, to specify the control point of a quadratic curve
dx2The amount to add to the x-coordinate of the last point on this contour, to specify the end point of a quadratic curve
dy2The amount to add to the y-coordinate of the last point on this contour, to specify the end point of a quadratic curve
void SkPath::setConvexity ( Convexity  )

Store a convexity setting in the path.

There is no automatic check to see if this value actually agrees with the return value that would be computed by getConvexity().

Note: even if this is set to a "known" value, if the path is later changed (e.g. lineTo(), addRect(), etc.) then the cached value will be reset to kUnknown_Convexity.

void SkPath::setFillType ( FillType  ft)
inline

Set the path's fill type.

This is used to define how "inside" is computed. The default value is kWinding_FillType.

Parameters
ftThe new fill type for this path
void SkPath::setIsConvex ( bool  isConvex)
inline

Set the isConvex flag to true or false.

Convex paths may draw faster if this flag is set, though setting this to true on a path that is in fact not convex can give undefined results when drawn. Paths default to isConvex == false

void SkPath::setIsVolatile ( bool  isVolatile)
inline

Specify whether this path is volatile.

Paths are not volatile by default. Temporary paths that are discarded or modified after use should be marked as volatile. This provides a hint to the device that the path should not be cached. Providing this hint when appropriate can improve performance by avoiding unnecessary overhead and resource consumption on the device.

void SkPath::setLastPt ( SkScalar  x,
SkScalar  y 
)

Set the last point on the path.

If no points have been added, moveTo(x,y) is automatically called.

Parameters
xThe new x-coordinate for the last point
yThe new y-coordinate for the last point
void SkPath::setLastPt ( const SkPoint p)
inline

Set the last point on the path.

If no points have been added, moveTo(p) is automatically called.

Parameters
pThe new location for the last point
void SkPath::toggleInverseFillType ( )
inline

Toggle between inverse and normal filltypes.

This reverse the return value of isInverseFillType()

void SkPath::transform ( const SkMatrix matrix,
SkPath dst 
) const

Transform the points in this path by matrix, and write the answer into dst.

Parameters
matrixThe matrix to apply to the path
dstThe transformed path is written here
void SkPath::transform ( const SkMatrix matrix)
inline

Transform the points in this path by matrix.

Parameters
matrixThe matrix to apply to the path
void SkPath::updateBoundsCache ( ) const
inline

Calling this will, if the internal cache of the bounds is out of date, update it so that subsequent calls to getBounds will be instantaneous.

This also means that any copies or simple transformations of the path will inherit the cached bounds.

size_t SkPath::writeToMemory ( void *  buffer) const

Write the path to the buffer, and return the number of bytes written.

If buffer is NULL, it still returns the number of bytes.


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