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

Unified Diff: src/core/SkStroke.cpp

Issue 948043002: break out of cubic stroker loop on degenerate case (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: find root cause for dash cubic failure; add more tests 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 | « gm/dashcubics.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 1a44a3a19f6654aaf8cf093e492df4db8ad5d6f7..5c65e6eb016e7f4f293f4c8d0921e039ba20a90c 100644
--- a/src/core/SkStroke.cpp
+++ b/src/core/SkStroke.cpp
@@ -905,9 +905,10 @@ void SkPathStroker::quadTo(const SkPoint& pt1, const SkPoint& pt2) {
// compute the perpendicular point and its tangent.
void SkPathStroker::setRayPts(const SkPoint& tPt, SkVector* dxy, SkPoint* onPt,
SkPoint* tangent) const {
+ SkPoint oldDxy = *dxy;
if (!dxy->setLength(fRadius)) { // consider moving double logic into SkPoint::setLength
- double xx = dxy->fX;
- double yy = dxy->fY;
+ double xx = oldDxy.fX;
+ double yy = oldDxy.fY;
double dscale = fRadius / sqrt(xx * xx + yy * yy);
dxy->fX = SkDoubleToScalar(xx * dscale);
dxy->fY = SkDoubleToScalar(yy * dscale);
@@ -1412,14 +1413,16 @@ void SkPathStroker::cubicTo(const SkPoint& pt1, const SkPoint& pt2,
SkQuadConstruct quadPts;
this->init(kOuter_StrokeType, &quadPts, lastT, nextT);
if (!this->cubicStroke(cubic, &quadPts)) {
- return;
+ break;
}
this->init(kInner_StrokeType, &quadPts, lastT, nextT);
if (!this->cubicStroke(cubic, &quadPts)) {
- return;
+ break;
}
lastT = nextT;
}
+ // emit the join even if one stroke succeeded but the last one failed
+ // this avoids reversing an inner stroke with a partial path followed by another moveto
this->setCubicEndNormal(cubic, normalAB, unitAB, &normalCD, &unitCD);
#else
bool degenerateAB = SkPath::IsLineDegenerate(fPrevPt, pt1);
« no previous file with comments | « gm/dashcubics.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698