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 <cmath> | 8 #include <cmath> |
9 #include "SkBuffer.h" | 9 #include "SkBuffer.h" |
10 #include "SkCubicClipper.h" | 10 #include "SkCubicClipper.h" |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1283 if (arc_is_lone_point(oval, startAngle, sweepAngle, &lonePt)) { | 1283 if (arc_is_lone_point(oval, startAngle, sweepAngle, &lonePt)) { |
1284 forceMoveTo ? this->moveTo(lonePt) : this->lineTo(lonePt); | 1284 forceMoveTo ? this->moveTo(lonePt) : this->lineTo(lonePt); |
1285 return; | 1285 return; |
1286 } | 1286 } |
1287 | 1287 |
1288 SkVector startV, stopV; | 1288 SkVector startV, stopV; |
1289 SkRotationDirection dir; | 1289 SkRotationDirection dir; |
1290 angles_to_unit_vectors(startAngle, sweepAngle, &startV, &stopV, &dir); | 1290 angles_to_unit_vectors(startAngle, sweepAngle, &startV, &stopV, &dir); |
1291 | 1291 |
1292 SkPoint singlePt; | 1292 SkPoint singlePt; |
1293 | |
1294 // At this point, we know that the arc is not a lone point, but startV == st opV | |
1295 // indicates that the sweepAngle is too small such that angles_to_unit_vecto rs | |
1296 // cannot handle it. | |
1297 if (startV == stopV) { | |
1298 SkScalar endAngle = SkDegreesToRadians(startAngle + sweepAngle); | |
1299 SkScalar radiusX = oval.width() / 2; | |
1300 SkScalar radiusY = oval.height() / 2; | |
1301 singlePt.set(oval.centerX() + radiusX * cosf(endAngle), | |
1302 oval.centerY() + radiusY * sinf(endAngle)); | |
caryclark
2016/10/05 14:08:11
SkScalarSinCos() is preferable
xidachen
2016/10/05 14:24:32
While I do agree that SkScalarSinCos() is preferab
caryclark
2016/10/05 14:47:03
A comment in the code to this effect would be help
xidachen
2016/10/05 16:33:51
comment added.
sk_float_sin and sk_float_cos work
| |
1303 forceMoveTo ? this->moveTo(singlePt) : this->lineTo(singlePt); | |
caryclark
2016/10/05 14:08:11
Does your example GM trigger both sides of this ex
xidachen
2016/10/05 14:24:32
No, it only triggers lineTo. This line is basicall
caryclark
2016/10/05 14:47:03
It would be great if was possible to verify that t
xidachen
2016/10/05 16:33:51
I believe SkPath::addArc calls arcTo with forceMov
| |
1304 return; | |
1305 } | |
1306 | |
1293 SkConic conics[SkConic::kMaxConicsForArc]; | 1307 SkConic conics[SkConic::kMaxConicsForArc]; |
1294 int count = build_arc_conics(oval, startV, stopV, dir, conics, &singlePt); | 1308 int count = build_arc_conics(oval, startV, stopV, dir, conics, &singlePt); |
1295 if (count) { | 1309 if (count) { |
1296 this->incReserve(count * 2 + 1); | 1310 this->incReserve(count * 2 + 1); |
1297 const SkPoint& pt = conics[0].fPts[0]; | 1311 const SkPoint& pt = conics[0].fPts[0]; |
1298 forceMoveTo ? this->moveTo(pt) : this->lineTo(pt); | 1312 forceMoveTo ? this->moveTo(pt) : this->lineTo(pt); |
1299 for (int i = 0; i < count; ++i) { | 1313 for (int i = 0; i < count; ++i) { |
1300 this->conicTo(conics[i].fPts[1], conics[i].fPts[2], conics[i].fW); | 1314 this->conicTo(conics[i].fPts[1], conics[i].fPts[2], conics[i].fW); |
1301 } | 1315 } |
1302 } else { | 1316 } else { |
(...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3373 path->arcTo(oval, startAngle, 180.f, false); | 3387 path->arcTo(oval, startAngle, 180.f, false); |
3374 startAngle += 180.f; | 3388 startAngle += 180.f; |
3375 forceMoveTo = false; | 3389 forceMoveTo = false; |
3376 sweepAngle -= 360.f; | 3390 sweepAngle -= 360.f; |
3377 } | 3391 } |
3378 path->arcTo(oval, startAngle, sweepAngle, forceMoveTo); | 3392 path->arcTo(oval, startAngle, sweepAngle, forceMoveTo); |
3379 if (useCenter) { | 3393 if (useCenter) { |
3380 path->close(); | 3394 path->close(); |
3381 } | 3395 } |
3382 } | 3396 } |
OLD | NEW |