OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkBuffer.h" | 10 #include "SkBuffer.h" |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 DIRTY_AFTER_EDIT; | 1280 DIRTY_AFTER_EDIT; |
1281 SkDEBUGCODE(this->validate();) | 1281 SkDEBUGCODE(this->validate();) |
1282 } | 1282 } |
1283 | 1283 |
1284 /* | 1284 /* |
1285 Need to handle the case when the angle is sharp, and our computed end-points | 1285 Need to handle the case when the angle is sharp, and our computed end-points |
1286 for the arc go behind pt1 and/or p2... | 1286 for the arc go behind pt1 and/or p2... |
1287 */ | 1287 */ |
1288 void SkPath::arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, | 1288 void SkPath::arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, |
1289 SkScalar radius) { | 1289 SkScalar radius) { |
1290 SkVector before, after; | 1290 if (radius == 0) { |
| 1291 this->lineTo(x1, y1); |
| 1292 return; |
| 1293 } |
| 1294 |
| 1295 SkVector before, after; |
1291 | 1296 |
1292 // need to know our prev pt so we can construct tangent vectors | 1297 // need to know our prev pt so we can construct tangent vectors |
1293 { | 1298 { |
1294 SkPoint start; | 1299 SkPoint start; |
1295 this->getLastPt(&start); | 1300 this->getLastPt(&start); |
1296 // Handle degenerate cases by adding a line to the first point and | 1301 // Handle degenerate cases by adding a line to the first point and |
1297 // bailing out. | 1302 // bailing out. |
1298 if ((x1 == start.fX && y1 == start.fY) || | |
1299 (x1 == x2 && y1 == y2) || | |
1300 radius == 0) { | |
1301 this->lineTo(x1, y1); | |
1302 return; | |
1303 } | |
1304 before.setNormalize(x1 - start.fX, y1 - start.fY); | 1303 before.setNormalize(x1 - start.fX, y1 - start.fY); |
1305 after.setNormalize(x2 - x1, y2 - y1); | 1304 after.setNormalize(x2 - x1, y2 - y1); |
1306 } | 1305 } |
1307 | 1306 |
1308 SkScalar cosh = SkPoint::DotProduct(before, after); | 1307 SkScalar cosh = SkPoint::DotProduct(before, after); |
1309 SkScalar sinh = SkPoint::CrossProduct(before, after); | 1308 SkScalar sinh = SkPoint::CrossProduct(before, after); |
1310 | 1309 |
1311 if (SkScalarNearlyZero(sinh)) { // angle is too tight | 1310 if (SkScalarNearlyZero(sinh)) { // angle is too tight |
1312 this->lineTo(x1, y1); | 1311 this->lineTo(x1, y1); |
1313 return; | 1312 return; |
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2879 switch (this->getFillType()) { | 2878 switch (this->getFillType()) { |
2880 case SkPath::kEvenOdd_FillType: | 2879 case SkPath::kEvenOdd_FillType: |
2881 case SkPath::kInverseEvenOdd_FillType: | 2880 case SkPath::kInverseEvenOdd_FillType: |
2882 w &= 1; | 2881 w &= 1; |
2883 break; | 2882 break; |
2884 default: | 2883 default: |
2885 break; | 2884 break; |
2886 } | 2885 } |
2887 return SkToBool(w); | 2886 return SkToBool(w); |
2888 } | 2887 } |
OLD | NEW |