aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPathPriv.h
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-06-15 11:41:37 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-17 14:34:02 +0000
commit1b0126b01511fe23d6e8f7b5be402d4d81921245 (patch)
tree41a10066697e6b383e122cf58b63971721aabbf1 /src/core/SkPathPriv.h
parentf86d3680b19f05b43a2404bbc87db14133047829 (diff)
Add a verbs iterator to SkPathPriv
Bug: skia: Change-Id: If846eeac2722b67a80266f01ede7ef03ef027ac8 Reviewed-on: https://skia-review.googlesource.com/20027 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/core/SkPathPriv.h')
-rw-r--r--src/core/SkPathPriv.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/SkPathPriv.h b/src/core/SkPathPriv.h
index 029cb759de..febc4e35e5 100644
--- a/src/core/SkPathPriv.h
+++ b/src/core/SkPathPriv.h
@@ -100,6 +100,30 @@ public:
SkScalar sweepAngle, bool useCenter, bool isFillNoPathEffect);
/**
+ * Returns a C++11-iterable object that traverses a path's verbs in order. e.g:
+ *
+ * for (SkPath::Verb verb : SkPathPriv::Verbs(path)) {
+ * ...
+ * }
+ */
+ struct Verbs {
+ public:
+ Verbs(const SkPath& path) : fPathRef(path.fPathRef.get()) {}
+ struct Iter {
+ void operator++() { --fVerb; } // verbs are laid out backwards in memory.
+ bool operator!=(const Iter& b) { return fVerb != b.fVerb; }
+ SkPath::Verb operator*() { return static_cast<SkPath::Verb>(*fVerb); }
+ const uint8_t* fVerb;
+ };
+ Iter begin() { return Iter{fPathRef->verbs() - 1}; }
+ Iter end() { return Iter{fPathRef->verbs() - fPathRef->countVerbs() - 1}; }
+ private:
+ Verbs(const Verbs&) = delete;
+ Verbs& operator=(const Verbs&) = delete;
+ SkPathRef* fPathRef;
+ };
+
+ /**
* Returns a pointer to the verb data. Note that the verbs are stored backwards in memory and
* thus the returned pointer is the last verb.
*/