debugger: Update inspector view data consistently while paused
Make all fields of inspector view (details tab, clipstack tab, geometry
view) update the correct info when user selects a draw command. Also
update the info regardless if the painting is paused or not.
Current clip and matrix will not update consistently even after this
patch, as they depend on stateful debug canvas draw (may be fixed
later).
Review URL: https://codereview.chromium.org/835903002
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 1b5a366..dade567 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -66,7 +66,8 @@
{
setupUi(this);
fListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection);
- connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(registerListClick(QListWidgetItem *)));
+ connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this,
+ SLOT(updateDrawCommandInfo()));
connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory()));
connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(loadFile(QListWidgetItem *)));
@@ -98,8 +99,6 @@
connect(&fCanvasWidget, SIGNAL(hitChanged(int)), this, SLOT(selectCommand(int)));
connect(&fCanvasWidget, SIGNAL(hitChanged(int)), this, SLOT(updateHit(int)));
connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this, SLOT(actionScale(float)));
- connect(&fCanvasWidget, SIGNAL(commandChanged(int)), this, SLOT(updateCommand(int)));
- connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fDrawCommandGeometryWidget, SLOT(updateImage()));
connect(&fActionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs()));
connect(&fActionSave, SIGNAL(triggered()), this, SLOT(actionSave()));
@@ -404,33 +403,44 @@
}
}
-void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
- if(!fLoading) {
- int currentRow = fListWidget.currentRow();
+void SkDebuggerGUI::updateDrawCommandInfo() {
+ int currentRow = -1;
+ if (!fLoading) {
+ currentRow = fListWidget.currentRow();
+ }
+ if (currentRow == -1) {
+ fInspectorWidget.setText("", SkInspectorWidget::kDetail_TabType);
+ fInspectorWidget.setText("", SkInspectorWidget::kClipStack_TabType);
+ fCurrentCommandBox.setText("");
+ fDrawCommandGeometryWidget.setDrawCommandIndex(-1);
+ } else {
+ if (!this->isPaused()) {
+ fCanvasWidget.drawTo(currentRow);
+ }
+ const SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(currentRow);
- if (currentRow != -1) {
- if (!this->isPaused()) {
- fCanvasWidget.drawTo(currentRow);
+ /* TODO(chudy): Add command type before parameters. Rename v
+ * to something more informative. */
+ if (currInfo) {
+ QString info;
+ info.append("<b>Parameters: </b><br/>");
+ for (int i = 0; i < currInfo->count(); i++) {
+ info.append(QString((*currInfo)[i]->c_str()));
+ info.append("<br/>");
}
- const SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(currentRow);
-
- /* TODO(chudy): Add command type before parameters. Rename v
- * to something more informative. */
- if (currInfo) {
- QString info;
- info.append("<b>Parameters: </b><br/>");
- for (int i = 0; i < currInfo->count(); i++) {
-
- info.append(QString((*currInfo)[i]->c_str()));
- info.append("<br/>");
- }
- fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType);
- fInspectorWidget.setDisabled(false);
- fViewStateFrame.setDisabled(false);
- }
- setupClipStackText();
+ fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType);
}
+ SkString clipStack;
+ fDebugger.getClipStackText(&clipStack);
+ fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_TabType);
+
+ fCurrentCommandBox.setText(QString::number(currentRow));
+
+ fDrawCommandGeometryWidget.setDrawCommandIndex(currentRow);
+
+ fInspectorWidget.setDisabled(false);
+ fViewStateFrame.setDisabled(false);
}
}
@@ -783,6 +793,8 @@
fActionSave.setDisabled(false);
fActionSaveAs.setDisabled(false);
fActionPause.setChecked(false);
+ fDrawCommandGeometryWidget.setDrawCommandIndex(-1);
+
fLoading = false;
actionPlay();
}
@@ -826,11 +838,6 @@
fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabType);
}
-void SkDebuggerGUI::setupClipStackText() {
- SkString clipStack;
- fDebugger.getClipStackText(&clipStack);
- fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_TabType);
-}
void SkDebuggerGUI::setupComboBox() {
fFilter.clear();
@@ -855,10 +862,6 @@
firstItem->setSelectable(false);
}
-void SkDebuggerGUI::updateCommand(int newCommand) {
- fCurrentCommandBox.setText(QString::number(newCommand));
-}
-
void SkDebuggerGUI::updateHit(int newHit) {
fCommandHitBox.setText(QString::number(newHit));
}
diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h
index 5c003b0..8c6865b 100644
--- a/debugger/QT/SkDebuggerGUI.h
+++ b/debugger/QT/SkDebuggerGUI.h
@@ -202,9 +202,9 @@
void pauseDrawing(bool isPaused = true);
/**
- Executes draw commands up to the selected command
+ Updates the UI based on the selected command.
*/
- void registerListClick(QListWidgetItem *item);
+ void updateDrawCommandInfo();
/**
Sets the command to active in the list widget.
@@ -232,7 +232,6 @@
*/
void toggleFilter(QString string);
- void updateCommand(int newCommand);
void updateHit(int newHit);
private:
QSplitter fCentralSplitter;
@@ -338,10 +337,6 @@
*/
void setupOverviewText(const SkTDArray<double>* typeTimes, double totTime, int numRuns);
- /**
- Fills in the clip stack pane with text
- */
- void setupClipStackText();
/**
Render the supplied picture several times tracking the time consumed
diff --git a/debugger/QT/SkDrawCommandGeometryWidget.cpp b/debugger/QT/SkDrawCommandGeometryWidget.cpp
index 1172e79..03572cf 100644
--- a/debugger/QT/SkDrawCommandGeometryWidget.cpp
+++ b/debugger/QT/SkDrawCommandGeometryWidget.cpp
@@ -13,7 +13,8 @@
SkDrawCommandGeometryWidget::SkDrawCommandGeometryWidget(SkDebugger *debugger)
: QFrame()
- , fDebugger(debugger) {
+ , fDebugger(debugger)
+ , fCommandIndex(-1) {
this->setStyleSheet("QFrame {background-color: black; border: 1px solid #cccccc;}");
}
@@ -65,6 +66,11 @@
}
}
+void SkDrawCommandGeometryWidget::setDrawCommandIndex(int commandIndex) {
+ fCommandIndex = commandIndex;
+ this->updateImage();
+}
+
void SkDrawCommandGeometryWidget::updateImage() {
if (!fSurface) {
return;
@@ -72,8 +78,9 @@
bool didRender = false;
const SkTDArray<SkDrawCommand*>& commands = fDebugger->getDrawCommands();
- if (0 != commands.count()) {
- SkDrawCommand* command = commands[fDebugger->index()];
+ if (0 != commands.count() && fCommandIndex >= 0) {
+ SkASSERT(commands.count() > fCommandIndex);
+ SkDrawCommand* command = commands[fCommandIndex];
didRender = command->render(fSurface->getCanvas());
}
@@ -82,5 +89,5 @@
}
fSurface->getCanvas()->flush();
- update();
+ this->update();
}
diff --git a/debugger/QT/SkDrawCommandGeometryWidget.h b/debugger/QT/SkDrawCommandGeometryWidget.h
index aa5d10a..0bdddd0 100644
--- a/debugger/QT/SkDrawCommandGeometryWidget.h
+++ b/debugger/QT/SkDrawCommandGeometryWidget.h
@@ -19,17 +19,18 @@
public:
SkDrawCommandGeometryWidget(SkDebugger* debugger);
-
-public slots:
- void updateImage();
+ void setDrawCommandIndex(int index);
protected:
void paintEvent(QPaintEvent* event);
void resizeEvent(QResizeEvent* event);
private:
+ void updateImage();
+
SkDebugger* fDebugger;
- SkAutoTUnref<SkSurface> fSurface;
+ SkAutoTUnref<SkSurface> fSurface;
+ int fCommandIndex;
};
#endif /* SKDRAWCOMMANDGEOMETRYWIDGET_H_ */