Add query to test our cached convexity

Sometimes our cache of convexity is wrong -- still trying to figure out
what do do about that.

Change-Id: Ie36292b87c4d07fc18643cc91f93be00c577b2ca
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/355616
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2021-01-19 09:15:08 -05:00 committed by Skia Commit-Bot
parent cc7aa8e318
commit 0bc32f23f6
2 changed files with 29 additions and 8 deletions

View File

@ -1850,17 +1850,15 @@ private:
/** Returns the comvexity type, computing if needed. Never returns kUnknown.
@return path's convexity type (convex or concave)
*/
SkPathConvexity getConvexity() const {
SkPathConvexity convexity = this->getConvexityOrUnknown();
if (convexity == SkPathConvexity::kUnknown) {
convexity = this->computeConvexity();
}
SkASSERT(convexity != SkPathConvexity::kUnknown);
return convexity;
}
SkPathConvexity getConvexity() const;
SkPathConvexity getConvexityOrUnknown() const {
return (SkPathConvexity)fConvexity.load(std::memory_order_relaxed);
}
// Compares the cached value with a freshly computed one (computeConvexity())
bool isConvexityAccurate() const;
/** Stores a convexity type for this path. This is what will be returned if
* getConvexityOrUnknown() is called. If you pass kUnknown, then if getContexityType()
* is called, the real convexity will be computed.

View File

@ -580,6 +580,29 @@ SkPathFirstDirection SkPath::getFirstDirection() const {
return (SkPathFirstDirection)fFirstDirection.load(std::memory_order_relaxed);
}
bool SkPath::isConvexityAccurate() const {
SkPathConvexity convexity = this->getConvexityOrUnknown();
if (convexity != SkPathConvexity::kUnknown) {
auto conv = this->computeConvexity();
if (conv != convexity) {
SkASSERT(false);
return false;
}
}
return true;
}
SkPathConvexity SkPath::getConvexity() const {
// Enable once we fix all the bugs
// SkDEBUGCODE(this->isConvexityAccurate());
SkPathConvexity convexity = this->getConvexityOrUnknown();
if (convexity == SkPathConvexity::kUnknown) {
convexity = this->computeConvexity();
}
SkASSERT(convexity != SkPathConvexity::kUnknown);
return convexity;
}
//////////////////////////////////////////////////////////////////////////////
// Construction methods