aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-10 14:05:43 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-10 14:05:43 +0000
commit7e6c4d16010550ee148f1c79cf088c0320fed5c1 (patch)
treea0a6c6d85998718a1e825d75ee71d8a13ab20983 /src
parent963a8fa542134f3ddbd40165e1b3f9edf9f074dd (diff)
add SkPath::isLine(), similar to isRect()
git-svn-id: http://skia.googlecode.com/svn/trunk@3892 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPath.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index de34fe8e1e..362232b4e4 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -249,6 +249,24 @@ bool SkPath::isEmpty() const {
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.