diff options
author | 2011-05-15 04:08:24 +0000 | |
---|---|---|
committer | 2011-05-15 04:08:24 +0000 | |
commit | 04863fa14a44ddf85acbc6268690ebc3f0d1d6db (patch) | |
tree | d0426edf125177122a4bf52c29cbe6f020ba947b /include/core/SkPath.h | |
parent | a8fd79d407ce056d32316932dce8b898d932ae6d (diff) |
add Convexity enum to SkPath
git-svn-id: http://skia.googlecode.com/svn/trunk@1324 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkPath.h')
-rw-r--r-- | include/core/SkPath.h | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h index 2ebc59d3eb..18dcd11070 100644 --- a/include/core/SkPath.h +++ b/include/core/SkPath.h @@ -96,19 +96,54 @@ public: GEN_ID_INC; } - /** Returns true if the path is flagged as being convex. This is not a - confirmed by any analysis, it is just the value set earlier. + enum Convexity { + kUnknown_Convexity, + kConvex_Convexity, + kConcave_Convexity + }; + + /** + * Return the path's convexity, as stored in the path. + */ + Convexity getConvexity() const { return (Convexity)fConvexity; } + + /** + * Store a convexity setting in the path. There is no automatic check to + * see if this value actually agress with the return value from + * ComputeConvexity(). + */ + void setConvexity(Convexity); + + /** + * Compute the convexity of the specified path. This does not look at the + * value stored in the path, but computes it directly from the path's data. + * + * If there is more than one contour, this returns kConcave_Convexity. + * If the contour is degenerate (i.e. all segements are colinear, + * then this returns kUnknown_Convexity. + * The contour is treated as if it were closed, even if there is no kClose + * verb. */ - bool isConvex() const { return fIsConvex != 0; } + static Convexity ComputeConvexity(const SkPath&); - /** Set the isConvex flag to true or false. Convex paths may draw faster if - this flag is set, though setting this to true on a path that is in fact - not convex can give undefined results when drawn. Paths default to - isConvex == false + /** + * DEPRECATED: use getConvexity() + * Returns true if the path is flagged as being convex. This is not a + * confirmed by any analysis, it is just the value set earlier. + */ + bool isConvex() const { + return kConvex_Convexity == this->getConvexity(); + } + + /** + * DEPRECATED: use setConvexity() + * Set the isConvex flag to true or false. Convex paths may draw faster if + * this flag is set, though setting this to true on a path that is in fact + * not convex can give undefined results when drawn. Paths default to + * isConvex == false */ void setIsConvex(bool isConvex) { - fIsConvex = (isConvex != 0); - GEN_ID_INC; + this->setConvexity(isConvex ? kConvex_Convexity : kConcave_Convexity); } /** Clear any lines and curves from the path, making it empty. This frees up @@ -600,7 +635,7 @@ private: mutable SkRect fBounds; mutable uint8_t fBoundsIsDirty; uint8_t fFillType; - uint8_t fIsConvex; + uint8_t fConvexity; #ifdef ANDROID uint32_t fGenerationID; #endif |