Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: debugger/QT/SkDebuggerGUI.cpp

Issue 810033004: debugger: Remove few redundant variables (Closed) Base URL: https://skia.googlesource.com/skia.git@debugger-small-things-01-sk-graphics
Patch Set: address review comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « debugger/QT/SkDebuggerGUI.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDebuggerGUI.h" 8 #include "SkDebuggerGUI.h"
9 #include "SkForceLinking.h" 9 #include "SkForceLinking.h"
10 #include <QListWidgetItem> 10 #include <QListWidgetItem>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 , fActionZoomOut(this) 55 , fActionZoomOut(this)
56 , fMapper(this) 56 , fMapper(this)
57 , fListWidget(&fCentralSplitter) 57 , fListWidget(&fCentralSplitter)
58 , fDirectoryWidget(&fCentralSplitter) 58 , fDirectoryWidget(&fCentralSplitter)
59 , fCanvasWidget(this, &fDebugger) 59 , fCanvasWidget(this, &fDebugger)
60 , fDrawCommandGeometryWidget(&fDebugger) 60 , fDrawCommandGeometryWidget(&fDebugger)
61 , fMenuBar(this) 61 , fMenuBar(this)
62 , fMenuFile(this) 62 , fMenuFile(this)
63 , fMenuNavigate(this) 63 , fMenuNavigate(this)
64 , fMenuView(this) 64 , fMenuView(this)
65 , fBreakpointsActivated(false)
66 , fIndexStyleToggle(false)
67 , fDeletesActivated(false)
68 , fPause(false)
69 , fLoading(false) 65 , fLoading(false)
70 { 66 {
71 setupUi(this); 67 setupUi(this);
72 fListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection); 68 fListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection);
73 connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidge tItem*)), this, SLOT(registerListClick(QListWidgetItem *))); 69 connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidge tItem*)), this, SLOT(registerListClick(QListWidgetItem *)));
74 connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile())); 70 connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
75 connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory() )); 71 connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory() ));
76 connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QList WidgetItem*)), this, SLOT(loadFile(QListWidgetItem *))); 72 connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QList WidgetItem*)), this, SLOT(loadFile(QListWidgetItem *)));
77 connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete())); 73 connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
78 connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLO T(toggleBreakpoint())); 74 connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLO T(toggleBreakpoint()));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 connect(&fMapper, SIGNAL(mapped(int)), &fCanvasWidget, SLOT(zoom(int))); 112 connect(&fMapper, SIGNAL(mapped(int)), &fCanvasWidget, SLOT(zoom(int)));
117 113
118 fViewStateFrame.setDisabled(true); 114 fViewStateFrame.setDisabled(true);
119 fInspectorWidget.setDisabled(true); 115 fInspectorWidget.setDisabled(true);
120 fMenuEdit.setDisabled(true); 116 fMenuEdit.setDisabled(true);
121 fMenuNavigate.setDisabled(true); 117 fMenuNavigate.setDisabled(true);
122 fMenuView.setDisabled(true); 118 fMenuView.setDisabled(true);
123 } 119 }
124 120
125 void SkDebuggerGUI::actionBreakpoints() { 121 void SkDebuggerGUI::actionBreakpoints() {
126 fBreakpointsActivated = !fBreakpointsActivated; 122 bool breakpointsActivated = fActionBreakpoint.isChecked();
127 for (int row = 0; row < fListWidget.count(); row++) { 123 for (int row = 0; row < fListWidget.count(); row++) {
128 QListWidgetItem *item = fListWidget.item(row); 124 QListWidgetItem *item = fListWidget.item(row);
129 item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActiv ated); 125 item->setHidden(item->checkState() == Qt::Unchecked && breakpointsActiva ted);
130 } 126 }
131 } 127 }
132 128
133 void SkDebuggerGUI::actionToggleIndexStyle() { 129 void SkDebuggerGUI::actionToggleIndexStyle() {
134 fIndexStyleToggle = !fIndexStyleToggle; 130 bool indexStyleToggle = fActionToggleIndexStyle.isChecked();
135 SkListWidget* list = (SkListWidget*) fListWidget.itemDelegate(); 131 SkListWidget* list = (SkListWidget*) fListWidget.itemDelegate();
136 list->setIndexStyle(fIndexStyleToggle ? SkListWidget::kIndex_IndexStyle : 132 list->setIndexStyle(indexStyleToggle ? SkListWidget::kOffset_IndexStyle
137 SkListWidget::kOffset_IndexStyle); 133 : SkListWidget::kIndex_IndexStyle);
138 fListWidget.update(); 134 fListWidget.update();
139 } 135 }
140 136
141 void SkDebuggerGUI::showDeletes() { 137 void SkDebuggerGUI::showDeletes() {
142 fDeletesActivated = !fDeletesActivated; 138 bool deletesActivated = fActionShowDeletes.isChecked();
143 for (int row = 0; row < fListWidget.count(); row++) { 139 for (int row = 0; row < fListWidget.count(); row++) {
144 QListWidgetItem *item = fListWidget.item(row); 140 QListWidgetItem *item = fListWidget.item(row);
145 item->setHidden(fDebugger.isCommandVisible(row) && fDeletesActivated); 141 item->setHidden(fDebugger.isCommandVisible(row) && deletesActivated);
146 } 142 }
147 } 143 }
148 // This is a simplification of PictureBenchmark's run with the addition of 144 // This is a simplification of PictureBenchmark's run with the addition of
149 // clearing of the times after the first pass (in resetTimes) 145 // clearing of the times after the first pass (in resetTimes)
150 void SkDebuggerGUI::run(const SkPicture* pict, 146 void SkDebuggerGUI::run(const SkPicture* pict,
151 sk_tools::PictureRenderer* renderer, 147 sk_tools::PictureRenderer* renderer,
152 int repeats) { 148 int repeats) {
153 SkASSERT(pict); 149 SkASSERT(pict);
154 if (NULL == pict) { 150 if (NULL == pict) {
155 return; 151 return;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 211 }
216 } 212 }
217 213
218 void SkDebuggerGUI::actionClearDeletes() { 214 void SkDebuggerGUI::actionClearDeletes() {
219 for (int row = 0; row < fListWidget.count(); row++) { 215 for (int row = 0; row < fListWidget.count(); row++) {
220 QListWidgetItem* item = fListWidget.item(row); 216 QListWidgetItem* item = fListWidget.item(row);
221 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); 217 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png"));
222 fDebugger.setCommandVisible(row, true); 218 fDebugger.setCommandVisible(row, true);
223 fSkipCommands[row] = false; 219 fSkipCommands[row] = false;
224 } 220 }
225 if (fPause) { 221 if (this->isPaused()) {
226 fCanvasWidget.drawTo(fPausedRow); 222 fCanvasWidget.drawTo(fPausedRow);
227 } else { 223 } else {
228 fCanvasWidget.drawTo(fListWidget.currentRow()); 224 fCanvasWidget.drawTo(fListWidget.currentRow());
229 } 225 }
230 } 226 }
231 227
232 void SkDebuggerGUI::actionClose() { 228 void SkDebuggerGUI::actionClose() {
233 this->close(); 229 this->close();
234 } 230 }
235 231
(...skipping 12 matching lines...) Expand all
248 fSkipCommands[row] = true; 244 fSkipCommands[row] = true;
249 } else { 245 } else {
250 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); 246 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png"));
251 fDebugger.setCommandVisible(row, true); 247 fDebugger.setCommandVisible(row, true);
252 fSkipCommands[row] = false; 248 fSkipCommands[row] = false;
253 } 249 }
254 } 250 }
255 251
256 int currentRow = fListWidget.currentRow(); 252 int currentRow = fListWidget.currentRow();
257 253
258 if (fPause) { 254 if (this->isPaused()) {
259 fCanvasWidget.drawTo(fPausedRow); 255 fCanvasWidget.drawTo(fPausedRow);
260 } else { 256 } else {
261 fCanvasWidget.drawTo(currentRow); 257 fCanvasWidget.drawTo(currentRow);
262 } 258 }
263 } 259 }
264 260
265 #if SK_SUPPORT_GPU 261 #if SK_SUPPORT_GPU
266 void SkDebuggerGUI::actionGLSettingsChanged() { 262 void SkDebuggerGUI::actionGLSettingsChanged() {
267 bool isToggled = fSettingsWidget.isGLActive(); 263 bool isToggled = fSettingsWidget.isGLActive();
268 if (isToggled) { 264 if (isToggled) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 fDirectoryWidgetActive = false; 391 fDirectoryWidgetActive = false;
396 if (!filename.isEmpty()) { 392 if (!filename.isEmpty()) {
397 QFileInfo pathInfo(filename); 393 QFileInfo pathInfo(filename);
398 loadPicture(SkString(filename.toAscii().data())); 394 loadPicture(SkString(filename.toAscii().data()));
399 setupDirectoryWidget(pathInfo.path()); 395 setupDirectoryWidget(pathInfo.path());
400 } 396 }
401 fDirectoryWidgetActive = true; 397 fDirectoryWidgetActive = true;
402 } 398 }
403 399
404 void SkDebuggerGUI::pauseDrawing(bool isPaused) { 400 void SkDebuggerGUI::pauseDrawing(bool isPaused) {
405 fPause = isPaused;
406 fPausedRow = fListWidget.currentRow(); 401 fPausedRow = fListWidget.currentRow();
407 fCanvasWidget.drawTo(fPausedRow); 402 if (!fLoading) {
403 fCanvasWidget.drawTo(fPausedRow);
404 }
408 } 405 }
409 406
410 void SkDebuggerGUI::registerListClick(QListWidgetItem *item) { 407 void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
411 if(!fLoading) { 408 if(!fLoading) {
412 int currentRow = fListWidget.currentRow(); 409 int currentRow = fListWidget.currentRow();
413 410
414 if (currentRow != -1) { 411 if (currentRow != -1) {
415 if (!fPause) { 412 if (!this->isPaused()) {
416 fCanvasWidget.drawTo(currentRow); 413 fCanvasWidget.drawTo(currentRow);
417 } 414 }
418 const SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(curr entRow); 415 const SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(curr entRow);
419 416
420 /* TODO(chudy): Add command type before parameters. Rename v 417 /* TODO(chudy): Add command type before parameters. Rename v
421 * to something more informative. */ 418 * to something more informative. */
422 if (currInfo) { 419 if (currInfo) {
423 QString info; 420 QString info;
424 info.append("<b>Parameters: </b><br/>"); 421 info.append("<b>Parameters: </b><br/>");
425 for (int i = 0; i < currInfo->count(); i++) { 422 for (int i = 0; i < currInfo->count(); i++) {
426 423
427 info.append(QString((*currInfo)[i]->c_str())); 424 info.append(QString((*currInfo)[i]->c_str()));
428 info.append("<br/>"); 425 info.append("<br/>");
429 } 426 }
430 fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabTyp e); 427 fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabTyp e);
431 fInspectorWidget.setDisabled(false); 428 fInspectorWidget.setDisabled(false);
432 fViewStateFrame.setDisabled(false); 429 fViewStateFrame.setDisabled(false);
433 } 430 }
434 setupClipStackText(); 431 setupClipStackText();
435 } 432 }
436 433
437 } 434 }
438 } 435 }
439 436
440 void SkDebuggerGUI::selectCommand(int command) { 437 void SkDebuggerGUI::selectCommand(int command) {
441 if (fPause) { 438 if (this->isPaused()) {
442 fListWidget.setCurrentRow(command); 439 fListWidget.setCurrentRow(command);
443 } 440 }
444 } 441 }
445 442
446 void SkDebuggerGUI::toggleBreakpoint() { 443 void SkDebuggerGUI::toggleBreakpoint() {
447 QListWidgetItem* item = fListWidget.currentItem(); 444 QListWidgetItem* item = fListWidget.currentItem();
448 if (item->checkState() == Qt::Unchecked) { 445 if (item->checkState() == Qt::Unchecked) {
449 item->setCheckState(Qt::Checked); 446 item->setCheckState(Qt::Checked);
450 item->setData(Qt::DecorationRole, 447 item->setData(Qt::DecorationRole,
451 QPixmap(":/breakpoint_16x16.png")); 448 QPixmap(":/breakpoint_16x16.png"));
(...skipping 26 matching lines...) Expand all
478 475
479 fActionOpen.setShortcuts(QKeySequence::Open); 476 fActionOpen.setShortcuts(QKeySequence::Open);
480 fActionOpen.setText("Open"); 477 fActionOpen.setText("Open");
481 478
482 QIcon breakpoint; 479 QIcon breakpoint;
483 breakpoint.addFile(QString::fromUtf8(":/breakpoint.png"), 480 breakpoint.addFile(QString::fromUtf8(":/breakpoint.png"),
484 QSize(), QIcon::Normal, QIcon::Off); 481 QSize(), QIcon::Normal, QIcon::Off);
485 fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B"))); 482 fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B")));
486 fActionBreakpoint.setIcon(breakpoint); 483 fActionBreakpoint.setIcon(breakpoint);
487 fActionBreakpoint.setText("Breakpoints"); 484 fActionBreakpoint.setText("Breakpoints");
485 fActionBreakpoint.setCheckable(true);
488 486
489 fActionToggleIndexStyle.setShortcut(QKeySequence(tr("Ctrl+T"))); 487 fActionToggleIndexStyle.setShortcut(QKeySequence(tr("Ctrl+T")));
490 fActionToggleIndexStyle.setText("Toggle Index Style"); 488 fActionToggleIndexStyle.setText("Toggle Index Style");
489 fActionToggleIndexStyle.setCheckable(true);
491 490
492 QIcon cancel; 491 QIcon cancel;
493 cancel.addFile(QString::fromUtf8(":/reload.png"), QSize(), 492 cancel.addFile(QString::fromUtf8(":/reload.png"), QSize(),
494 QIcon::Normal, QIcon::Off); 493 QIcon::Normal, QIcon::Off);
495 fActionCancel.setIcon(cancel); 494 fActionCancel.setIcon(cancel);
496 fActionCancel.setText("Clear Filter"); 495 fActionCancel.setText("Clear Filter");
497 496
498 fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B"))); 497 fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B")));
499 fActionClearBreakpoints.setText("Clear Breakpoints"); 498 fActionClearBreakpoints.setText("Clear Breakpoints");
500 499
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 557
559 fActionSave.setShortcut(QKeySequence::Save); 558 fActionSave.setShortcut(QKeySequence::Save);
560 fActionSave.setText("Save"); 559 fActionSave.setText("Save");
561 fActionSave.setDisabled(true); 560 fActionSave.setDisabled(true);
562 fActionSaveAs.setShortcut(QKeySequence::SaveAs); 561 fActionSaveAs.setShortcut(QKeySequence::SaveAs);
563 fActionSaveAs.setText("Save As"); 562 fActionSaveAs.setText("Save As");
564 fActionSaveAs.setDisabled(true); 563 fActionSaveAs.setDisabled(true);
565 564
566 fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X"))); 565 fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X")));
567 fActionShowDeletes.setText("Deleted Commands"); 566 fActionShowDeletes.setText("Deleted Commands");
567 fActionShowDeletes.setCheckable(true);
568 568
569 QIcon stepBack; 569 QIcon stepBack;
570 stepBack.addFile(QString::fromUtf8(":/previous.png"), QSize(), 570 stepBack.addFile(QString::fromUtf8(":/previous.png"), QSize(),
571 QIcon::Normal, QIcon::Off); 571 QIcon::Normal, QIcon::Off);
572 fActionStepBack.setShortcut(QKeySequence(tr("["))); 572 fActionStepBack.setShortcut(QKeySequence(tr("[")));
573 fActionStepBack.setIcon(stepBack); 573 fActionStepBack.setIcon(stepBack);
574 fActionStepBack.setText("Step Back"); 574 fActionStepBack.setText("Step Back");
575 575
576 QIcon stepForward; 576 QIcon stepForward;
577 stepForward.addFile(QString::fromUtf8(":/next.png"), 577 stepForward.addFile(QString::fromUtf8(":/next.png"),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 fMenuWindows.addAction(&fActionDirectory); 715 fMenuWindows.addAction(&fActionDirectory);
716 716
717 fActionGoToLine.setText("Go to Line..."); 717 fActionGoToLine.setText("Go to Line...");
718 fActionGoToLine.setDisabled(true); 718 fActionGoToLine.setDisabled(true);
719 fMenuBar.addAction(fMenuFile.menuAction()); 719 fMenuBar.addAction(fMenuFile.menuAction());
720 fMenuBar.addAction(fMenuEdit.menuAction()); 720 fMenuBar.addAction(fMenuEdit.menuAction());
721 fMenuBar.addAction(fMenuView.menuAction()); 721 fMenuBar.addAction(fMenuView.menuAction());
722 fMenuBar.addAction(fMenuNavigate.menuAction()); 722 fMenuBar.addAction(fMenuNavigate.menuAction());
723 fMenuBar.addAction(fMenuWindows.menuAction()); 723 fMenuBar.addAction(fMenuWindows.menuAction());
724 724
725 fPause = false;
726
727 SkDebuggerGUI->setMenuBar(&fMenuBar); 725 SkDebuggerGUI->setMenuBar(&fMenuBar);
728 QMetaObject::connectSlotsByName(SkDebuggerGUI); 726 QMetaObject::connectSlotsByName(SkDebuggerGUI);
729 } 727 }
730 728
731 void SkDebuggerGUI::setupDirectoryWidget(const QString& path) { 729 void SkDebuggerGUI::setupDirectoryWidget(const QString& path) {
732 fPath = path; 730 fPath = path;
733 QDir dir(path); 731 QDir dir(path);
734 QRegExp r(".skp"); 732 QRegExp r(".skp");
735 fDirectoryWidget.clear(); 733 fDirectoryWidget.clear();
736 const QStringList files = dir.entryList(); 734 const QStringList files = dir.entryList();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 this->setupComboBox(); 775 this->setupComboBox();
778 this->setupOverviewText(NULL, 0.0, 1); 776 this->setupOverviewText(NULL, 0.0, 1);
779 fInspectorWidget.setDisabled(false); 777 fInspectorWidget.setDisabled(false);
780 fViewStateFrame.setDisabled(false); 778 fViewStateFrame.setDisabled(false);
781 fSettingsWidget.setDisabled(false); 779 fSettingsWidget.setDisabled(false);
782 fMenuEdit.setDisabled(false); 780 fMenuEdit.setDisabled(false);
783 fMenuNavigate.setDisabled(false); 781 fMenuNavigate.setDisabled(false);
784 fMenuView.setDisabled(false); 782 fMenuView.setDisabled(false);
785 fActionSave.setDisabled(false); 783 fActionSave.setDisabled(false);
786 fActionSaveAs.setDisabled(false); 784 fActionSaveAs.setDisabled(false);
785 fActionPause.setChecked(false);
787 fLoading = false; 786 fLoading = false;
788 actionPlay(); 787 actionPlay();
789 } 788 }
790 789
791 void SkDebuggerGUI::setupListWidget() { 790 void SkDebuggerGUI::setupListWidget() {
792 fListWidget.clear(); 791 fListWidget.clear();
793 int counter = 0; 792 int counter = 0;
794 int indent = 0; 793 int indent = 0;
795 for (int i = 0; i < fDebugger.getSize(); i++) { 794 for (int i = 0; i < fDebugger.getSize(); i++) {
796 QListWidgetItem *item = new QListWidgetItem(); 795 QListWidgetItem *item = new QListWidgetItem();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 } 856 }
858 857
859 void SkDebuggerGUI::updateCommand(int newCommand) { 858 void SkDebuggerGUI::updateCommand(int newCommand) {
860 fCurrentCommandBox.setText(QString::number(newCommand)); 859 fCurrentCommandBox.setText(QString::number(newCommand));
861 } 860 }
862 861
863 void SkDebuggerGUI::updateHit(int newHit) { 862 void SkDebuggerGUI::updateHit(int newHit) {
864 fCommandHitBox.setText(QString::number(newHit)); 863 fCommandHitBox.setText(QString::number(newHit));
865 } 864 }
866 865
OLDNEW
« no previous file with comments | « debugger/QT/SkDebuggerGUI.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698