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

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

Issue 2478763003: Revert of use reversePathTo in place of addPathReverse (Closed)
Patch Set: Created 4 years, 1 month 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 | « include/pathops/SkPathOps.h ('k') | src/pathops/SkOpBuilder.cpp » ('j') | 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 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 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 0, // kClose 1560 0, // kClose
1561 0 // kDone 1561 0 // kDone
1562 }; 1562 };
1563 1563
1564 SkASSERT(verb < SK_ARRAY_COUNT(gPtsInVerb)); 1564 SkASSERT(verb < SK_ARRAY_COUNT(gPtsInVerb));
1565 return gPtsInVerb[verb]; 1565 return gPtsInVerb[verb];
1566 } 1566 }
1567 1567
1568 // ignore the last point of the 1st contour 1568 // ignore the last point of the 1st contour
1569 void SkPath::reversePathTo(const SkPath& path) { 1569 void SkPath::reversePathTo(const SkPath& path) {
1570 const uint8_t* verbs = path.fPathRef->verbsMemBegin(); // points at the last verb 1570 int i, vcount = path.fPathRef->countVerbs();
1571 if (!verbs) { // empty path returns nullptr 1571 // exit early if the path is empty, or just has a moveTo.
1572 if (vcount < 2) {
1572 return; 1573 return;
1573 } 1574 }
1574 const uint8_t* verbsEnd = path.fPathRef->verbs() - 1; // points just past th e first verb
1575 SkASSERT(verbsEnd[0] == kMove_Verb);
1576 const SkPoint* pts = path.fPathRef->pointsEnd() - 1;
1577 const SkScalar* conicWeights = path.fPathRef->conicWeightsEnd();
1578 1575
1579 while (verbs < verbsEnd) { 1576 SkPathRef::Editor(&fPathRef, vcount, path.countPoints());
1580 uint8_t v = *verbs++; 1577
1581 pts -= pts_in_verb(v); 1578 const uint8_t* verbs = path.fPathRef->verbs();
1582 switch (v) { 1579 const SkPoint* pts = path.fPathRef->points();
1580 const SkScalar* conicWeights = path.fPathRef->conicWeights();
1581
1582 SkASSERT(verbs[~0] == kMove_Verb);
1583 for (i = 1; i < vcount; ++i) {
1584 unsigned v = verbs[~i];
1585 int n = pts_in_verb(v);
1586 if (n == 0) {
1587 break;
1588 }
1589 pts += n;
1590 conicWeights += (SkPath::kConic_Verb == v);
1591 }
1592
1593 while (--i > 0) {
1594 switch (verbs[~i]) {
1583 case kLine_Verb: 1595 case kLine_Verb:
1584 this->lineTo(pts[0]); 1596 this->lineTo(pts[-1].fX, pts[-1].fY);
1585 break; 1597 break;
1586 case kQuad_Verb: 1598 case kQuad_Verb:
1587 this->quadTo(pts[1], pts[0]); 1599 this->quadTo(pts[-1].fX, pts[-1].fY, pts[-2].fX, pts[-2].fY);
1588 break; 1600 break;
1589 case kConic_Verb: 1601 case kConic_Verb:
1590 this->conicTo(pts[1], pts[0], *--conicWeights); 1602 this->conicTo(pts[-1], pts[-2], *--conicWeights);
1591 break; 1603 break;
1592 case kCubic_Verb: 1604 case kCubic_Verb:
1593 this->cubicTo(pts[2], pts[1], pts[0]); 1605 this->cubicTo(pts[-1].fX, pts[-1].fY, pts[-2].fX, pts[-2].fY,
1594 break; 1606 pts[-3].fX, pts[-3].fY);
1595 case kClose_Verb:
1596 SkASSERT(verbs - path.fPathRef->verbsMemBegin() == 1);
1597 break; 1607 break;
1598 default: 1608 default:
1599 SkDEBUGFAIL("bad verb"); 1609 SkDEBUGFAIL("bad verb");
1600 break; 1610 break;
1601 } 1611 }
1612 pts -= pts_in_verb(verbs[~i]);
1602 } 1613 }
1603 } 1614 }
1604 1615
1605 void SkPath::reverseAddPath(const SkPath& src) { 1616 void SkPath::reverseAddPath(const SkPath& src) {
1606 SkPathRef::Editor ed(&fPathRef, src.fPathRef->countPoints(), src.fPathRef->c ountVerbs()); 1617 SkPathRef::Editor ed(&fPathRef, src.fPathRef->countPoints(), src.fPathRef->c ountVerbs());
1607 1618
1608 const SkPoint* pts = src.fPathRef->pointsEnd(); 1619 const SkPoint* pts = src.fPathRef->pointsEnd();
1609 // we will iterator through src's verbs backwards 1620 // we will iterator through src's verbs backwards
1610 const uint8_t* verbs = src.fPathRef->verbsMemBegin(); // points at the last verb 1621 const uint8_t* verbs = src.fPathRef->verbsMemBegin(); // points at the last verb
1611 const uint8_t* verbsEnd = src.fPathRef->verbs(); // points just past the fir st verb 1622 const uint8_t* verbsEnd = src.fPathRef->verbs(); // points just past the fir st verb
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
3380 path->arcTo(oval, startAngle, 180.f, false); 3391 path->arcTo(oval, startAngle, 180.f, false);
3381 startAngle += 180.f; 3392 startAngle += 180.f;
3382 forceMoveTo = false; 3393 forceMoveTo = false;
3383 sweepAngle -= 360.f; 3394 sweepAngle -= 360.f;
3384 } 3395 }
3385 path->arcTo(oval, startAngle, sweepAngle, forceMoveTo); 3396 path->arcTo(oval, startAngle, sweepAngle, forceMoveTo);
3386 if (useCenter) { 3397 if (useCenter) {
3387 path->close(); 3398 path->close();
3388 } 3399 }
3389 } 3400 }
OLDNEW
« no previous file with comments | « include/pathops/SkPathOps.h ('k') | src/pathops/SkOpBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698