aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPath.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2015-11-19 14:47:43 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-19 14:47:44 -0800
commitda707bf5635c70d4c3c284a0b05d92489b76788e (patch)
tree837638f90905b75992ef030664b62e49952dbdf3 /src/core/SkPath.cpp
parentedb36445dbedff473a06a00de0813dc2e6e6845c (diff)
add SkPath::isRRect
Add helper to track when a round rect was added to a path, and then return the SkRRect specification that describes it. Move the implementation for SkPath::RawIter to SkPathRef so it can be used there as well. R=reed@google.com,robertphillips@google.com Review URL: https://codereview.chromium.org/1461763004
Diffstat (limited to 'src/core/SkPath.cpp')
-rw-r--r--src/core/SkPath.cpp73
1 files changed, 4 insertions, 69 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index a3f5e13d7f..2d4976a82a 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1072,6 +1072,7 @@ void SkPath::addRRect(const SkRRect &rrect, Direction dir, unsigned startIndex)
return;
}
+ bool isRRect = hasOnlyMoveTos();
const SkRect& bounds = rrect.getBounds();
if (rrect.isRect()) {
@@ -1119,6 +1120,9 @@ void SkPath::addRRect(const SkRRect &rrect, Direction dir, unsigned startIndex)
}
this->close();
+ SkPathRef::Editor ed(&fPathRef);
+ ed.setIsRRect(isRRect);
+
SkASSERT(this->countVerbs() == initialVerbCount + kVerbs);
}
@@ -1861,75 +1865,6 @@ SkPath::Verb SkPath::Iter::doNext(SkPoint ptsParam[4]) {
///////////////////////////////////////////////////////////////////////////////
-SkPath::RawIter::RawIter() {
-#ifdef SK_DEBUG
- fPts = nullptr;
- fConicWeights = nullptr;
-#endif
- // need to init enough to make next() harmlessly return kDone_Verb
- fVerbs = nullptr;
- fVerbStop = nullptr;
-}
-
-SkPath::RawIter::RawIter(const SkPath& path) {
- this->setPath(path);
-}
-
-void SkPath::RawIter::setPath(const SkPath& path) {
- fPts = path.fPathRef->points();
- fVerbs = path.fPathRef->verbs();
- fVerbStop = path.fPathRef->verbsMemBegin();
- fConicWeights = path.fPathRef->conicWeights() - 1; // begin one behind
-}
-
-SkPath::Verb SkPath::RawIter::next(SkPoint pts[4]) {
- SkASSERT(pts);
- if (fVerbs == fVerbStop) {
- return kDone_Verb;
- }
-
- // fVerbs points one beyond next verb so decrement first.
- unsigned verb = *(--fVerbs);
- const SkPoint* srcPts = fPts;
-
- switch (verb) {
- case kMove_Verb:
- pts[0] = srcPts[0];
- srcPts += 1;
- break;
- case kLine_Verb:
- pts[0] = srcPts[-1];
- pts[1] = srcPts[0];
- srcPts += 1;
- break;
- case kConic_Verb:
- fConicWeights += 1;
- // fall-through
- case kQuad_Verb:
- pts[0] = srcPts[-1];
- pts[1] = srcPts[0];
- pts[2] = srcPts[1];
- srcPts += 2;
- break;
- case kCubic_Verb:
- pts[0] = srcPts[-1];
- pts[1] = srcPts[0];
- pts[2] = srcPts[1];
- pts[3] = srcPts[2];
- srcPts += 3;
- break;
- case kClose_Verb:
- break;
- case kDone_Verb:
- SkASSERT(fVerbs == fVerbStop);
- break;
- }
- fPts = srcPts;
- return (Verb)verb;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
/*
Format in compressed buffer: [ptCount, verbCount, pts[], verbs[]]
*/