blob: f9960a32d961007788b36446b91bd79315c03677 [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001
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.comea5488b2012-07-26 19:38:22 +000014#include "SkCanvasWidget.h"
chudy@google.com607357f2012-08-07 16:12:23 +000015#include "SkDebugger.h"
chudy@google.comea5488b2012-07-26 19:38:22 +000016#include "SkGLWidget.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000017#include "SkListWidget.h"
18#include "SkInspectorWidget.h"
chudy@google.comea5488b2012-07-26 19:38:22 +000019#include "SkRasterWidget.h"
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000020#include "SkImageWidget.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000021#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.com8a1cdae2012-11-19 20:44:29 +000039class SkTimedPicture;
40namespace sk_tools {
41 class PictureRenderer;
42}
43
chudy@google.com902ebe52012-06-29 14:21:22 +000044/** \class SkDebuggerGUI
45
46 Container for the UI and it's functions.
47 */
48class SkDebuggerGUI : public QMainWindow {
49 Q_OBJECT
50
51public:
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.comff6e6ba2013-01-28 17:43:26 +000060 /**
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.com7dcae672012-07-09 20:26:53 +000071signals:
72 void commandChanged(int command);
73
chudy@google.com902ebe52012-06-29 14:21:22 +000074private slots:
75 /**
76 Toggles breakpoint view in the list widget.
77 */
78 void actionBreakpoints();
79
80 /**
robertphillips@google.comd26c7062012-11-12 20:42:12 +000081 Profile the commands
82 */
83 void actionProfile();
84
85 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000086 Cancels the command filter in the list widget.
87 */
88 void actionCancel();
89
90 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000091 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.com902ebe52012-06-29 14:21:22 +0000101 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.come8fe4bc2013-02-13 13:26:13 +0000115#if SK_SUPPORT_GPU
chudy@google.com902ebe52012-06-29 14:21:22 +0000116 /**
chudy@google.comea5488b2012-07-26 19:38:22 +0000117 Toggles the visibility of the GL canvas widget.
118 */
119 void actionGLWidget(bool isToggled);
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +0000120#endif
chudy@google.comea5488b2012-07-26 19:38:22 +0000121
122 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000123 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.comea5488b2012-07-26 19:38:22 +0000134 Toggles the visibility of the raster canvas widget.
135 */
136 void actionRasterWidget(bool isToggled);
137
138 /**
robertphillips@google.comf4741c12013-02-06 20:13:54 +0000139 Toggles the the overdraw visualization on and off
140 */
141 void actionOverdrawVizWidget(bool isToggled);
142
143 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000144 Rewinds from the current step back to the start of the commands.
145 */
146 void actionRewind();
147
148 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000149 Saves the current SKP with all modifications.
150 */
151 void actionSave();
152
153 /**
154 Saves the current SKP under a different name and/or location.
155 */
156 void actionSaveAs();
157
158 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000159 Sends the scale factor information to the settings widget.
160 */
161 void actionScale(float scaleFactor);
162
163 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000164 Toggles the settings widget visibility.
165 */
166 void actionSettings();
167
168 /**
169 Steps forward to the next draw command.
170 */
171 void actionStepBack();
172
173 /**
174 Steps backwards to the next draw command.
175 */
176 void actionStepForward();
177
178 /**
chudy@google.coma9e937c2012-08-03 17:32:05 +0000179 Called when the canvas is done being drawn to by SkCanvasWidget.
180 */
181 void drawComplete();
182
183 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000184 Loads an skpicture selected from the directory.
185 */
186 void loadFile(QListWidgetItem *item);
187
188 /**
189 Toggles a dialog with a file browser for navigating to a skpicture. Loads
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000190 the selected file.
chudy@google.com902ebe52012-06-29 14:21:22 +0000191 */
192 void openFile();
193
194 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000195 Toggles whether drawing to a new command requires a double click
196 or simple focus.
197 */
chudy@google.come504de02012-07-16 18:35:23 +0000198 void pauseDrawing(bool isPaused = true);
chudy@google.com7dcae672012-07-09 20:26:53 +0000199
200 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000201 Executes draw commands up to the selected command
202 */
203 void registerListClick(QListWidgetItem *item);
204
205 /**
chudy@google.com9ca9bfe2012-07-12 21:58:14 +0000206 Sets the command to active in the list widget.
207 */
208 void selectCommand(int command);
209
210 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000211 Toggles the exclusive listing of commands set as deleted.
212 */
213 void showDeletes();
214
215 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000216 Toggles a breakpoint on the current step in the list widget.
217 */
218 void toggleBreakpoint();
219
220 /**
221 Toggles the visibility of the directory widget.
222 */
223 void toggleDirectory();
224
225 /**
226 Filters the list widgets command visibility based on the currently
227 active selection.
228 */
229 void toggleFilter(QString string);
230
231private:
chudy@google.com2d537a12012-07-31 12:49:52 +0000232 QWidget fCentralWidget;
233 QStatusBar fStatusBar;
234 QToolBar fToolBar;
235
chudy@google.comc432f002012-07-10 13:19:25 +0000236 QAction fActionOpen;
237 QAction fActionBreakpoint;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000238 QAction fActionProfile;
chudy@google.comc432f002012-07-10 13:19:25 +0000239 QAction fActionCancel;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000240 QAction fActionClearBreakpoints;
chudy@google.come504de02012-07-16 18:35:23 +0000241 QAction fActionClearDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000242 QAction fActionClose;
chudy@google.come504de02012-07-16 18:35:23 +0000243 QAction fActionCreateBreakpoint;
chudy@google.comc432f002012-07-10 13:19:25 +0000244 QAction fActionDelete;
245 QAction fActionDirectory;
246 QAction fActionGoToLine;
247 QAction fActionInspector;
248 QAction fActionPlay;
chudy@google.come504de02012-07-16 18:35:23 +0000249 QAction fActionPause;
chudy@google.comc432f002012-07-10 13:19:25 +0000250 QAction fActionRewind;
chudy@google.com0ab03392012-07-28 20:16:11 +0000251 QAction fActionSave;
252 QAction fActionSaveAs;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000253 QAction fActionShowDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000254 QAction fActionStepBack;
255 QAction fActionStepForward;
chudy@google.coma1226312012-07-26 20:26:44 +0000256 QAction fActionZoomIn;
257 QAction fActionZoomOut;
258 QSignalMapper fMapper;
chudy@google.com2d537a12012-07-31 12:49:52 +0000259
chudy@google.com0ab03392012-07-28 20:16:11 +0000260 QWidget fSpacer;
chudy@google.comc432f002012-07-10 13:19:25 +0000261 QComboBox fFilter;
chudy@google.com902ebe52012-06-29 14:21:22 +0000262
chudy@google.com2d537a12012-07-31 12:49:52 +0000263 QHBoxLayout fContainerLayout;
chudy@google.comc432f002012-07-10 13:19:25 +0000264 QVBoxLayout fLeftColumnLayout;
265 QVBoxLayout fMainAndRightColumnLayout;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000266 QHBoxLayout fCanvasSettingsAndImageLayout;
267 QVBoxLayout fSettingsAndImageLayout;
chudy@google.com902ebe52012-06-29 14:21:22 +0000268
chudy@google.comc432f002012-07-10 13:19:25 +0000269 QListWidget fListWidget;
270 QListWidget fDirectoryWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000271
chudy@google.com607357f2012-08-07 16:12:23 +0000272 SkDebugger fDebugger;
chudy@google.comc432f002012-07-10 13:19:25 +0000273 SkCanvasWidget fCanvasWidget;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000274 SkImageWidget fImageWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000275 SkInspectorWidget fInspectorWidget;
276 SkSettingsWidget fSettingsWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000277
chudy@google.com902ebe52012-06-29 14:21:22 +0000278 QString fPath;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000279 SkString fFileName;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000280 SkTDArray<size_t> fOffsets; // the offset of each command in the SkPicture
robertphillips@google.com5f971142012-12-07 20:48:56 +0000281 SkTDArray<bool> fSkipCommands; // has a specific command been deleted?
chudy@google.com902ebe52012-06-29 14:21:22 +0000282 bool fDirectoryWidgetActive;
chudy@google.com902ebe52012-06-29 14:21:22 +0000283
chudy@google.comc432f002012-07-10 13:19:25 +0000284 QMenuBar fMenuBar;
285 QMenu fMenuFile;
chudy@google.come504de02012-07-16 18:35:23 +0000286 QMenu fMenuEdit;
chudy@google.comc432f002012-07-10 13:19:25 +0000287 QMenu fMenuNavigate;
288 QMenu fMenuView;
chudy@google.come504de02012-07-16 18:35:23 +0000289 QMenu fMenuWindows;
chudy@google.com902ebe52012-06-29 14:21:22 +0000290
291 bool fBreakpointsActivated;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000292 bool fDeletesActivated;
chudy@google.com7dcae672012-07-09 20:26:53 +0000293 bool fPause;
chudy@google.comd3058f52012-07-19 13:41:27 +0000294 bool fLoading;
chudy@google.com2d537a12012-07-31 12:49:52 +0000295 int fPausedRow;
chudy@google.com902ebe52012-06-29 14:21:22 +0000296
297 /**
298 Creates the entire UI.
299 */
300 void setupUi(QMainWindow *SkDebuggerGUI);
301
302 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000303 Pipes a QString in with the location of the filename, proceeds to updating
304 the listwidget, combowidget and inspectorwidget.
305 */
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000306 void loadPicture(const SkString& fileName);
chudy@google.com902ebe52012-06-29 14:21:22 +0000307
308 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000309 Creates a picture of the current canvas.
310 */
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000311 void saveToFile(const SkString& filename);
chudy@google.com0ab03392012-07-28 20:16:11 +0000312
313 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000314 Populates the list widget with the vector of strings passed in.
315 */
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000316 void setupListWidget(SkTArray<SkString>* command);
chudy@google.com902ebe52012-06-29 14:21:22 +0000317
318 /**
319 Populates the combo box widget with the vector of strings passed in.
320 */
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000321 void setupComboBox(SkTArray<SkString>* command);
322
323 /**
324 Fills in the overview pane with text
325 */
robertphillips@google.com20beb482013-03-07 19:32:45 +0000326 void setupOverviewText(const SkTDArray<double>* typeTimes, double totTime, int numRuns);
chudy@google.com902ebe52012-06-29 14:21:22 +0000327
328 /**
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000329 Render the supplied picture several times tracking the time consumed
330 by each command.
331 */
skia.committer@gmail.com34587162012-11-20 02:01:23 +0000332 void run(SkTimedPicture* pict,
333 sk_tools::PictureRenderer* renderer,
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000334 int repeats);
chudy@google.com902ebe52012-06-29 14:21:22 +0000335};
336
337#endif // SKDEBUGGERUI_H