chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | #ifndef SKDEBUGGERUI_H |
| 10 | #define SKDEBUGGERUI_H |
| 11 | |
| 12 | |
| 13 | #include "SkCanvas.h" |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 14 | #include "SkCanvasWidget.h" |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 15 | #include "SkDebugger.h" |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 16 | #include "SkGLWidget.h" |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 17 | #include "SkListWidget.h" |
| 18 | #include "SkInspectorWidget.h" |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 19 | #include "SkRasterWidget.h" |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 20 | #include "SkImageWidget.h" |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 21 | #include "SkSettingsWidget.h" |
| 22 | #include <QtCore/QVariant> |
| 23 | #include <QtGui/QAction> |
| 24 | #include <QtGui/QApplication> |
| 25 | #include <QtGui/QButtonGroup> |
| 26 | #include <QtGui/QHBoxLayout> |
| 27 | #include <QtGui/QHeaderView> |
| 28 | #include <QtGui/QListView> |
| 29 | #include <QtGui/QListWidget> |
| 30 | #include <QtGui/QMainWindow> |
| 31 | #include <QtGui/QStatusBar> |
| 32 | #include <QtGui/QToolBar> |
| 33 | #include <QtGui/QVBoxLayout> |
| 34 | #include <QtGui/QWidget> |
| 35 | #include <QtGui/QMenu> |
| 36 | #include <QtGui/QMenuBar> |
| 37 | #include <vector> |
| 38 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 39 | class SkTimedPicture; |
| 40 | namespace sk_tools { |
| 41 | class PictureRenderer; |
| 42 | } |
| 43 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 44 | /** \class SkDebuggerGUI |
| 45 | |
| 46 | Container for the UI and it's functions. |
| 47 | */ |
| 48 | class SkDebuggerGUI : public QMainWindow { |
| 49 | Q_OBJECT |
| 50 | |
| 51 | public: |
| 52 | /** |
| 53 | Constructs the view of the application. |
| 54 | @param parent The parent container of this widget. |
| 55 | */ |
| 56 | SkDebuggerGUI(QWidget *parent = 0); |
| 57 | |
| 58 | ~SkDebuggerGUI(); |
| 59 | |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 60 | /** |
| 61 | Updates the directory widget with the latest directory path stored in |
| 62 | the global class variable fPath. |
| 63 | */ |
| 64 | void setupDirectoryWidget(const QString& path); |
| 65 | |
| 66 | /** |
| 67 | Loads the specified file. |
| 68 | */ |
| 69 | void openFile(const QString& filename); |
| 70 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 71 | signals: |
| 72 | void commandChanged(int command); |
| 73 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 74 | private slots: |
| 75 | /** |
| 76 | Toggles breakpoint view in the list widget. |
| 77 | */ |
| 78 | void actionBreakpoints(); |
| 79 | |
| 80 | /** |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 81 | Profile the commands |
| 82 | */ |
| 83 | void actionProfile(); |
| 84 | |
| 85 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 86 | Cancels the command filter in the list widget. |
| 87 | */ |
| 88 | void actionCancel(); |
| 89 | |
| 90 | /** |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 91 | Clears the breakpoint state off of all commands marked as breakpoints. |
| 92 | */ |
| 93 | void actionClearBreakpoints(); |
| 94 | |
| 95 | /** |
| 96 | Clears the deleted state off of all commands marked as deleted. |
| 97 | */ |
| 98 | void actionClearDeletes(); |
| 99 | |
| 100 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 101 | Applies a visible filter to all drawing commands other than the previous. |
| 102 | */ |
| 103 | void actionCommandFilter(); |
| 104 | |
| 105 | /** |
| 106 | Closes the application. |
| 107 | */ |
| 108 | void actionClose(); |
| 109 | |
| 110 | /** |
| 111 | Deletes the command in question. |
| 112 | */ |
| 113 | void actionDelete(); |
| 114 | |
| 115 | /** |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 116 | Toggles the visibility of the GL canvas widget. |
| 117 | */ |
| 118 | void actionGLWidget(bool isToggled); |
| 119 | |
| 120 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 121 | Toggles the visibility of the inspector widget. |
| 122 | */ |
| 123 | void actionInspector(); |
| 124 | |
| 125 | /** |
| 126 | Plays from the current step to the next breakpoint if it exists, otherwise |
| 127 | executes all remaining draw commands. |
| 128 | */ |
| 129 | void actionPlay(); |
| 130 | |
| 131 | /** |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 132 | Toggles the visibility of the raster canvas widget. |
| 133 | */ |
| 134 | void actionRasterWidget(bool isToggled); |
| 135 | |
| 136 | /** |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 137 | Toggles the the overdraw visualization on and off |
| 138 | */ |
| 139 | void actionOverdrawVizWidget(bool isToggled); |
| 140 | |
| 141 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 142 | Rewinds from the current step back to the start of the commands. |
| 143 | */ |
| 144 | void actionRewind(); |
| 145 | |
| 146 | /** |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 147 | Saves the current SKP with all modifications. |
| 148 | */ |
| 149 | void actionSave(); |
| 150 | |
| 151 | /** |
| 152 | Saves the current SKP under a different name and/or location. |
| 153 | */ |
| 154 | void actionSaveAs(); |
| 155 | |
| 156 | /** |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 157 | Sends the scale factor information to the settings widget. |
| 158 | */ |
| 159 | void actionScale(float scaleFactor); |
| 160 | |
| 161 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 162 | Toggles the settings widget visibility. |
| 163 | */ |
| 164 | void actionSettings(); |
| 165 | |
| 166 | /** |
| 167 | Steps forward to the next draw command. |
| 168 | */ |
| 169 | void actionStepBack(); |
| 170 | |
| 171 | /** |
| 172 | Steps backwards to the next draw command. |
| 173 | */ |
| 174 | void actionStepForward(); |
| 175 | |
| 176 | /** |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 177 | Called when the canvas is done being drawn to by SkCanvasWidget. |
| 178 | */ |
| 179 | void drawComplete(); |
| 180 | |
| 181 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 182 | Loads an skpicture selected from the directory. |
| 183 | */ |
| 184 | void loadFile(QListWidgetItem *item); |
| 185 | |
| 186 | /** |
| 187 | Toggles a dialog with a file browser for navigating to a skpicture. Loads |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 188 | the selected file. |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 189 | */ |
| 190 | void openFile(); |
| 191 | |
| 192 | /** |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 193 | Toggles whether drawing to a new command requires a double click |
| 194 | or simple focus. |
| 195 | */ |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 196 | void pauseDrawing(bool isPaused = true); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 197 | |
| 198 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 199 | Executes draw commands up to the selected command |
| 200 | */ |
| 201 | void registerListClick(QListWidgetItem *item); |
| 202 | |
| 203 | /** |
chudy@google.com | 9ca9bfe | 2012-07-12 21:58:14 +0000 | [diff] [blame] | 204 | Sets the command to active in the list widget. |
| 205 | */ |
| 206 | void selectCommand(int command); |
| 207 | |
| 208 | /** |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 209 | Toggles the exclusive listing of commands set as deleted. |
| 210 | */ |
| 211 | void showDeletes(); |
| 212 | |
| 213 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 214 | Toggles a breakpoint on the current step in the list widget. |
| 215 | */ |
| 216 | void toggleBreakpoint(); |
| 217 | |
| 218 | /** |
| 219 | Toggles the visibility of the directory widget. |
| 220 | */ |
| 221 | void toggleDirectory(); |
| 222 | |
| 223 | /** |
| 224 | Filters the list widgets command visibility based on the currently |
| 225 | active selection. |
| 226 | */ |
| 227 | void toggleFilter(QString string); |
| 228 | |
| 229 | private: |
chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 230 | QWidget fCentralWidget; |
| 231 | QStatusBar fStatusBar; |
| 232 | QToolBar fToolBar; |
| 233 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 234 | QAction fActionOpen; |
| 235 | QAction fActionBreakpoint; |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 236 | QAction fActionProfile; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 237 | QAction fActionCancel; |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 238 | QAction fActionClearBreakpoints; |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 239 | QAction fActionClearDeletes; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 240 | QAction fActionClose; |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 241 | QAction fActionCreateBreakpoint; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 242 | QAction fActionDelete; |
| 243 | QAction fActionDirectory; |
| 244 | QAction fActionGoToLine; |
| 245 | QAction fActionInspector; |
| 246 | QAction fActionPlay; |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 247 | QAction fActionPause; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 248 | QAction fActionRewind; |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 249 | QAction fActionSave; |
| 250 | QAction fActionSaveAs; |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 251 | QAction fActionShowDeletes; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 252 | QAction fActionStepBack; |
| 253 | QAction fActionStepForward; |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 254 | QAction fActionZoomIn; |
| 255 | QAction fActionZoomOut; |
| 256 | QSignalMapper fMapper; |
chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 257 | |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 258 | QWidget fSpacer; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 259 | QComboBox fFilter; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 260 | |
chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 261 | QHBoxLayout fContainerLayout; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 262 | QVBoxLayout fLeftColumnLayout; |
| 263 | QVBoxLayout fMainAndRightColumnLayout; |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 264 | QHBoxLayout fCanvasSettingsAndImageLayout; |
| 265 | QVBoxLayout fSettingsAndImageLayout; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 266 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 267 | QListWidget fListWidget; |
| 268 | QListWidget fDirectoryWidget; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 269 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 270 | SkDebugger fDebugger; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 271 | SkCanvasWidget fCanvasWidget; |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 272 | SkImageWidget fImageWidget; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 273 | SkInspectorWidget fInspectorWidget; |
| 274 | SkSettingsWidget fSettingsWidget; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 275 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 276 | QString fPath; |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 277 | SkString fFileName; |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 278 | SkTDArray<size_t> fOffsets; // the offset of each command in the SkPicture |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 279 | SkTDArray<bool> fSkipCommands; // has a specific command been deleted? |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 280 | bool fDirectoryWidgetActive; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 281 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 282 | QMenuBar fMenuBar; |
| 283 | QMenu fMenuFile; |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 284 | QMenu fMenuEdit; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 285 | QMenu fMenuNavigate; |
| 286 | QMenu fMenuView; |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 287 | QMenu fMenuWindows; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 288 | |
| 289 | bool fBreakpointsActivated; |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 290 | bool fDeletesActivated; |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 291 | bool fPause; |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 292 | bool fLoading; |
chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 293 | int fPausedRow; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 294 | |
| 295 | /** |
| 296 | Creates the entire UI. |
| 297 | */ |
| 298 | void setupUi(QMainWindow *SkDebuggerGUI); |
| 299 | |
| 300 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 301 | Pipes a QString in with the location of the filename, proceeds to updating |
| 302 | the listwidget, combowidget and inspectorwidget. |
| 303 | */ |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 304 | void loadPicture(const SkString& fileName); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 305 | |
| 306 | /** |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 307 | Creates a picture of the current canvas. |
| 308 | */ |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 309 | void saveToFile(const SkString& filename); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 310 | |
| 311 | /** |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 312 | Populates the list widget with the vector of strings passed in. |
| 313 | */ |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 314 | void setupListWidget(SkTArray<SkString>* command); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 315 | |
| 316 | /** |
| 317 | Populates the combo box widget with the vector of strings passed in. |
| 318 | */ |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 319 | void setupComboBox(SkTArray<SkString>* command); |
| 320 | |
| 321 | /** |
| 322 | Fills in the overview pane with text |
| 323 | */ |
| 324 | void setupOverviewText(const SkTDArray<double>* typeTimes, double totTime); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 325 | |
| 326 | /** |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 327 | Render the supplied picture several times tracking the time consumed |
| 328 | by each command. |
| 329 | */ |
skia.committer@gmail.com | 3458716 | 2012-11-20 02:01:23 +0000 | [diff] [blame] | 330 | void run(SkTimedPicture* pict, |
| 331 | sk_tools::PictureRenderer* renderer, |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 332 | int repeats); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 333 | }; |
| 334 | |
| 335 | #endif // SKDEBUGGERUI_H |