aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-07 21:43:15 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-07 21:43:15 +0000
commitdf9d656c352928f995abce0a62c4ec3255232a45 (patch)
tree3cd391af1780d9b161b407178ef591b7d52d3de3 /include/core
parent88f7d0cb09707355bc9079d4b0569537e8048fa9 (diff)
Add SkPath::getVerbs/countVerbs
Review URL: http://codereview.appspot.com/6306053/ git-svn-id: http://skia.googlecode.com/svn/trunk@4209 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkPath.h15
-rw-r--r--include/core/SkTDArray.h19
2 files changed, 34 insertions, 0 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 4e987c0a20..e6989f2838 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -259,6 +259,21 @@ public:
*/
int getPoints(SkPoint points[], int max) const;
+ /** Return the number of verbs in the path
+ */
+ int countVerbs() const {
+ return this->getVerbs(NULL, 0);
+ }
+
+ /** Returns the number of verbs in the path. Up to max verbs are copied. The
+ verbs are copied as one byte per verb.
+
+ @param verbs If not null, receives up to max verbs
+ @param max The maximum number of verbs to copy into verbs
+ @return the actual number of verbs in the path
+ */
+ int getVerbs(uint8_t verbs[], int max) const;
+
//! Swap contents of this and other. Guaranteed not to throw
void swap(SkPath& other);
diff --git a/include/core/SkTDArray.h b/include/core/SkTDArray.h
index f0f94494f3..426bb6d303 100644
--- a/include/core/SkTDArray.h
+++ b/include/core/SkTDArray.h
@@ -228,6 +228,25 @@ public:
return -1;
}
+ /**
+ * Copies up to max elements into dst. The number of items copied is
+ * capped by count - index. The actual number copied is returned.
+ */
+ int copyRange(T* dst, size_t index, int max) const {
+ SkASSERT(max >= 0);
+ SkASSERT(!max || dst);
+ if (index >= fCount) {
+ return 0;
+ }
+ int count = SkMin32(max, fCount - index);
+ memcpy(dst, fArray + index, sizeof(T) * count);
+ return count;
+ }
+
+ void copy(T* dst) const {
+ this->copyRange(0, fCount, dst);
+ }
+
// routines to treat the array like a stack
T* push() { return this->append(); }
void push(const T& elem) { *this->append() = elem; }