diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-18 13:30:18 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-18 13:30:18 +0000 |
commit | 872017694b29fd08256ac99e3221bcd0b8a3f32b (patch) | |
tree | b74f302933770dde45cd90773849d3688d0794fb | |
parent | a0591698fdc13f9923a5a71a108f06ed12f31c9d (diff) |
Make debugger print more information for paths
https://codereview.appspot.com/6727052/
git-svn-id: http://skia.googlecode.com/svn/trunk@5993 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | debugger/SkObjectParser.cpp | 48 |
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; } |