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