aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-26 18:16:27 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-26 18:16:27 +0000
commita8a3b3d9a027ad54ce20f8b4ed7c577a176b31ca (patch)
tree180cbc1350a82b98e612c0be12775efb304c63bc /src
parent5f0add3ad6e1d6129307276c81ba6624f92ca112 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPath.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index c3aa44e117..80ca3011e3 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -872,12 +872,17 @@ void SkPath::close() {
///////////////////////////////////////////////////////////////////////////////
+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::addPoly(const SkPoint pts[], int count, bool close) {
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 @@ static void add_corner_arc(SkPath* path, const SkRect& rect,
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 @@ bool SkPath::hasOnlyMoveTos() const {
}
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.