blob: 41c5e242e20e563db3d23070e8e8ebd6833d9b8a [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>
commit-bot@chromium.orgbcd431e2013-11-21 13:41:37 +000031#include <QtGui/QSplitter>
chudy@google.com902ebe52012-06-29 14:21:22 +000032#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.com8a1cdae2012-11-19 20:44:29 +000040class SkTimedPicture;
41namespace sk_tools {
42 class PictureRenderer;
43}
44
chudy@google.com902ebe52012-06-29 14:21:22 +000045/** \class SkDebuggerGUI
46
47 Container for the UI and it's functions.
48 */
49class SkDebuggerGUI : public QMainWindow {
50 Q_OBJECT
51
52public:
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.comff6e6ba2013-01-28 17:43:26 +000061 /**
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.com7dcae672012-07-09 20:26:53 +000072signals:
73 void commandChanged(int command);
74
chudy@google.com902ebe52012-06-29 14:21:22 +000075private slots:
76 /**
77 Toggles breakpoint view in the list widget.
78 */
79 void actionBreakpoints();
80
81 /**
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000082 Toggles between count and offset style of command indexing in GUI
83 */
84 void actionToggleIndexStyle();
85
86 /**
robertphillips@google.comd26c7062012-11-12 20:42:12 +000087 Profile the commands
88 */
89 void actionProfile();
90
91 /**
chudy@google.com902ebe52012-06-29 14:21:22 +000092 Cancels the command filter in the list widget.
93 */
94 void actionCancel();
95
96 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000097 Clears the breakpoint state off of all commands marked as breakpoints.
98 */
99 void actionClearBreakpoints();
100
101 /**
102 Clears the deleted state off of all commands marked as deleted.
103 */
104 void actionClearDeletes();
105
106 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000107 Applies a visible filter to all drawing commands other than the previous.
108 */
109 void actionCommandFilter();
110
111 /**
112 Closes the application.
113 */
114 void actionClose();
115
116 /**
117 Deletes the command in question.
118 */
119 void actionDelete();
120
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +0000121#if SK_SUPPORT_GPU
chudy@google.com902ebe52012-06-29 14:21:22 +0000122 /**
commit-bot@chromium.orgfde1e7c2013-08-02 13:59:50 +0000123 Updates the visibility of the GL canvas widget and sample count of the GL surface.
chudy@google.comea5488b2012-07-26 19:38:22 +0000124 */
commit-bot@chromium.orgfde1e7c2013-08-02 13:59:50 +0000125 void actionGLWidget();
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +0000126#endif
chudy@google.comea5488b2012-07-26 19:38:22 +0000127
128 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000129 Toggles the visibility of the inspector widget.
130 */
131 void actionInspector();
132
133 /**
134 Plays from the current step to the next breakpoint if it exists, otherwise
135 executes all remaining draw commands.
136 */
137 void actionPlay();
138
139 /**
chudy@google.comea5488b2012-07-26 19:38:22 +0000140 Toggles the visibility of the raster canvas widget.
141 */
142 void actionRasterWidget(bool isToggled);
143
144 /**
robertphillips@google.comf4741c12013-02-06 20:13:54 +0000145 Toggles the the overdraw visualization on and off
146 */
147 void actionOverdrawVizWidget(bool isToggled);
148
149 /**
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000150 Toggles the the mega visualization on and off
151 */
152 void actionMegaVizWidget(bool isToggled);
153
154 /**
robertphillips@google.com32bbcf82013-10-17 17:56:10 +0000155 Applies the new texture filter override
156 */
157 void actionTextureFilter();
158
159 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000160 Rewinds from the current step back to the start of the commands.
161 */
162 void actionRewind();
163
164 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000165 Saves the current SKP with all modifications.
166 */
167 void actionSave();
168
169 /**
170 Saves the current SKP under a different name and/or location.
171 */
172 void actionSaveAs();
173
174 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000175 Sends the scale factor information to the settings widget.
176 */
177 void actionScale(float scaleFactor);
178
179 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000180 Toggles the settings widget visibility.
181 */
182 void actionSettings();
183
184 /**
185 Steps forward to the next draw command.
186 */
187 void actionStepBack();
188
189 /**
190 Steps backwards to the next draw command.
191 */
192 void actionStepForward();
193
194 /**
chudy@google.coma9e937c2012-08-03 17:32:05 +0000195 Called when the canvas is done being drawn to by SkCanvasWidget.
196 */
197 void drawComplete();
198
199 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000200 Loads an skpicture selected from the directory.
201 */
202 void loadFile(QListWidgetItem *item);
203
204 /**
205 Toggles a dialog with a file browser for navigating to a skpicture. Loads
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000206 the selected file.
chudy@google.com902ebe52012-06-29 14:21:22 +0000207 */
208 void openFile();
209
210 /**
chudy@google.com7dcae672012-07-09 20:26:53 +0000211 Toggles whether drawing to a new command requires a double click
212 or simple focus.
213 */
chudy@google.come504de02012-07-16 18:35:23 +0000214 void pauseDrawing(bool isPaused = true);
chudy@google.com7dcae672012-07-09 20:26:53 +0000215
216 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000217 Executes draw commands up to the selected command
218 */
219 void registerListClick(QListWidgetItem *item);
220
221 /**
chudy@google.com9ca9bfe2012-07-12 21:58:14 +0000222 Sets the command to active in the list widget.
223 */
224 void selectCommand(int command);
225
226 /**
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000227 Toggles the exclusive listing of commands set as deleted.
228 */
229 void showDeletes();
230
231 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000232 Toggles a breakpoint on the current step in the list widget.
233 */
234 void toggleBreakpoint();
235
236 /**
237 Toggles the visibility of the directory widget.
238 */
239 void toggleDirectory();
240
241 /**
242 Filters the list widgets command visibility based on the currently
243 active selection.
244 */
245 void toggleFilter(QString string);
246
247private:
commit-bot@chromium.orgbcd431e2013-11-21 13:41:37 +0000248 QSplitter fCentralSplitter;
chudy@google.com2d537a12012-07-31 12:49:52 +0000249 QStatusBar fStatusBar;
250 QToolBar fToolBar;
251
chudy@google.comc432f002012-07-10 13:19:25 +0000252 QAction fActionOpen;
253 QAction fActionBreakpoint;
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000254 QAction fActionToggleIndexStyle;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000255 QAction fActionProfile;
chudy@google.comc432f002012-07-10 13:19:25 +0000256 QAction fActionCancel;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000257 QAction fActionClearBreakpoints;
chudy@google.come504de02012-07-16 18:35:23 +0000258 QAction fActionClearDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000259 QAction fActionClose;
chudy@google.come504de02012-07-16 18:35:23 +0000260 QAction fActionCreateBreakpoint;
chudy@google.comc432f002012-07-10 13:19:25 +0000261 QAction fActionDelete;
262 QAction fActionDirectory;
263 QAction fActionGoToLine;
264 QAction fActionInspector;
bungeman@google.com2ff6d1d2013-07-01 14:24:12 +0000265 QAction fActionSettings;
chudy@google.comc432f002012-07-10 13:19:25 +0000266 QAction fActionPlay;
chudy@google.come504de02012-07-16 18:35:23 +0000267 QAction fActionPause;
chudy@google.comc432f002012-07-10 13:19:25 +0000268 QAction fActionRewind;
chudy@google.com0ab03392012-07-28 20:16:11 +0000269 QAction fActionSave;
270 QAction fActionSaveAs;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000271 QAction fActionShowDeletes;
chudy@google.comc432f002012-07-10 13:19:25 +0000272 QAction fActionStepBack;
273 QAction fActionStepForward;
chudy@google.coma1226312012-07-26 20:26:44 +0000274 QAction fActionZoomIn;
275 QAction fActionZoomOut;
276 QSignalMapper fMapper;
chudy@google.com2d537a12012-07-31 12:49:52 +0000277
chudy@google.com0ab03392012-07-28 20:16:11 +0000278 QWidget fSpacer;
chudy@google.comc432f002012-07-10 13:19:25 +0000279 QComboBox fFilter;
chudy@google.com902ebe52012-06-29 14:21:22 +0000280
commit-bot@chromium.orgbcd431e2013-11-21 13:41:37 +0000281 QSplitter fLeftColumnSplitter;
282 QWidget fMainAndRightColumnWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000283 QVBoxLayout fMainAndRightColumnLayout;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000284 QHBoxLayout fCanvasSettingsAndImageLayout;
285 QVBoxLayout fSettingsAndImageLayout;
chudy@google.com902ebe52012-06-29 14:21:22 +0000286
chudy@google.comc432f002012-07-10 13:19:25 +0000287 QListWidget fListWidget;
288 QListWidget fDirectoryWidget;
chudy@google.com902ebe52012-06-29 14:21:22 +0000289
chudy@google.com607357f2012-08-07 16:12:23 +0000290 SkDebugger fDebugger;
chudy@google.comc432f002012-07-10 13:19:25 +0000291 SkCanvasWidget fCanvasWidget;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000292 SkImageWidget fImageWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000293 SkInspectorWidget fInspectorWidget;
294 SkSettingsWidget fSettingsWidget;
chudy@google.comc432f002012-07-10 13:19:25 +0000295
chudy@google.com902ebe52012-06-29 14:21:22 +0000296 QString fPath;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000297 SkString fFileName;
robertphillips@google.com5f971142012-12-07 20:48:56 +0000298 SkTDArray<bool> fSkipCommands; // has a specific command been deleted?
chudy@google.com902ebe52012-06-29 14:21:22 +0000299 bool fDirectoryWidgetActive;
chudy@google.com902ebe52012-06-29 14:21:22 +0000300
chudy@google.comc432f002012-07-10 13:19:25 +0000301 QMenuBar fMenuBar;
302 QMenu fMenuFile;
chudy@google.come504de02012-07-16 18:35:23 +0000303 QMenu fMenuEdit;
chudy@google.comc432f002012-07-10 13:19:25 +0000304 QMenu fMenuNavigate;
305 QMenu fMenuView;
chudy@google.come504de02012-07-16 18:35:23 +0000306 QMenu fMenuWindows;
chudy@google.com902ebe52012-06-29 14:21:22 +0000307
308 bool fBreakpointsActivated;
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000309 bool fIndexStyleToggle;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000310 bool fDeletesActivated;
chudy@google.com7dcae672012-07-09 20:26:53 +0000311 bool fPause;
chudy@google.comd3058f52012-07-19 13:41:27 +0000312 bool fLoading;
chudy@google.com2d537a12012-07-31 12:49:52 +0000313 int fPausedRow;
chudy@google.com902ebe52012-06-29 14:21:22 +0000314
315 /**
316 Creates the entire UI.
317 */
318 void setupUi(QMainWindow *SkDebuggerGUI);
319
320 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000321 Pipes a QString in with the location of the filename, proceeds to updating
322 the listwidget, combowidget and inspectorwidget.
323 */
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000324 void loadPicture(const SkString& fileName);
chudy@google.com902ebe52012-06-29 14:21:22 +0000325
326 /**
chudy@google.com0ab03392012-07-28 20:16:11 +0000327 Creates a picture of the current canvas.
328 */
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000329 void saveToFile(const SkString& filename);
chudy@google.com0ab03392012-07-28 20:16:11 +0000330
331 /**
chudy@google.com902ebe52012-06-29 14:21:22 +0000332 Populates the list widget with the vector of strings passed in.
333 */
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000334 void setupListWidget(SkTArray<SkString>* commands, SkTDArray<size_t>* offsets);
chudy@google.com902ebe52012-06-29 14:21:22 +0000335
336 /**
337 Populates the combo box widget with the vector of strings passed in.
338 */
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000339 void setupComboBox(SkTArray<SkString>* command);
340
341 /**
342 Fills in the overview pane with text
343 */
robertphillips@google.com20beb482013-03-07 19:32:45 +0000344 void setupOverviewText(const SkTDArray<double>* typeTimes, double totTime, int numRuns);
chudy@google.com902ebe52012-06-29 14:21:22 +0000345
346 /**
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000347 Render the supplied picture several times tracking the time consumed
348 by each command.
349 */
skia.committer@gmail.com34587162012-11-20 02:01:23 +0000350 void run(SkTimedPicture* pict,
351 sk_tools::PictureRenderer* renderer,
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000352 int repeats);
chudy@google.com902ebe52012-06-29 14:21:22 +0000353};
354
355#endif // SKDEBUGGERUI_H