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

Unified Diff: src/core/SkPath.cpp

Issue 931183002: add gm for path-arcs, and catch degenerate arc in conic-case (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: The C parser and warnings as just AWESOME 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 | « include/core/SkPath.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPath.cpp
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 461ab3a7156d846ac0186aeb8fe83a043ea1a08f..de3d297da3fe87d7465b3f169d599f692a6cf37e 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -934,14 +934,23 @@ static int build_arc_points(const SkRect& oval, const SkVector& start, const SkV
return SkBuildQuadArc(start, stop, dir, &matrix, pts);
}
#else
+/**
+ * If this returns 0, then the caller should just line-to the singlePt, else it should
+ * ignore singlePt and append the specified number of conics.
+ */
static int build_arc_conics(const SkRect& oval, const SkVector& start, const SkVector& stop,
- SkRotationDirection dir, SkConic conics[SkConic::kMaxConicsForArc]) {
+ SkRotationDirection dir, SkConic conics[SkConic::kMaxConicsForArc],
+ SkPoint* singlePt) {
SkMatrix matrix;
matrix.setScale(SkScalarHalf(oval.width()), SkScalarHalf(oval.height()));
matrix.postTranslate(oval.centerX(), oval.centerY());
- return SkConic::BuildUnitArc(start, stop, dir, &matrix, conics);
+ int count = SkConic::BuildUnitArc(start, stop, dir, &matrix, conics);
+ if (0 == count) {
+ matrix.mapXY(start.x(), start.y(), singlePt);
+ }
+ return count;
}
#endif
@@ -1176,8 +1185,9 @@ void SkPath::arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
this->quadTo(pts[i], pts[i+1]);
}
#else
+ SkPoint singlePt;
SkConic conics[SkConic::kMaxConicsForArc];
- int count = build_arc_conics(oval, startV, stopV, dir, conics);
+ int count = build_arc_conics(oval, startV, stopV, dir, conics, &singlePt);
if (count) {
this->incReserve(count * 2 + 1);
const SkPoint& pt = conics[0].fPts[0];
@@ -1185,6 +1195,8 @@ void SkPath::arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
for (int i = 0; i < count; ++i) {
this->conicTo(conics[i].fPts[1], conics[i].fPts[2], conics[i].fW);
}
+ } else {
+ forceMoveTo ? this->moveTo(singlePt) : this->lineTo(singlePt);
}
#endif
}
« no previous file with comments | « include/core/SkPath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698