2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkPath_DEFINED
|
|
|
|
#define SkPath_DEFINED
|
|
|
|
|
|
|
|
#include "SkMatrix.h"
|
2017-06-07 14:57:22 +00:00
|
|
|
#include "../private/SkPathRef.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
class SkAutoPathBoundsUpdate;
|
2017-07-26 21:33:44 +00:00
|
|
|
class SkData;
|
2012-12-12 20:48:18 +00:00
|
|
|
class SkRRect;
|
2014-06-24 15:30:15 +00:00
|
|
|
class SkWStream;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** \class SkPath
|
2018-02-27 15:22:04 +00:00
|
|
|
SkPath contain geometry. SkPath may be empty, or contain one or more verbs that
|
2018-01-03 15:00:34 +00:00
|
|
|
outline a figure. SkPath always starts with a move verb to a Cartesian_Coordinate,
|
|
|
|
and may be followed by additional verbs that add lines or curves.
|
2017-09-21 16:28:43 +00:00
|
|
|
Adding a close verb makes the geometry into a continuous loop, a closed contour.
|
2018-02-27 15:22:04 +00:00
|
|
|
SkPath may contain any number of contours, each beginning with a move verb.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
SkPath contours may contain only a move verb, or may also contain lines,
|
|
|
|
quadratic beziers, conics, and cubic beziers. SkPath contours may be open or
|
|
|
|
closed.
|
|
|
|
|
|
|
|
When used to draw a filled area, SkPath describes whether the fill is inside or
|
|
|
|
outside the geometry. SkPath also describes the winding rule used to fill
|
|
|
|
overlapping contours.
|
|
|
|
|
|
|
|
Internally, SkPath lazily computes metrics likes bounds and convexity. Call
|
|
|
|
SkPath::updateBoundsCache to make SkPath thread safe.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2011-03-15 21:27:08 +00:00
|
|
|
class SK_API SkPath {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2016-05-27 16:17:04 +00:00
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** \enum SkPath::Direction
|
|
|
|
Direction describes whether contour is clockwise or counterclockwise.
|
|
|
|
When SkPath contains multiple overlapping contours, Direction together with
|
|
|
|
FillType determines whether overlaps are filled or form holes.
|
|
|
|
|
|
|
|
Direction also determines how contour is measured. For instance, dashing
|
|
|
|
measures along SkPath to determine where to start and stop stroke; Direction
|
|
|
|
will change dashed results as it steps clockwise or counterclockwise.
|
|
|
|
|
|
|
|
Closed contours like SkRect, SkRRect, circle, and oval added with
|
|
|
|
kCW_Direction travel clockwise; the same added with kCCW_Direction
|
|
|
|
travel counterclockwise.
|
|
|
|
*/
|
|
|
|
enum Direction {
|
2018-05-30 13:20:29 +00:00
|
|
|
kCW_Direction, //!< contour travels clockwise
|
|
|
|
kCCW_Direction, //!< contour travels counterclockwise
|
2017-10-30 15:48:35 +00:00
|
|
|
};
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** By default, SkPath has no verbs, no SkPoint, and no weights.
|
2017-09-01 17:49:54 +00:00
|
|
|
SkPath::FillType is set to kWinding_FillType.
|
|
|
|
|
|
|
|
@return empty SkPath
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
SkPath();
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
/** Copy constructor makes two paths identical by value. Internally, path and
|
2018-01-03 15:00:34 +00:00
|
|
|
the returned result share pointer values. The underlying verb array, SkPoint array
|
2017-09-01 17:49:54 +00:00
|
|
|
and weights are copied when modified.
|
|
|
|
|
|
|
|
Creating a SkPath copy is very efficient and never allocates memory.
|
2018-02-27 15:22:04 +00:00
|
|
|
SkPath are always copied by value from the interface; the underlying shared
|
2017-09-01 17:49:54 +00:00
|
|
|
pointers are not exposed.
|
|
|
|
|
|
|
|
@param path SkPath to copy by value
|
|
|
|
@return copy of SkPath
|
|
|
|
*/
|
2017-05-18 19:27:57 +00:00
|
|
|
SkPath(const SkPath& path);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
/** Releases ownership of any shared data and deletes data if SkPath is sole owner.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
~SkPath();
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** SkPath assignment makes two paths identical by value. Internally, assignment
|
2018-01-03 15:00:34 +00:00
|
|
|
shares pointer values. The underlying verb array, SkPoint array and weights
|
2017-09-01 17:49:54 +00:00
|
|
|
are copied when modified.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
Copying SkPath by assignment is very efficient and never allocates memory.
|
|
|
|
SkPath are always copied by value from the interface; the underlying shared
|
2017-09-01 17:49:54 +00:00
|
|
|
pointers are not exposed.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
@param path verb array, SkPoint array, weights, and SkPath::FillType to copy
|
2017-09-01 17:49:54 +00:00
|
|
|
@return SkPath copied by value
|
|
|
|
*/
|
2017-05-18 19:27:57 +00:00
|
|
|
SkPath& operator=(const SkPath& path);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights
|
2017-09-01 17:49:54 +00:00
|
|
|
are equivalent.
|
|
|
|
|
|
|
|
@param a SkPath to compare
|
|
|
|
@param b SkPath to compare
|
|
|
|
@return true if SkPath pair are equivalent
|
|
|
|
*/
|
2017-05-18 19:27:57 +00:00
|
|
|
friend SK_API bool operator==(const SkPath& a, const SkPath& b);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights
|
2017-09-01 17:49:54 +00:00
|
|
|
are not equivalent.
|
|
|
|
|
|
|
|
@param a SkPath to compare
|
|
|
|
@param b SkPath to compare
|
|
|
|
@return true if SkPath pair are not equivalent
|
|
|
|
*/
|
2009-03-02 05:36:20 +00:00
|
|
|
friend bool operator!=(const SkPath& a, const SkPath& b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Return true if SkPath contain equal verbs and equal weights.
|
|
|
|
If SkPath contain one or more conics, the weights must match.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
conicTo() may add different verbs depending on conic weight, so it is not
|
2018-02-27 15:22:04 +00:00
|
|
|
trivial to interpolate a pair of SkPath containing conics with different
|
2017-09-01 17:49:54 +00:00
|
|
|
conic weight values.
|
|
|
|
|
|
|
|
@param compare SkPath to compare
|
2018-02-27 15:22:04 +00:00
|
|
|
@return true if SkPath verb array and weights are equivalent
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2016-02-18 12:11:48 +00:00
|
|
|
bool isInterpolatable(const SkPath& compare) const;
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Interpolate between SkPath with SkPoint array of equal size.
|
2018-01-03 15:00:34 +00:00
|
|
|
Copy verb array and weights to out, and set out SkPoint array to a weighted
|
2018-02-27 15:22:04 +00:00
|
|
|
average of this SkPoint array and ending SkPoint array, using the formula: (Path Point * weight) + ending Point * (1 - weight).
|
2017-09-21 16:28:43 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
weight is most useful when between zero (ending SkPoint array) and
|
2017-09-21 16:28:43 +00:00
|
|
|
one (this Point_Array); will work with values outside of this
|
|
|
|
range.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
interpolate() returns false and leaves out unchanged if SkPoint array is not
|
|
|
|
the same size as ending SkPoint array. Call isInterpolatable() to check SkPath
|
2017-09-21 16:28:43 +00:00
|
|
|
compatibility prior to calling interpolate().
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
@param ending SkPoint array averaged with this SkPoint array
|
|
|
|
@param weight contribution of this SkPoint array, and
|
|
|
|
one minus contribution of ending SkPoint array
|
2017-09-01 17:49:54 +00:00
|
|
|
@param out SkPath replaced by interpolated averages
|
2018-02-27 15:22:04 +00:00
|
|
|
@return true if SkPath contain same number of SkPoint
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2016-02-18 12:11:48 +00:00
|
|
|
bool interpolate(const SkPath& ending, SkScalar weight, SkPath* out) const;
|
|
|
|
|
2015-02-12 20:08:40 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
2018-02-27 15:22:04 +00:00
|
|
|
/** To be deprecated soon.
|
|
|
|
Only valid for Android framework.
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2015-02-12 20:08:40 +00:00
|
|
|
bool unique() const { return fPathRef->unique(); }
|
|
|
|
#endif
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \enum SkPath::FillType
|
|
|
|
FillType selects the rule used to fill SkPath. SkPath set to kWinding_FillType
|
|
|
|
fills if the sum of contour edges is not zero, where clockwise edges add one, and
|
|
|
|
counterclockwise edges subtract one. SkPath set to kEvenOdd_FillType fills if the
|
|
|
|
number of contour edges is odd. Each FillType has an inverse variant that
|
|
|
|
reverses the rule:
|
|
|
|
kInverseWinding_FillType fills where the sum of contour edges is zero;
|
|
|
|
kInverseEvenOdd_FillType fills where the number of contour edges is even.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
enum FillType {
|
2018-05-30 13:20:29 +00:00
|
|
|
kWinding_FillType, //!< is enclosed by a non-zero sum of contour directions
|
|
|
|
kEvenOdd_FillType, //!< is enclosed by an odd number of contours
|
|
|
|
kInverseWinding_FillType, //!< is enclosed by a zero sum of contour directions
|
|
|
|
kInverseEvenOdd_FillType, //!< is enclosed by an even number of contours
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns FillType, the rule used to fill SkPath. FillType of a new SkPath is
|
|
|
|
kWinding_FillType.
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@return one of: kWinding_FillType, kEvenOdd_FillType, kInverseWinding_FillType,
|
|
|
|
kInverseEvenOdd_FillType
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
FillType getFillType() const { return (FillType)fFillType; }
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Sets FillType, the rule used to fill SkPath. While there is no check
|
|
|
|
that ft is legal, values outside of FillType are not supported.
|
2011-12-21 20:43:13 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param ft one of: kWinding_FillType, kEvenOdd_FillType, kInverseWinding_FillType,
|
|
|
|
kInverseEvenOdd_FillType
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2011-04-15 13:41:26 +00:00
|
|
|
void setFillType(FillType ft) {
|
|
|
|
fFillType = SkToU8(ft);
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns if FillType describes area outside SkPath geometry. The inverse fill area
|
|
|
|
extends indefinitely.
|
|
|
|
|
|
|
|
@return true if FillType is kInverseWinding_FillType or kInverseEvenOdd_FillType
|
|
|
|
*/
|
2012-12-17 21:16:45 +00:00
|
|
|
bool isInverseFillType() const { return IsInverseFillType((FillType)fFillType); }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Replace FillType with its inverse. The inverse of FillType describes the area
|
|
|
|
unmodified by the original FillType.
|
|
|
|
*/
|
2011-04-15 13:41:26 +00:00
|
|
|
void toggleInverseFillType() {
|
|
|
|
fFillType ^= 2;
|
2013-12-12 23:03:51 +00:00
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \enum SkPath::Convexity
|
|
|
|
SkPath is convex if it contains one contour and contour loops no more than
|
|
|
|
360 degrees, and contour angles all have same Direction. Convex SkPath
|
|
|
|
may have better performance and require fewer resources on GPU surface.
|
|
|
|
|
|
|
|
SkPath is concave when either at least one Direction change is clockwise and
|
|
|
|
another is counterclockwise, or the sum of the changes in Direction is not 360
|
|
|
|
degrees.
|
|
|
|
|
|
|
|
Initially SkPath Convexity is kUnknown_Convexity. SkPath Convexity is computed
|
|
|
|
if needed by destination SkSurface.
|
|
|
|
*/
|
2017-09-27 17:26:22 +00:00
|
|
|
enum Convexity : uint8_t {
|
2018-05-30 13:20:29 +00:00
|
|
|
kUnknown_Convexity, //!< indicates Convexity has not been determined
|
|
|
|
kConvex_Convexity, //!< one contour made of a simple geometry without indentations
|
|
|
|
kConcave_Convexity, //!< more than one contour, or a geometry with indentations
|
2011-05-15 04:08:24 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Computes SkPath::Convexity if required, and returns stored value.
|
|
|
|
SkPath::Convexity is computed if stored value is kUnknown_Convexity,
|
|
|
|
or if SkPath has been altered since SkPath::Convexity was computed or set.
|
|
|
|
|
|
|
|
@return computed or stored SkPath::Convexity
|
|
|
|
*/
|
2011-05-16 14:16:04 +00:00
|
|
|
Convexity getConvexity() const {
|
2017-09-27 17:26:22 +00:00
|
|
|
for (Convexity convexity = fConvexity.load(); kUnknown_Convexity != convexity; ) {
|
|
|
|
return convexity;
|
2011-05-16 14:16:04 +00:00
|
|
|
}
|
2017-09-27 17:26:22 +00:00
|
|
|
return this->internalGetConvexity();
|
2011-05-16 14:16:04 +00:00
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns last computed SkPath::Convexity, or kUnknown_Convexity if
|
|
|
|
SkPath has been altered since SkPath::Convexity was computed or set.
|
|
|
|
|
|
|
|
@return stored SkPath::Convexity
|
|
|
|
*/
|
2011-05-16 14:16:04 +00:00
|
|
|
Convexity getConvexityOrUnknown() const { return (Convexity)fConvexity; }
|
2011-05-15 04:08:24 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Stores convexity so that it is later returned by getConvexity() or getConvexityOrUnknown().
|
|
|
|
convexity may differ from getConvexity(), although setting an incorrect value may
|
|
|
|
cause incorrect or inefficient drawing.
|
|
|
|
|
|
|
|
If convexity is kUnknown_Convexity: getConvexity() will
|
|
|
|
compute SkPath::Convexity, and getConvexityOrUnknown() will return kUnknown_Convexity.
|
|
|
|
|
|
|
|
If convexity is kConvex_Convexity or kConcave_Convexity, getConvexity()
|
|
|
|
and getConvexityOrUnknown() will return convexity until the path is
|
|
|
|
altered.
|
|
|
|
|
|
|
|
@param convexity one of: kUnknown_Convexity, kConvex_Convexity, or kConcave_Convexity
|
|
|
|
*/
|
2017-05-18 19:27:57 +00:00
|
|
|
void setConvexity(Convexity convexity);
|
2011-05-15 04:08:24 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Computes SkPath::Convexity if required, and returns true if value is kConvex_Convexity.
|
|
|
|
If setConvexity() was called with kConvex_Convexity or kConcave_Convexity, and
|
|
|
|
the path has not been altered, SkPath::Convexity is not recomputed.
|
|
|
|
|
|
|
|
@return true if SkPath::Convexity stored or computed is kConvex_Convexity
|
|
|
|
*/
|
2011-05-15 04:08:24 +00:00
|
|
|
bool isConvex() const {
|
|
|
|
return kConvex_Convexity == this->getConvexity();
|
|
|
|
}
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns true if this path is recognized as an oval or circle.
|
|
|
|
|
|
|
|
bounds receives bounds of oval.
|
|
|
|
|
|
|
|
bounds is unmodified if oval is not found.
|
|
|
|
|
|
|
|
@param bounds storage for bounding SkRect of oval; may be nullptr
|
|
|
|
@return true if SkPath is recognized as an oval or circle
|
|
|
|
*/
|
2018-02-20 18:57:05 +00:00
|
|
|
bool isOval(SkRect* bounds) const;
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns true if this path is recognized as a SkRRect (but not an oval/circle or rect).
|
|
|
|
|
|
|
|
rrect receives bounds of SkRRect.
|
|
|
|
|
|
|
|
rrect is unmodified if SkRRect is not found.
|
|
|
|
|
|
|
|
@param rrect storage for bounding SkRect of SkRRect; may be nullptr
|
|
|
|
@return true if SkPath contains only SkRRect
|
|
|
|
*/
|
2018-02-20 18:57:05 +00:00
|
|
|
bool isRRect(SkRRect* rrect) const;
|
2015-11-19 22:47:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Sets SkPath to its initial state.
|
2018-01-03 15:00:34 +00:00
|
|
|
Removes verb array, SkPoint array, and weights, and sets FillType to kWinding_FillType.
|
2017-09-01 17:49:54 +00:00
|
|
|
Internal storage associated with SkPath is released.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void reset();
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Sets SkPath to its initial state, preserving internal storage.
|
2018-01-03 15:00:34 +00:00
|
|
|
Removes verb array, SkPoint array, and weights, and sets FillType to kWinding_FillType.
|
2017-09-01 17:49:54 +00:00
|
|
|
Internal storage associated with SkPath is retained.
|
|
|
|
|
|
|
|
Use rewind() instead of reset() if SkPath storage will be reused and performance
|
|
|
|
is critical.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void rewind();
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Empty SkPath may have FillType but has no SkPoint, SkPath::Verb, or conic weight.
|
|
|
|
SkPath() constructs empty SkPath; reset() and (rewind) make SkPath empty.
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@return true if the path contains no SkPath::Verb array
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2013-09-26 12:18:23 +00:00
|
|
|
bool isEmpty() const {
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
return 0 == fPathRef->countVerbs();
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Contour is closed if SkPath SkPath::Verb array was last modified by close(). When stroked,
|
|
|
|
closed contour draws SkPaint::Join instead of SkPaint::Cap at first and last SkPoint.
|
|
|
|
|
|
|
|
@return true if the last contour ends with a kClose_Verb
|
|
|
|
*/
|
2016-01-20 17:51:07 +00:00
|
|
|
bool isLastContourClosed() const;
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true for finite SkPoint array values between negative SK_ScalarMax and
|
|
|
|
positive SK_ScalarMax. Returns false for any SkPoint array value of
|
|
|
|
SK_ScalarInfinity, SK_ScalarNegativeInfinity, or SK_ScalarNaN.
|
|
|
|
|
|
|
|
@return true if all SkPoint values are finite
|
|
|
|
*/
|
2012-07-26 15:20:36 +00:00
|
|
|
bool isFinite() const {
|
2013-09-26 12:18:23 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
return fPathRef->isFinite();
|
2012-07-26 15:20:36 +00:00
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if the path is volatile; it will not be altered or discarded
|
2018-02-27 15:22:04 +00:00
|
|
|
by the caller after it is drawn. SkPath by default have volatile set false, allowing
|
2017-09-01 17:49:54 +00:00
|
|
|
SkSurface to attach a cache of data which speeds repeated drawing. If true, SkSurface
|
|
|
|
may not speed repeated drawing.
|
|
|
|
|
|
|
|
@return true if caller will alter SkPath after drawing
|
|
|
|
*/
|
2014-10-24 14:12:51 +00:00
|
|
|
bool isVolatile() const {
|
|
|
|
return SkToBool(fIsVolatile);
|
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Specify whether SkPath is volatile; whether it will be altered or discarded
|
2018-02-27 15:22:04 +00:00
|
|
|
by the caller after it is drawn. SkPath by default have volatile set false, allowing
|
2017-09-01 17:49:54 +00:00
|
|
|
SkBaseDevice to attach a cache of data which speeds repeated drawing.
|
|
|
|
|
|
|
|
Mark temporary paths, discarded or modified after use, as volatile
|
|
|
|
to inform SkBaseDevice that the path need not be cached.
|
|
|
|
|
|
|
|
Mark animating SkPath volatile to improve performance.
|
|
|
|
Mark unchanging SkPath non-volatile to improve repeated rendering.
|
|
|
|
|
|
|
|
raster surface SkPath draws are affected by volatile for some shadows.
|
|
|
|
GPU surface SkPath draws are affected by volatile for some shadows and concave geometries.
|
|
|
|
|
|
|
|
@param isVolatile true if caller will alter SkPath after drawing
|
|
|
|
*/
|
2014-10-24 14:12:51 +00:00
|
|
|
void setIsVolatile(bool isVolatile) {
|
|
|
|
fIsVolatile = isVolatile;
|
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Test if line between SkPoint pair is degenerate.
|
|
|
|
Line with no length or that moves a very short distance is degenerate; it is
|
|
|
|
treated as a point.
|
|
|
|
|
|
|
|
exact changes the equality test. If true, returns true only if p1 equals p2.
|
|
|
|
If false, returns true if p1 equals or nearly equals p2.
|
Modifying SkPath to store all verbs provided by the user, and to give
correct results for all stroke and fill modes even on the various types
of degenerate paths.
The goals of this patch include:
1. Have Skia store all of the verbs implied by path construction methods, even
if those define degenerate paths. The SVG implementation in WebKit, which is
backed by Skia, needs to know about all elements of the path, even degenerate
ones, for the correct drawing of markers and line caps. For example, in SVG you
should be able to draw a scatter plot by specifying a marker for vertices and
then giving a sequence of moveTo commands. Skia will not store the moveTos,
requiring a different storage mechanism.
2. Assuming 1, maintain the current Skia behavior. That is, make Skia robust to
degenerate paths.
3. Fix an existing bug in Skia where a degenerate moveTo-lineTo pair spits out
warnings from rasterization and produces incorrect results in inverse-fill
renderings.
4. Adds extensive testing for degenerate paths and path rendering in general.
To meet these goals, the patch I am proposing will result in minor additional
storage for degenerate paths (a few bytes per degenerate path, only if the user
defines such paths). There is also some additional overhead in the iteration
code, with the path now cleaned to remove degenerate segments as part of the
iteration process. I suspect this will also fix issues with computing normal
vectors to degenerate segments. Benchmarking suggests that this change may
result in slightly (< 1%) slower path drawing due to the checks for
degeneracy. This overhead could be removed (in fact, a significant speedup
could occur) if the results of iterating to clean up the path were cached.
This would cost memory, of course, and quite a bit of it.
BUG=398
TEST=tests/PathTest.cpp
gm/cubicpaths.cpp
gm/degeneratesegments.cpp
gm/movepaths.cpp
gm/linepaths.cpp
gm/quadpaths.cpp
Review URL: http://codereview.appspot.com/5482051
git-svn-id: http://skia.googlecode.com/svn/trunk@2901 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-12-20 15:14:18 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param p1 line start point
|
|
|
|
@param p2 line end point
|
|
|
|
@param exact if false, allow nearly equals
|
|
|
|
@return true if line is degenerate; its length is effectively zero
|
Modifying SkPath to store all verbs provided by the user, and to give
correct results for all stroke and fill modes even on the various types
of degenerate paths.
The goals of this patch include:
1. Have Skia store all of the verbs implied by path construction methods, even
if those define degenerate paths. The SVG implementation in WebKit, which is
backed by Skia, needs to know about all elements of the path, even degenerate
ones, for the correct drawing of markers and line caps. For example, in SVG you
should be able to draw a scatter plot by specifying a marker for vertices and
then giving a sequence of moveTo commands. Skia will not store the moveTos,
requiring a different storage mechanism.
2. Assuming 1, maintain the current Skia behavior. That is, make Skia robust to
degenerate paths.
3. Fix an existing bug in Skia where a degenerate moveTo-lineTo pair spits out
warnings from rasterization and produces incorrect results in inverse-fill
renderings.
4. Adds extensive testing for degenerate paths and path rendering in general.
To meet these goals, the patch I am proposing will result in minor additional
storage for degenerate paths (a few bytes per degenerate path, only if the user
defines such paths). There is also some additional overhead in the iteration
code, with the path now cleaned to remove degenerate segments as part of the
iteration process. I suspect this will also fix issues with computing normal
vectors to degenerate segments. Benchmarking suggests that this change may
result in slightly (< 1%) slower path drawing due to the checks for
degeneracy. This overhead could be removed (in fact, a significant speedup
could occur) if the results of iterating to clean up the path were cached.
This would cost memory, of course, and quite a bit of it.
BUG=398
TEST=tests/PathTest.cpp
gm/cubicpaths.cpp
gm/degeneratesegments.cpp
gm/movepaths.cpp
gm/linepaths.cpp
gm/quadpaths.cpp
Review URL: http://codereview.appspot.com/5482051
git-svn-id: http://skia.googlecode.com/svn/trunk@2901 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-12-20 15:14:18 +00:00
|
|
|
*/
|
2017-11-08 16:44:31 +00:00
|
|
|
static bool IsLineDegenerate(const SkPoint& p1, const SkPoint& p2, bool exact);
|
Modifying SkPath to store all verbs provided by the user, and to give
correct results for all stroke and fill modes even on the various types
of degenerate paths.
The goals of this patch include:
1. Have Skia store all of the verbs implied by path construction methods, even
if those define degenerate paths. The SVG implementation in WebKit, which is
backed by Skia, needs to know about all elements of the path, even degenerate
ones, for the correct drawing of markers and line caps. For example, in SVG you
should be able to draw a scatter plot by specifying a marker for vertices and
then giving a sequence of moveTo commands. Skia will not store the moveTos,
requiring a different storage mechanism.
2. Assuming 1, maintain the current Skia behavior. That is, make Skia robust to
degenerate paths.
3. Fix an existing bug in Skia where a degenerate moveTo-lineTo pair spits out
warnings from rasterization and produces incorrect results in inverse-fill
renderings.
4. Adds extensive testing for degenerate paths and path rendering in general.
To meet these goals, the patch I am proposing will result in minor additional
storage for degenerate paths (a few bytes per degenerate path, only if the user
defines such paths). There is also some additional overhead in the iteration
code, with the path now cleaned to remove degenerate segments as part of the
iteration process. I suspect this will also fix issues with computing normal
vectors to degenerate segments. Benchmarking suggests that this change may
result in slightly (< 1%) slower path drawing due to the checks for
degeneracy. This overhead could be removed (in fact, a significant speedup
could occur) if the results of iterating to clean up the path were cached.
This would cost memory, of course, and quite a bit of it.
BUG=398
TEST=tests/PathTest.cpp
gm/cubicpaths.cpp
gm/degeneratesegments.cpp
gm/movepaths.cpp
gm/linepaths.cpp
gm/quadpaths.cpp
Review URL: http://codereview.appspot.com/5482051
git-svn-id: http://skia.googlecode.com/svn/trunk@2901 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-12-20 15:14:18 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Test if quad is degenerate.
|
|
|
|
Quad with no length or that moves a very short distance is degenerate; it is
|
|
|
|
treated as a point.
|
Modifying SkPath to store all verbs provided by the user, and to give
correct results for all stroke and fill modes even on the various types
of degenerate paths.
The goals of this patch include:
1. Have Skia store all of the verbs implied by path construction methods, even
if those define degenerate paths. The SVG implementation in WebKit, which is
backed by Skia, needs to know about all elements of the path, even degenerate
ones, for the correct drawing of markers and line caps. For example, in SVG you
should be able to draw a scatter plot by specifying a marker for vertices and
then giving a sequence of moveTo commands. Skia will not store the moveTos,
requiring a different storage mechanism.
2. Assuming 1, maintain the current Skia behavior. That is, make Skia robust to
degenerate paths.
3. Fix an existing bug in Skia where a degenerate moveTo-lineTo pair spits out
warnings from rasterization and produces incorrect results in inverse-fill
renderings.
4. Adds extensive testing for degenerate paths and path rendering in general.
To meet these goals, the patch I am proposing will result in minor additional
storage for degenerate paths (a few bytes per degenerate path, only if the user
defines such paths). There is also some additional overhead in the iteration
code, with the path now cleaned to remove degenerate segments as part of the
iteration process. I suspect this will also fix issues with computing normal
vectors to degenerate segments. Benchmarking suggests that this change may
result in slightly (< 1%) slower path drawing due to the checks for
degeneracy. This overhead could be removed (in fact, a significant speedup
could occur) if the results of iterating to clean up the path were cached.
This would cost memory, of course, and quite a bit of it.
BUG=398
TEST=tests/PathTest.cpp
gm/cubicpaths.cpp
gm/degeneratesegments.cpp
gm/movepaths.cpp
gm/linepaths.cpp
gm/quadpaths.cpp
Review URL: http://codereview.appspot.com/5482051
git-svn-id: http://skia.googlecode.com/svn/trunk@2901 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-12-20 15:14:18 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param p1 quad start point
|
|
|
|
@param p2 quad control point
|
|
|
|
@param p3 quad end point
|
2017-09-01 17:49:54 +00:00
|
|
|
@param exact if true, returns true only if p1, p2, and p3 are equal;
|
|
|
|
if false, returns true if p1, p2, and p3 are equal or nearly equal
|
|
|
|
@return true if quad is degenerate; its length is effectively zero
|
Modifying SkPath to store all verbs provided by the user, and to give
correct results for all stroke and fill modes even on the various types
of degenerate paths.
The goals of this patch include:
1. Have Skia store all of the verbs implied by path construction methods, even
if those define degenerate paths. The SVG implementation in WebKit, which is
backed by Skia, needs to know about all elements of the path, even degenerate
ones, for the correct drawing of markers and line caps. For example, in SVG you
should be able to draw a scatter plot by specifying a marker for vertices and
then giving a sequence of moveTo commands. Skia will not store the moveTos,
requiring a different storage mechanism.
2. Assuming 1, maintain the current Skia behavior. That is, make Skia robust to
degenerate paths.
3. Fix an existing bug in Skia where a degenerate moveTo-lineTo pair spits out
warnings from rasterization and produces incorrect results in inverse-fill
renderings.
4. Adds extensive testing for degenerate paths and path rendering in general.
To meet these goals, the patch I am proposing will result in minor additional
storage for degenerate paths (a few bytes per degenerate path, only if the user
defines such paths). There is also some additional overhead in the iteration
code, with the path now cleaned to remove degenerate segments as part of the
iteration process. I suspect this will also fix issues with computing normal
vectors to degenerate segments. Benchmarking suggests that this change may
result in slightly (< 1%) slower path drawing due to the checks for
degeneracy. This overhead could be removed (in fact, a significant speedup
could occur) if the results of iterating to clean up the path were cached.
This would cost memory, of course, and quite a bit of it.
BUG=398
TEST=tests/PathTest.cpp
gm/cubicpaths.cpp
gm/degeneratesegments.cpp
gm/movepaths.cpp
gm/linepaths.cpp
gm/quadpaths.cpp
Review URL: http://codereview.appspot.com/5482051
git-svn-id: http://skia.googlecode.com/svn/trunk@2901 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-12-20 15:14:18 +00:00
|
|
|
*/
|
|
|
|
static bool IsQuadDegenerate(const SkPoint& p1, const SkPoint& p2,
|
2017-11-08 16:44:31 +00:00
|
|
|
const SkPoint& p3, bool exact);
|
Modifying SkPath to store all verbs provided by the user, and to give
correct results for all stroke and fill modes even on the various types
of degenerate paths.
The goals of this patch include:
1. Have Skia store all of the verbs implied by path construction methods, even
if those define degenerate paths. The SVG implementation in WebKit, which is
backed by Skia, needs to know about all elements of the path, even degenerate
ones, for the correct drawing of markers and line caps. For example, in SVG you
should be able to draw a scatter plot by specifying a marker for vertices and
then giving a sequence of moveTo commands. Skia will not store the moveTos,
requiring a different storage mechanism.
2. Assuming 1, maintain the current Skia behavior. That is, make Skia robust to
degenerate paths.
3. Fix an existing bug in Skia where a degenerate moveTo-lineTo pair spits out
warnings from rasterization and produces incorrect results in inverse-fill
renderings.
4. Adds extensive testing for degenerate paths and path rendering in general.
To meet these goals, the patch I am proposing will result in minor additional
storage for degenerate paths (a few bytes per degenerate path, only if the user
defines such paths). There is also some additional overhead in the iteration
code, with the path now cleaned to remove degenerate segments as part of the
iteration process. I suspect this will also fix issues with computing normal
vectors to degenerate segments. Benchmarking suggests that this change may
result in slightly (< 1%) slower path drawing due to the checks for
degeneracy. This overhead could be removed (in fact, a significant speedup
could occur) if the results of iterating to clean up the path were cached.
This would cost memory, of course, and quite a bit of it.
BUG=398
TEST=tests/PathTest.cpp
gm/cubicpaths.cpp
gm/degeneratesegments.cpp
gm/movepaths.cpp
gm/linepaths.cpp
gm/quadpaths.cpp
Review URL: http://codereview.appspot.com/5482051
git-svn-id: http://skia.googlecode.com/svn/trunk@2901 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-12-20 15:14:18 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Test if cubic is degenerate.
|
|
|
|
Cubic with no length or that moves a very short distance is degenerate; it is
|
|
|
|
treated as a point.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param p1 cubic start point
|
|
|
|
@param p2 cubic control point 1
|
|
|
|
@param p3 cubic control point 2
|
|
|
|
@param p4 cubic end point
|
2017-09-01 17:49:54 +00:00
|
|
|
@param exact if true, returns true only if p1, p2, p3, and p4 are equal;
|
|
|
|
if false, returns true if p1, p2, p3, and p4 are equal or nearly equal
|
|
|
|
@return true if cubic is degenerate; its length is effectively zero
|
Modifying SkPath to store all verbs provided by the user, and to give
correct results for all stroke and fill modes even on the various types
of degenerate paths.
The goals of this patch include:
1. Have Skia store all of the verbs implied by path construction methods, even
if those define degenerate paths. The SVG implementation in WebKit, which is
backed by Skia, needs to know about all elements of the path, even degenerate
ones, for the correct drawing of markers and line caps. For example, in SVG you
should be able to draw a scatter plot by specifying a marker for vertices and
then giving a sequence of moveTo commands. Skia will not store the moveTos,
requiring a different storage mechanism.
2. Assuming 1, maintain the current Skia behavior. That is, make Skia robust to
degenerate paths.
3. Fix an existing bug in Skia where a degenerate moveTo-lineTo pair spits out
warnings from rasterization and produces incorrect results in inverse-fill
renderings.
4. Adds extensive testing for degenerate paths and path rendering in general.
To meet these goals, the patch I am proposing will result in minor additional
storage for degenerate paths (a few bytes per degenerate path, only if the user
defines such paths). There is also some additional overhead in the iteration
code, with the path now cleaned to remove degenerate segments as part of the
iteration process. I suspect this will also fix issues with computing normal
vectors to degenerate segments. Benchmarking suggests that this change may
result in slightly (< 1%) slower path drawing due to the checks for
degeneracy. This overhead could be removed (in fact, a significant speedup
could occur) if the results of iterating to clean up the path were cached.
This would cost memory, of course, and quite a bit of it.
BUG=398
TEST=tests/PathTest.cpp
gm/cubicpaths.cpp
gm/degeneratesegments.cpp
gm/movepaths.cpp
gm/linepaths.cpp
gm/quadpaths.cpp
Review URL: http://codereview.appspot.com/5482051
git-svn-id: http://skia.googlecode.com/svn/trunk@2901 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-12-20 15:14:18 +00:00
|
|
|
*/
|
|
|
|
static bool IsCubicDegenerate(const SkPoint& p1, const SkPoint& p2,
|
2017-11-08 16:44:31 +00:00
|
|
|
const SkPoint& p3, const SkPoint& p4, bool exact);
|
Modifying SkPath to store all verbs provided by the user, and to give
correct results for all stroke and fill modes even on the various types
of degenerate paths.
The goals of this patch include:
1. Have Skia store all of the verbs implied by path construction methods, even
if those define degenerate paths. The SVG implementation in WebKit, which is
backed by Skia, needs to know about all elements of the path, even degenerate
ones, for the correct drawing of markers and line caps. For example, in SVG you
should be able to draw a scatter plot by specifying a marker for vertices and
then giving a sequence of moveTo commands. Skia will not store the moveTos,
requiring a different storage mechanism.
2. Assuming 1, maintain the current Skia behavior. That is, make Skia robust to
degenerate paths.
3. Fix an existing bug in Skia where a degenerate moveTo-lineTo pair spits out
warnings from rasterization and produces incorrect results in inverse-fill
renderings.
4. Adds extensive testing for degenerate paths and path rendering in general.
To meet these goals, the patch I am proposing will result in minor additional
storage for degenerate paths (a few bytes per degenerate path, only if the user
defines such paths). There is also some additional overhead in the iteration
code, with the path now cleaned to remove degenerate segments as part of the
iteration process. I suspect this will also fix issues with computing normal
vectors to degenerate segments. Benchmarking suggests that this change may
result in slightly (< 1%) slower path drawing due to the checks for
degeneracy. This overhead could be removed (in fact, a significant speedup
could occur) if the results of iterating to clean up the path were cached.
This would cost memory, of course, and quite a bit of it.
BUG=398
TEST=tests/PathTest.cpp
gm/cubicpaths.cpp
gm/degeneratesegments.cpp
gm/movepaths.cpp
gm/linepaths.cpp
gm/quadpaths.cpp
Review URL: http://codereview.appspot.com/5482051
git-svn-id: http://skia.googlecode.com/svn/trunk@2901 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-12-20 15:14:18 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if SkPath contains only one line;
|
|
|
|
SkPath::Verb array has two entries: kMove_Verb, kLine_Verb.
|
|
|
|
If SkPath contains one line and line is not nullptr, line is set to
|
|
|
|
line start point and line end point.
|
|
|
|
Returns false if SkPath is not one line; line is unaltered.
|
|
|
|
|
|
|
|
@param line storage for line. May be nullptr
|
|
|
|
@return true if SkPath contains exactly one line
|
|
|
|
*/
|
2012-05-10 14:05:43 +00:00
|
|
|
bool isLine(SkPoint line[2]) const;
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns the number of points in SkPath.
|
|
|
|
SkPoint count is initially zero.
|
|
|
|
|
|
|
|
@return SkPath SkPoint array length
|
|
|
|
*/
|
2012-10-03 13:46:20 +00:00
|
|
|
int countPoints() const;
|
2010-02-09 16:38:45 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Returns SkPoint at index in SkPoint array. Valid range for index is
|
2017-09-01 17:49:54 +00:00
|
|
|
0 to countPoints() - 1.
|
|
|
|
Returns (0, 0) if index is out of range.
|
|
|
|
|
|
|
|
@param index SkPoint array element selector
|
|
|
|
@return SkPoint array value or (0, 0)
|
|
|
|
*/
|
2010-02-09 16:38:45 +00:00
|
|
|
SkPoint getPoint(int index) const;
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns number of points in SkPath. Up to max points are copied.
|
|
|
|
points may be nullptr; then, max must be zero.
|
|
|
|
If max is greater than number of points, excess points storage is unaltered.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param points storage for SkPath SkPoint array. May be nullptr
|
|
|
|
@param max maximum to copy; must be greater than or equal to zero
|
|
|
|
@return SkPath SkPoint array length
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
int getPoints(SkPoint points[], int max) const;
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Returns the number of verbs: kMove_Verb, kLine_Verb, kQuad_Verb, kConic_Verb,
|
2017-09-01 17:49:54 +00:00
|
|
|
kCubic_Verb, and kClose_Verb; added to SkPath.
|
|
|
|
|
|
|
|
@return length of verb array
|
|
|
|
*/
|
2012-10-03 13:46:20 +00:00
|
|
|
int countVerbs() const;
|
2012-06-07 21:43:15 +00:00
|
|
|
|
|
|
|
/** Returns the number of verbs in the path. Up to max verbs are copied. The
|
|
|
|
verbs are copied as one byte per verb.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param verbs storage for verbs, may be nullptr
|
|
|
|
@param max maximum number to copy into verbs
|
|
|
|
@return the actual number of verbs in the path
|
2012-06-07 21:43:15 +00:00
|
|
|
*/
|
|
|
|
int getVerbs(uint8_t verbs[], int max) const;
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Exchanges the verb array, SkPoint array, weights, and SkPath::FillType with other.
|
2017-09-01 17:49:54 +00:00
|
|
|
Cached state is also exchanged. swap() internally exchanges pointers, so
|
|
|
|
it is lightweight and does not allocate memory.
|
|
|
|
|
|
|
|
swap() usage has largely been replaced by operator=(const SkPath& path).
|
2018-02-27 15:22:04 +00:00
|
|
|
SkPath do not copy their content on assignment until they are written to,
|
2017-09-01 17:49:54 +00:00
|
|
|
making assignment as efficient as swap().
|
|
|
|
|
|
|
|
@param other SkPath exchanged by value
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
void swap(SkPath& other);
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Returns minimum and maximum x and y values of SkPoint array.
|
2017-09-01 17:49:54 +00:00
|
|
|
Returns (0, 0, 0, 0) if SkPath contains no points. Returned bounds width and height may
|
|
|
|
be larger or smaller than area affected when SkPath is drawn.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
SkRect returned includes all SkPoint added to SkPath, including SkPoint associated with
|
2017-09-01 17:49:54 +00:00
|
|
|
kMove_Verb that define empty contours.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
@return bounds of all SkPoint in SkPoint array
|
2009-04-01 18:31:44 +00:00
|
|
|
*/
|
|
|
|
const SkRect& getBounds() const {
|
2013-09-26 12:18:23 +00:00
|
|
|
return fPathRef->getBounds();
|
2009-04-01 18:31:44 +00:00
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Update internal bounds so that subsequent calls to getBounds() are instantaneous.
|
|
|
|
Unaltered copies of SkPath may also access cached bounds through getBounds().
|
|
|
|
|
|
|
|
For now, identical to calling getBounds() and ignoring the returned value.
|
|
|
|
|
|
|
|
Call to prepare SkPath subsequently drawn from multiple threads,
|
|
|
|
to avoid a race condition where each draw separately computes the bounds.
|
|
|
|
*/
|
2009-04-01 18:31:44 +00:00
|
|
|
void updateBoundsCache() const {
|
|
|
|
// for now, just calling getBounds() is sufficient
|
|
|
|
this->getBounds();
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns minimum and maximum x and y values of the lines and curves in SkPath.
|
|
|
|
Returns (0, 0, 0, 0) if SkPath contains no points.
|
|
|
|
Returned bounds width and height may be larger or smaller than area affected
|
|
|
|
when SkPath is drawn.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
Includes SkPoint associated with kMove_Verb that define empty
|
2017-09-01 17:49:54 +00:00
|
|
|
contours.
|
|
|
|
|
|
|
|
Behaves identically to getBounds() when SkPath contains
|
|
|
|
only lines. If SkPath contains curves, computed bounds includes
|
|
|
|
the maximum extent of the quad, conic, or cubic; is slower than getBounds();
|
|
|
|
and unlike getBounds(), does not cache the result.
|
|
|
|
|
|
|
|
@return tight bounds of curves in SkPath
|
|
|
|
*/
|
2017-02-03 16:34:13 +00:00
|
|
|
SkRect computeTightBounds() const;
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if rect is contained by SkPath.
|
|
|
|
May return false when rect is contained by SkPath.
|
2012-11-13 21:51:38 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
For now, only returns true if SkPath has one contour and is convex.
|
|
|
|
rect may share points and edges with SkPath and be contained.
|
|
|
|
Returns true if rect is empty, that is, it has zero width or height; and
|
|
|
|
the SkPoint or line described by rect is contained by SkPath.
|
|
|
|
|
|
|
|
@param rect SkRect, line, or SkPoint checked for containment
|
|
|
|
@return true if rect is contained
|
|
|
|
*/
|
|
|
|
bool conservativelyContainsRect(const SkRect& rect) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** grows SkPath verb array and SkPoint array to contain extraPtCount additional SkPoint.
|
2017-09-01 17:49:54 +00:00
|
|
|
May improve performance and use less memory by
|
|
|
|
reducing the number and size of allocations when creating SkPath.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
@param extraPtCount number of additional SkPoint to allocate
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void incReserve(unsigned extraPtCount);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Adds beginning of contour at SkPoint (x, y).
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param x x-coordinate of contour start
|
|
|
|
@param y y-coordinate of contour start
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void moveTo(SkScalar x, SkScalar y);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Adds beginning of contour at SkPoint p.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param p contour start
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void moveTo(const SkPoint& p) {
|
|
|
|
this->moveTo(p.fX, p.fY);
|
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Adds beginning of contour relative to last point.
|
|
|
|
If SkPath is empty, starts contour at (dx, dy).
|
|
|
|
Otherwise, start contour at last point offset by (dx, dy).
|
|
|
|
Function name stands for "relative move to".
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param dx offset from last point x to contour start x
|
|
|
|
@param dy offset from last point y to contour start y
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void rMoveTo(SkScalar dx, SkScalar dy);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is
|
|
|
|
kClose_Verb, last point is set to (0, 0) before adding line.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
|
|
|
|
lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param x end of added line in x
|
|
|
|
@param y end of added line in y
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void lineTo(SkScalar x, SkScalar y);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Adds line from last point to SkPoint p. If SkPath is empty, or last SkPath::Verb is
|
|
|
|
kClose_Verb, last point is set to (0, 0) before adding line.
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
lineTo() first appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
|
|
|
|
lineTo() then appends kLine_Verb to verb array and SkPoint p to SkPoint array.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param p end SkPoint of added line
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void lineTo(const SkPoint& p) {
|
|
|
|
this->lineTo(p.fX, p.fY);
|
|
|
|
}
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Adds line from last point to vector (dx, dy). If SkPath is empty, or last SkPath::Verb is
|
2017-09-01 17:49:54 +00:00
|
|
|
kClose_Verb, last point is set to (0, 0) before adding line.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
|
|
|
|
then appends kLine_Verb to verb array and line end to SkPoint array.
|
|
|
|
Line end is last point plus vector (dx, dy).
|
2017-09-01 17:49:54 +00:00
|
|
|
Function name stands for "relative line to".
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param dx offset from last point x to line end x
|
|
|
|
@param dy offset from last point y to line end y
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void rLineTo(SkScalar dx, SkScalar dy);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Adds quad from last point towards (x1, y1), to (x2, y2).
|
|
|
|
If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
|
|
|
|
before adding quad.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
|
2017-09-01 17:49:54 +00:00
|
|
|
then appends kQuad_Verb to verb array; and (x1, y1), (x2, y2)
|
2018-01-03 15:00:34 +00:00
|
|
|
to SkPoint array.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param x1 control SkPoint of quad in x
|
|
|
|
@param y1 control SkPoint of quad in y
|
|
|
|
@param x2 end SkPoint of quad in x
|
|
|
|
@param y2 end SkPoint of quad in y
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Adds quad from last point towards SkPoint p1, to SkPoint p2.
|
|
|
|
If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
|
|
|
|
before adding quad.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
|
2018-02-27 15:22:04 +00:00
|
|
|
then appends kQuad_Verb to verb array; and SkPoint p1, p2
|
2018-01-03 15:00:34 +00:00
|
|
|
to SkPoint array.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param p1 control SkPoint of added quad
|
|
|
|
@param p2 end SkPoint of added quad
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void quadTo(const SkPoint& p1, const SkPoint& p2) {
|
|
|
|
this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY);
|
|
|
|
}
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2).
|
2017-09-01 17:49:54 +00:00
|
|
|
If SkPath is empty, or last SkPath::Verb
|
|
|
|
is kClose_Verb, last point is set to (0, 0) before adding quad.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
|
2017-09-01 17:49:54 +00:00
|
|
|
if needed; then appends kQuad_Verb to verb array; and appends quad
|
2018-01-03 15:00:34 +00:00
|
|
|
control and quad end to SkPoint array.
|
|
|
|
Quad control is last point plus vector (dx1, dy1).
|
|
|
|
Quad end is last point plus vector (dx2, dy2).
|
2017-09-01 17:49:54 +00:00
|
|
|
Function name stands for "relative quad to".
|
|
|
|
|
|
|
|
@param dx1 offset from last point x to quad control x
|
|
|
|
@param dy1 offset from last point x to quad control y
|
|
|
|
@param dx2 offset from last point x to quad end x
|
|
|
|
@param dy2 offset from last point x to quad end y
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.
|
|
|
|
If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
|
|
|
|
before adding conic.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If w is finite and not one, appends kConic_Verb to verb array;
|
2018-01-03 15:00:34 +00:00
|
|
|
and (x1, y1), (x2, y2) to SkPoint array; and w to conic weights.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If w is one, appends kQuad_Verb to verb array, and
|
2018-01-03 15:00:34 +00:00
|
|
|
(x1, y1), (x2, y2) to SkPoint array.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If w is not finite, appends kLine_Verb twice to verb array, and
|
2018-01-03 15:00:34 +00:00
|
|
|
(x1, y1), (x2, y2) to SkPoint array.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param x1 control SkPoint of conic in x
|
|
|
|
@param y1 control SkPoint of conic in y
|
|
|
|
@param x2 end SkPoint of conic in x
|
|
|
|
@param y2 end SkPoint of conic in y
|
|
|
|
@param w weight of added conic
|
|
|
|
*/
|
2013-05-31 15:17:50 +00:00
|
|
|
void conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
|
|
|
|
SkScalar w);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
/** Adds conic from last point towards SkPoint p1, to SkPoint p2, weighted by w.
|
|
|
|
If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
|
|
|
|
before adding conic.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If w is finite and not one, appends kConic_Verb to verb array;
|
2018-02-27 15:22:04 +00:00
|
|
|
and SkPoint p1, p2 to SkPoint array; and w to conic weights.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
If w is one, appends kQuad_Verb to verb array, and SkPoint p1, p2
|
2018-01-03 15:00:34 +00:00
|
|
|
to SkPoint array.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If w is not finite, appends kLine_Verb twice to verb array, and
|
2018-02-27 15:22:04 +00:00
|
|
|
SkPoint p1, p2 to SkPoint array.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param p1 control SkPoint of added conic
|
|
|
|
@param p2 end SkPoint of added conic
|
|
|
|
@param w weight of added conic
|
|
|
|
*/
|
2013-05-31 15:17:50 +00:00
|
|
|
void conicTo(const SkPoint& p1, const SkPoint& p2, SkScalar w) {
|
|
|
|
this->conicTo(p1.fX, p1.fY, p2.fX, p2.fY, w);
|
|
|
|
}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2),
|
2017-09-01 17:49:54 +00:00
|
|
|
weighted by w. If SkPath is empty, or last SkPath::Verb
|
|
|
|
is kClose_Verb, last point is set to (0, 0) before adding conic.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
|
2017-09-01 17:49:54 +00:00
|
|
|
if needed.
|
|
|
|
|
|
|
|
If w is finite and not one, next appends kConic_Verb to verb array,
|
|
|
|
and w is recorded as conic weight; otherwise, if w is one, appends
|
|
|
|
kQuad_Verb to verb array; or if w is not finite, appends kLine_Verb
|
|
|
|
twice to verb array.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
In all cases appends SkPoint control and end to SkPoint array.
|
2018-01-03 15:00:34 +00:00
|
|
|
control is last point plus vector (dx1, dy1).
|
|
|
|
end is last point plus vector (dx2, dy2).
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
Function name stands for "relative conic to".
|
|
|
|
|
|
|
|
@param dx1 offset from last point x to conic control x
|
|
|
|
@param dy1 offset from last point x to conic control y
|
|
|
|
@param dx2 offset from last point x to conic end x
|
|
|
|
@param dy2 offset from last point x to conic end y
|
|
|
|
@param w weight of added conic
|
|
|
|
*/
|
2013-05-31 15:17:50 +00:00
|
|
|
void rConicTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2,
|
|
|
|
SkScalar w);
|
2013-06-01 07:01:39 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at
|
|
|
|
(x3, y3). If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to
|
|
|
|
(0, 0) before adding cubic.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
|
2017-09-01 17:49:54 +00:00
|
|
|
then appends kCubic_Verb to verb array; and (x1, y1), (x2, y2), (x3, y3)
|
2018-01-03 15:00:34 +00:00
|
|
|
to SkPoint array.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param x1 first control SkPoint of cubic in x
|
|
|
|
@param y1 first control SkPoint of cubic in y
|
|
|
|
@param x2 second control SkPoint of cubic in x
|
|
|
|
@param y2 second control SkPoint of cubic in y
|
|
|
|
@param x3 end SkPoint of cubic in x
|
|
|
|
@param y3 end SkPoint of cubic in y
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
|
|
|
|
SkScalar x3, SkScalar y3);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Adds cubic from last point towards SkPoint p1, then towards SkPoint p2, ending at
|
|
|
|
SkPoint p3. If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to
|
|
|
|
(0, 0) before adding cubic.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
|
2018-02-27 15:22:04 +00:00
|
|
|
then appends kCubic_Verb to verb array; and SkPoint p1, p2, p3
|
2018-01-03 15:00:34 +00:00
|
|
|
to SkPoint array.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param p1 first control SkPoint of cubic
|
|
|
|
@param p2 second control SkPoint of cubic
|
|
|
|
@param p3 end SkPoint of cubic
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void cubicTo(const SkPoint& p1, const SkPoint& p2, const SkPoint& p3) {
|
|
|
|
this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY);
|
|
|
|
}
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Adds cubic from last point towards vector (dx1, dy1), then towards
|
|
|
|
vector (dx2, dy2), to vector (dx3, dy3).
|
2017-09-01 17:49:54 +00:00
|
|
|
If SkPath is empty, or last SkPath::Verb
|
|
|
|
is kClose_Verb, last point is set to (0, 0) before adding cubic.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
|
2017-09-01 17:49:54 +00:00
|
|
|
if needed; then appends kCubic_Verb to verb array; and appends cubic
|
2018-01-03 15:00:34 +00:00
|
|
|
control and cubic end to SkPoint array.
|
|
|
|
Cubic control is last point plus vector (dx1, dy1).
|
|
|
|
Cubic end is last point plus vector (dx2, dy2).
|
2017-09-01 17:49:54 +00:00
|
|
|
Function name stands for "relative cubic to".
|
|
|
|
|
|
|
|
@param x1 offset from last point x to first cubic control x
|
|
|
|
@param y1 offset from last point x to first cubic control y
|
|
|
|
@param x2 offset from last point x to second cubic control x
|
|
|
|
@param y2 offset from last point x to second cubic control y
|
|
|
|
@param x3 offset from last point x to cubic end x
|
|
|
|
@param y3 offset from last point x to cubic end y
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2013-12-12 23:03:51 +00:00
|
|
|
void rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
|
|
|
|
SkScalar x3, SkScalar y3);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append arc to SkPath. Arc added is part of ellipse
|
|
|
|
bounded by oval, from startAngle through sweepAngle. Both startAngle and
|
|
|
|
sweepAngle are measured in degrees, where zero degrees is aligned with the
|
|
|
|
positive x-axis, and positive sweeps extends arc clockwise.
|
|
|
|
|
|
|
|
arcTo() adds line connecting SkPath last SkPoint to initial arc SkPoint if forceMoveTo
|
|
|
|
is false and SkPath is not empty. Otherwise, added contour begins with first point
|
|
|
|
of arc. Angles greater than -360 and less than 360 are treated modulo 360.
|
|
|
|
|
|
|
|
@param oval bounds of ellipse containing arc
|
|
|
|
@param startAngle starting angle of arc in degrees
|
|
|
|
@param sweepAngle sweep, in degrees. Positive is clockwise; treated modulo 360
|
|
|
|
@param forceMoveTo true to start a new contour with arc
|
|
|
|
*/
|
2015-01-29 20:59:11 +00:00
|
|
|
void arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append arc to SkPath, after appending line if needed. Arc is implemented by conic
|
|
|
|
weighted to describe part of circle. Arc is contained by tangent from
|
|
|
|
last SkPath point (x0, y0) to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc
|
|
|
|
is part of circle sized to radius, positioned so it touches both tangent lines.
|
|
|
|
|
|
|
|
@param x1 x common to pair of tangents
|
|
|
|
@param y1 y common to pair of tangents
|
|
|
|
@param x2 x end of second tangent
|
|
|
|
@param y2 y end of second tangent
|
|
|
|
@param radius distance from arc to circle center
|
|
|
|
*/
|
2015-01-29 20:59:11 +00:00
|
|
|
void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append arc to SkPath, after appending line if needed. Arc is implemented by conic
|
|
|
|
weighted to describe part of circle. Arc is contained by tangent from
|
|
|
|
last SkPath point to p1, and tangent from p1 to p2. Arc
|
|
|
|
is part of circle sized to radius, positioned so it touches both tangent lines.
|
|
|
|
|
|
|
|
If last SkPath SkPoint does not start arc, arcTo() appends connecting line to SkPath.
|
2018-01-03 15:00:34 +00:00
|
|
|
The length of vector from p1 to p2 does not affect arc.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
Arc sweep is always less than 180 degrees. If radius is zero, or if
|
|
|
|
tangents are nearly parallel, arcTo() appends line from last SkPath SkPoint to p1.
|
|
|
|
|
|
|
|
arcTo() appends at most one line and one conic.
|
|
|
|
arcTo() implements the functionality of PostScript_Arct and HTML_Canvas_ArcTo.
|
|
|
|
|
|
|
|
@param p1 SkPoint common to pair of tangents
|
|
|
|
@param p2 end of second tangent
|
|
|
|
@param radius distance from arc to circle center
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void arcTo(const SkPoint p1, const SkPoint p2, SkScalar radius) {
|
|
|
|
this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius);
|
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \enum SkPath::ArcSize
|
|
|
|
Four oval parts with radii (rx, ry) start at last SkPath SkPoint and ends at (x, y).
|
|
|
|
ArcSize and Direction select one of the four oval parts.
|
|
|
|
*/
|
2016-01-23 13:07:04 +00:00
|
|
|
enum ArcSize {
|
2017-10-30 15:48:35 +00:00
|
|
|
kSmall_ArcSize, //!< smaller of arc pair
|
|
|
|
kLarge_ArcSize, //!< larger of arc pair
|
2016-01-23 13:07:04 +00:00
|
|
|
};
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** Append arc to SkPath. Arc is implemented by one or more conics weighted to
|
|
|
|
describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc
|
|
|
|
curves from last SkPath SkPoint to (x, y), choosing one of four possible routes:
|
|
|
|
clockwise or counterclockwise, and smaller or larger.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
Arc sweep is always less than 360 degrees. arcTo() appends line to (x, y) if
|
|
|
|
either radii are zero, or if last SkPath SkPoint equals (x, y). arcTo() scales radii
|
|
|
|
(rx, ry) to fit last SkPath SkPoint and (x, y) if both are greater than zero but
|
|
|
|
too small.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
arcTo() appends up to four conic curves.
|
2017-10-30 15:48:35 +00:00
|
|
|
arcTo() implements the functionality of svg arc, although SVG "sweep-flag" value
|
|
|
|
is opposite the integer value of sweep; SVG "sweep-flag" uses 1 for clockwise,
|
|
|
|
while kCW_Direction cast to int is zero.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param rx radius in x before x-axis rotation
|
|
|
|
@param ry radius in y before x-axis rotation
|
|
|
|
@param xAxisRotate x-axis rotation in degrees; positive values are clockwise
|
|
|
|
@param largeArc chooses smaller or larger arc
|
|
|
|
@param sweep chooses clockwise or counterclockwise arc
|
|
|
|
@param x end of arc
|
|
|
|
@param y end of arc
|
|
|
|
*/
|
2016-01-23 13:07:04 +00:00
|
|
|
void arcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
|
|
|
|
Direction sweep, SkScalar x, SkScalar y);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append arc to SkPath. Arc is implemented by one or more conic weighted to describe part of oval
|
|
|
|
with radii (r.fX, r.fY) rotated by xAxisRotate degrees. Arc curves from last SkPath SkPoint to
|
|
|
|
(xy.fX, xy.fY), choosing one of four possible routes: clockwise or counterclockwise,
|
|
|
|
and smaller or larger.
|
|
|
|
|
|
|
|
Arc sweep is always less than 360 degrees. arcTo() appends line to xy if either radii are zero,
|
|
|
|
or if last SkPath SkPoint equals (x, y). arcTo() scales radii r to fit last SkPath SkPoint and
|
|
|
|
xy if both are greater than zero but too small to describe an arc.
|
|
|
|
|
|
|
|
arcTo() appends up to four conic curves.
|
|
|
|
arcTo() implements the functionality of svg arc, although SVG "sweep-flag" value is
|
|
|
|
opposite the integer value of sweep; SVG "sweep-flag" uses 1 for clockwise, while
|
|
|
|
kCW_Direction cast to int is zero.
|
|
|
|
|
|
|
|
@param r radii in x and y before x-axis rotation
|
|
|
|
@param xAxisRotate x-axis rotation in degrees; positive values are clockwise
|
|
|
|
@param largeArc chooses smaller or larger arc
|
|
|
|
@param sweep chooses clockwise or counterclockwise arc
|
|
|
|
@param xy end of arc
|
|
|
|
*/
|
2016-01-23 13:07:04 +00:00
|
|
|
void arcTo(const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep,
|
|
|
|
const SkPoint xy) {
|
|
|
|
this->arcTo(r.fX, r.fY, xAxisRotate, largeArc, sweep, xy.fX, xy.fY);
|
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append arc to SkPath, relative to last SkPath SkPoint. Arc is implemented by one or
|
|
|
|
more conic, weighted to describe part of oval with radii (rx, ry) rotated by
|
2017-10-30 15:48:35 +00:00
|
|
|
xAxisRotate degrees. Arc curves from last SkPath SkPoint (x0, y0) to end SkPoint:
|
2017-09-21 16:28:43 +00:00
|
|
|
(x0 + dx, y0 + dy), choosing one of four possible routes: clockwise or
|
|
|
|
counterclockwise, and smaller or larger. If SkPath is empty, the start arc SkPoint
|
|
|
|
is (0, 0).
|
|
|
|
|
|
|
|
Arc sweep is always less than 360 degrees. arcTo() appends line to end SkPoint
|
|
|
|
if either radii are zero, or if last SkPath SkPoint equals end SkPoint.
|
|
|
|
arcTo() scales radii (rx, ry) to fit last SkPath SkPoint and end SkPoint if both are
|
|
|
|
greater than zero but too small to describe an arc.
|
|
|
|
|
|
|
|
arcTo() appends up to four conic curves.
|
|
|
|
arcTo() implements the functionality of svg arc, although SVG "sweep-flag" value is
|
|
|
|
opposite the integer value of sweep; SVG "sweep-flag" uses 1 for clockwise, while
|
|
|
|
kCW_Direction cast to int is zero.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param rx radius in x before x-axis rotation
|
|
|
|
@param ry radius in y before x-axis rotation
|
|
|
|
@param xAxisRotate x-axis rotation in degrees; positive values are clockwise
|
|
|
|
@param largeArc chooses smaller or larger arc
|
|
|
|
@param sweep chooses clockwise or counterclockwise arc
|
|
|
|
@param dx x offset end of arc from last SkPath SkPoint
|
|
|
|
@param dy y offset end of arc from last SkPath SkPoint
|
|
|
|
*/
|
2016-01-23 13:07:04 +00:00
|
|
|
void rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
|
|
|
|
Direction sweep, SkScalar dx, SkScalar dy);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append kClose_Verb to SkPath. A closed contour connects the first and last SkPoint
|
|
|
|
with line, forming a continuous loop. Open and closed contour draw the same
|
|
|
|
with SkPaint::kFill_Style. With SkPaint::kStroke_Style, open contour draws
|
|
|
|
SkPaint::Cap at contour start and end; closed contour draws
|
|
|
|
SkPaint::Join at contour start and end.
|
|
|
|
|
|
|
|
close() has no effect if SkPath is empty or last SkPath SkPath::Verb is kClose_Verb.
|
2016-01-23 13:07:04 +00:00
|
|
|
*/
|
|
|
|
void close();
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if fill is inverted and SkPath with fill represents area outside
|
|
|
|
of its geometric bounds.
|
|
|
|
|
|
|
|
@param fill one of: kWinding_FillType, kEvenOdd_FillType,
|
|
|
|
kInverseWinding_FillType, kInverseEvenOdd_FillType
|
|
|
|
@return true if SkPath fills outside its bounds
|
|
|
|
*/
|
2012-12-17 21:16:45 +00:00
|
|
|
static bool IsInverseFillType(FillType fill) {
|
2015-08-20 14:57:51 +00:00
|
|
|
static_assert(0 == kWinding_FillType, "fill_type_mismatch");
|
|
|
|
static_assert(1 == kEvenOdd_FillType, "fill_type_mismatch");
|
|
|
|
static_assert(2 == kInverseWinding_FillType, "fill_type_mismatch");
|
|
|
|
static_assert(3 == kInverseEvenOdd_FillType, "fill_type_mismatch");
|
2012-12-06 20:13:11 +00:00
|
|
|
return (fill & 2) != 0;
|
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns equivalent SkPath::FillType representing SkPath fill inside its bounds.
|
|
|
|
.
|
|
|
|
|
|
|
|
@param fill one of: kWinding_FillType, kEvenOdd_FillType,
|
|
|
|
kInverseWinding_FillType, kInverseEvenOdd_FillType
|
|
|
|
@return fill, or kWinding_FillType or kEvenOdd_FillType if fill is inverted
|
|
|
|
*/
|
2012-12-17 21:16:45 +00:00
|
|
|
static FillType ConvertToNonInverseFillType(FillType fill) {
|
2015-08-20 14:57:51 +00:00
|
|
|
static_assert(0 == kWinding_FillType, "fill_type_mismatch");
|
|
|
|
static_assert(1 == kEvenOdd_FillType, "fill_type_mismatch");
|
|
|
|
static_assert(2 == kInverseWinding_FillType, "fill_type_mismatch");
|
|
|
|
static_assert(3 == kInverseEvenOdd_FillType, "fill_type_mismatch");
|
2012-12-06 20:13:11 +00:00
|
|
|
return (FillType)(fill & 1);
|
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Approximates conic with quad array. Conic is constructed from start SkPoint p0,
|
|
|
|
control SkPoint p1, end SkPoint p2, and weight w.
|
|
|
|
Quad array is stored in pts; this storage is supplied by caller.
|
|
|
|
Maximum quad count is 2 to the pow2.
|
|
|
|
Every third point in array shares last SkPoint of previous quad and first SkPoint of
|
2017-10-30 15:48:35 +00:00
|
|
|
next quad. Maximum pts storage size is given by: (1 + 2 * (1 << pow2)) * sizeof(SkPoint).
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
Returns quad count used the approximation, which may be smaller
|
2017-09-21 16:28:43 +00:00
|
|
|
than the number requested.
|
|
|
|
|
|
|
|
conic weight determines the amount of influence conic control point has on the curve.
|
|
|
|
w less than one represents an elliptical section. w greater than one represents
|
|
|
|
a hyperbolic section. w equal to one represents a parabolic section.
|
|
|
|
|
|
|
|
Two quad curves are sufficient to approximate an elliptical conic with a sweep
|
|
|
|
of up to 90 degrees; in this case, set pow2 to one.
|
|
|
|
|
|
|
|
@param p0 conic start SkPoint
|
|
|
|
@param p1 conic control SkPoint
|
|
|
|
@param p2 conic end SkPoint
|
|
|
|
@param w conic weight
|
2017-09-01 17:49:54 +00:00
|
|
|
@param pts storage for quad array
|
2017-09-21 16:28:43 +00:00
|
|
|
@param pow2 quad count, as power of two, normally 0 to 5 (1 to 32 quad curves)
|
2017-09-01 17:49:54 +00:00
|
|
|
@return number of quad curves written to pts
|
|
|
|
*/
|
2015-12-01 17:13:23 +00:00
|
|
|
static int ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2,
|
|
|
|
SkScalar w, SkPoint pts[], int pow2);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if SkPath is equivalent to SkRect when filled.
|
|
|
|
If false: rect, isClosed, and direction are unchanged.
|
|
|
|
If true: rect, isClosed, and direction are written to if not nullptr.
|
|
|
|
|
|
|
|
rect may be smaller than the SkPath bounds. SkPath bounds may include kMove_Verb points
|
|
|
|
that do not alter the area drawn by the returned rect.
|
|
|
|
|
|
|
|
@param rect storage for bounds of SkRect; may be nullptr
|
|
|
|
@param isClosed storage set to true if SkPath is closed; may be nullptr
|
|
|
|
@param direction storage set to SkRect direction; may be nullptr
|
|
|
|
@return true if SkPath contains SkRect
|
|
|
|
*/
|
2017-08-28 14:34:05 +00:00
|
|
|
bool isRect(SkRect* rect, bool* isClosed = nullptr, Direction* direction = nullptr) const;
|
2013-06-25 15:39:58 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if SkPath is equivalent to nested SkRect pair when filled.
|
|
|
|
If false, rect and dirs are unchanged.
|
|
|
|
If true, rect and dirs are written to if not nullptr:
|
|
|
|
setting rect[0] to outer SkRect, and rect[1] to inner SkRect;
|
|
|
|
setting dirs[0] to SkPath::Direction of outer SkRect, and dirs[1] to SkPath::Direction of inner
|
|
|
|
SkRect.
|
2013-06-25 15:39:58 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param rect storage for SkRect pair; may be nullptr
|
|
|
|
@param dirs storage for SkPath::Direction pair; may be nullptr
|
|
|
|
@return true if SkPath contains nested SkRect pair
|
2013-06-25 15:39:58 +00:00
|
|
|
*/
|
2017-08-28 14:34:05 +00:00
|
|
|
bool isNestedFillRects(SkRect rect[2], Direction dirs[2] = nullptr) const;
|
2013-06-25 15:39:58 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Add SkRect to SkPath, appending kMove_Verb, three kLine_Verb, and kClose_Verb,
|
|
|
|
starting with top-left corner of SkRect; followed by top-right, bottom-right,
|
|
|
|
and bottom-left if dir is kCW_Direction; or followed by bottom-left,
|
|
|
|
bottom-right, and top-right if dir is kCCW_Direction.
|
|
|
|
|
|
|
|
@param rect SkRect to add as a closed contour
|
|
|
|
@param dir SkPath::Direction to wind added contour
|
|
|
|
*/
|
2013-09-26 12:18:23 +00:00
|
|
|
void addRect(const SkRect& rect, Direction dir = kCW_Direction);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Add SkRect to SkPath, appending kMove_Verb, three kLine_Verb, and kClose_Verb.
|
|
|
|
If dir is kCW_Direction, SkRect corners are added clockwise; if dir is
|
|
|
|
kCCW_Direction, SkRect corners are added counterclockwise.
|
|
|
|
start determines the first corner added.
|
|
|
|
|
|
|
|
@param rect SkRect to add as a closed contour
|
|
|
|
@param dir SkPath::Direction to wind added contour
|
|
|
|
@param start initial corner of SkRect to add
|
|
|
|
*/
|
2015-11-17 17:53:29 +00:00
|
|
|
void addRect(const SkRect& rect, Direction dir, unsigned start);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Add SkRect (left, top, right, bottom) to SkPath,
|
|
|
|
appending kMove_Verb, three kLine_Verb, and kClose_Verb,
|
|
|
|
starting with top-left corner of SkRect; followed by top-right, bottom-right,
|
|
|
|
and bottom-left if dir is kCW_Direction; or followed by bottom-left,
|
|
|
|
bottom-right, and top-right if dir is kCCW_Direction.
|
|
|
|
|
|
|
|
@param left smaller x of SkRect
|
|
|
|
@param top smaller y of SkRect
|
|
|
|
@param right larger x of SkRect
|
|
|
|
@param bottom larger y of SkRect
|
|
|
|
@param dir SkPath::Direction to wind added contour
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
void addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
|
|
|
|
Direction dir = kCW_Direction);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Add oval to path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.
|
|
|
|
Oval is upright ellipse bounded by SkRect oval with radii equal to half oval width
|
|
|
|
and half oval height. Oval begins at (oval.fRight, oval.centerY()) and continues
|
|
|
|
clockwise if dir is kCW_Direction, counterclockwise if dir is kCCW_Direction.
|
|
|
|
|
|
|
|
@param oval bounds of ellipse added
|
|
|
|
@param dir SkPath::Direction to wind ellipse
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
void addOval(const SkRect& oval, Direction dir = kCW_Direction);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Add oval to SkPath, appending kMove_Verb, four kConic_Verb, and kClose_Verb.
|
|
|
|
Oval is upright ellipse bounded by SkRect oval with radii equal to half oval width
|
|
|
|
and half oval height. Oval begins at start and continues
|
|
|
|
clockwise if dir is kCW_Direction, counterclockwise if dir is kCCW_Direction.
|
|
|
|
|
|
|
|
@param oval bounds of ellipse added
|
|
|
|
@param dir SkPath::Direction to wind ellipse
|
|
|
|
@param start index of initial point of ellipse
|
|
|
|
*/
|
2015-11-17 17:53:29 +00:00
|
|
|
void addOval(const SkRect& oval, Direction dir, unsigned start);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Add circle centered at (x, y) of size radius to SkPath, appending kMove_Verb,
|
2017-10-30 15:48:35 +00:00
|
|
|
four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing
|
|
|
|
clockwise if dir is kCW_Direction, and counterclockwise if dir is kCCW_Direction.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Has no effect if radius is zero or negative.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param x center of circle
|
|
|
|
@param y center of circle
|
|
|
|
@param radius distance from center to edge
|
|
|
|
@param dir SkPath::Direction to wind circle
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
void addCircle(SkScalar x, SkScalar y, SkScalar radius,
|
|
|
|
Direction dir = kCW_Direction);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append arc to SkPath, as the start of new contour. Arc added is part of ellipse
|
|
|
|
bounded by oval, from startAngle through sweepAngle. Both startAngle and
|
|
|
|
sweepAngle are measured in degrees, where zero degrees is aligned with the
|
|
|
|
positive x-axis, and positive sweeps extends arc clockwise.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
If sweepAngle <= -360, or sweepAngle >= 360; and startAngle modulo 90 is nearly
|
|
|
|
zero, append oval instead of arc. Otherwise, sweepAngle values are treated
|
|
|
|
modulo 360, and arc may or may not draw depending on numeric rounding.
|
|
|
|
|
|
|
|
@param oval bounds of ellipse containing arc
|
|
|
|
@param startAngle starting angle of arc in degrees
|
|
|
|
@param sweepAngle sweep, in degrees. Positive is clockwise; treated modulo 360
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append SkRRect to SkPath, creating a new closed contour. SkRRect has bounds
|
|
|
|
equal to rect; each corner is 90 degrees of an ellipse with radii (rx, ry). If
|
|
|
|
dir is kCW_Direction, SkRRect starts at top-left of the lower-left corner and
|
|
|
|
winds clockwise. If dir is kCCW_Direction, SkRRect starts at the bottom-left
|
|
|
|
of the upper-left corner and winds counterclockwise.
|
|
|
|
|
|
|
|
If either rx or ry is too large, rx and ry are scaled uniformly until the
|
|
|
|
corners fit. If rx or ry is less than or equal to zero, addRoundRect() appends
|
|
|
|
SkRect rect to SkPath.
|
|
|
|
|
|
|
|
After appending, SkPath may be empty, or may contain: SkRect, oval, or RoundRect.
|
|
|
|
|
|
|
|
@param rect bounds of SkRRect
|
|
|
|
@param rx x-radius of rounded corners on the SkRRect
|
|
|
|
@param ry y-radius of rounded corners on the SkRRect
|
|
|
|
@param dir SkPath::Direction to wind SkRRect
|
|
|
|
*/
|
2013-09-26 12:18:23 +00:00
|
|
|
void addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
|
|
|
|
Direction dir = kCW_Direction);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append SkRRect to SkPath, creating a new closed contour. SkRRect has bounds
|
|
|
|
equal to rect; each corner is 90 degrees of an ellipse with radii from the
|
|
|
|
array.
|
|
|
|
|
|
|
|
@param rect bounds of SkRRect
|
|
|
|
@param radii array of 8 SkScalar values, a radius pair for each corner
|
|
|
|
@param dir SkPath::Direction to wind SkRRect
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
void addRoundRect(const SkRect& rect, const SkScalar radii[],
|
|
|
|
Direction dir = kCW_Direction);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Add rrect to SkPath, creating a new closed contour. If
|
|
|
|
dir is kCW_Direction, rrect starts at top-left of the lower-left corner and
|
|
|
|
winds clockwise. If dir is kCCW_Direction, rrect starts at the bottom-left
|
|
|
|
of the upper-left corner and winds counterclockwise.
|
|
|
|
|
|
|
|
After appending, SkPath may be empty, or may contain: SkRect, oval, or SkRRect.
|
|
|
|
|
|
|
|
@param rrect bounds and radii of rounded rectangle
|
|
|
|
@param dir SkPath::Direction to wind SkRRect
|
|
|
|
*/
|
2012-12-17 21:48:19 +00:00
|
|
|
void addRRect(const SkRRect& rrect, Direction dir = kCW_Direction);
|
2012-12-12 20:48:18 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Add rrect to SkPath, creating a new closed contour. If dir is kCW_Direction, rrect
|
|
|
|
winds clockwise; if dir is kCCW_Direction, rrect winds counterclockwise.
|
|
|
|
start determines the first point of rrect to add.
|
|
|
|
|
|
|
|
@param rrect bounds and radii of rounded rectangle
|
|
|
|
@param dir SkPath::Direction to wind SkRRect
|
|
|
|
@param start index of initial point of SkRRect
|
|
|
|
*/
|
2015-11-17 17:53:29 +00:00
|
|
|
void addRRect(const SkRRect& rrect, Direction dir, unsigned start);
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
/** Add contour created from line array, adding (count - 1) line segments.
|
|
|
|
Contour added starts at pts[0], then adds a line for every additional SkPoint
|
|
|
|
in pts array. If close is true,appends kClose_Verb to SkPath, connecting
|
|
|
|
pts[count - 1] and pts[0].
|
|
|
|
|
|
|
|
If count is zero, append kMove_Verb to path.
|
|
|
|
Has no effect if count is less than one.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param pts array of line sharing end and start SkPoint
|
|
|
|
@param count length of SkPoint array
|
|
|
|
@param close true to add line connecting contour end and start
|
|
|
|
*/
|
2012-05-29 19:54:52 +00:00
|
|
|
void addPoly(const SkPoint pts[], int count, bool close);
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \enum SkPath::AddPathMode
|
|
|
|
AddPathMode chooses how addPath() appends. Adding one SkPath to another can extend
|
|
|
|
the last contour or start a new contour.
|
|
|
|
*/
|
2014-02-11 21:16:29 +00:00
|
|
|
enum AddPathMode {
|
2018-05-30 13:20:29 +00:00
|
|
|
kAppend_AddPathMode, //!< appended to destination unaltered
|
|
|
|
kExtend_AddPathMode, //!< add line if prior contour is not closed
|
2014-02-11 21:16:29 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append src to SkPath, offset by (dx, dy).
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are
|
2017-09-01 17:49:54 +00:00
|
|
|
added unaltered. If mode is kExtend_AddPathMode, add line before appending
|
2018-02-27 15:22:04 +00:00
|
|
|
verbs, SkPoint, and conic weights.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
@param src SkPath verbs, SkPoint, and conic weights to add
|
2018-01-03 15:00:34 +00:00
|
|
|
@param dx offset added to src SkPoint array x coordinates
|
|
|
|
@param dy offset added to src SkPoint array y coordinates
|
2017-09-01 17:49:54 +00:00
|
|
|
@param mode kAppend_AddPathMode or kExtend_AddPathMode
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-02-11 21:16:29 +00:00
|
|
|
void addPath(const SkPath& src, SkScalar dx, SkScalar dy,
|
|
|
|
AddPathMode mode = kAppend_AddPathMode);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append src to SkPath.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are
|
2017-09-01 17:49:54 +00:00
|
|
|
added unaltered. If mode is kExtend_AddPathMode, add line before appending
|
2018-02-27 15:22:04 +00:00
|
|
|
verbs, SkPoint, and conic weights.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
@param src SkPath verbs, SkPoint, and conic weights to add
|
2017-09-01 17:49:54 +00:00
|
|
|
@param mode kAppend_AddPathMode or kExtend_AddPathMode
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-02-11 21:16:29 +00:00
|
|
|
void addPath(const SkPath& src, AddPathMode mode = kAppend_AddPathMode) {
|
2008-12-17 15:59:43 +00:00
|
|
|
SkMatrix m;
|
|
|
|
m.reset();
|
2014-02-11 21:16:29 +00:00
|
|
|
this->addPath(src, m, mode);
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append src to SkPath, transformed by matrix. Transformed curves may have different
|
2018-02-27 15:22:04 +00:00
|
|
|
verbs, SkPoint, and conic weights.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are
|
2017-09-01 17:49:54 +00:00
|
|
|
added unaltered. If mode is kExtend_AddPathMode, add line before appending
|
2018-02-27 15:22:04 +00:00
|
|
|
verbs, SkPoint, and conic weights.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
@param src SkPath verbs, SkPoint, and conic weights to add
|
2017-09-01 17:49:54 +00:00
|
|
|
@param matrix transform applied to src
|
|
|
|
@param mode kAppend_AddPathMode or kExtend_AddPathMode
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-02-11 21:16:29 +00:00
|
|
|
void addPath(const SkPath& src, const SkMatrix& matrix, AddPathMode mode = kAppend_AddPathMode);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Append src to SkPath, from back to front.
|
|
|
|
Reversed src always appends a new contour to SkPath.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
@param src SkPath verbs, SkPoint, and conic weights to add
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2012-01-10 15:33:12 +00:00
|
|
|
void reverseAddPath(const SkPath& src);
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Offset SkPoint array by (dx, dy). Offset SkPath replaces dst.
|
2017-09-01 17:49:54 +00:00
|
|
|
If dst is nullptr, SkPath is replaced by offset data.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
@param dx offset added to SkPoint array x coordinates
|
|
|
|
@param dy offset added to SkPoint array y coordinates
|
2017-09-01 17:49:54 +00:00
|
|
|
@param dst overwritten, translated copy of SkPath; may be nullptr
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void offset(SkScalar dx, SkScalar dy, SkPath* dst) const;
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Offset SkPoint array by (dx, dy). SkPath is replaced by offset data.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
@param dx offset added to SkPoint array x coordinates
|
|
|
|
@param dy offset added to SkPoint array y coordinates
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void offset(SkScalar dx, SkScalar dy) {
|
|
|
|
this->offset(dx, dy, this);
|
|
|
|
}
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Transform verb array, SkPoint array, and weight by matrix.
|
|
|
|
transform may change verbs and increase their number.
|
2017-09-01 17:49:54 +00:00
|
|
|
Transformed SkPath replaces dst; if dst is nullptr, original data
|
|
|
|
is replaced.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param matrix SkMatrix to apply to SkPath
|
|
|
|
@param dst overwritten, transformed copy of SkPath; may be nullptr
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void transform(const SkMatrix& matrix, SkPath* dst) const;
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Transform verb array, SkPoint array, and weight by matrix.
|
|
|
|
transform may change verbs and increase their number.
|
2017-09-21 16:28:43 +00:00
|
|
|
SkPath is replaced by transformed data.
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param matrix SkMatrix to apply to SkPath
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void transform(const SkMatrix& matrix) {
|
|
|
|
this->transform(matrix, this);
|
|
|
|
}
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Returns last point on SkPath in lastPt. Returns false if SkPoint array is empty,
|
2017-09-01 17:49:54 +00:00
|
|
|
storing (0, 0) if lastPt is not nullptr.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
@param lastPt storage for final SkPoint in SkPoint array; may be nullptr
|
2018-02-27 15:22:04 +00:00
|
|
|
@return true if SkPoint array contains one or more SkPoint
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2011-10-11 11:58:32 +00:00
|
|
|
bool getLastPt(SkPoint* lastPt) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Set last point to (x, y). If SkPoint array is empty, append kMove_Verb to
|
2018-04-03 15:49:10 +00:00
|
|
|
verb array and append (x, y) to SkPoint array.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param x set x-coordinate of last point
|
|
|
|
@param y set y-coordinate of last point
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void setLastPt(SkScalar x, SkScalar y);
|
|
|
|
|
2018-04-03 15:49:10 +00:00
|
|
|
/** Set the last point on the path. If SkPoint array is empty, append kMove_Verb to
|
|
|
|
verb array and append p to SkPoint array.
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param p set value of last point
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void setLastPt(const SkPoint& p) {
|
|
|
|
this->setLastPt(p.fX, p.fY);
|
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \enum SkPath::SegmentMask
|
|
|
|
SegmentMask constants correspond to each drawing Verb type in SkPath; for
|
|
|
|
instance, if SkPath only contains lines, only the kLine_SegmentMask bit is set.
|
|
|
|
*/
|
2011-09-21 12:29:05 +00:00
|
|
|
enum SegmentMask {
|
2018-05-30 13:20:29 +00:00
|
|
|
kLine_SegmentMask = 1 << 0, //!< contains one or more lines
|
|
|
|
kQuad_SegmentMask = 1 << 1, //!< contains one or more quads
|
|
|
|
kConic_SegmentMask = 1 << 2, //!< contains one or more conics
|
|
|
|
kCubic_SegmentMask = 1 << 3, //!< contains one or more cubics
|
2011-09-21 12:29:05 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns a mask, where each set bit corresponds to a SegmentMask constant
|
2018-01-03 15:00:34 +00:00
|
|
|
if SkPath contains one or more verbs of that type.
|
2017-09-01 17:49:54 +00:00
|
|
|
Returns zero if SkPath contains no lines, or curves: quads, conics, or cubics.
|
|
|
|
|
|
|
|
getSegmentMasks() returns a cached result; it is very fast.
|
|
|
|
|
|
|
|
@return SegmentMask bits or zero
|
|
|
|
*/
|
2013-12-12 23:03:51 +00:00
|
|
|
uint32_t getSegmentMasks() const { return fPathRef->getSegmentMasks(); }
|
2011-09-21 12:29:05 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \enum SkPath::Verb
|
|
|
|
Verb instructs SkPath how to interpret one or more SkPoint and optional conic weight;
|
|
|
|
manage contour, and terminate SkPath.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
enum Verb {
|
2018-05-30 13:20:29 +00:00
|
|
|
kMove_Verb, //!< starts new contour at next SkPoint
|
|
|
|
kLine_Verb, //!< adds line from last point to next SkPoint
|
|
|
|
kQuad_Verb, //!< adds quad from last point
|
|
|
|
kConic_Verb, //!< adds conic from last point
|
|
|
|
kCubic_Verb, //!< adds cubic from last point
|
|
|
|
kClose_Verb, //!< closes contour
|
|
|
|
kDone_Verb, //!< terminates SkPath
|
2017-09-01 17:49:54 +00:00
|
|
|
};
|
2011-12-29 21:03:28 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \class SkPath::Iter
|
2018-05-30 13:20:29 +00:00
|
|
|
Iterates through verb array, and associated SkPoint array and conic weight.
|
|
|
|
Provides options to treat open contours as closed, and to ignore
|
|
|
|
degenerate data.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2011-03-15 21:27:08 +00:00
|
|
|
class SK_API Iter {
|
2017-10-30 15:48:35 +00:00
|
|
|
public:
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Initializes SkPath::Iter with an empty SkPath. next() on SkPath::Iter returns kDone_Verb.
|
|
|
|
Call setPath to initialize SkPath::Iter at a later time.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
@return SkPath::Iter of empty SkPath
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2011-12-29 21:03:28 +00:00
|
|
|
Iter();
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Sets SkPath::Iter to return elements of verb array, SkPoint array, and conic weight in path.
|
|
|
|
If forceClose is true, SkPath::Iter will add kLine_Verb and kClose_Verb after each
|
2017-09-01 17:49:54 +00:00
|
|
|
open contour. path is not altered.
|
|
|
|
|
|
|
|
@param path SkPath to iterate
|
|
|
|
@param forceClose true if open contours generate kClose_Verb
|
2018-02-27 15:22:04 +00:00
|
|
|
@return SkPath::Iter of path
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-08-29 21:36:51 +00:00
|
|
|
Iter(const SkPath& path, bool forceClose);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Sets SkPath::Iter to return elements of verb array, SkPoint array, and conic weight in path.
|
|
|
|
If forceClose is true, SkPath::Iter will add kLine_Verb and kClose_Verb after each
|
2017-09-01 17:49:54 +00:00
|
|
|
open contour. path is not altered.
|
|
|
|
|
|
|
|
@param path SkPath to iterate
|
|
|
|
@param forceClose true if open contours generate kClose_Verb
|
|
|
|
*/
|
2017-08-29 21:36:51 +00:00
|
|
|
void setPath(const SkPath& path, bool forceClose);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns next SkPath::Verb in verb array, and advances SkPath::Iter.
|
2017-09-01 17:49:54 +00:00
|
|
|
When verb array is exhausted, returns kDone_Verb.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
Zero to four SkPoint are stored in pts, depending on the returned SkPath::Verb.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If doConsumeDegenerates is true, skip consecutive kMove_Verb entries, returning
|
|
|
|
only the last in the series; and skip very small lines, quads, and conics; and
|
|
|
|
skip kClose_Verb following kMove_Verb.
|
|
|
|
if doConsumeDegenerates is true and exact is true, only skip lines, quads, and
|
|
|
|
conics with zero lengths.
|
|
|
|
|
|
|
|
@param pts storage for SkPoint data describing returned SkPath::Verb
|
|
|
|
@param doConsumeDegenerates if true, skip degenerate verbs
|
|
|
|
@param exact skip zero length curves
|
|
|
|
@return next SkPath::Verb from verb array
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2017-08-29 21:36:51 +00:00
|
|
|
Verb next(SkPoint pts[4], bool doConsumeDegenerates = true, bool exact = false) {
|
|
|
|
if (doConsumeDegenerates) {
|
2015-07-14 18:19:26 +00:00
|
|
|
this->consumeDegenerateSegments(exact);
|
2012-05-16 17:16:46 +00:00
|
|
|
}
|
|
|
|
return this->doNext(pts);
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns conic weight if next() returned kConic_Verb.
|
|
|
|
|
|
|
|
If next() has not been called, or next() did not return kConic_Verb,
|
|
|
|
result is undefined.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
@return conic weight for conic SkPoint returned by next()
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2013-05-31 15:17:50 +00:00
|
|
|
SkScalar conicWeight() const { return *fConicWeights; }
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if last kLine_Verb returned by next() was generated
|
|
|
|
by kClose_Verb. When true, the end point returned by next() is
|
|
|
|
also the start point of contour.
|
|
|
|
|
|
|
|
If next() has not been called, or next() did not return kLine_Verb,
|
|
|
|
result is undefined.
|
2011-12-21 20:43:13 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@return true if last kLine_Verb was generated by kClose_Verb
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
bool isCloseLine() const { return SkToBool(fCloseLine); }
|
2011-12-21 20:43:13 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if subsequent calls to next() return kClose_Verb before returning
|
2018-02-27 15:22:04 +00:00
|
|
|
kMove_Verb. if true, contour SkPath::Iter is processing may end with kClose_Verb, or
|
|
|
|
SkPath::Iter may have been initialized with force close set to true.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@return true if contour is closed
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
bool isClosedContour() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const SkPoint* fPts;
|
|
|
|
const uint8_t* fVerbs;
|
|
|
|
const uint8_t* fVerbStop;
|
2013-05-31 15:17:50 +00:00
|
|
|
const SkScalar* fConicWeights;
|
2008-12-17 15:59:43 +00:00
|
|
|
SkPoint fMoveTo;
|
|
|
|
SkPoint fLastPt;
|
|
|
|
SkBool8 fForceClose;
|
|
|
|
SkBool8 fNeedClose;
|
|
|
|
SkBool8 fCloseLine;
|
2011-12-21 20:43:13 +00:00
|
|
|
SkBool8 fSegmentState;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2012-05-15 17:05:38 +00:00
|
|
|
inline const SkPoint& cons_moveTo();
|
2008-12-17 15:59:43 +00:00
|
|
|
Verb autoClose(SkPoint pts[2]);
|
2015-07-14 18:19:26 +00:00
|
|
|
void consumeDegenerateSegments(bool exact);
|
2012-05-16 17:16:46 +00:00
|
|
|
Verb doNext(SkPoint pts[4]);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \class SkPath::RawIter
|
2018-05-30 13:20:29 +00:00
|
|
|
Iterates through verb array, and associated SkPoint array and conic weight.
|
|
|
|
verb array, SkPoint array, and conic weight are returned unaltered.
|
2012-01-04 21:05:51 +00:00
|
|
|
*/
|
|
|
|
class SK_API RawIter {
|
2017-10-30 15:48:35 +00:00
|
|
|
public:
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
/** Initializes RawIter with an empty SkPath. next() on RawIter returns kDone_Verb.
|
2018-02-27 15:22:04 +00:00
|
|
|
Call setPath to initialize SkPath::Iter at a later time.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@return RawIter of empty SkPath
|
|
|
|
*/
|
2015-11-19 22:47:43 +00:00
|
|
|
RawIter() {}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Sets RawIter to return elements of verb array, SkPoint array, and conic weight in path.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param path SkPath to iterate
|
|
|
|
@return RawIter of path
|
|
|
|
*/
|
2015-11-19 22:47:43 +00:00
|
|
|
RawIter(const SkPath& path) {
|
|
|
|
setPath(path);
|
|
|
|
}
|
2012-01-04 21:05:51 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Sets SkPath::Iter to return elements of verb array, SkPoint array, and conic weight in path.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param path SkPath to iterate
|
|
|
|
*/
|
2015-11-19 22:47:43 +00:00
|
|
|
void setPath(const SkPath& path) {
|
|
|
|
fRawIter.setPathRef(*path.fPathRef.get());
|
|
|
|
}
|
2012-01-04 21:05:51 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns next SkPath::Verb in verb array, and advances RawIter.
|
|
|
|
When verb array is exhausted, returns kDone_Verb.
|
2018-02-27 15:22:04 +00:00
|
|
|
Zero to four SkPoint are stored in pts, depending on the returned SkPath::Verb.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param pts storage for SkPoint data describing returned SkPath::Verb
|
|
|
|
@return next SkPath::Verb from verb array
|
2012-01-04 21:05:51 +00:00
|
|
|
*/
|
2015-11-19 22:47:43 +00:00
|
|
|
Verb next(SkPoint pts[4]) {
|
|
|
|
return (Verb) fRawIter.next(pts);
|
|
|
|
}
|
2012-01-04 21:05:51 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns next SkPath::Verb, but does not advance RawIter.
|
2015-12-09 22:04:46 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@return next SkPath::Verb from verb array
|
2015-12-09 22:04:46 +00:00
|
|
|
*/
|
|
|
|
Verb peek() const {
|
|
|
|
return (Verb) fRawIter.peek();
|
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns conic weight if next() returned kConic_Verb.
|
|
|
|
|
|
|
|
If next() has not been called, or next() did not return kConic_Verb,
|
|
|
|
result is undefined.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
@return conic weight for conic SkPoint returned by next()
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2015-11-19 22:47:43 +00:00
|
|
|
SkScalar conicWeight() const {
|
|
|
|
return fRawIter.conicWeight();
|
|
|
|
}
|
2013-05-31 15:17:50 +00:00
|
|
|
|
2012-01-04 21:05:51 +00:00
|
|
|
private:
|
2015-11-19 22:47:43 +00:00
|
|
|
SkPathRef::Iter fRawIter;
|
|
|
|
friend class SkPath;
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2012-01-04 21:05:51 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if the point (x, y) is contained by SkPath, taking into
|
|
|
|
account FillType.
|
|
|
|
|
|
|
|
@param x x-coordinate of containment test
|
|
|
|
@param y y-coordinate of containment test
|
|
|
|
@return true if SkPoint is in SkPath
|
|
|
|
*/
|
2012-07-11 01:51:33 +00:00
|
|
|
bool contains(SkScalar x, SkScalar y) const;
|
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** Writes text representation of SkPath to stream. If stream is nullptr, writes to
|
|
|
|
standard output. Set forceClose to true to get edges used to fill SkPath.
|
|
|
|
Set dumpAsHex true to generate exact binary representations
|
2018-01-03 15:00:34 +00:00
|
|
|
of floating point numbers used in SkPoint array and conic weights.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
@param stream writable SkWStream receiving SkPath text representation; may be nullptr
|
2017-09-01 17:49:54 +00:00
|
|
|
@param forceClose true if missing kClose_Verb is output
|
|
|
|
@param dumpAsHex true if SkScalar values are written as hexadecimal
|
|
|
|
*/
|
2017-05-18 19:27:57 +00:00
|
|
|
void dump(SkWStream* stream, bool forceClose, bool dumpAsHex) const;
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
/** Writes text representation of SkPath to standard output. The representation may be
|
|
|
|
directly compiled as C++ code. Floating point values are written
|
|
|
|
with limited precision; it may not be possible to reconstruct original SkPath
|
|
|
|
from output.
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2009-11-23 20:10:41 +00:00
|
|
|
void dump() const;
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
/** Writes text representation of SkPath to standard output. The representation may be
|
|
|
|
directly compiled as C++ code. Floating point values are written
|
|
|
|
in hexadecimal to preserve their exact bit pattern. The output reconstructs the
|
|
|
|
original SkPath.
|
|
|
|
|
|
|
|
Use instead of dump() when submitting
|
|
|
|
*/
|
2014-09-15 16:26:09 +00:00
|
|
|
void dumpHex() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Writes SkPath to buffer, returning the number of bytes written.
|
|
|
|
Pass nullptr to obtain the storage size.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Writes SkPath::FillType, verb array, SkPoint array, conic weight, and
|
2017-09-01 17:49:54 +00:00
|
|
|
additionally writes computed information like SkPath::Convexity and bounds.
|
|
|
|
|
|
|
|
Use only be used in concert with readFromMemory();
|
|
|
|
the format used for SkPath in memory is not guaranteed.
|
|
|
|
|
|
|
|
@param buffer storage for SkPath; may be nullptr
|
|
|
|
@return size of storage required for SkPath; always a multiple of 4
|
|
|
|
*/
|
2013-11-05 15:46:56 +00:00
|
|
|
size_t writeToMemory(void* buffer) const;
|
2017-07-26 21:33:44 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Write SkPath to buffer, returning the buffer written to, wrapped in SkData.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
serialize() writes SkPath::FillType, verb array, SkPoint array, conic weight, and
|
2017-09-01 17:49:54 +00:00
|
|
|
additionally writes computed information like SkPath::Convexity and bounds.
|
|
|
|
|
|
|
|
serialize() should only be used in concert with readFromMemory().
|
|
|
|
The format used for SkPath in memory is not guaranteed.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
@return SkPath data wrapped in SkData buffer
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-07-26 21:33:44 +00:00
|
|
|
sk_sp<SkData> serialize() const;
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Initializes SkPath from buffer of size length. Returns zero if the buffer is
|
|
|
|
data is inconsistent, or the length is too small.
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Reads SkPath::FillType, verb array, SkPoint array, conic weight, and
|
2017-09-01 17:49:54 +00:00
|
|
|
additionally reads computed information like SkPath::Convexity and bounds.
|
|
|
|
|
|
|
|
Used only in concert with writeToMemory();
|
|
|
|
the format used for SkPath in memory is not guaranteed.
|
|
|
|
|
|
|
|
@param buffer storage for SkPath
|
|
|
|
@param length buffer size in bytes; must be multiple of 4
|
|
|
|
@return number of bytes read, or zero on failure
|
|
|
|
*/
|
2013-11-05 15:46:56 +00:00
|
|
|
size_t readFromMemory(const void* buffer, size_t length);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** (see skbug.com/1762)
|
|
|
|
Returns a non-zero, globally unique value. A different value is returned
|
2018-01-03 15:00:34 +00:00
|
|
|
if verb array, SkPoint array, or conic weight changes.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
Setting SkPath::FillType does not change generation id.
|
|
|
|
|
|
|
|
Each time the path is modified, a different generation id will be returned.
|
2018-02-27 15:22:04 +00:00
|
|
|
SkPath::FillType does affect generation id on Android framework.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@return non-zero, globally unique value
|
2013-10-30 18:57:55 +00:00
|
|
|
*/
|
2013-10-29 22:45:37 +00:00
|
|
|
uint32_t getGenerationID() const;
|
2013-10-30 18:57:55 +00:00
|
|
|
|
2017-09-14 14:31:36 +00:00
|
|
|
#ifdef SK_SUPPORT_DIRECT_PATHREF_VALIDATION
|
2017-08-25 19:13:38 +00:00
|
|
|
/** Returns if SkPath data is consistent. Corrupt SkPath data is detected if
|
|
|
|
internal values are out of range or internal storage does not match
|
|
|
|
array dimensions.
|
|
|
|
|
|
|
|
@return true if SkPath data is consistent
|
2017-09-21 16:28:43 +00:00
|
|
|
*/
|
2017-08-25 19:13:38 +00:00
|
|
|
bool isValid() const { return this->isValidImpl() && fPathRef->isValid(); }
|
|
|
|
#else
|
|
|
|
bool isValid() const { return this->isValidImpl(); }
|
2017-08-10 19:16:37 +00:00
|
|
|
bool pathRefIsValid() const { return fPathRef->isValid(); }
|
2017-08-25 19:13:38 +00:00
|
|
|
#endif
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
private:
|
2017-09-27 17:26:22 +00:00
|
|
|
sk_sp<SkPathRef> fPathRef;
|
|
|
|
int fLastMoveToIndex;
|
|
|
|
uint8_t fFillType;
|
|
|
|
mutable SkAtomic<Convexity, sk_memory_order_relaxed> fConvexity;
|
|
|
|
mutable SkAtomic<uint8_t, sk_memory_order_relaxed> fFirstDirection;// SkPathPriv::FirstDirection
|
|
|
|
SkBool8 fIsVolatile;
|
2018-04-11 20:34:06 +00:00
|
|
|
SkBool8 fIsBadForDAA = false;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2013-06-21 15:13:34 +00:00
|
|
|
/** 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 resetFields();
|
|
|
|
|
|
|
|
/** Sets all fields other than fPathRef to the values in 'that'.
|
|
|
|
* Assumes the caller has already set fPathRef.
|
2013-08-07 19:17:53 +00:00
|
|
|
* Doesn't change fGenerationID or fSourcePath on Android.
|
2013-06-21 15:13:34 +00:00
|
|
|
*/
|
|
|
|
void copyFields(const SkPath& that);
|
|
|
|
|
2018-02-21 20:55:14 +00:00
|
|
|
size_t writeToMemoryAsRRect(void* buffer) const;
|
|
|
|
size_t readAsRRect(const void*, size_t);
|
|
|
|
size_t readFromMemory_LE3(const void*, size_t);
|
|
|
|
size_t readFromMemory_EQ4(const void*, size_t);
|
2017-09-21 16:29:24 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
friend class Iter;
|
2015-06-10 21:23:15 +00:00
|
|
|
friend class SkPathPriv;
|
2008-12-17 15:59:43 +00:00
|
|
|
friend class SkPathStroker;
|
|
|
|
|
|
|
|
/* Append, in reverse order, the first contour of path, ignoring path's
|
|
|
|
last point. If no moveTo() call has been made for this contour, the
|
|
|
|
first point is automatically set to (0,0).
|
|
|
|
*/
|
|
|
|
void reversePathTo(const SkPath&);
|
|
|
|
|
2012-01-12 18:17:11 +00:00
|
|
|
// called before we add points for lineTo, quadTo, cubicTo, checking to see
|
|
|
|
// if we need to inject a leading moveTo first
|
|
|
|
//
|
|
|
|
// SkPath path; path.lineTo(...); <--- need a leading moveTo(0, 0)
|
|
|
|
// SkPath path; ... path.close(); path.lineTo(...) <-- need a moveTo(previous moveTo)
|
|
|
|
//
|
2014-02-12 17:44:30 +00:00
|
|
|
inline void injectMoveToIfNeeded();
|
2012-01-12 18:17:11 +00:00
|
|
|
|
2012-04-18 13:29:52 +00:00
|
|
|
inline bool hasOnlyMoveTos() const;
|
|
|
|
|
2012-11-13 14:36:42 +00:00
|
|
|
Convexity internalGetConvexity() const;
|
2012-11-20 02:01:23 +00:00
|
|
|
|
2017-08-25 19:13:38 +00:00
|
|
|
/** Asserts if SkPath data is inconsistent.
|
|
|
|
Debugging check intended for internal use only.
|
|
|
|
*/
|
|
|
|
SkDEBUGCODE(void validate() const { SkASSERT(this->isValidImpl()); } )
|
|
|
|
bool isValidImpl() const;
|
|
|
|
SkDEBUGCODE(void validateRef() const { fPathRef->validate(); } )
|
|
|
|
|
2012-11-21 15:18:06 +00:00
|
|
|
bool isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts,
|
2018-04-09 20:07:11 +00:00
|
|
|
bool* isClosed, Direction* direction, SkRect* rect) const;
|
2012-11-13 14:36:42 +00:00
|
|
|
|
2017-07-10 19:09:26 +00:00
|
|
|
// called by stroker to see if all points (in the last contour) are equal and worthy of a cap
|
|
|
|
bool isZeroLengthSincePoint(int startPtIndex) const;
|
2016-02-22 20:44:54 +00:00
|
|
|
|
2013-09-26 12:18:23 +00:00
|
|
|
/** Returns if the path can return a bound at no cost (true) or will have to
|
|
|
|
perform some computation (false).
|
|
|
|
*/
|
|
|
|
bool hasComputedBounds() const {
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
return fPathRef->hasComputedBounds();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 'rect' needs to be sorted
|
|
|
|
void setBounds(const SkRect& rect) {
|
2013-12-13 19:36:25 +00:00
|
|
|
SkPathRef::Editor ed(&fPathRef);
|
|
|
|
|
|
|
|
ed.setBounds(rect);
|
2013-09-26 12:18:23 +00:00
|
|
|
}
|
|
|
|
|
2015-04-29 15:28:30 +00:00
|
|
|
void setPt(int index, SkScalar x, SkScalar y);
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
friend class SkAutoPathBoundsUpdate;
|
2012-04-18 13:29:52 +00:00
|
|
|
friend class SkAutoDisableOvalCheck;
|
2012-11-13 14:36:42 +00:00
|
|
|
friend class SkAutoDisableDirectionCheck;
|
2016-11-07 13:09:28 +00:00
|
|
|
friend class SkPathWriter;
|
|
|
|
friend class SkOpBuilder;
|
2013-11-14 16:53:22 +00:00
|
|
|
friend class SkBench_AddPathTest; // perf test reversePathTo
|
|
|
|
friend class PathTest_Private; // unit test reversePathTo
|
2015-11-19 22:47:43 +00:00
|
|
|
friend class ForceIsRRect_Private; // unit test isRRect
|
2017-08-25 19:13:38 +00:00
|
|
|
friend class FuzzPath; // for legacy access to validateRef
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|