aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-16 14:16:04 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-16 14:16:04 +0000
commitb54455e440e66e0b1c30954d226226f49aac26d6 (patch)
tree961a3683ec759e54413ce437522fbf55d1bd682c /include
parent27a4dc4c362a345431428cb61db27647ec1acd48 (diff)
Change getConvexity() to now compute it if the value is set to kUnkown.
Change behavior for degenerate paths: now those return kConvex instead of kUnknown git-svn-id: http://skia.googlecode.com/svn/trunk@1330 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r--include/core/SkPath.h38
1 files changed, 30 insertions, 8 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 18dcd11070..7120d3fa95 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -88,9 +88,10 @@ public:
/** Returns true if the filltype is one of the Inverse variants */
bool isInverseFillType() const { return (fFillType & 2) != 0; }
- /** Toggle between inverse and normal filltypes. This reverse the return
- value of isInverseFillType()
- */
+ /**
+ * Toggle between inverse and normal filltypes. This reverse the return
+ * value of isInverseFillType()
+ */
void toggleInverseFillType() {
fFillType ^= 2;
GEN_ID_INC;
@@ -103,14 +104,33 @@ public:
};
/**
- * Return the path's convexity, as stored in the path.
+ * Return the path's convexity, as stored in the path. If it is currently
+ * unknown, and the computeIfUnknown bool is true, then this will first
+ * call ComputeConvexity() and then return that (cached) value.
+ */
+ Convexity getConvexity() const {
+ if (kUnknown_Convexity == fConvexity) {
+ fConvexity = (uint8_t)ComputeConvexity(*this);
+ }
+ return (Convexity)fConvexity;
+ }
+
+ /**
+ * Return the currently cached value for convexity, even if that is set to
+ * kUnknown_Convexity. Note: getConvexity() will automatically call
+ * ComputeConvexity and cache its return value if the current setting is
+ * kUnknown.
*/
- Convexity getConvexity() const { return (Convexity)fConvexity; }
+ Convexity getConvexityOrUnknown() 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().
+ *
+ * Note: even if this is set to a "known" value, if the path is later
+ * changed (e.g. lineTo(), addRect(), etc.) then the cached value will be
+ * reset to kUnknown_Convexity.
*/
void setConvexity(Convexity);
@@ -118,9 +138,11 @@ public:
* 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.
*
+ * This never returns kUnknown_Convexity.
+ *
* 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.
+ * If the contour is degenerate (e.g. there are fewer than 3 non-degenerate
+ * segments), then this returns kConvex_Convexity.
* The contour is treated as if it were closed, even if there is no kClose
* verb.
*/
@@ -635,7 +657,7 @@ private:
mutable SkRect fBounds;
mutable uint8_t fBoundsIsDirty;
uint8_t fFillType;
- uint8_t fConvexity;
+ mutable uint8_t fConvexity;
#ifdef ANDROID
uint32_t fGenerationID;
#endif