aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkPath.h22
-rw-r--r--samplecode/SamplePathFuzz.cpp3
-rw-r--r--src/core/SkPath.cpp2
3 files changed, 22 insertions, 5 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index f0d6f3b2ae..c3031660a6 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -1119,10 +1119,18 @@ public:
static const int kPathRefGenIDBitCnt = 32;
#endif
- bool isValid() const;
+ /** 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
+ */
+#ifdef SK_SUPPORT_DIRECT_PATHREF_VALIDATION
+ bool isValid() const { return this->isValidImpl() && fPathRef->isValid(); }
+#else
+ bool isValid() const { return this->isValidImpl(); }
bool pathRefIsValid() const { return fPathRef->isValid(); }
- SkDEBUGCODE(void validate() const { SkASSERT(this->isValid()); } )
- SkDEBUGCODE(void experimentalValidateRef() const { fPathRef->validate(); } )
+#endif
private:
enum SerializationOffsets {
@@ -1183,6 +1191,13 @@ private:
Convexity internalGetConvexity() const;
+ /** 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(); } )
+
bool isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts,
bool* isClosed, Direction* direction) const;
@@ -1215,6 +1230,7 @@ private:
friend class SkBench_AddPathTest; // perf test reversePathTo
friend class PathTest_Private; // unit test reversePathTo
friend class ForceIsRRect_Private; // unit test isRRect
+ friend class FuzzPath; // for legacy access to validateRef
};
#endif
diff --git a/samplecode/SamplePathFuzz.cpp b/samplecode/SamplePathFuzz.cpp
index b66b881547..ac9ffc9122 100644
--- a/samplecode/SamplePathFuzz.cpp
+++ b/samplecode/SamplePathFuzz.cpp
@@ -574,7 +574,8 @@ SkVector makeVector() {
void validate(const SkPath& path) {
if (fValidate) {
- SkDEBUGCODE(path.experimentalValidateRef());
+ // FIXME: this could probably assert on path.isValid() instead
+ SkDEBUGCODE(path.validateRef());
}
}
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 32ec2c560b..5dcca6fff1 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -2220,7 +2220,7 @@ void SkPath::dumpHex() const {
}
-bool SkPath::isValid() const {
+bool SkPath::isValidImpl() const {
if ((fFillType & ~3) != 0) {
return false;
}