add SkPath::isLine(), similar to isRect()
git-svn-id: http://skia.googlecode.com/svn/trunk@3892 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index de34fe8..362232b 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -249,6 +249,24 @@
return 0 == fVerbs.count();
}
+bool SkPath::isLine(SkPoint line[2]) const {
+ int verbCount = fVerbs.count();
+ int ptCount = fPts.count();
+
+ if (2 == verbCount && 2 == ptCount) {
+ const uint8_t* verbs = fVerbs.begin();
+ if (kMove_Verb == verbs[0] && kLine_Verb == verbs[1]) {
+ if (line) {
+ const SkPoint* pts = fPts.begin();
+ line[0] = pts[0];
+ line[1] = pts[1];
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
/*
Determines if path is a rect by keeping track of changes in direction
and looking for a loop either clockwise or counterclockwise.