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