chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 8 | #include "SkDebuggerGUI.h" |
fmalita | 3f0424f | 2015-11-02 09:32:54 -0800 | [diff] [blame] | 9 | #include "SkPicture.h" |
kkinnunen | cfdc0e3 | 2015-01-13 22:49:02 -0800 | [diff] [blame] | 10 | #include <QListWidgetItem> |
| 11 | #include <QtGui> |
robertphillips | 3e5c2b1 | 2015-03-23 05:46:51 -0700 | [diff] [blame] | 12 | #include "sk_tool_utils.h" |
robertphillips@google.com | e174a8b | 2012-11-27 16:04:42 +0000 | [diff] [blame] | 13 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 14 | SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 15 | QMainWindow(parent) |
commit-bot@chromium.org | bcd431e | 2013-11-21 13:41:37 +0000 | [diff] [blame] | 16 | , fCentralSplitter(this) |
chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 17 | , fStatusBar(this) |
| 18 | , fToolBar(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 19 | , fActionOpen(this) |
| 20 | , fActionBreakpoint(this) |
| 21 | , fActionCancel(this) |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 22 | , fActionClearBreakpoints(this) |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 23 | , fActionClearDeletes(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 24 | , fActionClose(this) |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 25 | , fActionCreateBreakpoint(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 26 | , fActionDelete(this) |
| 27 | , fActionDirectory(this) |
| 28 | , fActionGoToLine(this) |
| 29 | , fActionInspector(this) |
bungeman@google.com | 2ff6d1d | 2013-07-01 14:24:12 +0000 | [diff] [blame] | 30 | , fActionSettings(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 31 | , fActionPlay(this) |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 32 | , fActionPause(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 33 | , fActionRewind(this) |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 34 | , fActionSave(this) |
| 35 | , fActionSaveAs(this) |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 36 | , fActionShowDeletes(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 37 | , fActionStepBack(this) |
| 38 | , fActionStepForward(this) |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 39 | , fActionZoomIn(this) |
| 40 | , fActionZoomOut(this) |
| 41 | , fMapper(this) |
commit-bot@chromium.org | bcd431e | 2013-11-21 13:41:37 +0000 | [diff] [blame] | 42 | , fListWidget(&fCentralSplitter) |
| 43 | , fDirectoryWidget(&fCentralSplitter) |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 44 | , fCanvasWidget(this, &fDebugger) |
kkinnunen | 63a4702 | 2014-12-30 23:03:56 -0800 | [diff] [blame] | 45 | , fDrawCommandGeometryWidget(&fDebugger) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 46 | , fMenuBar(this) |
| 47 | , fMenuFile(this) |
| 48 | , fMenuNavigate(this) |
| 49 | , fMenuView(this) |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 50 | , fLoading(false) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 51 | { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 52 | setupUi(this); |
robertphillips@google.com | dd4b745 | 2013-01-22 19:38:46 +0000 | [diff] [blame] | 53 | fListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection); |
kkinnunen | 0cfeaf3 | 2015-01-07 07:33:46 -0800 | [diff] [blame] | 54 | connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, |
| 55 | SLOT(updateDrawCommandInfo())); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 56 | connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 57 | connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory())); |
| 58 | connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(loadFile(QListWidgetItem *))); |
djsollen | a745186 | 2015-11-18 13:00:21 -0800 | [diff] [blame] | 59 | connect(&fDirectoryWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(populateDirectoryWidget())); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 60 | connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 61 | connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(toggleBreakpoint())); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 62 | connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind())); |
| 63 | connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay())); |
| 64 | connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 65 | connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForward())); |
| 66 | connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoints())); |
| 67 | connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector())); |
bungeman@google.com | 2ff6d1d | 2013-07-01 14:24:12 +0000 | [diff] [blame] | 68 | connect(&fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 69 | connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QString))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 70 | connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel())); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 71 | connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints())); |
| 72 | connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes())); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 73 | connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose())); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 74 | #if SK_SUPPORT_GPU |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 75 | connect(&fSettingsWidget, SIGNAL(glSettingsChanged()), this, SLOT(actionGLSettingsChanged())); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 76 | #endif |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 77 | connect(&fSettingsWidget, SIGNAL(rasterSettingsChanged()), this, SLOT(actionRasterSettingsChanged())); |
| 78 | connect(&fSettingsWidget, SIGNAL(visualizationsChanged()), this, SLOT(actionVisualizationsChanged())); |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 79 | connect(&fSettingsWidget, SIGNAL(texFilterSettingsChanged()), this, SLOT(actionTextureFilter())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 80 | connect(&fActionPause, SIGNAL(toggled(bool)), this, SLOT(pauseDrawing(bool))); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 81 | connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint())); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 82 | connect(&fActionShowDeletes, SIGNAL(triggered()), this, SLOT(showDeletes())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 83 | connect(&fCanvasWidget, SIGNAL(hitChanged(int)), this, SLOT(selectCommand(int))); |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 84 | connect(&fCanvasWidget, SIGNAL(hitChanged(int)), this, SLOT(updateHit(int))); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 85 | connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this, SLOT(actionScale(float))); |
kkinnunen | 63a4702 | 2014-12-30 23:03:56 -0800 | [diff] [blame] | 86 | |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 87 | connect(&fActionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs())); |
| 88 | connect(&fActionSave, SIGNAL(triggered()), this, SLOT(actionSave())); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 89 | |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 90 | fMapper.setMapping(&fActionZoomIn, SkCanvasWidget::kIn_ZoomCommand); |
| 91 | fMapper.setMapping(&fActionZoomOut, SkCanvasWidget::kOut_ZoomCommand); |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 92 | |
| 93 | connect(&fActionZoomIn, SIGNAL(triggered()), &fMapper, SLOT(map())); |
| 94 | connect(&fActionZoomOut, SIGNAL(triggered()), &fMapper, SLOT(map())); |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 95 | connect(&fMapper, SIGNAL(mapped(int)), &fCanvasWidget, SLOT(zoom(int))); |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 96 | |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 97 | fViewStateFrame.setDisabled(true); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 98 | fInspectorWidget.setDisabled(true); |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 99 | fMenuEdit.setDisabled(true); |
| 100 | fMenuNavigate.setDisabled(true); |
| 101 | fMenuView.setDisabled(true); |
chudy@google.com | bbad34d | 2012-08-13 14:26:36 +0000 | [diff] [blame] | 102 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 103 | |
| 104 | void SkDebuggerGUI::actionBreakpoints() { |
kkinnunen | f3a9e99 | 2015-01-05 01:14:11 -0800 | [diff] [blame] | 105 | bool breakpointsActivated = fActionBreakpoint.isChecked(); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 106 | for (int row = 0; row < fListWidget.count(); row++) { |
| 107 | QListWidgetItem *item = fListWidget.item(row); |
kkinnunen | f3a9e99 | 2015-01-05 01:14:11 -0800 | [diff] [blame] | 108 | item->setHidden(item->checkState() == Qt::Unchecked && breakpointsActivated); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 109 | } |
| 110 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 111 | |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 112 | void SkDebuggerGUI::showDeletes() { |
kkinnunen | f3a9e99 | 2015-01-05 01:14:11 -0800 | [diff] [blame] | 113 | bool deletesActivated = fActionShowDeletes.isChecked(); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 114 | for (int row = 0; row < fListWidget.count(); row++) { |
| 115 | QListWidgetItem *item = fListWidget.item(row); |
kkinnunen | f3a9e99 | 2015-01-05 01:14:11 -0800 | [diff] [blame] | 116 | item->setHidden(fDebugger.isCommandVisible(row) && deletesActivated); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 117 | } |
| 118 | } |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 119 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 120 | void SkDebuggerGUI::actionCancel() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 121 | for (int row = 0; row < fListWidget.count(); row++) { |
| 122 | fListWidget.item(row)->setHidden(false); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 123 | } |
| 124 | } |
| 125 | |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 126 | void SkDebuggerGUI::actionClearBreakpoints() { |
| 127 | for (int row = 0; row < fListWidget.count(); row++) { |
| 128 | QListWidgetItem* item = fListWidget.item(row); |
| 129 | item->setCheckState(Qt::Unchecked); |
| 130 | item->setData(Qt::DecorationRole, |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 131 | QPixmap(":/blank.png")); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | |
| 135 | void SkDebuggerGUI::actionClearDeletes() { |
| 136 | for (int row = 0; row < fListWidget.count(); row++) { |
| 137 | QListWidgetItem* item = fListWidget.item(row); |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 138 | item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 139 | fDebugger.setCommandVisible(row, true); |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 140 | fSkipCommands[row] = false; |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 141 | } |
kkinnunen | cfdc0e3 | 2015-01-13 22:49:02 -0800 | [diff] [blame] | 142 | this->updateImage(); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 143 | } |
| 144 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 145 | void SkDebuggerGUI::actionClose() { |
| 146 | this->close(); |
| 147 | } |
| 148 | |
| 149 | void SkDebuggerGUI::actionDelete() { |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 150 | |
robertphillips@google.com | dd4b745 | 2013-01-22 19:38:46 +0000 | [diff] [blame] | 151 | for (int row = 0; row < fListWidget.count(); ++row) { |
| 152 | QListWidgetItem* item = fListWidget.item(row); |
| 153 | |
| 154 | if (!item->isSelected()) { |
| 155 | continue; |
| 156 | } |
| 157 | |
| 158 | if (fDebugger.isCommandVisible(row)) { |
| 159 | item->setData(Qt::UserRole + 2, QPixmap(":/delete.png")); |
| 160 | fDebugger.setCommandVisible(row, false); |
| 161 | fSkipCommands[row] = true; |
| 162 | } else { |
| 163 | item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); |
| 164 | fDebugger.setCommandVisible(row, true); |
| 165 | fSkipCommands[row] = false; |
| 166 | } |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 167 | } |
| 168 | |
kkinnunen | cfdc0e3 | 2015-01-13 22:49:02 -0800 | [diff] [blame] | 169 | this->updateImage(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 170 | } |
| 171 | |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 172 | #if SK_SUPPORT_GPU |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 173 | void SkDebuggerGUI::actionGLSettingsChanged() { |
commit-bot@chromium.org | fde1e7c | 2013-08-02 13:59:50 +0000 | [diff] [blame] | 174 | bool isToggled = fSettingsWidget.isGLActive(); |
| 175 | if (isToggled) { |
| 176 | fCanvasWidget.setGLSampleCount(fSettingsWidget.getGLSampleCount()); |
| 177 | } |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 178 | fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggled); |
| 179 | } |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 180 | #endif |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 181 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 182 | void SkDebuggerGUI::actionInspector() { |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 183 | bool newState = !fInspectorWidget.isHidden(); |
| 184 | |
| 185 | fInspectorWidget.setHidden(newState); |
| 186 | fViewStateFrame.setHidden(newState); |
kkinnunen | 63a4702 | 2014-12-30 23:03:56 -0800 | [diff] [blame] | 187 | fDrawCommandGeometryWidget.setHidden(newState); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | void SkDebuggerGUI::actionPlay() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 191 | for (int row = fListWidget.currentRow() + 1; row < fListWidget.count(); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 192 | row++) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 193 | QListWidgetItem *item = fListWidget.item(row); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 194 | if (item->checkState() == Qt::Checked) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 195 | fListWidget.setCurrentItem(item); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 196 | return; |
| 197 | } |
| 198 | } |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 199 | fListWidget.setCurrentRow(fListWidget.count() - 1); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 200 | } |
| 201 | |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 202 | void SkDebuggerGUI::actionRasterSettingsChanged() { |
| 203 | fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType, |
| 204 | !fSettingsWidget.isRasterEnabled()); |
kkinnunen | cfdc0e3 | 2015-01-13 22:49:02 -0800 | [diff] [blame] | 205 | this->updateImage(); |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 206 | } |
| 207 | |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 208 | void SkDebuggerGUI::actionVisualizationsChanged() { |
| 209 | fDebugger.setMegaViz(fSettingsWidget.isMegaVizEnabled()); |
| 210 | fDebugger.setPathOps(fSettingsWidget.isPathOpsEnabled()); |
| 211 | fDebugger.highlightCurrentCommand(fSettingsWidget.isVisibilityFilterEnabled()); |
robertphillips | f42fca4 | 2016-01-27 05:00:04 -0800 | [diff] [blame] | 212 | fDebugger.setOverdrawViz(fSettingsWidget.isOverdrawVizEnabled()); |
kkinnunen | cfdc0e3 | 2015-01-13 22:49:02 -0800 | [diff] [blame] | 213 | this->updateImage(); |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 214 | } |
| 215 | |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 216 | void SkDebuggerGUI::actionTextureFilter() { |
reed | e7903c7 | 2015-03-16 10:26:13 -0700 | [diff] [blame] | 217 | SkFilterQuality quality; |
| 218 | bool enabled = fSettingsWidget.getFilterOverride(&quality); |
| 219 | fDebugger.setTexFilterOverride(enabled, quality); |
robertphillips@google.com | 32bbcf8 | 2013-10-17 17:56:10 +0000 | [diff] [blame] | 220 | fCanvasWidget.update(); |
| 221 | } |
| 222 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 223 | void SkDebuggerGUI::actionRewind() { |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 224 | fListWidget.setCurrentRow(0); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 225 | } |
| 226 | |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 227 | void SkDebuggerGUI::actionSave() { |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 228 | fFileName = fPath.toAscii().data(); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 229 | fFileName.append("/"); |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 230 | fFileName.append(fDirectoryWidget.currentItem()->text().toAscii().data()); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 231 | saveToFile(fFileName); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | void SkDebuggerGUI::actionSaveAs() { |
| 235 | QString filename = QFileDialog::getSaveFileName(this, "Save File", "", |
| 236 | "Skia Picture (*skp)"); |
chudy@google.com | 38b08ce | 2012-07-28 23:26:10 +0000 | [diff] [blame] | 237 | if (!filename.endsWith(".skp", Qt::CaseInsensitive)) { |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 238 | filename.append(".skp"); |
| 239 | } |
djsollen@google.com | c3c8216 | 2012-11-13 18:35:10 +0000 | [diff] [blame] | 240 | saveToFile(SkString(filename.toAscii().data())); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 241 | } |
| 242 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 243 | void SkDebuggerGUI::actionScale(float scaleFactor) { |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 244 | fZoomBox.setText(QString::number(scaleFactor * 100, 'f', 0).append("%")); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 245 | } |
| 246 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 247 | void SkDebuggerGUI::actionSettings() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 248 | if (fSettingsWidget.isHidden()) { |
| 249 | fSettingsWidget.setHidden(false); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 250 | } else { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 251 | fSettingsWidget.setHidden(true); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 252 | } |
| 253 | } |
| 254 | |
| 255 | void SkDebuggerGUI::actionStepBack() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 256 | int currentRow = fListWidget.currentRow(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 257 | if (currentRow != 0) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 258 | fListWidget.setCurrentRow(currentRow - 1); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 259 | } |
| 260 | } |
| 261 | |
| 262 | void SkDebuggerGUI::actionStepForward() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 263 | int currentRow = fListWidget.currentRow(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 264 | QString curRow = QString::number(currentRow); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 265 | QString curCount = QString::number(fListWidget.count()); |
| 266 | if (currentRow < fListWidget.count() - 1) { |
| 267 | fListWidget.setCurrentRow(currentRow + 1); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 271 | void SkDebuggerGUI::drawComplete() { |
kkinnunen | cfdc0e3 | 2015-01-13 22:49:02 -0800 | [diff] [blame] | 272 | SkString clipStack; |
| 273 | fDebugger.getClipStackText(&clipStack); |
| 274 | fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_TabType); |
| 275 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 276 | fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix()); |
| 277 | fInspectorWidget.setClip(fDebugger.getCurrentClip()); |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 278 | } |
| 279 | |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 280 | void SkDebuggerGUI::saveToFile(const SkString& filename) { |
| 281 | SkFILEWStream file(filename.c_str()); |
Mike Reed | ef03848 | 2017-12-16 08:41:28 -0500 | [diff] [blame] | 282 | fDebugger.copyPicture()->serialize(&file); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 283 | } |
| 284 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 285 | void SkDebuggerGUI::loadFile(QListWidgetItem *item) { |
djsollen | a745186 | 2015-11-18 13:00:21 -0800 | [diff] [blame] | 286 | if (item == nullptr) { |
| 287 | return; |
| 288 | } |
| 289 | |
| 290 | SkString fileName(fPath.toAscii().data()); |
| 291 | // don't add a '/' to files in the local directory |
| 292 | if (fileName.size() > 0) { |
| 293 | fileName.append("/"); |
| 294 | } |
| 295 | fileName.append(item->text().toAscii().data()); |
| 296 | |
| 297 | if (!fileName.equals(fFileName)) { |
| 298 | fFileName = fileName; |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 299 | loadPicture(fFileName); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | |
| 303 | void SkDebuggerGUI::openFile() { |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 304 | QString temp = QFileDialog::getOpenFileName(this, tr("Open File"), "", |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 305 | tr("Files (*.*)")); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 306 | openFile(temp); |
| 307 | } |
| 308 | |
| 309 | void SkDebuggerGUI::openFile(const QString &filename) { |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 310 | if (!filename.isEmpty()) { |
| 311 | QFileInfo pathInfo(filename); |
| 312 | loadPicture(SkString(filename.toAscii().data())); |
| 313 | setupDirectoryWidget(pathInfo.path()); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 314 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 315 | } |
| 316 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 317 | void SkDebuggerGUI::pauseDrawing(bool isPaused) { |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 318 | fPausedRow = fListWidget.currentRow(); |
kkinnunen | cfdc0e3 | 2015-01-13 22:49:02 -0800 | [diff] [blame] | 319 | this->updateDrawCommandInfo(); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 320 | } |
| 321 | |
kkinnunen | 0cfeaf3 | 2015-01-07 07:33:46 -0800 | [diff] [blame] | 322 | void SkDebuggerGUI::updateDrawCommandInfo() { |
| 323 | int currentRow = -1; |
| 324 | if (!fLoading) { |
| 325 | currentRow = fListWidget.currentRow(); |
| 326 | } |
| 327 | if (currentRow == -1) { |
| 328 | fInspectorWidget.setText("", SkInspectorWidget::kDetail_TabType); |
| 329 | fInspectorWidget.setText("", SkInspectorWidget::kClipStack_TabType); |
| 330 | fCurrentCommandBox.setText(""); |
| 331 | fDrawCommandGeometryWidget.setDrawCommandIndex(-1); |
| 332 | } else { |
kkinnunen | cfdc0e3 | 2015-01-13 22:49:02 -0800 | [diff] [blame] | 333 | this->updateImage(); |
| 334 | |
kkinnunen | 0cfeaf3 | 2015-01-07 07:33:46 -0800 | [diff] [blame] | 335 | const SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(currentRow); |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 336 | |
kkinnunen | 0cfeaf3 | 2015-01-07 07:33:46 -0800 | [diff] [blame] | 337 | /* TODO(chudy): Add command type before parameters. Rename v |
| 338 | * to something more informative. */ |
| 339 | if (currInfo) { |
| 340 | QString info; |
| 341 | info.append("<b>Parameters: </b><br/>"); |
| 342 | for (int i = 0; i < currInfo->count(); i++) { |
| 343 | info.append(QString((*currInfo)[i]->c_str())); |
| 344 | info.append("<br/>"); |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 345 | } |
kkinnunen | 0cfeaf3 | 2015-01-07 07:33:46 -0800 | [diff] [blame] | 346 | fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType); |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 347 | } |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 348 | |
kkinnunen | 0cfeaf3 | 2015-01-07 07:33:46 -0800 | [diff] [blame] | 349 | fCurrentCommandBox.setText(QString::number(currentRow)); |
| 350 | |
| 351 | fDrawCommandGeometryWidget.setDrawCommandIndex(currentRow); |
| 352 | |
| 353 | fInspectorWidget.setDisabled(false); |
| 354 | fViewStateFrame.setDisabled(false); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 355 | } |
| 356 | } |
| 357 | |
chudy@google.com | 9ca9bfe | 2012-07-12 21:58:14 +0000 | [diff] [blame] | 358 | void SkDebuggerGUI::selectCommand(int command) { |
kkinnunen | f3a9e99 | 2015-01-05 01:14:11 -0800 | [diff] [blame] | 359 | if (this->isPaused()) { |
chudy@google.com | 9ca9bfe | 2012-07-12 21:58:14 +0000 | [diff] [blame] | 360 | fListWidget.setCurrentRow(command); |
| 361 | } |
| 362 | } |
| 363 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 364 | void SkDebuggerGUI::toggleBreakpoint() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 365 | QListWidgetItem* item = fListWidget.currentItem(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 366 | if (item->checkState() == Qt::Unchecked) { |
| 367 | item->setCheckState(Qt::Checked); |
chudy@google.com | e565de4 | 2012-07-12 14:15:54 +0000 | [diff] [blame] | 368 | item->setData(Qt::DecorationRole, |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 369 | QPixmap(":/breakpoint_16x16.png")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 370 | } else { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 371 | item->setCheckState(Qt::Unchecked); |
chudy@google.com | e565de4 | 2012-07-12 14:15:54 +0000 | [diff] [blame] | 372 | item->setData(Qt::DecorationRole, |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 373 | QPixmap(":/blank.png")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 374 | } |
| 375 | } |
| 376 | |
| 377 | void SkDebuggerGUI::toggleDirectory() { |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 378 | fDirectoryWidget.setHidden(!fDirectoryWidget.isHidden()); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | void SkDebuggerGUI::toggleFilter(QString string) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 382 | for (int row = 0; row < fListWidget.count(); row++) { |
| 383 | QListWidgetItem *item = fListWidget.item(row); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 384 | item->setHidden(item->text() != string); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 385 | } |
| 386 | } |
| 387 | |
| 388 | void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) { |
| 389 | QIcon windowIcon; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 390 | windowIcon.addFile(QString::fromUtf8(":/skia.png"), QSize(), |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 391 | QIcon::Normal, QIcon::Off); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 392 | SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI")); |
| 393 | SkDebuggerGUI->resize(1200, 1000); |
| 394 | SkDebuggerGUI->setWindowIcon(windowIcon); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 395 | SkDebuggerGUI->setWindowTitle("Skia Debugger"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 396 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 397 | fActionOpen.setShortcuts(QKeySequence::Open); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 398 | fActionOpen.setText("Open"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 399 | |
| 400 | QIcon breakpoint; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 401 | breakpoint.addFile(QString::fromUtf8(":/breakpoint.png"), |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 402 | QSize(), QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 403 | fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 404 | fActionBreakpoint.setIcon(breakpoint); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 405 | fActionBreakpoint.setText("Breakpoints"); |
kkinnunen | f3a9e99 | 2015-01-05 01:14:11 -0800 | [diff] [blame] | 406 | fActionBreakpoint.setCheckable(true); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 407 | |
| 408 | QIcon cancel; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 409 | cancel.addFile(QString::fromUtf8(":/reload.png"), QSize(), |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 410 | QIcon::Normal, QIcon::Off); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 411 | fActionCancel.setIcon(cancel); |
| 412 | fActionCancel.setText("Clear Filter"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 413 | |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 414 | fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B"))); |
| 415 | fActionClearBreakpoints.setText("Clear Breakpoints"); |
| 416 | |
| 417 | fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X"))); |
| 418 | fActionClearDeletes.setText("Clear Deletes"); |
| 419 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 420 | fActionClose.setShortcuts(QKeySequence::Quit); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 421 | fActionClose.setText("Exit"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 422 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 423 | fActionCreateBreakpoint.setShortcut(QKeySequence(tr("B"))); |
| 424 | fActionCreateBreakpoint.setText("Set Breakpoint"); |
| 425 | |
| 426 | fActionDelete.setShortcut(QKeySequence(tr("X"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 427 | fActionDelete.setText("Delete Command"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 428 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 429 | fActionDirectory.setShortcut(QKeySequence(tr("Ctrl+D"))); |
| 430 | fActionDirectory.setText("Directory"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 431 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 432 | QIcon inspector; |
robertphillips@google.com | d163636 | 2012-11-19 18:25:09 +0000 | [diff] [blame] | 433 | inspector.addFile(QString::fromUtf8(":/inspector.png"), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 434 | QSize(), QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 435 | fActionInspector.setShortcut(QKeySequence(tr("Ctrl+I"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 436 | fActionInspector.setIcon(inspector); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 437 | fActionInspector.setText("Inspector"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 438 | |
bungeman@google.com | 2ff6d1d | 2013-07-01 14:24:12 +0000 | [diff] [blame] | 439 | QIcon settings; |
| 440 | settings.addFile(QString::fromUtf8(":/inspector.png"), |
| 441 | QSize(), QIcon::Normal, QIcon::Off); |
| 442 | fActionSettings.setShortcut(QKeySequence(tr("Ctrl+G"))); |
| 443 | fActionSettings.setIcon(settings); |
| 444 | fActionSettings.setText("Settings"); |
skia.committer@gmail.com | 0d55dd7 | 2013-07-02 07:00:59 +0000 | [diff] [blame] | 445 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 446 | QIcon play; |
robertphillips@google.com | d163636 | 2012-11-19 18:25:09 +0000 | [diff] [blame] | 447 | play.addFile(QString::fromUtf8(":/play.png"), QSize(), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 448 | QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 449 | fActionPlay.setShortcut(QKeySequence(tr("Ctrl+P"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 450 | fActionPlay.setIcon(play); |
| 451 | fActionPlay.setText("Play"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 452 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 453 | QIcon pause; |
robertphillips@google.com | d163636 | 2012-11-19 18:25:09 +0000 | [diff] [blame] | 454 | pause.addFile(QString::fromUtf8(":/pause.png"), QSize(), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 455 | QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 456 | fActionPause.setShortcut(QKeySequence(tr("Space"))); |
| 457 | fActionPause.setCheckable(true); |
| 458 | fActionPause.setIcon(pause); |
| 459 | fActionPause.setText("Pause"); |
| 460 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 461 | QIcon rewind; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 462 | rewind.addFile(QString::fromUtf8(":/rewind.png"), QSize(), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 463 | QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 464 | fActionRewind.setShortcut(QKeySequence(tr("Ctrl+R"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 465 | fActionRewind.setIcon(rewind); |
| 466 | fActionRewind.setText("Rewind"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 467 | |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 468 | fActionSave.setShortcut(QKeySequence::Save); |
| 469 | fActionSave.setText("Save"); |
| 470 | fActionSave.setDisabled(true); |
| 471 | fActionSaveAs.setShortcut(QKeySequence::SaveAs); |
| 472 | fActionSaveAs.setText("Save As"); |
| 473 | fActionSaveAs.setDisabled(true); |
| 474 | |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 475 | fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X"))); |
| 476 | fActionShowDeletes.setText("Deleted Commands"); |
kkinnunen | f3a9e99 | 2015-01-05 01:14:11 -0800 | [diff] [blame] | 477 | fActionShowDeletes.setCheckable(true); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 478 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 479 | QIcon stepBack; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 480 | stepBack.addFile(QString::fromUtf8(":/previous.png"), QSize(), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 481 | QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 482 | fActionStepBack.setShortcut(QKeySequence(tr("["))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 483 | fActionStepBack.setIcon(stepBack); |
| 484 | fActionStepBack.setText("Step Back"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 485 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 486 | QIcon stepForward; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 487 | stepForward.addFile(QString::fromUtf8(":/next.png"), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 488 | QSize(), QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 489 | fActionStepForward.setShortcut(QKeySequence(tr("]"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 490 | fActionStepForward.setIcon(stepForward); |
| 491 | fActionStepForward.setText("Step Forward"); |
| 492 | |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 493 | fActionZoomIn.setShortcut(QKeySequence(tr("Ctrl+="))); |
| 494 | fActionZoomIn.setText("Zoom In"); |
| 495 | fActionZoomOut.setShortcut(QKeySequence(tr("Ctrl+-"))); |
| 496 | fActionZoomOut.setText("Zoom Out"); |
| 497 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 498 | fListWidget.setItemDelegate(new SkListWidget(&fListWidget)); |
| 499 | fListWidget.setObjectName(QString::fromUtf8("listWidget")); |
commit-bot@chromium.org | bcd431e | 2013-11-21 13:41:37 +0000 | [diff] [blame] | 500 | fListWidget.setMinimumWidth(250); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 501 | |
| 502 | fFilter.addItem("--Filter By Available Commands--"); |
| 503 | |
commit-bot@chromium.org | bcd431e | 2013-11-21 13:41:37 +0000 | [diff] [blame] | 504 | fDirectoryWidget.setMinimumWidth(250); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 505 | fDirectoryWidget.setStyleSheet("QListWidget::Item {padding: 5px;}"); |
| 506 | |
| 507 | fCanvasWidget.setSizePolicy(QSizePolicy::Expanding, |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 508 | QSizePolicy::Expanding); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 509 | |
kkinnunen | 63a4702 | 2014-12-30 23:03:56 -0800 | [diff] [blame] | 510 | fDrawCommandGeometryWidget.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 511 | |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 512 | fSettingsAndImageLayout.addWidget(&fSettingsWidget); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 513 | |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 514 | // View state group, part of inspector. |
| 515 | fViewStateFrame.setFrameStyle(QFrame::Panel); |
| 516 | fViewStateFrame.setLayout(&fViewStateFrameLayout); |
| 517 | fViewStateFrameLayout.addWidget(&fViewStateGroup); |
kkinnunen | 63a4702 | 2014-12-30 23:03:56 -0800 | [diff] [blame] | 518 | fViewStateGroup.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 519 | fViewStateGroup.setTitle("View"); |
| 520 | fViewStateLayout.addRow("Zoom Level", &fZoomBox); |
| 521 | fZoomBox.setText("100%"); |
| 522 | fZoomBox.setMinimumSize(QSize(50,25)); |
| 523 | fZoomBox.setMaximumSize(QSize(50,25)); |
| 524 | fZoomBox.setAlignment(Qt::AlignRight); |
| 525 | fZoomBox.setReadOnly(true); |
| 526 | fViewStateLayout.addRow("Command HitBox", &fCommandHitBox); |
| 527 | fCommandHitBox.setText("0"); |
| 528 | fCommandHitBox.setMinimumSize(QSize(50,25)); |
| 529 | fCommandHitBox.setMaximumSize(QSize(50,25)); |
| 530 | fCommandHitBox.setAlignment(Qt::AlignRight); |
| 531 | fCommandHitBox.setReadOnly(true); |
| 532 | fViewStateLayout.addRow("Current Command", &fCurrentCommandBox); |
| 533 | fCurrentCommandBox.setText("0"); |
| 534 | fCurrentCommandBox.setMinimumSize(QSize(50,25)); |
| 535 | fCurrentCommandBox.setMaximumSize(QSize(50,25)); |
| 536 | fCurrentCommandBox.setAlignment(Qt::AlignRight); |
| 537 | fCurrentCommandBox.setReadOnly(true); |
| 538 | fViewStateGroup.setLayout(&fViewStateLayout); |
| 539 | fSettingsAndImageLayout.addWidget(&fViewStateFrame); |
| 540 | |
kkinnunen | 63a4702 | 2014-12-30 23:03:56 -0800 | [diff] [blame] | 541 | fDrawCommandGeometryWidget.setToolTip("Current Command Geometry"); |
| 542 | fSettingsAndImageLayout.addWidget(&fDrawCommandGeometryWidget); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 543 | |
commit-bot@chromium.org | bcd431e | 2013-11-21 13:41:37 +0000 | [diff] [blame] | 544 | fLeftColumnSplitter.addWidget(&fListWidget); |
| 545 | fLeftColumnSplitter.addWidget(&fDirectoryWidget); |
| 546 | fLeftColumnSplitter.setOrientation(Qt::Vertical); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 547 | |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 548 | fCanvasSettingsAndImageLayout.setSpacing(6); |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 549 | fCanvasSettingsAndImageLayout.addWidget(&fCanvasWidget, 1); |
| 550 | fCanvasSettingsAndImageLayout.addLayout(&fSettingsAndImageLayout, 0); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 551 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 552 | fMainAndRightColumnLayout.setSpacing(6); |
kkinnunen | 7c339ae | 2015-01-02 06:35:43 -0800 | [diff] [blame] | 553 | fMainAndRightColumnLayout.addLayout(&fCanvasSettingsAndImageLayout, 1); |
| 554 | fMainAndRightColumnLayout.addWidget(&fInspectorWidget, 0); |
commit-bot@chromium.org | bcd431e | 2013-11-21 13:41:37 +0000 | [diff] [blame] | 555 | fMainAndRightColumnWidget.setLayout(&fMainAndRightColumnLayout); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 556 | |
commit-bot@chromium.org | bcd431e | 2013-11-21 13:41:37 +0000 | [diff] [blame] | 557 | fCentralSplitter.addWidget(&fLeftColumnSplitter); |
| 558 | fCentralSplitter.addWidget(&fMainAndRightColumnWidget); |
| 559 | fCentralSplitter.setStretchFactor(0, 0); |
| 560 | fCentralSplitter.setStretchFactor(1, 1); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 561 | |
commit-bot@chromium.org | bcd431e | 2013-11-21 13:41:37 +0000 | [diff] [blame] | 562 | SkDebuggerGUI->setCentralWidget(&fCentralSplitter); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 563 | SkDebuggerGUI->setStatusBar(&fStatusBar); |
| 564 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 565 | fToolBar.setIconSize(QSize(32, 32)); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 566 | fToolBar.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); |
| 567 | SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, &fToolBar); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 568 | |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 569 | fSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 570 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 571 | fToolBar.addAction(&fActionRewind); |
| 572 | fToolBar.addAction(&fActionStepBack); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 573 | fToolBar.addAction(&fActionPause); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 574 | fToolBar.addAction(&fActionStepForward); |
| 575 | fToolBar.addAction(&fActionPlay); |
| 576 | fToolBar.addSeparator(); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 577 | fToolBar.addAction(&fActionInspector); |
bungeman@google.com | 2ff6d1d | 2013-07-01 14:24:12 +0000 | [diff] [blame] | 578 | fToolBar.addAction(&fActionSettings); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 579 | |
| 580 | fToolBar.addSeparator(); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 581 | fToolBar.addWidget(&fSpacer); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 582 | fToolBar.addWidget(&fFilter); |
| 583 | fToolBar.addAction(&fActionCancel); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 584 | |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 585 | fFileName = ""; |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 586 | setupDirectoryWidget(""); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 587 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 588 | // Menu Bar |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 589 | fMenuFile.setTitle("File"); |
| 590 | fMenuFile.addAction(&fActionOpen); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 591 | fMenuFile.addAction(&fActionSave); |
| 592 | fMenuFile.addAction(&fActionSaveAs); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 593 | fMenuFile.addAction(&fActionClose); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 594 | |
| 595 | fMenuEdit.setTitle("Edit"); |
| 596 | fMenuEdit.addAction(&fActionDelete); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 597 | fMenuEdit.addAction(&fActionClearDeletes); |
| 598 | fMenuEdit.addSeparator(); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 599 | fMenuEdit.addAction(&fActionCreateBreakpoint); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 600 | fMenuEdit.addAction(&fActionClearBreakpoints); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 601 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 602 | fMenuNavigate.setTitle("Navigate"); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 603 | fMenuNavigate.addAction(&fActionRewind); |
| 604 | fMenuNavigate.addAction(&fActionStepBack); |
| 605 | fMenuNavigate.addAction(&fActionStepForward); |
| 606 | fMenuNavigate.addAction(&fActionPlay); |
| 607 | fMenuNavigate.addAction(&fActionPause); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 608 | fMenuNavigate.addAction(&fActionGoToLine); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 609 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 610 | fMenuView.setTitle("View"); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 611 | fMenuView.addAction(&fActionBreakpoint); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 612 | fMenuView.addAction(&fActionShowDeletes); |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 613 | fMenuView.addAction(&fActionZoomIn); |
| 614 | fMenuView.addAction(&fActionZoomOut); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 615 | |
| 616 | fMenuWindows.setTitle("Window"); |
| 617 | fMenuWindows.addAction(&fActionInspector); |
bungeman@google.com | 2ff6d1d | 2013-07-01 14:24:12 +0000 | [diff] [blame] | 618 | fMenuWindows.addAction(&fActionSettings); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 619 | fMenuWindows.addAction(&fActionDirectory); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 620 | |
| 621 | fActionGoToLine.setText("Go to Line..."); |
| 622 | fActionGoToLine.setDisabled(true); |
| 623 | fMenuBar.addAction(fMenuFile.menuAction()); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 624 | fMenuBar.addAction(fMenuEdit.menuAction()); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 625 | fMenuBar.addAction(fMenuView.menuAction()); |
| 626 | fMenuBar.addAction(fMenuNavigate.menuAction()); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 627 | fMenuBar.addAction(fMenuWindows.menuAction()); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 628 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 629 | SkDebuggerGUI->setMenuBar(&fMenuBar); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 630 | QMetaObject::connectSlotsByName(SkDebuggerGUI); |
| 631 | } |
| 632 | |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 633 | void SkDebuggerGUI::setupDirectoryWidget(const QString& path) { |
| 634 | fPath = path; |
djsollen | a745186 | 2015-11-18 13:00:21 -0800 | [diff] [blame] | 635 | populateDirectoryWidget(); |
| 636 | |
| 637 | // clear the existing watched directory and setup a new directory to watch |
| 638 | if (!fDirectoryWatcher.directories().empty()) { |
| 639 | fDirectoryWatcher.removePaths(fDirectoryWatcher.directories()); |
| 640 | } |
| 641 | if (!path.isEmpty()) { |
| 642 | fDirectoryWatcher.addPath(fPath); |
| 643 | } |
| 644 | } |
| 645 | |
| 646 | void SkDebuggerGUI::populateDirectoryWidget() { |
| 647 | QDir dir(fPath); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 648 | QRegExp r(".skp"); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 649 | const QStringList files = dir.entryList(); |
djsollen | a745186 | 2015-11-18 13:00:21 -0800 | [diff] [blame] | 650 | |
| 651 | // check if a file has been removed |
| 652 | for (int i = fDirectoryWidget.count() - 1; i >= 0; i--) { |
| 653 | QListWidgetItem* item = fDirectoryWidget.item(i); |
| 654 | if (!files.contains(item->text())) { |
| 655 | fDirectoryWidget.removeItemWidget(item); |
| 656 | delete item; |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | // add any new files |
robertphillips | 9ea8acd | 2016-03-01 09:34:38 -0800 | [diff] [blame] | 661 | Q_FOREACH (QString f, files) { |
djsollen | a745186 | 2015-11-18 13:00:21 -0800 | [diff] [blame] | 662 | if (f.contains(r) && fDirectoryWidget.findItems(f, Qt::MatchExactly).size() == 0) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 663 | fDirectoryWidget.addItem(f); |
djsollen | a745186 | 2015-11-18 13:00:21 -0800 | [diff] [blame] | 664 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 665 | } |
| 666 | } |
| 667 | |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 668 | void SkDebuggerGUI::loadPicture(const SkString& fileName) { |
| 669 | fFileName = fileName; |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 670 | fLoading = true; |
Florin Malita | f530586 | 2016-11-15 10:03:32 -0500 | [diff] [blame] | 671 | SkFILEStream stream(fileName.c_str()); |
robertphillips@google.com | 2d40ec4 | 2013-02-07 20:39:40 +0000 | [diff] [blame] | 672 | |
Florin Malita | f530586 | 2016-11-15 10:03:32 -0500 | [diff] [blame] | 673 | auto picture = SkPicture::MakeFromStream(&stream); |
robertphillips@google.com | 2d40ec4 | 2013-02-07 20:39:40 +0000 | [diff] [blame] | 674 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 675 | if (nullptr == picture) { |
robertphillips@google.com | 2d40ec4 | 2013-02-07 20:39:40 +0000 | [diff] [blame] | 676 | QMessageBox::critical(this, "Error loading file", "Couldn't read file, sorry."); |
robertphillips@google.com | 2d40ec4 | 2013-02-07 20:39:40 +0000 | [diff] [blame] | 677 | return; |
| 678 | } |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 679 | |
chudy@google.com | 686e680 | 2012-08-14 16:00:32 +0000 | [diff] [blame] | 680 | fCanvasWidget.resetWidgetTransform(); |
reed | ca2622b | 2016-03-18 07:25:55 -0700 | [diff] [blame] | 681 | fDebugger.loadPicture(picture.get()); |
chudy@google.com | 4c7962e | 2012-08-14 19:38:31 +0000 | [diff] [blame] | 682 | |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 683 | fSkipCommands.setCount(fDebugger.getSize()); |
| 684 | for (int i = 0; i < fSkipCommands.count(); ++i) { |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 685 | fSkipCommands[i] = false; |
| 686 | } |
| 687 | |
reed | ca2622b | 2016-03-18 07:25:55 -0700 | [diff] [blame] | 688 | picture.reset(); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 689 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 690 | /* fDebugCanvas is reinitialized every load picture. Need it to retain value |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 691 | * of the visibility filter. |
| 692 | * TODO(chudy): This should be deprecated since fDebugger is not |
| 693 | * recreated. |
| 694 | * */ |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 695 | fDebugger.highlightCurrentCommand(fSettingsWidget.isVisibilityFilterEnabled()); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 696 | |
kkinnunen | 5037e9d | 2014-12-30 07:22:58 -0800 | [diff] [blame] | 697 | this->setupListWidget(); |
| 698 | this->setupComboBox(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 699 | this->setupOverviewText(nullptr, 0.0, 1); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 700 | fInspectorWidget.setDisabled(false); |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 701 | fViewStateFrame.setDisabled(false); |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 702 | fSettingsWidget.setDisabled(false); |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 703 | fMenuEdit.setDisabled(false); |
| 704 | fMenuNavigate.setDisabled(false); |
| 705 | fMenuView.setDisabled(false); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 706 | fActionSave.setDisabled(false); |
| 707 | fActionSaveAs.setDisabled(false); |
kkinnunen | f3a9e99 | 2015-01-05 01:14:11 -0800 | [diff] [blame] | 708 | fActionPause.setChecked(false); |
kkinnunen | 0cfeaf3 | 2015-01-07 07:33:46 -0800 | [diff] [blame] | 709 | fDrawCommandGeometryWidget.setDrawCommandIndex(-1); |
| 710 | |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 711 | fLoading = false; |
| 712 | actionPlay(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 713 | } |
| 714 | |
kkinnunen | 5037e9d | 2014-12-30 07:22:58 -0800 | [diff] [blame] | 715 | void SkDebuggerGUI::setupListWidget() { |
robertphillips | 546db46 | 2015-03-26 10:08:04 -0700 | [diff] [blame] | 716 | |
| 717 | SkASSERT(!strcmp("Save", |
| 718 | SkDrawCommand::GetCommandString(SkDrawCommand::kSave_OpType))); |
| 719 | SkASSERT(!strcmp("SaveLayer", |
| 720 | SkDrawCommand::GetCommandString(SkDrawCommand::kSaveLayer_OpType))); |
| 721 | SkASSERT(!strcmp("Restore", |
| 722 | SkDrawCommand::GetCommandString(SkDrawCommand::kRestore_OpType))); |
fmalita | 160ebb2 | 2015-04-01 20:58:37 -0700 | [diff] [blame] | 723 | SkASSERT(!strcmp("BeginDrawPicture", |
| 724 | SkDrawCommand::GetCommandString(SkDrawCommand::kBeginDrawPicture_OpType))); |
| 725 | SkASSERT(!strcmp("EndDrawPicture", |
| 726 | SkDrawCommand::GetCommandString(SkDrawCommand::kEndDrawPicture_OpType))); |
robertphillips | 546db46 | 2015-03-26 10:08:04 -0700 | [diff] [blame] | 727 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 728 | fListWidget.clear(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 729 | int counter = 0; |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame] | 730 | int indent = 0; |
kkinnunen | 5037e9d | 2014-12-30 07:22:58 -0800 | [diff] [blame] | 731 | for (int i = 0; i < fDebugger.getSize(); i++) { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 732 | QListWidgetItem *item = new QListWidgetItem(); |
kkinnunen | 5037e9d | 2014-12-30 07:22:58 -0800 | [diff] [blame] | 733 | SkDrawCommand* command = fDebugger.getDrawCommandAt(i); |
| 734 | SkString commandString = command->toString(); |
| 735 | item->setData(Qt::DisplayRole, commandString.c_str()); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 736 | item->setData(Qt::UserRole + 1, counter++); |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame] | 737 | |
kkinnunen | 5037e9d | 2014-12-30 07:22:58 -0800 | [diff] [blame] | 738 | if (0 == strcmp("Restore", commandString.c_str()) || |
fmalita | 160ebb2 | 2015-04-01 20:58:37 -0700 | [diff] [blame] | 739 | 0 == strcmp("EndDrawPicture", commandString.c_str())) { |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame] | 740 | indent -= 10; |
| 741 | } |
| 742 | |
| 743 | item->setData(Qt::UserRole + 3, indent); |
| 744 | |
kkinnunen | 5037e9d | 2014-12-30 07:22:58 -0800 | [diff] [blame] | 745 | if (0 == strcmp("Save", commandString.c_str()) || |
robertphillips | 546db46 | 2015-03-26 10:08:04 -0700 | [diff] [blame] | 746 | 0 == strcmp("SaveLayer", commandString.c_str()) || |
fmalita | 160ebb2 | 2015-04-01 20:58:37 -0700 | [diff] [blame] | 747 | 0 == strcmp("BeginDrawPicture", commandString.c_str())) { |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame] | 748 | indent += 10; |
| 749 | } |
| 750 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 751 | item->setData(Qt::UserRole + 4, -1); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 752 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 753 | fListWidget.addItem(item); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 754 | } |
| 755 | } |
| 756 | |
skia.committer@gmail.com | 91274b9 | 2013-03-13 07:01:04 +0000 | [diff] [blame] | 757 | void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes, |
robertphillips@google.com | e428f9b | 2013-03-12 15:33:40 +0000 | [diff] [blame] | 758 | double totTime, |
| 759 | int numRuns) { |
borenet@google.com | 2d9dbd4 | 2013-03-12 13:07:40 +0000 | [diff] [blame] | 760 | SkString overview; |
robertphillips@google.com | e428f9b | 2013-03-12 15:33:40 +0000 | [diff] [blame] | 761 | fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns); |
borenet@google.com | 2d9dbd4 | 2013-03-12 13:07:40 +0000 | [diff] [blame] | 762 | fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabType); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 763 | } |
| 764 | |
commit-bot@chromium.org | 2a67e12 | 2014-05-19 13:53:10 +0000 | [diff] [blame] | 765 | |
kkinnunen | 5037e9d | 2014-12-30 07:22:58 -0800 | [diff] [blame] | 766 | void SkDebuggerGUI::setupComboBox() { |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 767 | fFilter.clear(); |
| 768 | fFilter.addItem("--Filter By Available Commands--"); |
| 769 | |
| 770 | std::map<std::string, int> map; |
kkinnunen | 5037e9d | 2014-12-30 07:22:58 -0800 | [diff] [blame] | 771 | for (int i = 0; i < fDebugger.getSize(); i++) { |
| 772 | map[fDebugger.getDrawCommandAt(i)->toString().c_str()]++; |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 773 | } |
| 774 | |
skia.committer@gmail.com | 3458716 | 2012-11-20 02:01:23 +0000 | [diff] [blame] | 775 | for (std::map<std::string, int>::iterator it = map.begin(); it != map.end(); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 776 | ++it) { |
| 777 | fFilter.addItem((it->first).c_str()); |
| 778 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 779 | |
| 780 | // NOTE(chudy): Makes first item unselectable. |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 781 | QStandardItemModel* model = qobject_cast<QStandardItemModel*>( |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 782 | fFilter.model()); |
| 783 | QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), |
| 784 | fFilter.rootModelIndex()); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 785 | QStandardItem* firstItem = model->itemFromIndex(firstIndex); |
| 786 | firstItem->setSelectable(false); |
| 787 | } |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 788 | |
kkinnunen | cfdc0e3 | 2015-01-13 22:49:02 -0800 | [diff] [blame] | 789 | void SkDebuggerGUI::updateImage() { |
| 790 | if (this->isPaused()) { |
| 791 | fCanvasWidget.drawTo(fPausedRow); |
| 792 | } else { |
| 793 | fCanvasWidget.drawTo(fListWidget.currentRow()); |
| 794 | } |
| 795 | } |
| 796 | |
kkinnunen | 41c79cc | 2014-12-30 22:49:58 -0800 | [diff] [blame] | 797 | void SkDebuggerGUI::updateHit(int newHit) { |
| 798 | fCommandHitBox.setText(QString::number(newHit)); |
| 799 | } |
| 800 | |