| OLD | NEW |
| 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 "PictureRenderer.h" | |
| 10 #include "SkPictureData.h" | 9 #include "SkPictureData.h" |
| 11 #include "SkPicturePlayback.h" | 10 #include "SkPicturePlayback.h" |
| 12 #include "SkPictureRecord.h" | 11 #include "SkPictureRecord.h" |
| 13 #include <QListWidgetItem> | 12 #include <QListWidgetItem> |
| 14 #include <QtGui> | 13 #include <QtGui> |
| 15 #include "sk_tool_utils.h" | 14 #include "sk_tool_utils.h" |
| 16 | 15 |
| 17 #if defined(SK_BUILD_FOR_WIN32) | |
| 18 #include "SysTimer_windows.h" | |
| 19 #elif defined(SK_BUILD_FOR_MAC) | |
| 20 #include "SysTimer_mach.h" | |
| 21 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) | |
| 22 #include "SysTimer_posix.h" | |
| 23 #else | |
| 24 #include "SysTimer_c.h" | |
| 25 #endif | |
| 26 | |
| 27 | |
| 28 SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : | 16 SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : |
| 29 QMainWindow(parent) | 17 QMainWindow(parent) |
| 30 , fCentralSplitter(this) | 18 , fCentralSplitter(this) |
| 31 , fStatusBar(this) | 19 , fStatusBar(this) |
| 32 , fToolBar(this) | 20 , fToolBar(this) |
| 33 , fActionOpen(this) | 21 , fActionOpen(this) |
| 34 , fActionBreakpoint(this) | 22 , fActionBreakpoint(this) |
| 35 , fActionProfile(this) | |
| 36 , fActionCancel(this) | 23 , fActionCancel(this) |
| 37 , fActionClearBreakpoints(this) | 24 , fActionClearBreakpoints(this) |
| 38 , fActionClearDeletes(this) | 25 , fActionClearDeletes(this) |
| 39 , fActionClose(this) | 26 , fActionClose(this) |
| 40 , fActionCreateBreakpoint(this) | 27 , fActionCreateBreakpoint(this) |
| 41 , fActionDelete(this) | 28 , fActionDelete(this) |
| 42 , fActionDirectory(this) | 29 , fActionDirectory(this) |
| 43 , fActionGoToLine(this) | 30 , fActionGoToLine(this) |
| 44 , fActionInspector(this) | 31 , fActionInspector(this) |
| 45 , fActionSettings(this) | 32 , fActionSettings(this) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 74 connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete())); | 61 connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete())); |
| 75 connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLO
T(toggleBreakpoint())); | 62 connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLO
T(toggleBreakpoint())); |
| 76 connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind())); | 63 connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind())); |
| 77 connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay())); | 64 connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay())); |
| 78 connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()))
; | 65 connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()))
; |
| 79 connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForwa
rd())); | 66 connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForwa
rd())); |
| 80 connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoint
s())); | 67 connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoint
s())); |
| 81 connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()
)); | 68 connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()
)); |
| 82 connect(&fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings()))
; | 69 connect(&fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings()))
; |
| 83 connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QStrin
g))); | 70 connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QStrin
g))); |
| 84 connect(&fActionProfile, SIGNAL(triggered()), this, SLOT(actionProfile())); | |
| 85 connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel())); | 71 connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel())); |
| 86 connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClea
rBreakpoints())); | 72 connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClea
rBreakpoints())); |
| 87 connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDel
etes())); | 73 connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDel
etes())); |
| 88 connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose())); | 74 connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose())); |
| 89 #if SK_SUPPORT_GPU | 75 #if SK_SUPPORT_GPU |
| 90 connect(&fSettingsWidget, SIGNAL(glSettingsChanged()), this, SLOT(actionGLSe
ttingsChanged())); | 76 connect(&fSettingsWidget, SIGNAL(glSettingsChanged()), this, SLOT(actionGLSe
ttingsChanged())); |
| 91 #endif | 77 #endif |
| 92 connect(&fSettingsWidget, SIGNAL(rasterSettingsChanged()), this, SLOT(action
RasterSettingsChanged())); | 78 connect(&fSettingsWidget, SIGNAL(rasterSettingsChanged()), this, SLOT(action
RasterSettingsChanged())); |
| 93 connect(&fSettingsWidget, SIGNAL(visualizationsChanged()), this, SLOT(action
VisualizationsChanged())); | 79 connect(&fSettingsWidget, SIGNAL(visualizationsChanged()), this, SLOT(action
VisualizationsChanged())); |
| 94 connect(&fSettingsWidget, SIGNAL(texFilterSettingsChanged()), this, SLOT(act
ionTextureFilter())); | 80 connect(&fSettingsWidget, SIGNAL(texFilterSettingsChanged()), this, SLOT(act
ionTextureFilter())); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 124 } | 110 } |
| 125 } | 111 } |
| 126 | 112 |
| 127 void SkDebuggerGUI::showDeletes() { | 113 void SkDebuggerGUI::showDeletes() { |
| 128 bool deletesActivated = fActionShowDeletes.isChecked(); | 114 bool deletesActivated = fActionShowDeletes.isChecked(); |
| 129 for (int row = 0; row < fListWidget.count(); row++) { | 115 for (int row = 0; row < fListWidget.count(); row++) { |
| 130 QListWidgetItem *item = fListWidget.item(row); | 116 QListWidgetItem *item = fListWidget.item(row); |
| 131 item->setHidden(fDebugger.isCommandVisible(row) && deletesActivated); | 117 item->setHidden(fDebugger.isCommandVisible(row) && deletesActivated); |
| 132 } | 118 } |
| 133 } | 119 } |
| 134 // This is a simplification of PictureBenchmark's run with the addition of | |
| 135 // clearing of the times after the first pass (in resetTimes) | |
| 136 void SkDebuggerGUI::run(const SkPicture* pict, | |
| 137 sk_tools::PictureRenderer* renderer, | |
| 138 int repeats) { | |
| 139 SkASSERT(pict); | |
| 140 if (nullptr == pict) { | |
| 141 return; | |
| 142 } | |
| 143 | |
| 144 SkASSERT(renderer != nullptr); | |
| 145 if (nullptr == renderer) { | |
| 146 return; | |
| 147 } | |
| 148 | |
| 149 renderer->init(pict, nullptr, nullptr, nullptr, false, false); | |
| 150 | |
| 151 renderer->setup(); | |
| 152 renderer->render(); | |
| 153 renderer->resetState(true); // flush, swapBuffers and Finish | |
| 154 | |
| 155 for (int i = 0; i < repeats; ++i) { | |
| 156 renderer->setup(); | |
| 157 renderer->render(); | |
| 158 renderer->resetState(false); // flush & swapBuffers, but don't Finish | |
| 159 } | |
| 160 renderer->resetState(true); // flush, swapBuffers and Finish | |
| 161 | |
| 162 renderer->end(); | |
| 163 } | |
| 164 | |
| 165 void SkDebuggerGUI::actionProfile() { | |
| 166 // In order to profile we pass the command offsets (that were read-in | |
| 167 // in loadPicture by the SkOffsetPicture) to an SkTimedPlaybackPicture. | |
| 168 // The SkTimedPlaybackPicture in turn passes the offsets to an | |
| 169 // SkTimedPicturePlayback object which uses them to track the performance | |
| 170 // of individual commands. | |
| 171 if (fFileName.isEmpty()) { | |
| 172 return; | |
| 173 } | |
| 174 | |
| 175 SkFILEStream inputStream; | |
| 176 | |
| 177 inputStream.setPath(fFileName.c_str()); | |
| 178 if (!inputStream.isValid()) { | |
| 179 return; | |
| 180 } | |
| 181 | |
| 182 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, | |
| 183 &SkImageDecoder::DecodeMemory)); // , fS
kipCommands)); | |
| 184 if (nullptr == picture.get()) { | |
| 185 return; | |
| 186 } | |
| 187 } | |
| 188 | 120 |
| 189 void SkDebuggerGUI::actionCancel() { | 121 void SkDebuggerGUI::actionCancel() { |
| 190 for (int row = 0; row < fListWidget.count(); row++) { | 122 for (int row = 0; row < fListWidget.count(); row++) { |
| 191 fListWidget.item(row)->setHidden(false); | 123 fListWidget.item(row)->setHidden(false); |
| 192 } | 124 } |
| 193 } | 125 } |
| 194 | 126 |
| 195 void SkDebuggerGUI::actionClearBreakpoints() { | 127 void SkDebuggerGUI::actionClearBreakpoints() { |
| 196 for (int row = 0; row < fListWidget.count(); row++) { | 128 for (int row = 0; row < fListWidget.count(); row++) { |
| 197 QListWidgetItem* item = fListWidget.item(row); | 129 QListWidgetItem* item = fListWidget.item(row); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 422 |
| 491 fActionCreateBreakpoint.setShortcut(QKeySequence(tr("B"))); | 423 fActionCreateBreakpoint.setShortcut(QKeySequence(tr("B"))); |
| 492 fActionCreateBreakpoint.setText("Set Breakpoint"); | 424 fActionCreateBreakpoint.setText("Set Breakpoint"); |
| 493 | 425 |
| 494 fActionDelete.setShortcut(QKeySequence(tr("X"))); | 426 fActionDelete.setShortcut(QKeySequence(tr("X"))); |
| 495 fActionDelete.setText("Delete Command"); | 427 fActionDelete.setText("Delete Command"); |
| 496 | 428 |
| 497 fActionDirectory.setShortcut(QKeySequence(tr("Ctrl+D"))); | 429 fActionDirectory.setShortcut(QKeySequence(tr("Ctrl+D"))); |
| 498 fActionDirectory.setText("Directory"); | 430 fActionDirectory.setText("Directory"); |
| 499 | 431 |
| 500 QIcon profile; | |
| 501 profile.addFile(QString::fromUtf8(":/profile.png"), QSize(), | |
| 502 QIcon::Normal, QIcon::Off); | |
| 503 fActionProfile.setIcon(profile); | |
| 504 fActionProfile.setText("Profile"); | |
| 505 fActionProfile.setDisabled(true); | |
| 506 | |
| 507 QIcon inspector; | 432 QIcon inspector; |
| 508 inspector.addFile(QString::fromUtf8(":/inspector.png"), | 433 inspector.addFile(QString::fromUtf8(":/inspector.png"), |
| 509 QSize(), QIcon::Normal, QIcon::Off); | 434 QSize(), QIcon::Normal, QIcon::Off); |
| 510 fActionInspector.setShortcut(QKeySequence(tr("Ctrl+I"))); | 435 fActionInspector.setShortcut(QKeySequence(tr("Ctrl+I"))); |
| 511 fActionInspector.setIcon(inspector); | 436 fActionInspector.setIcon(inspector); |
| 512 fActionInspector.setText("Inspector"); | 437 fActionInspector.setText("Inspector"); |
| 513 | 438 |
| 514 QIcon settings; | 439 QIcon settings; |
| 515 settings.addFile(QString::fromUtf8(":/inspector.png"), | 440 settings.addFile(QString::fromUtf8(":/inspector.png"), |
| 516 QSize(), QIcon::Normal, QIcon::Off); | 441 QSize(), QIcon::Normal, QIcon::Off); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 fSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | 569 fSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
| 645 | 570 |
| 646 fToolBar.addAction(&fActionRewind); | 571 fToolBar.addAction(&fActionRewind); |
| 647 fToolBar.addAction(&fActionStepBack); | 572 fToolBar.addAction(&fActionStepBack); |
| 648 fToolBar.addAction(&fActionPause); | 573 fToolBar.addAction(&fActionPause); |
| 649 fToolBar.addAction(&fActionStepForward); | 574 fToolBar.addAction(&fActionStepForward); |
| 650 fToolBar.addAction(&fActionPlay); | 575 fToolBar.addAction(&fActionPlay); |
| 651 fToolBar.addSeparator(); | 576 fToolBar.addSeparator(); |
| 652 fToolBar.addAction(&fActionInspector); | 577 fToolBar.addAction(&fActionInspector); |
| 653 fToolBar.addAction(&fActionSettings); | 578 fToolBar.addAction(&fActionSettings); |
| 654 fToolBar.addSeparator(); | |
| 655 fToolBar.addAction(&fActionProfile); | |
| 656 | 579 |
| 657 fToolBar.addSeparator(); | 580 fToolBar.addSeparator(); |
| 658 fToolBar.addWidget(&fSpacer); | 581 fToolBar.addWidget(&fSpacer); |
| 659 fToolBar.addWidget(&fFilter); | 582 fToolBar.addWidget(&fFilter); |
| 660 fToolBar.addAction(&fActionCancel); | 583 fToolBar.addAction(&fActionCancel); |
| 661 | 584 |
| 662 // TODO(chudy): Remove static call. | 585 // TODO(chudy): Remove static call. |
| 663 fDirectoryWidgetActive = false; | 586 fDirectoryWidgetActive = false; |
| 664 fFileName = ""; | 587 fFileName = ""; |
| 665 setupDirectoryWidget(""); | 588 setupDirectoryWidget(""); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 fCanvasWidget.resetWidgetTransform(); | 660 fCanvasWidget.resetWidgetTransform(); |
| 738 fDebugger.loadPicture(picture); | 661 fDebugger.loadPicture(picture); |
| 739 | 662 |
| 740 fSkipCommands.setCount(fDebugger.getSize()); | 663 fSkipCommands.setCount(fDebugger.getSize()); |
| 741 for (int i = 0; i < fSkipCommands.count(); ++i) { | 664 for (int i = 0; i < fSkipCommands.count(); ++i) { |
| 742 fSkipCommands[i] = false; | 665 fSkipCommands[i] = false; |
| 743 } | 666 } |
| 744 | 667 |
| 745 SkSafeUnref(picture); | 668 SkSafeUnref(picture); |
| 746 | 669 |
| 747 fActionProfile.setDisabled(false); | |
| 748 | |
| 749 /* fDebugCanvas is reinitialized every load picture. Need it to retain value | 670 /* fDebugCanvas is reinitialized every load picture. Need it to retain value |
| 750 * of the visibility filter. | 671 * of the visibility filter. |
| 751 * TODO(chudy): This should be deprecated since fDebugger is not | 672 * TODO(chudy): This should be deprecated since fDebugger is not |
| 752 * recreated. | 673 * recreated. |
| 753 * */ | 674 * */ |
| 754 fDebugger.highlightCurrentCommand(fSettingsWidget.isVisibilityFilterEnabled(
)); | 675 fDebugger.highlightCurrentCommand(fSettingsWidget.isVisibilityFilterEnabled(
)); |
| 755 | 676 |
| 756 this->setupListWidget(); | 677 this->setupListWidget(); |
| 757 this->setupComboBox(); | 678 this->setupComboBox(); |
| 758 this->setupOverviewText(nullptr, 0.0, 1); | 679 this->setupOverviewText(nullptr, 0.0, 1); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 fCanvasWidget.drawTo(fPausedRow); | 771 fCanvasWidget.drawTo(fPausedRow); |
| 851 } else { | 772 } else { |
| 852 fCanvasWidget.drawTo(fListWidget.currentRow()); | 773 fCanvasWidget.drawTo(fListWidget.currentRow()); |
| 853 } | 774 } |
| 854 } | 775 } |
| 855 | 776 |
| 856 void SkDebuggerGUI::updateHit(int newHit) { | 777 void SkDebuggerGUI::updateHit(int newHit) { |
| 857 fCommandHitBox.setText(QString::number(newHit)); | 778 fCommandHitBox.setText(QString::number(newHit)); |
| 858 } | 779 } |
| 859 | 780 |
| OLD | NEW |