Chromium Code Reviews| Index: src/core/SkPath.cpp |
| diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp |
| index b6269027d2cc1ab744b5b002df1cff8cc335f6bc..8b9ff86911ebe25549175f8aeed84e12b80c0bba 100644 |
| --- a/src/core/SkPath.cpp |
| +++ b/src/core/SkPath.cpp |
| @@ -5,6 +5,7 @@ |
| * found in the LICENSE file. |
| */ |
| +#include <cmath> |
| #include "SkBuffer.h" |
| #include "SkCubicClipper.h" |
| #include "SkErrorInternals.h" |
| @@ -1421,10 +1422,24 @@ void SkPath::addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle |
| const SkScalar kFullCircleAngle = SkIntToScalar(360); |
|
robertphillips
2016/05/27 12:12:29
It is unfortunate we have to always do this since
bsalomon
2016/05/27 14:29:32
I agree that this is painful. The problem is that
|
| if (sweepAngle >= kFullCircleAngle || sweepAngle <= -kFullCircleAngle) { |
| - this->addOval(oval, sweepAngle > 0 ? kCW_Direction : kCCW_Direction); |
| - } else { |
| - this->arcTo(oval, startAngle, sweepAngle, true); |
| + // We can treat the arc as an oval if it begins at one of our legal starting positions. |
| + // See SkPath::addOval() docs. |
| + float n = startAngle / 90.f; |
|
robertphillips
2016/05/27 12:12:29
i -> intPortion, r -> remainder ?
bsalomon
2016/05/27 14:29:32
This code wasn't quite correct. The new version is
|
| + float i; |
| + float r = std::modf(n, &i); |
| + if (SkScalarNearlyEqual(r, 0.f)) { |
| + if (r < 0) { |
| + // If we were just under an integer multiple of 90, bump up. |
| + i += 1.f; |
| + } |
| + i += 1; // index 1 is at angle 0. |
|
robertphillips
2016/05/27 12:12:30
Maybe introduce a new variable (int startIndex) he
bsalomon
2016/05/27 14:29:33
Done.
|
| + r = std::fmod(i, 4.f); |
| + r = r < 0 ? r + 4.f : r; |
| + this->addOval(oval, sweepAngle > 0 ? kCW_Direction : kCCW_Direction, (unsigned) r); |
| + return; |
| + } |
| } |
| + this->arcTo(oval, startAngle, sweepAngle, true); |
| } |
| /* |