aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-01-10 18:00:10 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-01-10 18:00:10 +0000
commit69a9943b67cc52c24beac853c6f8865dcb197b85 (patch)
treea3e62e9bc4f71404ce044f09b484cc5fa5d9bc16 /include/core
parent63d73749fbe36491403ea521005fd298dc70a94c (diff)
add SkPath::cheapComputeDirection() plus unittests
git-svn-id: http://skia.googlecode.com/svn/trunk@2996 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkPath.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 471dbc516d..859486cb4e 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -453,6 +453,24 @@ public:
kCCW_Direction
};
+ /**
+ * Tries to quickly compute the direction of the first non-degenerate
+ * contour. If it can be computed, return true and set dir to that
+ * direction. If it cannot be (quickly) determined, return false and ignore
+ * the dir parameter.
+ */
+ bool cheapComputeDirection(Direction* dir) const;
+
+ /**
+ * Returns true if the path's direction can be computed via
+ * cheapComputDirection() and if that computed direction matches the
+ * specified direction.
+ */
+ bool cheapIsDirection(Direction dir) const {
+ Direction computedDir;
+ return this->cheapComputeDirection(&computedDir) && computedDir == dir;
+ }
+
/** Add a closed rectangle contour to the path
@param rect The rectangle to add as a closed contour to the path
@param dir The direction to wind the rectangle's contour