| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkStrokerPriv.h" | 8 #include "SkStrokerPriv.h" |
| 9 #include "SkGeometry.h" | 9 #include "SkGeometry.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| 11 | 11 |
| 12 static void ButtCapper(SkPath* path, const SkPoint& pivot, const SkVector& norma
l, | 12 static void ButtCapper(SkPath* path, const SkPoint& pivot, const SkVector& norma
l, |
| 13 const SkPoint& stop, SkPath*) { | 13 const SkPoint& stop, SkPath*) { |
| 14 path->lineTo(stop.fX, stop.fY); | 14 path->lineTo(stop.fX, stop.fY); |
| 15 } | 15 } |
| 16 | 16 |
| 17 static void RoundCapper(SkPath* path, const SkPoint& pivot, const SkVector& norm
al, | 17 static void RoundCapper(SkPath* path, const SkPoint& pivot, const SkVector& norm
al, |
| 18 const SkPoint& stop, SkPath*) { | 18 const SkPoint& stop, SkPath*) { |
| 19 SkVector parallel; | 19 SkVector parallel; |
| 20 normal.rotateCW(¶llel); | 20 normal.rotateCW(¶llel); |
| 21 | 21 |
| 22 SkPoint projectedCenter = pivot + parallel; | 22 SkPoint projectedCenter = pivot + parallel; |
| 23 | 23 |
| 24 path->conicTo(projectedCenter + normal, projectedCenter, SK_ScalarRoot2Over2
); | 24 path->conicTo(pivot + (parallel + normal) * 0.999, projectedCenter, SK_Scala
rRoot2Over2); |
| 25 path->conicTo(projectedCenter - normal, stop, SK_ScalarRoot2Over2); | 25 path->conicTo(pivot + (parallel - normal) * 0.999, stop, SK_ScalarRoot2Over2
); |
| 26 } | 26 } |
| 27 | 27 |
| 28 static void SquareCapper(SkPath* path, const SkPoint& pivot, const SkVector& nor
mal, | 28 static void SquareCapper(SkPath* path, const SkPoint& pivot, const SkVector& nor
mal, |
| 29 const SkPoint& stop, SkPath* otherPath) { | 29 const SkPoint& stop, SkPath* otherPath) { |
| 30 SkVector parallel; | 30 SkVector parallel; |
| 31 normal.rotateCW(¶llel); | 31 normal.rotateCW(¶llel); |
| 32 | 32 |
| 33 if (otherPath) { | 33 if (otherPath) { |
| 34 path->setLastPt(pivot.fX + normal.fX + parallel.fX, pivot.fY + normal.fY
+ parallel.fY); | 34 path->setLastPt(pivot.fX + normal.fX + parallel.fX, pivot.fY + normal.fY
+ parallel.fY); |
| 35 path->lineTo(pivot.fX - normal.fX + parallel.fX, pivot.fY - normal.fY +
parallel.fY); | 35 path->lineTo(pivot.fX - normal.fX + parallel.fX, pivot.fY - normal.fY +
parallel.fY); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 220 } |
| 221 | 221 |
| 222 SkStrokerPriv::JoinProc SkStrokerPriv::JoinFactory(SkPaint::Join join) { | 222 SkStrokerPriv::JoinProc SkStrokerPriv::JoinFactory(SkPaint::Join join) { |
| 223 const SkStrokerPriv::JoinProc gJoiners[] = { | 223 const SkStrokerPriv::JoinProc gJoiners[] = { |
| 224 MiterJoiner, RoundJoiner, BluntJoiner | 224 MiterJoiner, RoundJoiner, BluntJoiner |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 SkASSERT((unsigned)join < SkPaint::kJoinCount); | 227 SkASSERT((unsigned)join < SkPaint::kJoinCount); |
| 228 return gJoiners[join]; | 228 return gJoiners[join]; |
| 229 } | 229 } |
| OLD | NEW |