diff options
author | Cary Clark <caryclark@skia.org> | 2017-08-25 15:13:38 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-29 18:37:11 +0000 |
commit | 0461e9fa44e0cb6035f14be00430f7294da68993 (patch) | |
tree | 6635af7e7537281c3b471a02c55a5149d475a4cd | |
parent | 4eaadf1c548c421b985af35f5da286db92955f63 (diff) |
simplify path validate
Reduce path validation interfaces,
deferring the harder work of rewriting
the callers until later.
R=reed@google.com,enne@chromium.org
Change-Id: Iea56f1cd1be93bb1d96b50836a9bd3cd4872ad23
Reviewed-on: https://skia-review.googlesource.com/37541
Commit-Queue: Cary Clark <caryclark@google.com>
Reviewed-by: Adrienne Walker <enne@chromium.org>
-rw-r--r-- | include/core/SkPath.h | 22 | ||||
-rw-r--r-- | samplecode/SamplePathFuzz.cpp | 3 | ||||
-rw-r--r-- | src/core/SkPath.cpp | 2 |
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; } |