| 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 "SkBuffer.h" | 8 #include "SkBuffer.h" |
| 9 #include "SkErrorInternals.h" | 9 #include "SkErrorInternals.h" |
| 10 #include "SkGeometry.h" | 10 #include "SkGeometry.h" |
| (...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 | 1333 |
| 1334 void SkPath::addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle
) { | 1334 void SkPath::addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle
) { |
| 1335 if (oval.isEmpty() || 0 == sweepAngle) { | 1335 if (oval.isEmpty() || 0 == sweepAngle) { |
| 1336 return; | 1336 return; |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 const SkScalar kFullCircleAngle = SkIntToScalar(360); | 1339 const SkScalar kFullCircleAngle = SkIntToScalar(360); |
| 1340 | 1340 |
| 1341 if (sweepAngle >= kFullCircleAngle || sweepAngle <= -kFullCircleAngle) { | 1341 if (sweepAngle >= kFullCircleAngle || sweepAngle <= -kFullCircleAngle) { |
| 1342 this->addOval(oval, sweepAngle > 0 ? kCW_Direction : kCCW_Direction); | 1342 this->addOval(oval, sweepAngle > 0 ? kCW_Direction : kCCW_Direction); |
| 1343 return; | 1343 } else { |
| 1344 this->arcTo(oval, startAngle, sweepAngle, true); |
| 1344 } | 1345 } |
| 1345 | |
| 1346 SkPoint lonePt; | |
| 1347 if (arc_is_lone_point(oval, startAngle, sweepAngle, &lonePt)) { | |
| 1348 this->moveTo(lonePt); | |
| 1349 return; | |
| 1350 } | |
| 1351 | |
| 1352 SkPoint pts[kSkBuildQuadArcStorage]; | |
| 1353 int count = build_arc_points(oval, startAngle, sweepAngle, pts); | |
| 1354 | |
| 1355 SkDEBUGCODE(this->validate();) | |
| 1356 SkASSERT(count & 1); | |
| 1357 | |
| 1358 fLastMoveToIndex = fPathRef->countPoints(); | |
| 1359 | |
| 1360 SkPathRef::Editor ed(&fPathRef, 1+(count-1)/2, count); | |
| 1361 | |
| 1362 ed.growForVerb(kMove_Verb)->set(pts[0].fX, pts[0].fY); | |
| 1363 if (count > 1) { | |
| 1364 SkPoint* p = ed.growForRepeatedVerb(kQuad_Verb, (count-1)/2); | |
| 1365 memcpy(p, &pts[1], (count-1) * sizeof(SkPoint)); | |
| 1366 } | |
| 1367 | |
| 1368 DIRTY_AFTER_EDIT; | |
| 1369 SkDEBUGCODE(this->validate();) | |
| 1370 } | 1346 } |
| 1371 | 1347 |
| 1372 /* | 1348 /* |
| 1373 Need to handle the case when the angle is sharp, and our computed end-points | 1349 Need to handle the case when the angle is sharp, and our computed end-points |
| 1374 for the arc go behind pt1 and/or p2... | 1350 for the arc go behind pt1 and/or p2... |
| 1375 */ | 1351 */ |
| 1376 void SkPath::arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, | 1352 void SkPath::arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar
radius) { |
| 1377 SkScalar radius) { | |
| 1378 if (radius == 0) { | 1353 if (radius == 0) { |
| 1379 this->lineTo(x1, y1); | 1354 this->lineTo(x1, y1); |
| 1380 return; | 1355 return; |
| 1381 } | 1356 } |
| 1382 | 1357 |
| 1383 SkVector before, after; | 1358 SkVector before, after; |
| 1384 | 1359 |
| 1385 // need to know our prev pt so we can construct tangent vectors | 1360 // need to know our prev pt so we can construct tangent vectors |
| 1386 { | 1361 { |
| 1387 SkPoint start; | 1362 SkPoint start; |
| (...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2941 switch (this->getFillType()) { | 2916 switch (this->getFillType()) { |
| 2942 case SkPath::kEvenOdd_FillType: | 2917 case SkPath::kEvenOdd_FillType: |
| 2943 case SkPath::kInverseEvenOdd_FillType: | 2918 case SkPath::kInverseEvenOdd_FillType: |
| 2944 w &= 1; | 2919 w &= 1; |
| 2945 break; | 2920 break; |
| 2946 default: | 2921 default: |
| 2947 break; | 2922 break; |
| 2948 } | 2923 } |
| 2949 return SkToBool(w); | 2924 return SkToBool(w); |
| 2950 } | 2925 } |
| OLD | NEW |