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