From 30d35f23ae390043462e2aa5fc6863a4621aa74d Mon Sep 17 00:00:00 2001 From: "robertphillips@google.com" Date: Tue, 6 Nov 2012 16:45:36 +0000 Subject: [PATCH] Enhanced debugger with command indenting and Path Bound print out https://codereview.appspot.com/6820099/ git-svn-id: http://skia.googlecode.com/svn/trunk@6309 2bbb7eff-a529-9590-31e7-b0007b416f81 --- debugger/QT/SkDebuggerGUI.cpp | 13 +++++++++++++ debugger/QT/SkListWidget.cpp | 10 ++++++---- debugger/SkDrawCommand.cpp | 8 ++++---- debugger/SkObjectParser.cpp | 18 ++++++++++++++++-- debugger/SkObjectParser.h | 2 +- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp index a03c878..df34891 100644 --- a/debugger/QT/SkDebuggerGUI.cpp +++ b/debugger/QT/SkDebuggerGUI.cpp @@ -607,10 +607,23 @@ void SkDebuggerGUI::loadPicture(QString fileName) { void SkDebuggerGUI::setupListWidget(SkTDArray* command) { fListWidget.clear(); int counter = 0; + int indent = 0; for (int i = 0; i < command->count(); i++) { QListWidgetItem *item = new QListWidgetItem(); item->setData(Qt::DisplayRole, (*command)[i]->c_str()); item->setData(Qt::UserRole + 1, counter++); + + if (0 == strcmp("Restore", (*command)[i]->c_str())) { + indent -= 10; + } + + item->setData(Qt::UserRole + 3, indent); + + if (0 == strcmp("Save", (*command)[i]->c_str()) || + 0 == strcmp("Save Layer", (*command)[i]->c_str())) { + indent += 10; + } + fListWidget.addItem(item); } } diff --git a/debugger/QT/SkListWidget.cpp b/debugger/QT/SkListWidget.cpp index 669f225..2d8d2da 100644 --- a/debugger/QT/SkListWidget.cpp +++ b/debugger/QT/SkListWidget.cpp @@ -61,6 +61,7 @@ void SkListWidget::paint (QPainter *painter, QIcon(qvariant_cast(index.data(Qt::DecorationRole))); QIcon deleteIcon = QIcon(qvariant_cast(index.data(Qt::UserRole + 2))); + int indent = index.data(Qt::UserRole + 3).toInt(); QString drawCommandText = index.data(Qt::DisplayRole).toString(); QString drawCommandNumber = index.data(Qt::UserRole + 1).toString(); @@ -74,7 +75,8 @@ void SkListWidget::paint (QPainter *painter, * spot act as a margin for the bottom and right sides. Positive values in * x1,y1 act as a margin for the top and left. The target area will not * affect size of text but will scale icons. */ - int imageSpace = 35; + static const int kImageSpace = 35; + static const int kCommandNumberSpace = 30; // Breakpoint Icon r = option.rect.adjusted(5, 10, -10, -10); @@ -85,12 +87,12 @@ void SkListWidget::paint (QPainter *painter, deleteIcon.paint(painter, r, Qt::AlignVCenter|Qt::AlignLeft); // Draw Command - r = option.rect.adjusted(imageSpace, 0, -10, -7); + r = option.rect.adjusted(kImageSpace+kCommandNumberSpace+indent, 0, -10, -7); painter->drawText(r.left(), r.top(), r.width(), r.height(), - Qt::AlignBottom|Qt::AlignRight, drawCommandText, &r); + Qt::AlignBottom|Qt::AlignLeft, drawCommandText, &r); // Draw Command Number - r = option.rect.adjusted(imageSpace, 0, -10, -7); + r = option.rect.adjusted(kImageSpace, 0, -10, -7); painter->drawText(r.left(), r.top(), r.width(), r.height(), Qt::AlignBottom|Qt::AlignLeft, drawCommandNumber, &r); } diff --git a/debugger/SkDrawCommand.cpp b/debugger/SkDrawCommand.cpp index 2c4847a..74c9258 100644 --- a/debugger/SkDrawCommand.cpp +++ b/debugger/SkDrawCommand.cpp @@ -172,7 +172,7 @@ DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); this->fInfo.push(SkObjectParser::IRectToString(center)); - this->fInfo.push(SkObjectParser::RectToString(dst)); + this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint)); } @@ -189,8 +189,8 @@ DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, this->fDrawType = DRAW_BITMAP_RECT_TO_RECT; this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); - if (src) this->fInfo.push(SkObjectParser::RectToString(*src)); - this->fInfo.push(SkObjectParser::RectToString(dst)); + if (src) this->fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); + this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint)); } @@ -429,7 +429,7 @@ SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint, this->fFlags = flags; this->fDrawType = SAVE_LAYER; - if (bounds) this->fInfo.push(SkObjectParser::RectToString(*bounds)); + if (bounds) this->fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint)); this->fInfo.push(SkObjectParser::SaveFlagsToString(flags)); } diff --git a/debugger/SkObjectParser.cpp b/debugger/SkObjectParser.cpp index 892df99..6b5207c 100644 --- a/debugger/SkObjectParser.cpp +++ b/debugger/SkObjectParser.cpp @@ -152,6 +152,13 @@ SkString* SkObjectParser::PathToString(const SkPath& path) { } } + SkString* boundStr = SkObjectParser::RectToString(path.getBounds(), " Bound: "); + + if (NULL != boundStr) { + mPath->append(*boundStr); + SkDELETE(boundStr); + } + return mPath; } @@ -179,8 +186,15 @@ SkString* SkObjectParser::PointModeToString(SkCanvas::PointMode mode) { return mMode; } -SkString* SkObjectParser::RectToString(const SkRect& rect) { - SkString* mRect = new SkString("SkRect: "); +SkString* SkObjectParser::RectToString(const SkRect& rect, const char* title) { + + SkString* mRect = new SkString; + + if (NULL == title) { + mRect->append("SkRect: "); + } else { + mRect->append(title); + } mRect->append("("); mRect->appendScalar(rect.left()); mRect->append(", "); diff --git a/debugger/SkObjectParser.h b/debugger/SkObjectParser.h index fc6fb1a..e30bd13 100644 --- a/debugger/SkObjectParser.h +++ b/debugger/SkObjectParser.h @@ -83,7 +83,7 @@ public: Returns a string representation of the SkRects coordinates. @param rect SkRect */ - static SkString* RectToString(const SkRect& rect); + static SkString* RectToString(const SkRect& rect, const char* title = NULL); /** Returns a string representation of the SkRegion enum. -- 2.7.4