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