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

Unified Diff: src/core/SkPath.cpp

Issue 2388833002: Fix SkPath::arcTo when sweepAngle is tiny and radius is big (Closed)
Patch Set: remove stdio Created 4 years, 2 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/addarc.cpp ('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 1fb3e117663002984277987f75c3b6ac69019ceb..61ab862935fe5c288b11319c4b2e52c37824e49e 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1290,6 +1290,20 @@ void SkPath::arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
angles_to_unit_vectors(startAngle, sweepAngle, &startV, &stopV, &dir);
SkPoint singlePt;
+
+ // At this point, we know that the arc is not a lone point, but startV == stopV
+ // indicates that the sweepAngle is too small such that angles_to_unit_vectors
+ // cannot handle it.
+ if (startV == stopV) {
+ SkScalar endAngle = SkDegreesToRadians(startAngle + sweepAngle);
+ SkScalar radiusX = oval.width() / 2;
+ SkScalar radiusY = oval.height() / 2;
+ singlePt.set(oval.centerX() + radiusX * cosf(endAngle),
+ oval.centerY() + radiusY * sinf(endAngle));
caryclark 2016/10/05 14:08:11 SkScalarSinCos() is preferable
xidachen 2016/10/05 14:24:32 While I do agree that SkScalarSinCos() is preferab
caryclark 2016/10/05 14:47:03 A comment in the code to this effect would be help
xidachen 2016/10/05 16:33:51 comment added. sk_float_sin and sk_float_cos work
+ forceMoveTo ? this->moveTo(singlePt) : this->lineTo(singlePt);
caryclark 2016/10/05 14:08:11 Does your example GM trigger both sides of this ex
xidachen 2016/10/05 14:24:32 No, it only triggers lineTo. This line is basicall
caryclark 2016/10/05 14:47:03 It would be great if was possible to verify that t
xidachen 2016/10/05 16:33:51 I believe SkPath::addArc calls arcTo with forceMov
+ return;
+ }
+
SkConic conics[SkConic::kMaxConicsForArc];
int count = build_arc_conics(oval, startV, stopV, dir, conics, &singlePt);
if (count) {
« no previous file with comments | « gm/addarc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698