blob: 3f445500c7801a7c8e18c94080d3d0ce5c644801 [file] [log] [blame]
David Ghandehari9e5b5872016-07-28 09:50:04 -07001
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"
14#include "SkCanvasWidget.h"
15#include "SkDebugger.h"
16#include "SkGLWidget.h"
17#include "SkListWidget.h"
18#include "SkInspectorWidget.h"
19#include "SkRasterWidget.h"
20#include "SkImageWidget.h"
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/QSplitter>
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
40class SkTimedPicture;
41namespace sk_tools {
42 class PictureRenderer;
43}
44
45/** \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
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
72signals:
73 void commandChanged(int command);
74
75private slots:
76 /**
77 Toggles breakpoint view in the list widget.
78 */
79 void actionBreakpoints();
80
81 /**
82 Toggles between count and offset style of command indexing in GUI
83 */
84 void actionToggleIndexStyle();
85
86 /**
87 Profile the commands
88 */
89 void actionProfile();
90
91 /**
92 Cancels the command filter in the list widget.
93 */
94 void actionCancel();
95
96 /**
97 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 /**
107 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
121#if SK_SUPPORT_GPU
122 /**
123 Updates the visibility of the GL canvas widget and sample count of the GL surface.
124 */
125 void actionGLWidget();
126#endif
127
128 /**
129 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 /**
140 Toggles the visibility of the raster canvas widget.
141 */
142 void actionRasterWidget(bool isToggled);
143
144 /**
145 Toggles the the overdraw visualization on and off
146 */
147 void actionOverdrawVizWidget(bool isToggled);
148
149 /**
150 Toggles the the mega visualization on and off
151 */
152 void actionMegaVizWidget(bool isToggled);
153
154 /**
155 Toggles using path ops to simplify the clip stack
156 */
157 void actionPathOpsWidget(bool );
158
159 /**
160 Applies the new texture filter override
161 */
162 void actionTextureFilter();
163
164 /**
165 Rewinds from the current step back to the start of the commands.
166 */
167 void actionRewind();
168
169 /**
170 Saves the current SKP with all modifications.
171 */
172 void actionSave();
173
174 /**
175 Saves the current SKP under a different name and/or location.
176 */
177 void actionSaveAs();
178
179 /**
180 Sends the scale factor information to the settings widget.
181 */
182 void actionScale(float scaleFactor);
183
184 /**
185 Toggles the settings widget visibility.
186 */
187 void actionSettings();
188
189 /**
190 Steps forward to the next draw command.
191 */
192 void actionStepBack();
193
194 /**
195 Steps backwards to the next draw command.
196 */
197 void actionStepForward();
198
199 /**
200 Called when the canvas is done being drawn to by SkCanvasWidget.
201 */
202 void drawComplete();
203
204 /**
205 Loads an skpicture selected from the directory.
206 */
207 void loadFile(QListWidgetItem *item);
208
209 /**
210 Toggles a dialog with a file browser for navigating to a skpicture. Loads
211 the selected file.
212 */
213 void openFile();
214
215 /**
216 Toggles whether drawing to a new command requires a double click
217 or simple focus.
218 */
219 void pauseDrawing(bool isPaused = true);
220
221 /**
222 Executes draw commands up to the selected command
223 */
224 void registerListClick(QListWidgetItem *item);
225
226 /**
227 Sets the command to active in the list widget.
228 */
229 void selectCommand(int command);
230
231 /**
232 Toggles the exclusive listing of commands set as deleted.
233 */
234 void showDeletes();
235
236 /**
237 Toggles a breakpoint on the current step in the list widget.
238 */
239 void toggleBreakpoint();
240
241 /**
242 Toggles the visibility of the directory widget.
243 */
244 void toggleDirectory();
245
246 /**
247 Filters the list widgets command visibility based on the currently
248 active selection.
249 */
250 void toggleFilter(QString string);
251
252private:
253 QSplitter fCentralSplitter;
254 QStatusBar fStatusBar;
255 QToolBar fToolBar;
256
257 QAction fActionOpen;
258 QAction fActionBreakpoint;
259 QAction fActionToggleIndexStyle;
260 QAction fActionProfile;
261 QAction fActionCancel;
262 QAction fActionClearBreakpoints;
263 QAction fActionClearDeletes;
264 QAction fActionClose;
265 QAction fActionCreateBreakpoint;
266 QAction fActionDelete;
267 QAction fActionDirectory;
268 QAction fActionGoToLine;
269 QAction fActionInspector;
270 QAction fActionSettings;
271 QAction fActionPlay;
272 QAction fActionPause;
273 QAction fActionRewind;
274 QAction fActionSave;
275 QAction fActionSaveAs;
276 QAction fActionShowDeletes;
277 QAction fActionStepBack;
278 QAction fActionStepForward;
279 QAction fActionZoomIn;
280 QAction fActionZoomOut;
281 QSignalMapper fMapper;
282
283 QWidget fSpacer;
284 QComboBox fFilter;
285
286 QSplitter fLeftColumnSplitter;
287 QWidget fMainAndRightColumnWidget;
288 QVBoxLayout fMainAndRightColumnLayout;
289 QHBoxLayout fCanvasSettingsAndImageLayout;
290 QVBoxLayout fSettingsAndImageLayout;
291
292 QListWidget fListWidget;
293 QListWidget fDirectoryWidget;
294
295 SkDebugger fDebugger;
296 SkCanvasWidget fCanvasWidget;
297 SkImageWidget fImageWidget;
298 SkInspectorWidget fInspectorWidget;
299 SkSettingsWidget fSettingsWidget;
300
301 QString fPath;
302 SkString fFileName;
303 SkTDArray<bool> fSkipCommands; // has a specific command been deleted?
304 bool fDirectoryWidgetActive;
305
306 QMenuBar fMenuBar;
307 QMenu fMenuFile;
308 QMenu fMenuEdit;
309 QMenu fMenuNavigate;
310 QMenu fMenuView;
311 QMenu fMenuWindows;
312
313 bool fBreakpointsActivated;
314 bool fIndexStyleToggle;
315 bool fDeletesActivated;
316 bool fPause;
317 bool fLoading;
318 int fPausedRow;
319
320 /**
321 Creates the entire UI.
322 */
323 void setupUi(QMainWindow *SkDebuggerGUI);
324
325 /**
326 Pipes a QString in with the location of the filename, proceeds to updating
327 the listwidget, combowidget and inspectorwidget.
328 */
329 void loadPicture(const SkString& fileName);
330
331 /**
332 Creates a picture of the current canvas.
333 */
334 void saveToFile(const SkString& filename);
335
336 /**
337 Populates the list widget with the vector of strings passed in.
338 */
339 void setupListWidget(SkTArray<SkString>* commands, SkTDArray<size_t>* offsets);
340
341 /**
342 Populates the combo box widget with the vector of strings passed in.
343 */
344 void setupComboBox(SkTArray<SkString>* command);
345
346 /**
347 Fills in the overview pane with text
348 */
349 void setupOverviewText(const SkTDArray<double>* typeTimes, double totTime, int numRuns);
350
351 /**
352 Fills in the clip stack pane with text
353 */
354 void setupClipStackText();
355
356 /**
357 Render the supplied picture several times tracking the time consumed
358 by each command.
359 */
360 void run(const SkPicture* pict,
361 sk_tools::PictureRenderer* renderer,
362 int repeats);
363};
364
365#endif // SKDEBUGGERUI_H