aboutsummaryrefslogtreecommitdiffhomepage
path: root/debugger
diff options
context:
space:
mode:
authorGravatar chudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-17 15:40:51 +0000
committerGravatar chudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-17 15:40:51 +0000
commit7e4cfbf144af7d530d552946cee2a21d30b9b50f (patch)
tree02bfbef3ccc1a1f8140d11e95e99cb39465bb90d /debugger
parent2a021292f5a024e6f6b99be375e8ec2bf61718a8 (diff)
Added more features to deletes and breakpoints
Review URL: https://codereview.appspot.com/6406050 git-svn-id: http://skia.googlecode.com/svn/trunk@4637 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'debugger')
-rw-r--r--debugger/QT/SkCanvasWidget.h9
-rw-r--r--debugger/QT/SkDebuggerGUI.cpp99
-rw-r--r--debugger/QT/SkDebuggerGUI.h24
-rw-r--r--debugger/QT/SkListWidget.cpp3
-rw-r--r--debugger/QT/moc_SkDebuggerGUI.cpp101
-rw-r--r--debugger/SkDebugCanvas.cpp57
-rw-r--r--debugger/SkDebugCanvas.h14
7 files changed, 161 insertions, 146 deletions
diff --git a/debugger/QT/SkCanvasWidget.h b/debugger/QT/SkCanvasWidget.h
index 65fa2baf09..94295bbae7 100644
--- a/debugger/QT/SkCanvasWidget.h
+++ b/debugger/QT/SkCanvasWidget.h
@@ -94,17 +94,18 @@ public:
void loadPicture(QString filename);
/**
- Toggles the visibility / execution of the draw command at index i.
+ Returns the visibility of the command at the specified index.
+ @param index The index of the draw command
*/
- void toggleCommand(int index) {
- fDebugCanvas->toggleCommand(index);
+ bool commandIsVisibleAtIndex(int index) {
+ return fDebugCanvas->getDrawCommandVisibilityAt(index);
}
/**
Toggles the visibility / execution of the draw command at index i with
the value of toggle.
*/
- void toggleCommand(int index, bool toggle) {
+ void setCommandVisibliltyAtIndex(int index, bool toggle) {
fDebugCanvas->toggleCommand(index, toggle);
}
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 1c5b48c2df..ea9d687b85 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -14,6 +14,7 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
, fActionOpen(this)
, fActionBreakpoint(this)
, fActionCancel(this)
+ , fActionClearBreakpoints(this)
, fActionClearDeletes(this)
, fActionClose(this)
, fActionCreateBreakpoint(this)
@@ -23,8 +24,8 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
, fActionInspector(this)
, fActionPlay(this)
, fActionPause(this)
- , fActionReload(this)
, fActionRewind(this)
+ , fActionShowDeletes(this)
, fActionStepBack(this)
, fActionStepForward(this)
, fCentralWidget(this)
@@ -40,6 +41,9 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
, fMenuNavigate(this)
, fMenuView(this)
, fToolBar(this)
+ , fBreakpointsActivated(false)
+ , fDeletesActivated(false)
+ , fPause(false)
{
setupUi(this);
connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
@@ -52,7 +56,6 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
QListWidgetItem*)), this,
SLOT(loadFile(QListWidgetItem *)));
connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
- connect(&fActionReload, SIGNAL(triggered()), this, SLOT(actionReload()));
connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
SLOT(toggleBreakpoint()));
connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
@@ -69,6 +72,8 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
connect(&fFilter, SIGNAL(activated(QString)), this,
SLOT(toggleFilter(QString)));
connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
+ connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints()));
+ connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes()));
connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this,
SLOT(actionCommandFilter()));
@@ -82,26 +87,29 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget,
SLOT(updateHit(int)));
connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint()));
+ connect(&fActionShowDeletes, SIGNAL(triggered()), this, SLOT(showDeletes()));
+
+ fInspectorWidget.setDisabled(true);
+ fMenuBar.setDisabled(true);
}
SkDebuggerGUI::~SkDebuggerGUI() {
}
void SkDebuggerGUI::actionBreakpoints() {
- if (!fBreakpointsActivated) {
- fBreakpointsActivated = true;
- } else {
- fBreakpointsActivated = false;
+ fBreakpointsActivated = !fBreakpointsActivated;
+ for (int row = 0; row < fListWidget.count(); row++) {
+ QListWidgetItem *item = fListWidget.item(row);
+ item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated);
}
+}
+void SkDebuggerGUI::showDeletes() {
+ fDeletesActivated = !fDeletesActivated;
for (int row = 0; row < fListWidget.count(); row++) {
QListWidgetItem *item = fListWidget.item(row);
-
- if (item->checkState() == Qt::Unchecked && fBreakpointsActivated) {
- item->setHidden(true);
- } else {
- item->setHidden(false);
- }
+ bool isVisible = fCanvasWidget.commandIsVisibleAtIndex(row);
+ item->setHidden(isVisible && fDeletesActivated);
}
}
@@ -111,6 +119,28 @@ void SkDebuggerGUI::actionCancel() {
}
}
+void SkDebuggerGUI::actionClearBreakpoints() {
+ for (int row = 0; row < fListWidget.count(); row++) {
+ QListWidgetItem* item = fListWidget.item(row);
+ item->setCheckState(Qt::Unchecked);
+ item->setData(Qt::DecorationRole,
+ QPixmap(":/images/Icons/blank.png"));
+ }
+}
+
+void SkDebuggerGUI::actionClearDeletes() {
+ for (int row = 0; row < fListWidget.count(); row++) {
+ QListWidgetItem* item = fListWidget.item(row);
+ item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/blank.png"));
+ fCanvasWidget.setCommandVisibliltyAtIndex(row, true);
+ }
+ if (fPause) {
+ fCanvasWidget.drawTo(fPausedRow);
+ } else {
+ fCanvasWidget.drawTo(fListWidget.currentRow());
+ }
+}
+
void SkDebuggerGUI::actionCommandFilter() {
fCanvasWidget.toggleCurrentCommandFilter(
fSettingsWidget.getVisibilityButton()->isChecked());
@@ -122,16 +152,17 @@ void SkDebuggerGUI::actionClose() {
}
void SkDebuggerGUI::actionDelete() {
+ int currentRow = fListWidget.currentRow();
QListWidgetItem* item = fListWidget.currentItem();
- if (item->data(Qt::UserRole + 2) == true) {
- item->setData(Qt::UserRole + 2, false);
- item->setData(Qt::UserRole + 3, QPixmap(":/images/Icons/delete.png"));
+
+ if (fCanvasWidget.commandIsVisibleAtIndex(currentRow)) {
+ item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/delete.png"));
+ fCanvasWidget.setCommandVisibliltyAtIndex(currentRow, false);
} else {
- item->setData(Qt::UserRole + 2, true);
- item->setData(Qt::UserRole + 3, QPixmap(":/images/Icons/blank.png"));
+ item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/blank.png"));
+ fCanvasWidget.setCommandVisibliltyAtIndex(currentRow, true);
}
- int currentRow = fListWidget.currentRow();
- fCanvasWidget.toggleCommand(currentRow);
+
if (fPause) {
fCanvasWidget.drawTo(fPausedRow);
} else {
@@ -159,16 +190,6 @@ void SkDebuggerGUI::actionPlay() {
fListWidget.setCurrentRow(fListWidget.count() - 1);
}
-void SkDebuggerGUI::actionReload() {
- for (int row = 0; row < fListWidget.count(); row++) {
- QListWidgetItem* item = fListWidget.item(row);
- item->setData(Qt::UserRole + 2, true);
- item->setData(Qt::DecorationRole, QPixmap(":/images/Icons/blank.png"));
- fCanvasWidget.toggleCommand(row, true);
- }
- fCanvasWidget.drawTo(fListWidget.currentRow());
-}
-
void SkDebuggerGUI::actionRewind() {
fListWidget.setCurrentRow(0);
}
@@ -316,7 +337,7 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
QSize(), QIcon::Normal, QIcon::Off);
fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B")));
fActionBreakpoint.setIcon(breakpoint);
- fActionBreakpoint.setText("Show Breakpoints");
+ fActionBreakpoint.setText("Breakpoints");
QIcon cancel;
cancel.addFile(QString::fromUtf8(":/images/Ico/reload.png"), QSize(),
@@ -324,6 +345,12 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fActionCancel.setIcon(cancel);
fActionCancel.setText("Clear Filter");
+ fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B")));
+ fActionClearBreakpoints.setText("Clear Breakpoints");
+
+ fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X")));
+ fActionClearDeletes.setText("Clear Deletes");
+
fActionClose.setShortcuts(QKeySequence::Quit);
fActionClose.setText("Exit");
@@ -358,8 +385,6 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fActionPause.setIcon(pause);
fActionPause.setText("Pause");
- fActionReload.setText("Reset Picture");
-
QIcon rewind;
rewind.addFile(QString::fromUtf8(":/images/Ico/rewind.png"), QSize(),
QIcon::Normal, QIcon::Off);
@@ -367,6 +392,9 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fActionRewind.setIcon(rewind);
fActionRewind.setText("Rewind");
+ fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X")));
+ fActionShowDeletes.setText("Deleted Commands");
+
QIcon stepBack;
stepBack.addFile(QString::fromUtf8(":/images/Ico/previous.png"), QSize(),
QIcon::Normal, QIcon::Off);
@@ -453,7 +481,10 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fMenuEdit.setTitle("Edit");
fMenuEdit.addAction(&fActionDelete);
+ fMenuEdit.addAction(&fActionClearDeletes);
+ fMenuEdit.addSeparator();
fMenuEdit.addAction(&fActionCreateBreakpoint);
+ fMenuEdit.addAction(&fActionClearBreakpoints);
fMenuNavigate.setTitle("Navigate");
fMenuNavigate.addAction(&fActionRewind);
@@ -465,6 +496,7 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fMenuView.setTitle("View");
fMenuView.addAction(&fActionBreakpoint);
+ fMenuView.addAction(&fActionShowDeletes);
fMenuWindows.setTitle("Window");
fMenuWindows.addAction(&fActionInspector);
@@ -504,7 +536,9 @@ void SkDebuggerGUI::loadPicture(QString fileName) {
fSettingsWidget.getVisibilityButton()->isChecked());
setupListWidget(cv);
setupComboBox(cv);
+ fInspectorWidget.setDisabled(false);
fSettingsWidget.setDisabled(false);
+ fMenuBar.setDisabled(false);
}
void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) {
@@ -514,7 +548,6 @@ void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) {
QListWidgetItem *item = new QListWidgetItem();
item->setData(Qt::DisplayRole, (*cv)[i].c_str());
item->setData(Qt::UserRole + 1, counter++);
- item->setData(Qt::UserRole + 2, true);
fListWidget.addItem(item);
}
}
diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h
index 937476ab9a..b1ecb88c51 100644
--- a/debugger/QT/SkDebuggerGUI.h
+++ b/debugger/QT/SkDebuggerGUI.h
@@ -64,6 +64,16 @@ private slots:
void actionCancel();
/**
+ Clears the breakpoint state off of all commands marked as breakpoints.
+ */
+ void actionClearBreakpoints();
+
+ /**
+ Clears the deleted state off of all commands marked as deleted.
+ */
+ void actionClearDeletes();
+
+ /**
Applies a visible filter to all drawing commands other than the previous.
*/
void actionCommandFilter();
@@ -90,11 +100,6 @@ private slots:
void actionPlay();
/**
- Resets all deleted commands.
- */
- void actionReload();
-
- /**
Rewinds from the current step back to the start of the commands.
*/
void actionRewind();
@@ -147,6 +152,11 @@ private slots:
void selectCommand(int command);
/**
+ Toggles the exclusive listing of commands set as deleted.
+ */
+ void showDeletes();
+
+ /**
Toggles a breakpoint on the current step in the list widget.
*/
void toggleBreakpoint();
@@ -166,6 +176,7 @@ private:
QAction fActionOpen;
QAction fActionBreakpoint;
QAction fActionCancel;
+ QAction fActionClearBreakpoints;
QAction fActionClearDeletes;
QAction fActionClose;
QAction fActionCreateBreakpoint;
@@ -175,8 +186,8 @@ private:
QAction fActionInspector;
QAction fActionPlay;
QAction fActionPause;
- QAction fActionReload;
QAction fActionRewind;
+ QAction fActionShowDeletes;
QAction fActionStepBack;
QAction fActionStepForward;
QWidget fCentralWidget;
@@ -208,6 +219,7 @@ private:
QToolBar fToolBar;
bool fBreakpointsActivated;
+ bool fDeletesActivated;
bool fPause;
int fPausedRow;
diff --git a/debugger/QT/SkListWidget.cpp b/debugger/QT/SkListWidget.cpp
index f0459dd093..669f2258f5 100644
--- a/debugger/QT/SkListWidget.cpp
+++ b/debugger/QT/SkListWidget.cpp
@@ -60,11 +60,10 @@ void SkListWidget::paint (QPainter *painter,
QIcon breakpointIcon =
QIcon(qvariant_cast<QPixmap>(index.data(Qt::DecorationRole)));
QIcon deleteIcon =
- QIcon(qvariant_cast<QPixmap>(index.data(Qt::UserRole + 3)));
+ QIcon(qvariant_cast<QPixmap>(index.data(Qt::UserRole + 2)));
QString drawCommandText = index.data(Qt::DisplayRole).toString();
QString drawCommandNumber = index.data(Qt::UserRole + 1).toString();
- QString isDeleted = index.data(Qt::UserRole + 2).toString();
/* option.rect is a struct that Qt uses as a target to draw into. Following
* the format (x1,y1,x2,y2) x1 and y1 represent where the painter can start
diff --git a/debugger/QT/moc_SkDebuggerGUI.cpp b/debugger/QT/moc_SkDebuggerGUI.cpp
index bf2370dc82..3f11cb116c 100644
--- a/debugger/QT/moc_SkDebuggerGUI.cpp
+++ b/debugger/QT/moc_SkDebuggerGUI.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
** Meta object code from reading C++ file 'SkDebuggerGUI.h'
**
-** Created: Wed Jul 11 17:21:44 2012
+** Created: Mon Jul 16 16:36:08 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
@@ -23,7 +23,7 @@ static const uint qt_meta_data_SkDebuggerGUI[] = {
4, // revision
0, // classname
0, 0, // classinfo
- 22, 14, // methods
+ 25, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
@@ -37,24 +37,27 @@ static const uint qt_meta_data_SkDebuggerGUI[] = {
43, 14, 14, 14, 0x08,
63, 14, 14, 14, 0x08,
78, 14, 14, 14, 0x08,
- 100, 14, 14, 14, 0x08,
- 114, 14, 14, 14, 0x08,
- 129, 14, 14, 14, 0x08,
- 147, 14, 14, 14, 0x08,
+ 103, 14, 14, 14, 0x08,
+ 124, 14, 14, 14, 0x08,
+ 146, 14, 14, 14, 0x08,
160, 14, 14, 14, 0x08,
175, 14, 14, 14, 0x08,
- 202, 190, 14, 14, 0x08,
- 221, 14, 14, 14, 0x08,
- 238, 14, 14, 14, 0x08,
- 255, 14, 14, 14, 0x08,
- 280, 275, 14, 14, 0x08,
- 307, 14, 14, 14, 0x08,
- 327, 318, 14, 14, 0x08,
- 346, 275, 14, 14, 0x08,
- 382, 15, 14, 14, 0x08,
- 401, 14, 14, 14, 0x08,
- 420, 14, 14, 14, 0x08,
- 445, 438, 14, 14, 0x08,
+ 193, 14, 14, 14, 0x08,
+ 206, 14, 14, 14, 0x08,
+ 233, 221, 14, 14, 0x08,
+ 252, 14, 14, 14, 0x08,
+ 269, 14, 14, 14, 0x08,
+ 286, 14, 14, 14, 0x08,
+ 311, 306, 14, 14, 0x08,
+ 338, 14, 14, 14, 0x08,
+ 358, 349, 14, 14, 0x08,
+ 377, 14, 14, 14, 0x28,
+ 392, 306, 14, 14, 0x08,
+ 428, 15, 14, 14, 0x08,
+ 447, 14, 14, 14, 0x08,
+ 461, 14, 14, 14, 0x08,
+ 480, 14, 14, 14, 0x08,
+ 505, 498, 14, 14, 0x08,
0 // eod
};
@@ -62,17 +65,18 @@ static const uint qt_meta_data_SkDebuggerGUI[] = {
static const char qt_meta_stringdata_SkDebuggerGUI[] = {
"SkDebuggerGUI\0\0command\0commandChanged(int)\0"
"actionBreakpoints()\0actionCancel()\0"
+ "actionClearBreakpoints()\0actionClearDeletes()\0"
"actionCommandFilter()\0actionClose()\0"
"actionDelete()\0actionInspector()\0"
- "actionPlay()\0actionReload()\0actionRewind()\0"
- "scaleFactor\0actionScale(float)\0"
- "actionSettings()\0actionStepBack()\0"
- "actionStepForward()\0item\0"
- "loadFile(QListWidgetItem*)\0openFile()\0"
- "isPaused\0pauseDrawing(bool)\0"
- "registerListClick(QListWidgetItem*)\0"
- "selectCommand(int)\0toggleBreakpoint()\0"
- "toggleDirectory()\0string\0toggleFilter(QString)\0"
+ "actionPlay()\0actionRewind()\0scaleFactor\0"
+ "actionScale(float)\0actionSettings()\0"
+ "actionStepBack()\0actionStepForward()\0"
+ "item\0loadFile(QListWidgetItem*)\0"
+ "openFile()\0isPaused\0pauseDrawing(bool)\0"
+ "pauseDrawing()\0registerListClick(QListWidgetItem*)\0"
+ "selectCommand(int)\0showDeletes()\0"
+ "toggleBreakpoint()\0toggleDirectory()\0"
+ "string\0toggleFilter(QString)\0"
};
const QMetaObject SkDebuggerGUI::staticMetaObject = {
@@ -107,28 +111,31 @@ int SkDebuggerGUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
case 0: commandChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 1: actionBreakpoints(); break;
case 2: actionCancel(); break;
- case 3: actionCommandFilter(); break;
- case 4: actionClose(); break;
- case 5: actionDelete(); break;
- case 6: actionInspector(); break;
- case 7: actionPlay(); break;
- case 8: actionReload(); break;
- case 9: actionRewind(); break;
- case 10: actionScale((*reinterpret_cast< float(*)>(_a[1]))); break;
- case 11: actionSettings(); break;
- case 12: actionStepBack(); break;
- case 13: actionStepForward(); break;
- case 14: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
- case 15: openFile(); break;
- case 16: pauseDrawing((*reinterpret_cast< bool(*)>(_a[1]))); break;
- case 17: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
- case 18: selectCommand((*reinterpret_cast< int(*)>(_a[1]))); break;
- case 19: toggleBreakpoint(); break;
- case 20: toggleDirectory(); break;
- case 21: toggleFilter((*reinterpret_cast< QString(*)>(_a[1]))); break;
+ case 3: actionClearBreakpoints(); break;
+ case 4: actionClearDeletes(); break;
+ case 5: actionCommandFilter(); break;
+ case 6: actionClose(); break;
+ case 7: actionDelete(); break;
+ case 8: actionInspector(); break;
+ case 9: actionPlay(); break;
+ case 10: actionRewind(); break;
+ case 11: actionScale((*reinterpret_cast< float(*)>(_a[1]))); break;
+ case 12: actionSettings(); break;
+ case 13: actionStepBack(); break;
+ case 14: actionStepForward(); break;
+ case 15: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
+ case 16: openFile(); break;
+ case 17: pauseDrawing((*reinterpret_cast< bool(*)>(_a[1]))); break;
+ case 18: pauseDrawing(); break;
+ case 19: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
+ case 20: selectCommand((*reinterpret_cast< int(*)>(_a[1]))); break;
+ case 21: showDeletes(); break;
+ case 22: toggleBreakpoint(); break;
+ case 23: toggleDirectory(); break;
+ case 24: toggleFilter((*reinterpret_cast< QString(*)>(_a[1]))); break;
default: ;
}
- _id -= 22;
+ _id -= 25;
}
return _id;
}
diff --git a/debugger/SkDebugCanvas.cpp b/debugger/SkDebugCanvas.cpp
index 8586878485..c811a05118 100644
--- a/debugger/SkDebugCanvas.cpp
+++ b/debugger/SkDebugCanvas.cpp
@@ -73,32 +73,18 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index, SkBitmap* bitmap) {
}
SkDrawCommand* SkDebugCanvas::getDrawCommandAt(int index) {
- int counter = 0;
- if(!commandVector.empty()) {
- for(it = commandVector.begin(); it != commandVector.end(); ++it) {
- if (counter==index) {
- return (*it);
- }
- ++counter;
- }
- }
- return NULL;
+ SkASSERT(index < commandVector.size());
+ return commandVector[index];
}
std::vector<std::string>* SkDebugCanvas::getCommandInfoAt(int index) {
- std::string info;
-
- int counter = 0;
- if(!commandVector.empty()) {
- for(it = commandVector.begin(); it != commandVector.end(); ++it) {
- if (counter==index) {
- return (*it)->Info();
- }
- ++counter;
- }
- }
+ SkASSERT(index < commandVector.size());
+ return commandVector[index]->Info();
+}
- return NULL;
+bool SkDebugCanvas::getDrawCommandVisibilityAt(int index) {
+ SkASSERT(index < commandVector.size());
+ return commandVector[index]->getVisibility();
}
std::vector<SkDrawCommand*> SkDebugCanvas::getDrawCommands() {
@@ -262,30 +248,7 @@ bool SkDebugCanvas::translate(SkScalar dx, SkScalar dy) {
return true;
}
-void SkDebugCanvas::toggleCommand(int index) {
- int counter = 0;
- if(!commandVector.empty()) {
- for(it = commandVector.begin(); it != commandVector.end(); ++it) {
- if (counter == index) {
- if ((*it)->getVisibility()) {
- (*it)->setVisibility(false);
- } else {
- (*it)->setVisibility(true);
- }
- }
- counter++;
- }
- }
-}
-
void SkDebugCanvas::toggleCommand(int index, bool toggle) {
- int counter = 0;
- if(!commandVector.empty()) {
- for(it = commandVector.begin(); it != commandVector.end(); ++it) {
- if (counter == index) {
- (*it)->setVisibility(toggle);
- }
- counter++;
- }
- }
+ SkASSERT(index < commandVector.size());
+ commandVector[index]->setVisibility(toggle);
}
diff --git a/debugger/SkDebugCanvas.h b/debugger/SkDebugCanvas.h
index e6dd56a961..373ef5df49 100644
--- a/debugger/SkDebugCanvas.h
+++ b/debugger/SkDebugCanvas.h
@@ -10,7 +10,6 @@
#ifndef SKDEBUGCANVAS_H_
#define SKDEBUGCANVAS_H_
-#include <iostream>
#include "SkCanvas.h"
#include "SkDrawCommand.h"
#include "SkPicture.h"
@@ -19,8 +18,6 @@
class SkDebugCanvas : public SkCanvas {
public:
- bool fFilter;
-
SkDebugCanvas();
~SkDebugCanvas();
@@ -61,6 +58,12 @@ public:
std::vector<std::string>* getCommandInfoAt(int index);
/**
+ Returns the visibility of the command at the given index.
+ @param index The index of the command
+ */
+ bool getDrawCommandVisibilityAt(int index);
+
+ /**
Returns the vector of draw commands
*/
std::vector<SkDrawCommand*> getDrawCommands();
@@ -95,10 +98,6 @@ public:
void isCalculatingHits(bool isEnabled) {
fCalculateHits = isEnabled;
}
- /**
- Toggles the execution of the draw command at index i.
- */
- void toggleCommand(int index);
/**
Toggles the visibility / execution of the draw command at index i with
@@ -197,6 +196,7 @@ private:
SkBitmap fBm;
SkHitBox fHitBox;
bool fCalculateHits;
+ bool fFilter;
/**
Adds the command to the classes vector of commands.