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

Unified Diff: src/core/SkStroke.cpp

Issue 1862753002: cubic stroke fix (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | « gm/cubicpaths.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkStroke.cpp
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp
index 0f1a15f0b6deb6ad48eced5dba6fe7a6e65b4e1d..20bd286316d9b33f3f705bd3c69a1cb26a5dbb48 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;
« no previous file with comments | « gm/cubicpaths.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698