Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: src/core/SkPath.cpp

Issue 971773002: treat backwards quads as not convex (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add fall through comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPath.cpp
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 2babe70185d51cabb9059f47c774acd2d1f80d74..738edd9d232c79ea40e9aab40653f5396e971e2f 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -2129,7 +2129,8 @@ struct Convexicator {
: fPtCount(0)
, fConvexity(SkPath::kConvex_Convexity)
, fDirection(SkPath::kUnknown_Direction)
- , fIsFinite(true) {
+ , fIsFinite(true)
+ , fIsCurve(false) {
fExpectedDir = kInvalid_DirChange;
// warnings
fLastPt.set(0, 0);
@@ -2193,6 +2194,10 @@ struct Convexicator {
return fIsFinite;
}
+ void setCurve(bool isCurve) {
+ fIsCurve = isCurve;
+ }
+
private:
void addVec(const SkVector& vec) {
SkASSERT(vec.fX || vec.fY);
@@ -2213,6 +2218,10 @@ private:
case kStraight_DirChange:
break;
case kBackwards_DirChange:
+ if (fIsCurve) {
+ fConvexity = SkPath::kConcave_Convexity;
+ fDirection = SkPath::kUnknown_Direction;
+ }
fLastVec = vec;
break;
case kInvalid_DirChange:
@@ -2232,6 +2241,7 @@ private:
SkPath::Direction fDirection;
int fDx, fDy, fSx, fSy;
bool fIsFinite;
+ bool fIsCurve;
};
SkPath::Convexity SkPath::internalGetConvexity() const {
@@ -2255,13 +2265,23 @@ SkPath::Convexity SkPath::internalGetConvexity() const {
return kConcave_Convexity;
}
pts[1] = pts[0];
+ // fall through
+ case kLine_Verb:
count = 1;
+ state.setCurve(false);
+ break;
+ case kQuad_Verb:
+ // fall through
+ case kConic_Verb:
+ // fall through
+ case kCubic_Verb:
+ count = 2 + (kCubic_Verb == verb);
+ // As an additional enhancement, this could set curve true only
+ // if the curve is nonlinear
+ state.setCurve(true);
break;
- case kLine_Verb: count = 1; break;
- case kQuad_Verb: count = 2; break;
- case kConic_Verb: count = 2; break;
- case kCubic_Verb: count = 3; break;
case kClose_Verb:
+ state.setCurve(false);
state.close();
count = 0;
break;
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698