OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 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" |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 (void) this->quadStroke(quad, &quadPts); | 669 (void) this->quadStroke(quad, &quadPts); |
670 this->setQuadEndNormal(quad, normalAB, unitAB, &normalBC, &unitBC); | 670 this->setQuadEndNormal(quad, normalAB, unitAB, &normalBC, &unitBC); |
671 | 671 |
672 this->postJoinTo(pt2, normalBC, unitBC); | 672 this->postJoinTo(pt2, normalBC, unitBC); |
673 } | 673 } |
674 | 674 |
675 // Given a point on the curve and its derivative, scale the derivative by the ra
dius, and | 675 // Given a point on the curve and its derivative, scale the derivative by the ra
dius, and |
676 // compute the perpendicular point and its tangent. | 676 // compute the perpendicular point and its tangent. |
677 void SkPathStroker::setRayPts(const SkPoint& tPt, SkVector* dxy, SkPoint* onPt, | 677 void SkPathStroker::setRayPts(const SkPoint& tPt, SkVector* dxy, SkPoint* onPt, |
678 SkPoint* tangent) const { | 678 SkPoint* tangent) const { |
| 679 #if 01 |
679 SkPoint oldDxy = *dxy; | 680 SkPoint oldDxy = *dxy; |
680 if (!dxy->setLength(fRadius)) { // consider moving double logic into SkPoin
t::setLength | 681 if (!dxy->setLength(fRadius)) { // consider moving double logic into SkPoin
t::setLength |
681 double xx = oldDxy.fX; | 682 double xx = oldDxy.fX; |
682 double yy = oldDxy.fY; | 683 double yy = oldDxy.fY; |
683 double dscale = fRadius / sqrt(xx * xx + yy * yy); | 684 double dscale = fRadius / sqrt(xx * xx + yy * yy); |
684 dxy->fX = SkDoubleToScalar(xx * dscale); | 685 dxy->fX = SkDoubleToScalar(xx * dscale); |
685 dxy->fY = SkDoubleToScalar(yy * dscale); | 686 dxy->fY = SkDoubleToScalar(yy * dscale); |
686 } | 687 } |
| 688 #else |
| 689 SkScalar scale = fRadius * sk_float_rsqrt(dxy->fX * dxy->fX + dxy->fY * dxy-
>fY); |
| 690 dxy->fX *= scale; |
| 691 dxy->fY *= scale; |
| 692 #endif |
687 SkScalar axisFlip = SkIntToScalar(fStrokeType); // go opposite ways for out
er, inner | 693 SkScalar axisFlip = SkIntToScalar(fStrokeType); // go opposite ways for out
er, inner |
688 onPt->fX = tPt.fX + axisFlip * dxy->fY; | 694 onPt->fX = tPt.fX + axisFlip * dxy->fY; |
689 onPt->fY = tPt.fY - axisFlip * dxy->fX; | 695 onPt->fY = tPt.fY - axisFlip * dxy->fX; |
690 if (tangent) { | 696 if (tangent) { |
691 tangent->fX = onPt->fX + dxy->fX; | 697 tangent->fX = onPt->fX + dxy->fX; |
692 tangent->fY = onPt->fY + dxy->fY; | 698 tangent->fY = onPt->fY + dxy->fY; |
693 } | 699 } |
694 } | 700 } |
695 | 701 |
696 // Given a conic and t, return the point on curve, its perpendicular, and the pe
rpendicular tangent. | 702 // Given a conic and t, return the point on curve, its perpendicular, and the pe
rpendicular tangent. |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 default: | 1456 default: |
1451 break; | 1457 break; |
1452 } | 1458 } |
1453 | 1459 |
1454 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) { | 1460 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) { |
1455 r = rect; | 1461 r = rect; |
1456 r.inset(radius, radius); | 1462 r.inset(radius, radius); |
1457 dst->addRect(r, reverse_direction(dir)); | 1463 dst->addRect(r, reverse_direction(dir)); |
1458 } | 1464 } |
1459 } | 1465 } |
OLD | NEW |