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