aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-18 13:30:18 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-18 13:30:18 +0000
commit872017694b29fd08256ac99e3221bcd0b8a3f32b (patch)
treeb74f302933770dde45cd90773849d3688d0794fb
parenta0591698fdc13f9923a5a71a108f06ed12f31c9d (diff)
Make debugger print more information for paths
-rw-r--r--debugger/SkObjectParser.cpp48
1 files changed, 41 insertions, 7 deletions
diff --git a/debugger/SkObjectParser.cpp b/debugger/SkObjectParser.cpp
index bf6a053d71..0cac6c9d67 100644
--- a/debugger/SkObjectParser.cpp
+++ b/debugger/SkObjectParser.cpp
@@ -69,14 +69,48 @@ SkString* SkObjectParser::PaintToString(const SkPaint& paint) {
}
SkString* SkObjectParser::PathToString(const SkPath& path) {
- SkString* mPath = new SkString("SkPath: ");
- for (int i = 0; i < path.countPoints(); i++) {
- mPath->append("(");
- mPath->appendScalar(path.getPoint(i).fX);
- mPath->append(", ");
- mPath->appendScalar(path.getPoint(i).fY);
- mPath->append(") ");
+ SkString* mPath = new SkString("Path (");
+
+ static const char* gConvexityStrings[] = {
+ "Unknown", "Convex", "Concave"
+ };
+ SkASSERT(SkPath::kConcave_Convexity == 2);
+
+ mPath->append(gConvexityStrings[path.getConvexity()]);
+ mPath->append(", ");
+
+ mPath->appendS32(path.countVerbs());
+ mPath->append("V, ");
+ mPath->appendS32(path.countPoints());
+ mPath->append("P): ");
+
+ static const char* gVerbStrings[] = {
+ "Move", "Line", "Quad", "Cubic", "Close", "Done"
+ };
+ static const int gPtsPerVerb[] = { 1, 1, 2, 3, 0, 0 };
+ static const int gPtOffsetPerVerb[] = { 0, 1, 1, 1, 0, 0 };
+ SkASSERT(SkPath::kDone_Verb == 5);
+
+ SkPath::Iter iter(const_cast<SkPath&>(path), false);
+ SkPath::Verb verb;
+ SkPoint points[4];
+
+ for(verb = iter.next(points, false);
+ verb != SkPath::kDone_Verb;
+ verb = iter.next(points, false)) {
+
+ mPath->append(gVerbStrings[verb]);
+ mPath->append(" ");
+
+ for (int i = 0; i < gPtsPerVerb[verb]; ++i) {
+ mPath->append("(");
+ mPath->appendScalar(points[gPtOffsetPerVerb[verb]+i].fX);
+ mPath->append(", ");
+ mPath->appendScalar(points[gPtOffsetPerVerb[verb]+i].fY);
+ mPath->append(") ");
+ }
}
+
return mPath;
}