check for bad enum use when adding contours
Review URL: https://codereview.appspot.com/6849103
git-svn-id: http://skia.googlecode.com/svn/trunk@6547 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index c3aa44e..80ca301 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -872,12 +872,17 @@
///////////////////////////////////////////////////////////////////////////////
+static void assert_known_direction(int dir) {
+ SkASSERT(SkPath::kCW_Direction == dir || SkPath::kCCW_Direction == dir);
+}
+
void SkPath::addRect(const SkRect& rect, Direction dir) {
this->addRect(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, dir);
}
void SkPath::addRect(SkScalar left, SkScalar top, SkScalar right,
SkScalar bottom, Direction dir) {
+ assert_known_direction(dir);
fDirection = this->hasOnlyMoveTos() ? dir : kUnknown_Direction;
SkAutoDisableDirectionCheck addc(this);
@@ -938,6 +943,8 @@
void SkPath::addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
Direction dir) {
+ assert_known_direction(dir);
+
SkScalar w = rect.width();
SkScalar halfW = SkScalarHalf(w);
SkScalar h = rect.height();
@@ -1058,6 +1065,8 @@
void SkPath::addRoundRect(const SkRect& rect, const SkScalar rad[],
Direction dir) {
+ assert_known_direction(dir);
+
// abort before we invoke SkAutoPathBoundsUpdate()
if (rect.isEmpty()) {
return;
@@ -1094,6 +1103,8 @@
}
void SkPath::addOval(const SkRect& oval, Direction dir) {
+ assert_known_direction(dir);
+
/* If addOval() is called after previous moveTo(),
this path is still marked as an oval. This is used to
fit into WebKit's calling sequences.