| 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 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 static int build_arc_points(const SkRect& oval, const SkVector& start, const SkV
ector& stop, | 950 static int build_arc_points(const SkRect& oval, const SkVector& start, const SkV
ector& stop, |
| 951 SkRotationDirection dir, SkPoint pts[kSkBuildQuadArc
Storage]) { | 951 SkRotationDirection dir, SkPoint pts[kSkBuildQuadArc
Storage]) { |
| 952 SkMatrix matrix; | 952 SkMatrix matrix; |
| 953 | 953 |
| 954 matrix.setScale(SkScalarHalf(oval.width()), SkScalarHalf(oval.height())); | 954 matrix.setScale(SkScalarHalf(oval.width()), SkScalarHalf(oval.height())); |
| 955 matrix.postTranslate(oval.centerX(), oval.centerY()); | 955 matrix.postTranslate(oval.centerX(), oval.centerY()); |
| 956 | 956 |
| 957 return SkBuildQuadArc(start, stop, dir, &matrix, pts); | 957 return SkBuildQuadArc(start, stop, dir, &matrix, pts); |
| 958 } | 958 } |
| 959 #else | 959 #else |
| 960 /** |
| 961 * If this returns 0, then the caller should just line-to the singlePt, else it
should |
| 962 * ignore singlePt and append the specified number of conics. |
| 963 */ |
| 960 static int build_arc_conics(const SkRect& oval, const SkVector& start, const SkV
ector& stop, | 964 static int build_arc_conics(const SkRect& oval, const SkVector& start, const SkV
ector& stop, |
| 961 SkRotationDirection dir, SkConic conics[SkConic::kMa
xConicsForArc]) { | 965 SkRotationDirection dir, SkConic conics[SkConic::kMa
xConicsForArc], |
| 966 SkPoint* singlePt) { |
| 962 SkMatrix matrix; | 967 SkMatrix matrix; |
| 963 | 968 |
| 964 matrix.setScale(SkScalarHalf(oval.width()), SkScalarHalf(oval.height())); | 969 matrix.setScale(SkScalarHalf(oval.width()), SkScalarHalf(oval.height())); |
| 965 matrix.postTranslate(oval.centerX(), oval.centerY()); | 970 matrix.postTranslate(oval.centerX(), oval.centerY()); |
| 966 | 971 |
| 967 return SkConic::BuildUnitArc(start, stop, dir, &matrix, conics); | 972 int count = SkConic::BuildUnitArc(start, stop, dir, &matrix, conics); |
| 973 if (0 == count) { |
| 974 matrix.mapXY(start.x(), start.y(), singlePt); |
| 975 } |
| 976 return count; |
| 968 } | 977 } |
| 969 #endif | 978 #endif |
| 970 | 979 |
| 971 void SkPath::addRoundRect(const SkRect& rect, const SkScalar radii[], | 980 void SkPath::addRoundRect(const SkRect& rect, const SkScalar radii[], |
| 972 Direction dir) { | 981 Direction dir) { |
| 973 SkRRect rrect; | 982 SkRRect rrect; |
| 974 rrect.setRectRadii(rect, (const SkVector*) radii); | 983 rrect.setRectRadii(rect, (const SkVector*) radii); |
| 975 this->addRRect(rrect, dir); | 984 this->addRRect(rrect, dir); |
| 976 } | 985 } |
| 977 | 986 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 SkPoint pts[kSkBuildQuadArcStorage]; | 1349 SkPoint pts[kSkBuildQuadArcStorage]; |
| 1341 int count = build_arc_points(oval, startV, stopV, dir, pts); | 1350 int count = build_arc_points(oval, startV, stopV, dir, pts); |
| 1342 SkASSERT((count & 1) == 1); | 1351 SkASSERT((count & 1) == 1); |
| 1343 | 1352 |
| 1344 this->incReserve(count); | 1353 this->incReserve(count); |
| 1345 forceMoveTo ? this->moveTo(pts[0]) : this->lineTo(pts[0]); | 1354 forceMoveTo ? this->moveTo(pts[0]) : this->lineTo(pts[0]); |
| 1346 for (int i = 1; i < count; i += 2) { | 1355 for (int i = 1; i < count; i += 2) { |
| 1347 this->quadTo(pts[i], pts[i+1]); | 1356 this->quadTo(pts[i], pts[i+1]); |
| 1348 } | 1357 } |
| 1349 #else | 1358 #else |
| 1359 SkPoint singlePt; |
| 1350 SkConic conics[SkConic::kMaxConicsForArc]; | 1360 SkConic conics[SkConic::kMaxConicsForArc]; |
| 1351 int count = build_arc_conics(oval, startV, stopV, dir, conics); | 1361 int count = build_arc_conics(oval, startV, stopV, dir, conics, &singlePt); |
| 1352 if (count) { | 1362 if (count) { |
| 1353 this->incReserve(count * 2 + 1); | 1363 this->incReserve(count * 2 + 1); |
| 1354 const SkPoint& pt = conics[0].fPts[0]; | 1364 const SkPoint& pt = conics[0].fPts[0]; |
| 1355 forceMoveTo ? this->moveTo(pt) : this->lineTo(pt); | 1365 forceMoveTo ? this->moveTo(pt) : this->lineTo(pt); |
| 1356 for (int i = 0; i < count; ++i) { | 1366 for (int i = 0; i < count; ++i) { |
| 1357 this->conicTo(conics[i].fPts[1], conics[i].fPts[2], conics[i].fW); | 1367 this->conicTo(conics[i].fPts[1], conics[i].fPts[2], conics[i].fW); |
| 1358 } | 1368 } |
| 1369 } else { |
| 1370 forceMoveTo ? this->moveTo(singlePt) : this->lineTo(singlePt); |
| 1359 } | 1371 } |
| 1360 #endif | 1372 #endif |
| 1361 } | 1373 } |
| 1362 | 1374 |
| 1363 void SkPath::addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle
) { | 1375 void SkPath::addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle
) { |
| 1364 if (oval.isEmpty() || 0 == sweepAngle) { | 1376 if (oval.isEmpty() || 0 == sweepAngle) { |
| 1365 return; | 1377 return; |
| 1366 } | 1378 } |
| 1367 | 1379 |
| 1368 const SkScalar kFullCircleAngle = SkIntToScalar(360); | 1380 const SkScalar kFullCircleAngle = SkIntToScalar(360); |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2945 switch (this->getFillType()) { | 2957 switch (this->getFillType()) { |
| 2946 case SkPath::kEvenOdd_FillType: | 2958 case SkPath::kEvenOdd_FillType: |
| 2947 case SkPath::kInverseEvenOdd_FillType: | 2959 case SkPath::kInverseEvenOdd_FillType: |
| 2948 w &= 1; | 2960 w &= 1; |
| 2949 break; | 2961 break; |
| 2950 default: | 2962 default: |
| 2951 break; | 2963 break; |
| 2952 } | 2964 } |
| 2953 return SkToBool(w); | 2965 return SkToBool(w); |
| 2954 } | 2966 } |
| OLD | NEW |