Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: src/core/SkStroke.cpp

Issue 1160163002: use inline version of eval quad if tangent is not needed (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more toy stroke changes Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698