diff options
author | 2017-08-25 08:04:43 -0400 | |
---|---|---|
committer | 2017-08-25 14:40:47 +0000 | |
commit | c8323aa51ab27259076532ba081d2ed5c26aedfc (patch) | |
tree | 4f04e12142cd870b4d0ee165060c53ab3d5bf4a5 /src/core/SkPath.cpp | |
parent | 5563d8da7dbbb36d00298d97448e8de1e68ca916 (diff) |
tiny concave path point fix
The tiny path added to PathTest.cpp has
tinier cross products (e.g. 1e-12)
so appears to be a series of unbending
lines as far as getConvexity is concerned.
This point fix looks for paths that
do not bend left or right or go backwards,
but do have a bounds, and calls them
concave.
A better fix may be to consider empty
and degenerate paths to be concave
instead of convex; I don't know if
anyone relies on the existing behavior.
Another better fix may be to change
the math to compute the path turns
even though the numbers are very small;
on the surface, very difficult.
R=bsalomon@google.com,reed@google.com
Bug:755839
Change-Id: Ie2280f3f0b95fecab2899f5fc579fd39258e0647
Reviewed-on: https://skia-review.googlesource.com/38720
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
Diffstat (limited to 'src/core/SkPath.cpp')
-rw-r--r-- | src/core/SkPath.cpp | 15 |
1 files changed, 13 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); } |