Chromium Code Reviews| Index: src/core/SkStrokerPriv.cpp |
| diff --git a/src/core/SkStrokerPriv.cpp b/src/core/SkStrokerPriv.cpp |
| index ad9c0c4d6fd66991cc1df133c9bf2c7619dfdc3f..65d685e092e8eb8704dc78b18dfb5c455c7c2553 100644 |
| --- a/src/core/SkStrokerPriv.cpp |
| +++ b/src/core/SkStrokerPriv.cpp |
| @@ -22,6 +22,7 @@ static void RoundCapper(SkPath* path, const SkPoint& pivot, |
| const SkVector& normal, const SkPoint& stop, |
| SkPath*) |
| { |
| +#ifdef SK_SUPPORT_LEGACY_ARCTO_QUADS |
| SkScalar px = pivot.fX; |
| SkScalar py = pivot.fY; |
| SkScalar nx = normal.fX; |
| @@ -35,6 +36,15 @@ static void RoundCapper(SkPath* path, const SkPoint& pivot, |
| path->cubicTo(px + CWX(nx, ny) - sx, py + CWY(nx, ny) - sy, |
| px - nx + CWX(sx, sy), py - ny + CWY(sx, sy), |
| stop.fX, stop.fY); |
| +#else |
| + SkVector parallel; |
| + normal.rotateCW(¶llel); |
| + |
| + path->conicTo(pivot.fX + normal.fX + parallel.fX, pivot.fY + normal.fY + parallel.fY, |
| + pivot.fX + parallel.fX, pivot.fY + parallel.fY, SK_ScalarRoot2Over2); |
| + path->conicTo(pivot.fX - normal.fX + parallel.fX, pivot.fY - normal.fY + parallel.fY, |
| + stop.fX, stop.fY, SK_ScalarRoot2Over2); |
|
caryclark
2015/02/10 11:59:34
I wonder if the compiler can't fold
pivot.fX +
|
| +#endif |
| } |
| static void SquareCapper(SkPath* path, const SkPoint& pivot, |
| @@ -136,21 +146,31 @@ static void RoundJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit |
| dir = kCCW_SkRotationDirection; |
| } |
| - SkPoint pts[kSkBuildQuadArcStorage]; |
| SkMatrix matrix; |
| matrix.setScale(radius, radius); |
| matrix.postTranslate(pivot.fX, pivot.fY); |
| +#ifdef SK_SUPPORT_LEGACY_ARCTO_QUADS |
| + SkPoint pts[kSkBuildQuadArcStorage]; |
| int count = SkBuildQuadArc(before, after, dir, &matrix, pts); |
| SkASSERT((count & 1) == 1); |
| - |
| - if (count > 1) |
| - { |
| - for (int i = 1; i < count; i += 2) |
| + if (count > 1) { |
| + for (int i = 1; i < count; i += 2) { |
| outer->quadTo(pts[i].fX, pts[i].fY, pts[i+1].fX, pts[i+1].fY); |
| - |
| + } |
| + after.scale(radius); |
| + HandleInnerJoin(inner, pivot, after); |
| + } |
| +#else |
| + SkConic conics[SkConic::kMaxConicsForArc]; |
| + int count = SkConic::BuildUnitArc(before, after, dir, &matrix, conics); |
|
caryclark
2015/02/10 11:59:34
SkASSERT(count <= SkConic::kMaxConicsForArc); ? m
|
| + if (count > 0) { |
| + for (int i = 0; i < count; ++i) { |
| + outer->conicTo(conics[i].fPts[1], conics[i].fPts[2], conics[i].fW); |
| + } |
| after.scale(radius); |
| HandleInnerJoin(inner, pivot, after); |
| } |
| +#endif |
| } |
| #define kOneOverSqrt2 (0.707106781f) |