aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-02-09 16:38:45 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-02-09 16:38:45 +0000
commitd3aa4ff7a564953dff9a15ff03fd42eebf64569f (patch)
tree3f226317ba64864f43527a0c01c60b46052def04
parent218521e15706c4377b1be49d931c4d7c8d597445 (diff)
add countPoints() and getPoint()
git-svn-id: http://skia.googlecode.com/svn/trunk@494 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/core/SkPath.h12
-rw-r--r--src/core/SkPath.cpp7
2 files changed, 19 insertions, 0 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index ecdfd1ab41..3afea09433 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -123,6 +123,18 @@ public:
*/
bool isRect(SkRect* rect) const;
+ /** Return the number of points in the path
+ */
+ int countPoints() const {
+ return this->getPoints(NULL, 0);
+ }
+
+ /** Return the point at the specified index. If the index is out of range
+ (i.e. is not 0 <= index < countPoints()) then the returned coordinates
+ will be (0,0)
+ */
+ SkPoint getPoint(int index) const;
+
/** Returns the number of points in the path. Up to max points are copied.
@param points If not null, receives up to max points
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 1c771072a2..2308ec67ad 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -184,6 +184,13 @@ int SkPath::getPoints(SkPoint copy[], int max) const {
return count;
}
+SkPoint SkPath::getPoint(int index) const {
+ if ((unsigned)index < (unsigned)fPts.count()) {
+ return fPts[index];
+ }
+ return SkPoint::Make(0, 0);
+}
+
void SkPath::getLastPt(SkPoint* lastPt) const {
SkDEBUGCODE(this->validate();)