Add dump() to SkClipStack to help with debugging.
R=robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/311263015
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp
index d087592..a965b1b 100644
--- a/src/core/SkClipStack.cpp
+++ b/src/core/SkClipStack.cpp
@@ -845,3 +845,63 @@
return back->getGenID();
}
+
+#ifdef SK_DEVELOPER
+void SkClipStack::Element::dump() const {
+ static const char* kTypeStrings[] = {
+ "empty",
+ "rect",
+ "rrect",
+ "path"
+ };
+ SK_COMPILE_ASSERT(0 == kEmpty_Type, type_str);
+ SK_COMPILE_ASSERT(1 == kRect_Type, type_str);
+ SK_COMPILE_ASSERT(2 == kRRect_Type, type_str);
+ SK_COMPILE_ASSERT(3 == kPath_Type, type_str);
+ SK_COMPILE_ASSERT(SK_ARRAY_COUNT(kTypeStrings) == kTypeCnt, type_str);
+
+ static const char* kOpStrings[] = {
+ "difference",
+ "intersect",
+ "union",
+ "xor",
+ "reverse-difference",
+ "replace",
+ };
+ SK_COMPILE_ASSERT(0 == SkRegion::kDifference_Op, op_str);
+ SK_COMPILE_ASSERT(1 == SkRegion::kIntersect_Op, op_str);
+ SK_COMPILE_ASSERT(2 == SkRegion::kUnion_Op, op_str);
+ SK_COMPILE_ASSERT(3 == SkRegion::kXOR_Op, op_str);
+ SK_COMPILE_ASSERT(4 == SkRegion::kReverseDifference_Op, op_str);
+ SK_COMPILE_ASSERT(5 == SkRegion::kReplace_Op, op_str);
+ SK_COMPILE_ASSERT(SK_ARRAY_COUNT(kOpStrings) == SkRegion::kOpCnt, op_str);
+
+ SkDebugf("Type: %s, Op: %s, AA: %s, Save Count: %d\n", kTypeStrings[fType],
+ kOpStrings[fOp], (fDoAA ? "yes" : "no"), fSaveCount);
+ switch (fType) {
+ case kEmpty_Type:
+ SkDebugf("\n");
+ break;
+ case kRect_Type:
+ this->getRect().dump();
+ SkDebugf("\n");
+ break;
+ case kRRect_Type:
+ this->getRRect().dump();
+ SkDebugf("\n");
+ break;
+ case kPath_Type:
+ this->getPath().dump(true);
+ break;
+ }
+}
+
+void SkClipStack::dump() const {
+ B2TIter iter(*this);
+ const Element* e;
+ while ((e = iter.next())) {
+ e->dump();
+ SkDebugf("\n");
+ }
+}
+#endif