diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-01-10 15:33:12 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-01-10 15:33:12 +0000 |
commit | 63d73749fbe36491403ea521005fd298dc70a94c (patch) | |
tree | 806a3a3af960c42494521cff2b8622458ec01dfa /src/core | |
parent | d6256557cd99070e92693ebc6847d456d0579494 (diff) |
add SkPath::reverseAddPath()
git-svn-id: http://skia.googlecode.com/svn/trunk@2995 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPath.cpp | 47 | ||||
-rw-r--r-- | src/core/SkStroke.cpp | 8 |
2 files changed, 55 insertions, 0 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 75a1e40034..76d0a58d18 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -1052,6 +1052,53 @@ void SkPath::reversePathTo(const SkPath& path) { } } +void SkPath::reverseAddPath(const SkPath& src) { + this->incReserve(src.fPts.count()); + + const SkPoint* startPts = src.fPts.begin(); + const SkPoint* pts = src.fPts.end(); + const uint8_t* startVerbs = src.fVerbs.begin(); + const uint8_t* verbs = src.fVerbs.end(); + + bool needMove = true; + bool needClose = false; + while (verbs > startVerbs) { + uint8_t v = *--verbs; + int n = gPtsInVerb[v]; + + if (needMove) { + --pts; + this->moveTo(pts->fX, pts->fY); + needMove = false; + } + pts -= n; + switch (v) { + case kMove_Verb: + if (needClose) { + this->close(); + needClose = false; + } + needMove = true; + pts += 1; // so we see the point in "if (needMove)" above + break; + case kLine_Verb: + this->lineTo(pts[0]); + break; + case kQuad_Verb: + this->quadTo(pts[1], pts[0]); + break; + case kCubic_Verb: + this->cubicTo(pts[2], pts[1], pts[0]); + break; + case kClose_Verb: + needClose = true; + break; + default: + SkASSERT(!"unexpected verb"); + } + } +} + /////////////////////////////////////////////////////////////////////////////// void SkPath::offset(SkScalar dx, SkScalar dy, SkPath* dst) const { diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp index 03301c1fd5..34278afd07 100644 --- a/src/core/SkStroke.cpp +++ b/src/core/SkStroke.cpp @@ -619,6 +619,14 @@ void SkStroke::strokePath(const SkPath& src, SkPath* dst) const { #endif if (fDoFill) { + const SkPath* srcPtr = &src; +#if 0 + SkPath tmp; + if (fast_is_ccw(src)) { + reverse(src, &tmp); + srcPtr = tmp; + } +#endif dst->addPath(src); } else { // Seems like we can assume that a 2-point src would always result in |