aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/SkPath.cpp15
-rw-r--r--tests/PathTest.cpp10
2 files changed, 23 insertions, 2 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 1cc92a41b4..8aecf1b624 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -2301,7 +2301,8 @@ struct Convexicator {
, fConvexity(SkPath::kConvex_Convexity)
, fFirstDirection(SkPathPriv::kUnknown_FirstDirection)
, fIsFinite(true)
- , fIsCurve(false) {
+ , fIsCurve(false)
+ , fBackwards(false) {
fExpectedDir = kInvalid_DirChange;
// warnings
fPriorPt.set(0,0);
@@ -2400,6 +2401,9 @@ struct Convexicator {
return kStraight_DirChange;
}
+ bool hasBackwards() const {
+ return fBackwards;
+ }
bool isFinite() const {
return fIsFinite;
@@ -2435,6 +2439,7 @@ private:
fExpectedDir = dir;
}
fLastVec = vec;
+ fBackwards = true;
break;
case kInvalid_DirChange:
SK_ABORT("Use of invalid direction change flag");
@@ -2455,6 +2460,7 @@ private:
int fDx, fDy, fSx, fSy;
bool fIsFinite;
bool fIsCurve;
+ bool fBackwards;
};
SkPath::Convexity SkPath::internalGetConvexity() const {
@@ -2518,7 +2524,12 @@ SkPath::Convexity SkPath::internalGetConvexity() const {
}
fConvexity = state.getConvexity();
if (kConvex_Convexity == fConvexity && SkPathPriv::kUnknown_FirstDirection == fFirstDirection) {
- fFirstDirection = state.getFirstDirection();
+ if (SkPathPriv::kUnknown_FirstDirection == state.getFirstDirection() &&
+ !this->getBounds().isEmpty() && !state.hasBackwards()) {
+ fConvexity = Convexity::kConcave_Convexity;
+ } else {
+ fFirstDirection = state.getFirstDirection();
+ }
}
return static_cast<Convexity>(fConvexity);
}
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 6e1cf011c4..7c9c0076c0 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -1681,6 +1681,16 @@ static void test_convexity(skiatest::Reporter* reporter) {
: SkPath::kUnknown_Convexity);
}
+ path.reset();
+ path.moveTo(SkBits2Float(0xbe9171db), SkBits2Float(0xbd7eeb5d)); // -0.284072f, -0.0622362f
+ path.lineTo(SkBits2Float(0xbe9171db), SkBits2Float(0xbd7eea38)); // -0.284072f, -0.0622351f
+ path.lineTo(SkBits2Float(0xbe9171a0), SkBits2Float(0xbd7ee5a7)); // -0.28407f, -0.0622307f
+ path.lineTo(SkBits2Float(0xbe917147), SkBits2Float(0xbd7ed886)); // -0.284067f, -0.0622182f
+ path.lineTo(SkBits2Float(0xbe917378), SkBits2Float(0xbd7ee1a9)); // -0.284084f, -0.0622269f
+ path.lineTo(SkBits2Float(0xbe9171db), SkBits2Float(0xbd7eeb5d)); // -0.284072f, -0.0622362f
+ path.close();
+ check_convexity(reporter, path, SkPath::kConcave_Convexity);
+
}
static void test_isLine(skiatest::Reporter* reporter) {