aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2016-04-06 08:54:06 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-06 08:54:06 -0700
commit4693a1748f19fa4ee83c6eee2333b39ffb3febd4 (patch)
treeedba3e060e46c29e8092521152af7109b51c8a6d /src/core
parentc416912da4840af0c49bd8cdcf00044ed39500f6 (diff)
cubic stroke fix
Normally parallel tangents means that the stroke can be represented with a line. But looping cubics can have parallel tangents if the loop is 180 degrees. Check to see if the tangents direction is opposite to subdivide further. R=reed@google.com BUG=skia:5099 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1862753002 Review URL: https://codereview.chromium.org/1862753002
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkStroke.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp
index 0f1a15f0b6..20bd286316 100644
--- a/src/core/SkStroke.cpp
+++ b/src/core/SkStroke.cpp
@@ -85,6 +85,7 @@ struct SkQuadConstruct { // The state of the quad stroke under construction.
SkScalar fEndT; // "
bool fStartSet; // state to share common points across structs
bool fEndSet; // "
+ bool fOppositeTangents; // set if coincident tangents have opposite directions
// return false if start and end are too close to have a unique middle
bool init(SkScalar start, SkScalar end) {
@@ -861,8 +862,10 @@ SkPathStroker::ResultType SkPathStroker::intersectRay(SkQuadConstruct* quadPts,
*/
SkScalar denom = aLen.cross(bLen);
if (denom == 0 || !SkScalarIsFinite(denom)) {
+ quadPts->fOppositeTangents = aLen.dot(bLen) < 0;
return STROKER_RESULT(kDegenerate_ResultType, depth, quadPts, "denom == 0");
}
+ quadPts->fOppositeTangents = false;
SkVector ab0 = start - end;
SkScalar numerA = bLen.cross(ab0);
SkScalar numerB = aLen.cross(ab0);
@@ -893,6 +896,7 @@ SkPathStroker::ResultType SkPathStroker::intersectRay(SkQuadConstruct* quadPts,
return STROKER_RESULT(kQuad_ResultType, depth, quadPts,
"(numerA=%g >= 0) != (numerB=%g >= 0)", numerA, numerB);
}
+ quadPts->fOppositeTangents = aLen.dot(bLen) < 0;
// if the lines are parallel, straight line is good enough
return STROKER_RESULT(kDegenerate_ResultType, depth, quadPts,
"SkScalarNearlyZero(denom=%g)", denom);
@@ -1116,8 +1120,10 @@ bool SkPathStroker::cubicStroke(const SkPoint cubic[4], SkQuadConstruct* quadPts
return true;
}
if (kDegenerate_ResultType == resultType) {
- addDegenerateLine(quadPts);
- return true;
+ if (!quadPts->fOppositeTangents) {
+ addDegenerateLine(quadPts);
+ return true;
+ }
}
if (kNormalError_ResultType == resultType) {
return false;