blob: 0f4299fb3643283bc01e417f382216ba1b6981d9 [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
chudy@google.com902ebe52012-06-29 14:21:22 +00008#include "SkDebuggerGUI.h"
scroggo@google.com7def5e12013-05-31 14:00:10 +00009#include "SkForceLinking.h"
chudy@google.combbad34d2012-08-13 14:26:36 +000010#include "SkGraphics.h"
scroggo@google.comb4467e62012-11-06 23:10:09 +000011#include "SkImageDecoder.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000012#include <QListWidgetItem>
robertphillips@google.com2bde91d2012-11-15 14:57:57 +000013#include "PictureRenderer.h"
robertphillips@google.com2bde91d2012-11-15 14:57:57 +000014#include "SkPictureRecord.h"
15#include "SkPicturePlayback.h"
robertphillips@google.come174a8b2012-11-27 16:04:42 +000016
scroggo@google.com7def5e12013-05-31 14:00:10 +000017__SK_FORCE_IMAGE_DECODER_LINKING;
18
robertphillips@google.come174a8b2012-11-27 16:04:42 +000019#if defined(SK_BUILD_FOR_WIN32)
20 #include "BenchSysTimer_windows.h"
21#elif defined(SK_BUILD_FOR_MAC)
22 #include "BenchSysTimer_mach.h"
23#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
24 #include "BenchSysTimer_posix.h"
25#else
26 #include "BenchSysTimer_c.h"
27#endif
28
chudy@google.com902ebe52012-06-29 14:21:22 +000029
30SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
chudy@google.comc432f002012-07-10 13:19:25 +000031 QMainWindow(parent)
chudy@google.com2d537a12012-07-31 12:49:52 +000032 , fCentralWidget(this)
33 , fStatusBar(this)
34 , fToolBar(this)
chudy@google.comc432f002012-07-10 13:19:25 +000035 , fActionOpen(this)
36 , fActionBreakpoint(this)
robertphillips@google.comd26c7062012-11-12 20:42:12 +000037 , fActionProfile(this)
chudy@google.comc432f002012-07-10 13:19:25 +000038 , fActionCancel(this)
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000039 , fActionClearBreakpoints(this)
chudy@google.come504de02012-07-16 18:35:23 +000040 , fActionClearDeletes(this)
chudy@google.comc432f002012-07-10 13:19:25 +000041 , fActionClose(this)
chudy@google.come504de02012-07-16 18:35:23 +000042 , fActionCreateBreakpoint(this)
chudy@google.comc432f002012-07-10 13:19:25 +000043 , fActionDelete(this)
44 , fActionDirectory(this)
45 , fActionGoToLine(this)
46 , fActionInspector(this)
bungeman@google.com2ff6d1d2013-07-01 14:24:12 +000047 , fActionSettings(this)
chudy@google.comc432f002012-07-10 13:19:25 +000048 , fActionPlay(this)
chudy@google.come504de02012-07-16 18:35:23 +000049 , fActionPause(this)
chudy@google.comc432f002012-07-10 13:19:25 +000050 , fActionRewind(this)
chudy@google.com0ab03392012-07-28 20:16:11 +000051 , fActionSave(this)
52 , fActionSaveAs(this)
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000053 , fActionShowDeletes(this)
chudy@google.comc432f002012-07-10 13:19:25 +000054 , fActionStepBack(this)
55 , fActionStepForward(this)
chudy@google.coma1226312012-07-26 20:26:44 +000056 , fActionZoomIn(this)
57 , fActionZoomOut(this)
58 , fMapper(this)
chudy@google.comc432f002012-07-10 13:19:25 +000059 , fListWidget(&fCentralWidget)
60 , fDirectoryWidget(&fCentralWidget)
chudy@google.com607357f2012-08-07 16:12:23 +000061 , fCanvasWidget(this, &fDebugger)
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000062 , fImageWidget(&fDebugger)
chudy@google.comc432f002012-07-10 13:19:25 +000063 , fMenuBar(this)
64 , fMenuFile(this)
65 , fMenuNavigate(this)
66 , fMenuView(this)
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000067 , fBreakpointsActivated(false)
68 , fDeletesActivated(false)
69 , fPause(false)
chudy@google.comd3058f52012-07-19 13:41:27 +000070 , fLoading(false)
chudy@google.comc432f002012-07-10 13:19:25 +000071{
chudy@google.com902ebe52012-06-29 14:21:22 +000072 setupUi(this);
robertphillips@google.comdd4b7452013-01-22 19:38:46 +000073 fListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection);
chudy@google.comea5488b2012-07-26 19:38:22 +000074 connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(registerListClick(QListWidgetItem *)));
chudy@google.comc432f002012-07-10 13:19:25 +000075 connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
chudy@google.comea5488b2012-07-26 19:38:22 +000076 connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory()));
77 connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(loadFile(QListWidgetItem *)));
chudy@google.comc432f002012-07-10 13:19:25 +000078 connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
chudy@google.comea5488b2012-07-26 19:38:22 +000079 connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(toggleBreakpoint()));
chudy@google.comc432f002012-07-10 13:19:25 +000080 connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
81 connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay()));
82 connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()));
chudy@google.comea5488b2012-07-26 19:38:22 +000083 connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForward()));
84 connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoints()));
85 connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()));
bungeman@google.com2ff6d1d2013-07-01 14:24:12 +000086 connect(&fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings()));
chudy@google.comea5488b2012-07-26 19:38:22 +000087 connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QString)));
robertphillips@google.comd26c7062012-11-12 20:42:12 +000088 connect(&fActionProfile, SIGNAL(triggered()), this, SLOT(actionProfile()));
chudy@google.comc432f002012-07-10 13:19:25 +000089 connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000090 connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints()));
91 connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes()));
chudy@google.comc432f002012-07-10 13:19:25 +000092 connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
chudy@google.comea5488b2012-07-26 19:38:22 +000093 connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this, SLOT(actionCommandFilter()));
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +000094#if SK_SUPPORT_GPU
chudy@google.comea5488b2012-07-26 19:38:22 +000095 connect(fSettingsWidget.getGLCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionGLWidget(bool)));
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +000096#endif
chudy@google.comea5488b2012-07-26 19:38:22 +000097 connect(fSettingsWidget.getRasterCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionRasterWidget(bool)));
robertphillips@google.comf4741c12013-02-06 20:13:54 +000098 connect(fSettingsWidget.getOverdrawVizCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionOverdrawVizWidget(bool)));
chudy@google.comea5488b2012-07-26 19:38:22 +000099 connect(&fActionPause, SIGNAL(toggled(bool)), this, SLOT(pauseDrawing(bool)));
chudy@google.come504de02012-07-16 18:35:23 +0000100 connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint()));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000101 connect(&fActionShowDeletes, SIGNAL(triggered()), this, SLOT(showDeletes()));
chudy@google.comea5488b2012-07-26 19:38:22 +0000102 connect(&fCanvasWidget, SIGNAL(hitChanged(int)), this, SLOT(selectCommand(int)));
103 connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget, SLOT(updateHit(int)));
104 connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this, SLOT(actionScale(float)));
105 connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fSettingsWidget, SLOT(updateCommand(int)));
chudy@google.com0ab03392012-07-28 20:16:11 +0000106 connect(&fActionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs()));
107 connect(&fActionSave, SIGNAL(triggered()), this, SLOT(actionSave()));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000108
bungeman@google.come8cc6e82013-01-17 16:30:56 +0000109 fMapper.setMapping(&fActionZoomIn, SkCanvasWidget::kIn_ZoomCommand);
110 fMapper.setMapping(&fActionZoomOut, SkCanvasWidget::kOut_ZoomCommand);
chudy@google.coma1226312012-07-26 20:26:44 +0000111
112 connect(&fActionZoomIn, SIGNAL(triggered()), &fMapper, SLOT(map()));
113 connect(&fActionZoomOut, SIGNAL(triggered()), &fMapper, SLOT(map()));
bungeman@google.come8cc6e82013-01-17 16:30:56 +0000114 connect(&fMapper, SIGNAL(mapped(int)), &fCanvasWidget, SLOT(zoom(int)));
chudy@google.coma1226312012-07-26 20:26:44 +0000115
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000116 fInspectorWidget.setDisabled(true);
chudy@google.comd3058f52012-07-19 13:41:27 +0000117 fMenuEdit.setDisabled(true);
118 fMenuNavigate.setDisabled(true);
119 fMenuView.setDisabled(true);
chudy@google.combbad34d2012-08-13 14:26:36 +0000120
121 SkGraphics::Init();
chudy@google.com902ebe52012-06-29 14:21:22 +0000122}
123
chudy@google.combbad34d2012-08-13 14:26:36 +0000124SkDebuggerGUI::~SkDebuggerGUI() {
125 SkGraphics::Term();
126}
chudy@google.com902ebe52012-06-29 14:21:22 +0000127
128void SkDebuggerGUI::actionBreakpoints() {
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000129 fBreakpointsActivated = !fBreakpointsActivated;
chudy@google.comc432f002012-07-10 13:19:25 +0000130 for (int row = 0; row < fListWidget.count(); row++) {
131 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000132 item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated);
133 }
134}
chudy@google.com902ebe52012-06-29 14:21:22 +0000135
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000136void SkDebuggerGUI::showDeletes() {
137 fDeletesActivated = !fDeletesActivated;
138 for (int row = 0; row < fListWidget.count(); row++) {
139 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com607357f2012-08-07 16:12:23 +0000140 item->setHidden(fDebugger.isCommandVisible(row)
141 && fDeletesActivated);
chudy@google.com902ebe52012-06-29 14:21:22 +0000142 }
143}
144
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000145// The timed picture playback uses the SkPicturePlayback's profiling stubs
146// to time individual commands. The offsets are needed to map SkPicture
147// offsets to individual commands.
148class SkTimedPicturePlayback : public SkPicturePlayback {
149public:
scroggo@google.com12d588a2013-02-25 16:05:00 +0000150 SkTimedPicturePlayback(SkStream* stream, const SkPictInfo& info,
skia.committer@gmail.com3e2345a2013-05-24 07:01:26 +0000151 SkPicture::InstallPixelRefProc proc,
robertphillips@google.com5f971142012-12-07 20:48:56 +0000152 const SkTDArray<bool>& deletedCommands)
scroggo@google.com12d588a2013-02-25 16:05:00 +0000153 : INHERITED(stream, info, proc)
bungeman@google.come8cc6e82013-01-17 16:30:56 +0000154 , fSkipCommands(deletedCommands)
155 , fTot(0.0)
156 , fCurCommand(0) {
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000157 fTimes.setCount(deletedCommands.count());
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000158 fTypeTimes.setCount(LAST_DRAWTYPE_ENUM+1);
159 this->resetTimes();
160 }
161
162 void resetTimes() {
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000163 for (int i = 0; i < fTimes.count(); ++i) {
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000164 fTimes[i] = 0.0;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000165 }
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000166 for (int i = 0; i < fTypeTimes.count(); ++i) {
167 fTypeTimes[i] = 0.0f;
168 }
169 fTot = 0.0;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000170 }
171
172 int count() const { return fTimes.count(); }
173
174 double time(int index) const { return fTimes[index] / fTot; }
175
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000176 const SkTDArray<double>* typeTimes() const { return &fTypeTimes; }
177
178 double totTime() const { return fTot; }
179
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000180protected:
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000181 BenchSysTimer fTimer;
robertphillips@google.com5f971142012-12-07 20:48:56 +0000182 SkTDArray<bool> fSkipCommands; // has the command been deleted in the GUI?
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000183 SkTDArray<double> fTimes; // sum of time consumed for each command
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000184 SkTDArray<double> fTypeTimes; // sum of time consumed for each type of command (e.g., drawPath)
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000185 double fTot; // total of all times in 'fTimes'
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000186 int fCurType;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000187 int fCurCommand; // the current command being executed/timed
188
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000189#ifdef SK_DEVELOPER
190 virtual bool preDraw(int opIndex, int type) SK_OVERRIDE {
191 fCurCommand = opIndex;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000192
robertphillips@google.com5f971142012-12-07 20:48:56 +0000193 if (fSkipCommands[fCurCommand]) {
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000194 return true;
robertphillips@google.com5f971142012-12-07 20:48:56 +0000195 }
196
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000197 fCurType = type;
198 // The SkDebugCanvas doesn't recognize these types. This class needs to
199 // convert or else we'll wind up with a mismatch between the type counts
200 // the debugger displays and the profile times.
201 if (DRAW_POS_TEXT_TOP_BOTTOM == type) {
202 fCurType = DRAW_POS_TEXT;
203 } else if (DRAW_POS_TEXT_H_TOP_BOTTOM == type) {
204 fCurType = DRAW_POS_TEXT_H;
205 }
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000206
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000207#if defined(SK_BUILD_FOR_WIN32)
208 // CPU timer doesn't work well on Windows
209 fTimer.startWall();
210#else
211 fTimer.startCpu();
212#endif
robertphillips@google.com5f971142012-12-07 20:48:56 +0000213
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000214 return false;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000215 }
216
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000217 virtual void postDraw(int opIndex) SK_OVERRIDE {
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000218#if defined(SK_BUILD_FOR_WIN32)
219 // CPU timer doesn't work well on Windows
220 double time = fTimer.endWall();
221#else
222 double time = fTimer.endCpu();
223#endif
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000224
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000225 SkASSERT(opIndex == fCurCommand);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000226 SkASSERT(fCurType <= LAST_DRAWTYPE_ENUM);
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000227
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000228 fTimes[fCurCommand] += time;
229 fTypeTimes[fCurType] += time;
230 fTot += time;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000231 }
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000232#endif
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000233
234private:
235 typedef SkPicturePlayback INHERITED;
236};
237
238// Wrap SkPicture to allow installation of an SkTimedPicturePlayback object
239class SkTimedPicture : public SkPicture {
240public:
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000241 static SkTimedPicture* CreateTimedPicture(SkStream* stream,
242 SkPicture::InstallPixelRefProc proc,
243 const SkTDArray<bool>& deletedCommands) {
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000244 SkPictInfo info;
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000245 if (!StreamIsSKP(stream, &info)) {
246 return NULL;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000247 }
248
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000249 SkTimedPicturePlayback* playback;
250 // Check to see if there is a playback to recreate.
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000251 if (stream->readBool()) {
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000252 playback = SkNEW_ARGS(SkTimedPicturePlayback,
253 (stream, info, proc, deletedCommands));
254 } else {
255 playback = NULL;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000256 }
257
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000258 return SkNEW_ARGS(SkTimedPicture, (playback, info.fWidth, info.fHeight));
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000259 }
260
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000261 void resetTimes() { ((SkTimedPicturePlayback*) fPlayback)->resetTimes(); }
262
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000263 int count() const { return ((SkTimedPicturePlayback*) fPlayback)->count(); }
264
265 // return the fraction of the total time this command consumed
266 double time(int index) const { return ((SkTimedPicturePlayback*) fPlayback)->time(index); }
267
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000268 const SkTDArray<double>* typeTimes() const { return ((SkTimedPicturePlayback*) fPlayback)->typeTimes(); }
269
270 double totTime() const { return ((SkTimedPicturePlayback*) fPlayback)->totTime(); }
271
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000272private:
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000273 // disallow default ctor b.c. we don't have a good way to setup the fPlayback ptr
274 SkTimedPicture();
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000275 // Private ctor only used by CreateTimedPicture, which has created the playback.
276 SkTimedPicture(SkTimedPicturePlayback* playback, int width, int height)
277 : INHERITED(playback, width, height) {}
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000278 // disallow the copy ctor - enabling would require copying code from SkPicture
279 SkTimedPicture(const SkTimedPicture& src);
280
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000281 typedef SkPicture INHERITED;
282};
283
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000284// This is a simplification of PictureBenchmark's run with the addition of
285// clearing of the times after the first pass (in resetTimes)
skia.committer@gmail.com34587162012-11-20 02:01:23 +0000286void SkDebuggerGUI::run(SkTimedPicture* pict,
287 sk_tools::PictureRenderer* renderer,
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000288 int repeats) {
289 SkASSERT(pict);
290 if (NULL == pict) {
291 return;
292 }
293
294 SkASSERT(renderer != NULL);
295 if (NULL == renderer) {
296 return;
297 }
298
299 renderer->init(pict);
300
301 renderer->setup();
302 renderer->render(NULL);
jvanverth@google.comade32662013-01-28 21:09:05 +0000303 renderer->resetState(true);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000304
305 // We throw this away the first batch of times to remove first time effects (such as paging in this program)
306 pict->resetTimes();
307
308 for (int i = 0; i < repeats; ++i) {
309 renderer->setup();
310 renderer->render(NULL);
jvanverth@google.comade32662013-01-28 21:09:05 +0000311 renderer->resetState(true);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000312 }
313
314 renderer->end();
315}
316
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000317void SkDebuggerGUI::actionProfile() {
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000318 // In order to profile we pass the command offsets (that were read-in
319 // in loadPicture by the SkOffsetPicture) to an SkTimedPlaybackPicture.
skia.committer@gmail.com884e60b2012-11-16 02:01:17 +0000320 // The SkTimedPlaybackPicture in turn passes the offsets to an
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000321 // SkTimedPicturePlayback object which uses them to track the performance
322 // of individual commands.
323 if (fFileName.isEmpty()) {
324 return;
325 }
326
327 SkFILEStream inputStream;
328
329 inputStream.setPath(fFileName.c_str());
330 if (!inputStream.isValid()) {
331 return;
332 }
333
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000334 SkAutoTUnref<SkTimedPicture> picture(SkTimedPicture::CreateTimedPicture(&inputStream,
335 &SkImageDecoder::DecodeMemory, fSkipCommands));
336 if (NULL == picture.get()) {
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000337 return;
338 }
339
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000340 // For now this #if allows switching between tiled and simple rendering
341 // modes. Eventually this will be accomplished via the GUI
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000342#if 0
343 // With the current batch of SysTimers, profiling in tiled mode
344 // gets swamped by the timing overhead:
345 //
346 // tile mode simple mode
347 // debugger 64.2ms 12.8ms
348 // bench_pictures 16.9ms 12.4ms
349 //
350 // This is b.c. in tiled mode each command is called many more times
351 // but typically does less work on each invocation (due to clipping)
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000352 sk_tools::TiledPictureRenderer* renderer = NULL;
353
354 renderer = SkNEW(sk_tools::TiledPictureRenderer);
355 renderer->setTileWidth(256);
356 renderer->setTileHeight(256);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000357#else
358 sk_tools::SimplePictureRenderer* renderer = NULL;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000359
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000360 renderer = SkNEW(sk_tools::SimplePictureRenderer);
robertphillips@google.com1447aa32013-01-30 21:09:09 +0000361
362#if SK_SUPPORT_GPU
363 if (Qt::Checked == fSettingsWidget.getGLCheckBox()->checkState()) {
364 renderer->setDeviceType(sk_tools::PictureRenderer::kGPU_DeviceType);
365 }
366#endif
367
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000368#endif
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000369
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000370 static const int kNumRepeats = 10;
371
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000372 run(picture.get(), renderer, kNumRepeats);
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000373
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000374 SkASSERT(picture->count() == fListWidget.count());
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000375
376 // extract the individual command times from the SkTimedPlaybackPicture
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000377 for (int i = 0; i < picture->count(); ++i) {
378 double temp = picture->time(i);
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000379
380 QListWidgetItem* item = fListWidget.item(i);
381
382 item->setData(Qt::UserRole + 4, 100.0*temp);
383 }
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000384
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000385 setupOverviewText(picture->typeTimes(), picture->totTime(), kNumRepeats);
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000386}
387
chudy@google.com902ebe52012-06-29 14:21:22 +0000388void SkDebuggerGUI::actionCancel() {
chudy@google.comc432f002012-07-10 13:19:25 +0000389 for (int row = 0; row < fListWidget.count(); row++) {
390 fListWidget.item(row)->setHidden(false);
chudy@google.com902ebe52012-06-29 14:21:22 +0000391 }
392}
393
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000394void SkDebuggerGUI::actionClearBreakpoints() {
395 for (int row = 0; row < fListWidget.count(); row++) {
396 QListWidgetItem* item = fListWidget.item(row);
397 item->setCheckState(Qt::Unchecked);
398 item->setData(Qt::DecorationRole,
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000399 QPixmap(":/blank.png"));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000400 }
401}
402
403void SkDebuggerGUI::actionClearDeletes() {
404 for (int row = 0; row < fListWidget.count(); row++) {
405 QListWidgetItem* item = fListWidget.item(row);
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000406 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png"));
chudy@google.com607357f2012-08-07 16:12:23 +0000407 fDebugger.setCommandVisible(row, true);
robertphillips@google.com5f971142012-12-07 20:48:56 +0000408 fSkipCommands[row] = false;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000409 }
410 if (fPause) {
411 fCanvasWidget.drawTo(fPausedRow);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000412 fImageWidget.draw();
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000413 } else {
414 fCanvasWidget.drawTo(fListWidget.currentRow());
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000415 fImageWidget.draw();
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000416 }
417}
418
chudy@google.com902ebe52012-06-29 14:21:22 +0000419void SkDebuggerGUI::actionCommandFilter() {
chudy@google.com607357f2012-08-07 16:12:23 +0000420 fDebugger.highlightCurrentCommand(
chudy@google.comc432f002012-07-10 13:19:25 +0000421 fSettingsWidget.getVisibilityButton()->isChecked());
422 fCanvasWidget.drawTo(fListWidget.currentRow());
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000423 fImageWidget.draw();
chudy@google.com902ebe52012-06-29 14:21:22 +0000424}
425
426void SkDebuggerGUI::actionClose() {
427 this->close();
428}
429
430void SkDebuggerGUI::actionDelete() {
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000431
robertphillips@google.comdd4b7452013-01-22 19:38:46 +0000432 for (int row = 0; row < fListWidget.count(); ++row) {
433 QListWidgetItem* item = fListWidget.item(row);
434
435 if (!item->isSelected()) {
436 continue;
437 }
438
439 if (fDebugger.isCommandVisible(row)) {
440 item->setData(Qt::UserRole + 2, QPixmap(":/delete.png"));
441 fDebugger.setCommandVisible(row, false);
442 fSkipCommands[row] = true;
443 } else {
444 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png"));
445 fDebugger.setCommandVisible(row, true);
446 fSkipCommands[row] = false;
447 }
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000448 }
449
robertphillips@google.comdd4b7452013-01-22 19:38:46 +0000450 int currentRow = fListWidget.currentRow();
451
chudy@google.come504de02012-07-16 18:35:23 +0000452 if (fPause) {
453 fCanvasWidget.drawTo(fPausedRow);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000454 fImageWidget.draw();
chudy@google.come504de02012-07-16 18:35:23 +0000455 } else {
456 fCanvasWidget.drawTo(currentRow);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000457 fImageWidget.draw();
chudy@google.come504de02012-07-16 18:35:23 +0000458 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000459}
460
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +0000461#if SK_SUPPORT_GPU
chudy@google.comea5488b2012-07-26 19:38:22 +0000462void SkDebuggerGUI::actionGLWidget(bool isToggled) {
463 fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggled);
464}
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +0000465#endif
chudy@google.comea5488b2012-07-26 19:38:22 +0000466
chudy@google.com902ebe52012-06-29 14:21:22 +0000467void SkDebuggerGUI::actionInspector() {
chudy@google.comc432f002012-07-10 13:19:25 +0000468 if (fInspectorWidget.isHidden()) {
469 fInspectorWidget.setHidden(false);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000470 fImageWidget.setHidden(false);
chudy@google.com902ebe52012-06-29 14:21:22 +0000471 } else {
chudy@google.comc432f002012-07-10 13:19:25 +0000472 fInspectorWidget.setHidden(true);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000473 fImageWidget.setHidden(true);
chudy@google.com902ebe52012-06-29 14:21:22 +0000474 }
475}
476
477void SkDebuggerGUI::actionPlay() {
chudy@google.comc432f002012-07-10 13:19:25 +0000478 for (int row = fListWidget.currentRow() + 1; row < fListWidget.count();
chudy@google.com7dcae672012-07-09 20:26:53 +0000479 row++) {
chudy@google.comc432f002012-07-10 13:19:25 +0000480 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com902ebe52012-06-29 14:21:22 +0000481 if (item->checkState() == Qt::Checked) {
chudy@google.comc432f002012-07-10 13:19:25 +0000482 fListWidget.setCurrentItem(item);
chudy@google.com902ebe52012-06-29 14:21:22 +0000483 return;
484 }
485 }
chudy@google.comc432f002012-07-10 13:19:25 +0000486 fListWidget.setCurrentRow(fListWidget.count() - 1);
chudy@google.com902ebe52012-06-29 14:21:22 +0000487}
488
chudy@google.comea5488b2012-07-26 19:38:22 +0000489void SkDebuggerGUI::actionRasterWidget(bool isToggled) {
490 fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType, !isToggled);
491}
492
robertphillips@google.comf4741c12013-02-06 20:13:54 +0000493void SkDebuggerGUI::actionOverdrawVizWidget(bool isToggled) {
494 fDebugger.setOverdrawViz(isToggled);
495 fCanvasWidget.update();
496}
497
chudy@google.com902ebe52012-06-29 14:21:22 +0000498void SkDebuggerGUI::actionRewind() {
chudy@google.come504de02012-07-16 18:35:23 +0000499 fListWidget.setCurrentRow(0);
chudy@google.com902ebe52012-06-29 14:21:22 +0000500}
501
chudy@google.com0ab03392012-07-28 20:16:11 +0000502void SkDebuggerGUI::actionSave() {
robertphillips@google.come219baf2013-01-28 19:25:43 +0000503 fFileName = fPath.toAscii().data();
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000504 fFileName.append("/");
robertphillips@google.come219baf2013-01-28 19:25:43 +0000505 fFileName.append(fDirectoryWidget.currentItem()->text().toAscii().data());
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000506 saveToFile(fFileName);
chudy@google.com0ab03392012-07-28 20:16:11 +0000507}
508
509void SkDebuggerGUI::actionSaveAs() {
510 QString filename = QFileDialog::getSaveFileName(this, "Save File", "",
511 "Skia Picture (*skp)");
chudy@google.com38b08ce2012-07-28 23:26:10 +0000512 if (!filename.endsWith(".skp", Qt::CaseInsensitive)) {
chudy@google.com0ab03392012-07-28 20:16:11 +0000513 filename.append(".skp");
514 }
djsollen@google.comc3c82162012-11-13 18:35:10 +0000515 saveToFile(SkString(filename.toAscii().data()));
chudy@google.com0ab03392012-07-28 20:16:11 +0000516}
517
chudy@google.com7dcae672012-07-09 20:26:53 +0000518void SkDebuggerGUI::actionScale(float scaleFactor) {
chudy@google.comc432f002012-07-10 13:19:25 +0000519 fSettingsWidget.setZoomText(scaleFactor);
chudy@google.com7dcae672012-07-09 20:26:53 +0000520}
521
chudy@google.com902ebe52012-06-29 14:21:22 +0000522void SkDebuggerGUI::actionSettings() {
chudy@google.comc432f002012-07-10 13:19:25 +0000523 if (fSettingsWidget.isHidden()) {
524 fSettingsWidget.setHidden(false);
chudy@google.com902ebe52012-06-29 14:21:22 +0000525 } else {
chudy@google.comc432f002012-07-10 13:19:25 +0000526 fSettingsWidget.setHidden(true);
chudy@google.com902ebe52012-06-29 14:21:22 +0000527 }
528}
529
530void SkDebuggerGUI::actionStepBack() {
chudy@google.comc432f002012-07-10 13:19:25 +0000531 int currentRow = fListWidget.currentRow();
chudy@google.com902ebe52012-06-29 14:21:22 +0000532 if (currentRow != 0) {
chudy@google.comc432f002012-07-10 13:19:25 +0000533 fListWidget.setCurrentRow(currentRow - 1);
chudy@google.com902ebe52012-06-29 14:21:22 +0000534 }
535}
536
537void SkDebuggerGUI::actionStepForward() {
chudy@google.comc432f002012-07-10 13:19:25 +0000538 int currentRow = fListWidget.currentRow();
chudy@google.com902ebe52012-06-29 14:21:22 +0000539 QString curRow = QString::number(currentRow);
chudy@google.comc432f002012-07-10 13:19:25 +0000540 QString curCount = QString::number(fListWidget.count());
541 if (currentRow < fListWidget.count() - 1) {
542 fListWidget.setCurrentRow(currentRow + 1);
chudy@google.com902ebe52012-06-29 14:21:22 +0000543 }
544}
545
chudy@google.coma9e937c2012-08-03 17:32:05 +0000546void SkDebuggerGUI::drawComplete() {
chudy@google.com607357f2012-08-07 16:12:23 +0000547 fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix());
548 fInspectorWidget.setClip(fDebugger.getCurrentClip());
chudy@google.coma9e937c2012-08-03 17:32:05 +0000549}
550
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000551void SkDebuggerGUI::saveToFile(const SkString& filename) {
552 SkFILEWStream file(filename.c_str());
robertphillips@google.com25bc2f82013-01-22 18:03:56 +0000553 SkAutoTUnref<SkPicture> copy(fDebugger.copyPicture());
554
555 copy->serialize(&file);
chudy@google.com0ab03392012-07-28 20:16:11 +0000556}
557
chudy@google.com902ebe52012-06-29 14:21:22 +0000558void SkDebuggerGUI::loadFile(QListWidgetItem *item) {
559 if (fDirectoryWidgetActive) {
robertphillips@google.come219baf2013-01-28 19:25:43 +0000560 fFileName = fPath.toAscii().data();
jvanverth@google.com0ac6f162013-02-05 19:44:07 +0000561 // don't add a '/' to files in the local directory
562 if (fFileName.size() > 0) {
563 fFileName.append("/");
564 }
robertphillips@google.come219baf2013-01-28 19:25:43 +0000565 fFileName.append(item->text().toAscii().data());
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000566 loadPicture(fFileName);
chudy@google.com902ebe52012-06-29 14:21:22 +0000567 }
568}
569
570void SkDebuggerGUI::openFile() {
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000571 QString temp = QFileDialog::getOpenFileName(this, tr("Open File"), "",
chudy@google.com7dcae672012-07-09 20:26:53 +0000572 tr("Files (*.*)"));
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000573 openFile(temp);
574}
575
576void SkDebuggerGUI::openFile(const QString &filename) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000577 fDirectoryWidgetActive = false;
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000578 if (!filename.isEmpty()) {
579 QFileInfo pathInfo(filename);
580 loadPicture(SkString(filename.toAscii().data()));
581 setupDirectoryWidget(pathInfo.path());
chudy@google.com902ebe52012-06-29 14:21:22 +0000582 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000583 fDirectoryWidgetActive = true;
584}
585
chudy@google.comc432f002012-07-10 13:19:25 +0000586void SkDebuggerGUI::pauseDrawing(bool isPaused) {
chudy@google.com607357f2012-08-07 16:12:23 +0000587 fPause = isPaused;
588 fPausedRow = fListWidget.currentRow();
589 fCanvasWidget.drawTo(fPausedRow);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000590 fImageWidget.draw();
chudy@google.com7dcae672012-07-09 20:26:53 +0000591}
592
chudy@google.com902ebe52012-06-29 14:21:22 +0000593void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
chudy@google.comd3058f52012-07-19 13:41:27 +0000594 if(!fLoading) {
595 int currentRow = fListWidget.currentRow();
chudy@google.comd3058f52012-07-19 13:41:27 +0000596
chudy@google.comea5488b2012-07-26 19:38:22 +0000597 if (currentRow != -1) {
598 if (!fPause) {
599 fCanvasWidget.drawTo(currentRow);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000600 fImageWidget.draw();
chudy@google.comd3058f52012-07-19 13:41:27 +0000601 }
chudy@google.com97cee972012-08-07 20:41:37 +0000602 SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(
chudy@google.comea5488b2012-07-26 19:38:22 +0000603 currentRow);
604
605 /* TODO(chudy): Add command type before parameters. Rename v
606 * to something more informative. */
chudy@google.com97cee972012-08-07 20:41:37 +0000607 if (currInfo) {
chudy@google.comea5488b2012-07-26 19:38:22 +0000608 QString info;
609 info.append("<b>Parameters: </b><br/>");
chudy@google.com97cee972012-08-07 20:41:37 +0000610 for (int i = 0; i < currInfo->count(); i++) {
611
612 info.append(QString((*currInfo)[i]->c_str()));
chudy@google.comea5488b2012-07-26 19:38:22 +0000613 info.append("<br/>");
614 }
chudy@google.com6bd109a2012-08-14 19:34:13 +0000615 fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType);
chudy@google.comea5488b2012-07-26 19:38:22 +0000616 fInspectorWidget.setDisabled(false);
chudy@google.comea5488b2012-07-26 19:38:22 +0000617 }
chudy@google.comd3058f52012-07-19 13:41:27 +0000618 }
chudy@google.comea5488b2012-07-26 19:38:22 +0000619
chudy@google.com902ebe52012-06-29 14:21:22 +0000620 }
621}
622
chudy@google.com9ca9bfe2012-07-12 21:58:14 +0000623void SkDebuggerGUI::selectCommand(int command) {
624 if (fPause) {
625 fListWidget.setCurrentRow(command);
626 }
627}
628
chudy@google.com902ebe52012-06-29 14:21:22 +0000629void SkDebuggerGUI::toggleBreakpoint() {
chudy@google.comc432f002012-07-10 13:19:25 +0000630 QListWidgetItem* item = fListWidget.currentItem();
chudy@google.com902ebe52012-06-29 14:21:22 +0000631 if (item->checkState() == Qt::Unchecked) {
632 item->setCheckState(Qt::Checked);
chudy@google.come565de42012-07-12 14:15:54 +0000633 item->setData(Qt::DecorationRole,
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000634 QPixmap(":/breakpoint_16x16.png"));
chudy@google.com902ebe52012-06-29 14:21:22 +0000635 } else {
chudy@google.com902ebe52012-06-29 14:21:22 +0000636 item->setCheckState(Qt::Unchecked);
chudy@google.come565de42012-07-12 14:15:54 +0000637 item->setData(Qt::DecorationRole,
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000638 QPixmap(":/blank.png"));
chudy@google.com902ebe52012-06-29 14:21:22 +0000639 }
640}
641
642void SkDebuggerGUI::toggleDirectory() {
chudy@google.com607357f2012-08-07 16:12:23 +0000643 fDirectoryWidget.setHidden(!fDirectoryWidget.isHidden());
chudy@google.com902ebe52012-06-29 14:21:22 +0000644}
645
646void SkDebuggerGUI::toggleFilter(QString string) {
chudy@google.comc432f002012-07-10 13:19:25 +0000647 for (int row = 0; row < fListWidget.count(); row++) {
648 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com607357f2012-08-07 16:12:23 +0000649 item->setHidden(item->text() != string);
chudy@google.com902ebe52012-06-29 14:21:22 +0000650 }
651}
652
653void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
654 QIcon windowIcon;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000655 windowIcon.addFile(QString::fromUtf8(":/skia.png"), QSize(),
chudy@google.com7dcae672012-07-09 20:26:53 +0000656 QIcon::Normal, QIcon::Off);
chudy@google.com902ebe52012-06-29 14:21:22 +0000657 SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI"));
658 SkDebuggerGUI->resize(1200, 1000);
659 SkDebuggerGUI->setWindowIcon(windowIcon);
chudy@google.comc432f002012-07-10 13:19:25 +0000660 SkDebuggerGUI->setWindowTitle("Skia Debugger");
chudy@google.com902ebe52012-06-29 14:21:22 +0000661
chudy@google.come504de02012-07-16 18:35:23 +0000662 fActionOpen.setShortcuts(QKeySequence::Open);
chudy@google.comc432f002012-07-10 13:19:25 +0000663 fActionOpen.setText("Open");
chudy@google.com902ebe52012-06-29 14:21:22 +0000664
665 QIcon breakpoint;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000666 breakpoint.addFile(QString::fromUtf8(":/breakpoint.png"),
chudy@google.com7dcae672012-07-09 20:26:53 +0000667 QSize(), QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000668 fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B")));
chudy@google.comc432f002012-07-10 13:19:25 +0000669 fActionBreakpoint.setIcon(breakpoint);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000670 fActionBreakpoint.setText("Breakpoints");
chudy@google.com902ebe52012-06-29 14:21:22 +0000671
672 QIcon cancel;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000673 cancel.addFile(QString::fromUtf8(":/reload.png"), QSize(),
chudy@google.com7dcae672012-07-09 20:26:53 +0000674 QIcon::Normal, QIcon::Off);
chudy@google.comc432f002012-07-10 13:19:25 +0000675 fActionCancel.setIcon(cancel);
676 fActionCancel.setText("Clear Filter");
chudy@google.com902ebe52012-06-29 14:21:22 +0000677
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000678 fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B")));
679 fActionClearBreakpoints.setText("Clear Breakpoints");
680
681 fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X")));
682 fActionClearDeletes.setText("Clear Deletes");
683
chudy@google.come504de02012-07-16 18:35:23 +0000684 fActionClose.setShortcuts(QKeySequence::Quit);
chudy@google.comc432f002012-07-10 13:19:25 +0000685 fActionClose.setText("Exit");
chudy@google.com902ebe52012-06-29 14:21:22 +0000686
chudy@google.come504de02012-07-16 18:35:23 +0000687 fActionCreateBreakpoint.setShortcut(QKeySequence(tr("B")));
688 fActionCreateBreakpoint.setText("Set Breakpoint");
689
690 fActionDelete.setShortcut(QKeySequence(tr("X")));
chudy@google.comc432f002012-07-10 13:19:25 +0000691 fActionDelete.setText("Delete Command");
chudy@google.com902ebe52012-06-29 14:21:22 +0000692
chudy@google.come504de02012-07-16 18:35:23 +0000693 fActionDirectory.setShortcut(QKeySequence(tr("Ctrl+D")));
694 fActionDirectory.setText("Directory");
chudy@google.com902ebe52012-06-29 14:21:22 +0000695
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000696 QIcon profile;
robertphillips@google.comd1636362012-11-19 18:25:09 +0000697 profile.addFile(QString::fromUtf8(":/profile.png"), QSize(),
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000698 QIcon::Normal, QIcon::Off);
699 fActionProfile.setIcon(profile);
700 fActionProfile.setText("Profile");
robertphillips@google.come099bc42012-11-19 16:26:40 +0000701 fActionProfile.setDisabled(true);
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000702
chudy@google.comc432f002012-07-10 13:19:25 +0000703 QIcon inspector;
robertphillips@google.comd1636362012-11-19 18:25:09 +0000704 inspector.addFile(QString::fromUtf8(":/inspector.png"),
chudy@google.comc432f002012-07-10 13:19:25 +0000705 QSize(), QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000706 fActionInspector.setShortcut(QKeySequence(tr("Ctrl+I")));
chudy@google.comc432f002012-07-10 13:19:25 +0000707 fActionInspector.setIcon(inspector);
chudy@google.come504de02012-07-16 18:35:23 +0000708 fActionInspector.setText("Inspector");
chudy@google.com902ebe52012-06-29 14:21:22 +0000709
bungeman@google.com2ff6d1d2013-07-01 14:24:12 +0000710 QIcon settings;
711 settings.addFile(QString::fromUtf8(":/inspector.png"),
712 QSize(), QIcon::Normal, QIcon::Off);
713 fActionSettings.setShortcut(QKeySequence(tr("Ctrl+G")));
714 fActionSettings.setIcon(settings);
715 fActionSettings.setText("Settings");
skia.committer@gmail.com0d55dd72013-07-02 07:00:59 +0000716
chudy@google.comc432f002012-07-10 13:19:25 +0000717 QIcon play;
robertphillips@google.comd1636362012-11-19 18:25:09 +0000718 play.addFile(QString::fromUtf8(":/play.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000719 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000720 fActionPlay.setShortcut(QKeySequence(tr("Ctrl+P")));
chudy@google.comc432f002012-07-10 13:19:25 +0000721 fActionPlay.setIcon(play);
722 fActionPlay.setText("Play");
chudy@google.com902ebe52012-06-29 14:21:22 +0000723
chudy@google.come504de02012-07-16 18:35:23 +0000724 QIcon pause;
robertphillips@google.comd1636362012-11-19 18:25:09 +0000725 pause.addFile(QString::fromUtf8(":/pause.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000726 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000727 fActionPause.setShortcut(QKeySequence(tr("Space")));
728 fActionPause.setCheckable(true);
729 fActionPause.setIcon(pause);
730 fActionPause.setText("Pause");
731
chudy@google.comc432f002012-07-10 13:19:25 +0000732 QIcon rewind;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000733 rewind.addFile(QString::fromUtf8(":/rewind.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000734 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000735 fActionRewind.setShortcut(QKeySequence(tr("Ctrl+R")));
chudy@google.comc432f002012-07-10 13:19:25 +0000736 fActionRewind.setIcon(rewind);
737 fActionRewind.setText("Rewind");
chudy@google.com902ebe52012-06-29 14:21:22 +0000738
chudy@google.com0ab03392012-07-28 20:16:11 +0000739 fActionSave.setShortcut(QKeySequence::Save);
740 fActionSave.setText("Save");
741 fActionSave.setDisabled(true);
742 fActionSaveAs.setShortcut(QKeySequence::SaveAs);
743 fActionSaveAs.setText("Save As");
744 fActionSaveAs.setDisabled(true);
745
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000746 fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X")));
747 fActionShowDeletes.setText("Deleted Commands");
748
chudy@google.comc432f002012-07-10 13:19:25 +0000749 QIcon stepBack;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000750 stepBack.addFile(QString::fromUtf8(":/previous.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000751 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000752 fActionStepBack.setShortcut(QKeySequence(tr("[")));
chudy@google.comc432f002012-07-10 13:19:25 +0000753 fActionStepBack.setIcon(stepBack);
754 fActionStepBack.setText("Step Back");
chudy@google.com902ebe52012-06-29 14:21:22 +0000755
chudy@google.comc432f002012-07-10 13:19:25 +0000756 QIcon stepForward;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000757 stepForward.addFile(QString::fromUtf8(":/next.png"),
chudy@google.comc432f002012-07-10 13:19:25 +0000758 QSize(), QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000759 fActionStepForward.setShortcut(QKeySequence(tr("]")));
chudy@google.comc432f002012-07-10 13:19:25 +0000760 fActionStepForward.setIcon(stepForward);
761 fActionStepForward.setText("Step Forward");
762
chudy@google.coma1226312012-07-26 20:26:44 +0000763 fActionZoomIn.setShortcut(QKeySequence(tr("Ctrl+=")));
764 fActionZoomIn.setText("Zoom In");
765 fActionZoomOut.setShortcut(QKeySequence(tr("Ctrl+-")));
766 fActionZoomOut.setText("Zoom Out");
767
chudy@google.comc432f002012-07-10 13:19:25 +0000768 fListWidget.setItemDelegate(new SkListWidget(&fListWidget));
769 fListWidget.setObjectName(QString::fromUtf8("listWidget"));
770 fListWidget.setMaximumWidth(250);
771
772 fFilter.addItem("--Filter By Available Commands--");
773
774 fDirectoryWidget.setMaximumWidth(250);
775 fDirectoryWidget.setStyleSheet("QListWidget::Item {padding: 5px;}");
776
777 fCanvasWidget.setSizePolicy(QSizePolicy::Expanding,
chudy@google.com7dcae672012-07-09 20:26:53 +0000778 QSizePolicy::Expanding);
chudy@google.com902ebe52012-06-29 14:21:22 +0000779
skia.committer@gmail.com1c9c0d32012-11-22 02:02:41 +0000780 fImageWidget.setFixedSize(SkImageWidget::kImageWidgetWidth,
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000781 SkImageWidget::kImageWidgetHeight);
782
chudy@google.comc432f002012-07-10 13:19:25 +0000783 fInspectorWidget.setSizePolicy(QSizePolicy::Expanding,
chudy@google.com7dcae672012-07-09 20:26:53 +0000784 QSizePolicy::Expanding);
chudy@google.comc432f002012-07-10 13:19:25 +0000785 fInspectorWidget.setMaximumHeight(300);
chudy@google.com902ebe52012-06-29 14:21:22 +0000786
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000787 fSettingsAndImageLayout.setSpacing(6);
788 fSettingsAndImageLayout.addWidget(&fSettingsWidget);
789 fSettingsAndImageLayout.addWidget(&fImageWidget);
790
chudy@google.comc432f002012-07-10 13:19:25 +0000791 fSettingsWidget.setSizePolicy(QSizePolicy::Expanding,
792 QSizePolicy::Expanding);
793 fSettingsWidget.setMaximumWidth(250);
chudy@google.com902ebe52012-06-29 14:21:22 +0000794
chudy@google.comc432f002012-07-10 13:19:25 +0000795 fLeftColumnLayout.setSpacing(6);
796 fLeftColumnLayout.addWidget(&fListWidget);
797 fLeftColumnLayout.addWidget(&fDirectoryWidget);
chudy@google.com902ebe52012-06-29 14:21:22 +0000798
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000799 fCanvasSettingsAndImageLayout.setSpacing(6);
800 fCanvasSettingsAndImageLayout.addWidget(&fCanvasWidget);
801 fCanvasSettingsAndImageLayout.addLayout(&fSettingsAndImageLayout);
802
chudy@google.com902ebe52012-06-29 14:21:22 +0000803
chudy@google.comc432f002012-07-10 13:19:25 +0000804 fMainAndRightColumnLayout.setSpacing(6);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000805 fMainAndRightColumnLayout.addLayout(&fCanvasSettingsAndImageLayout);
chudy@google.comc432f002012-07-10 13:19:25 +0000806 fMainAndRightColumnLayout.addWidget(&fInspectorWidget);
chudy@google.com902ebe52012-06-29 14:21:22 +0000807
chudy@google.com2d537a12012-07-31 12:49:52 +0000808 fCentralWidget.setLayout(&fContainerLayout);
chudy@google.comc432f002012-07-10 13:19:25 +0000809 fContainerLayout.setSpacing(6);
810 fContainerLayout.setContentsMargins(11, 11, 11, 11);
811 fContainerLayout.addLayout(&fLeftColumnLayout);
812 fContainerLayout.addLayout(&fMainAndRightColumnLayout);
813
814 SkDebuggerGUI->setCentralWidget(&fCentralWidget);
815 SkDebuggerGUI->setStatusBar(&fStatusBar);
816
chudy@google.come504de02012-07-16 18:35:23 +0000817 fToolBar.setIconSize(QSize(32, 32));
chudy@google.comc432f002012-07-10 13:19:25 +0000818 fToolBar.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
819 SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, &fToolBar);
chudy@google.com902ebe52012-06-29 14:21:22 +0000820
chudy@google.com0ab03392012-07-28 20:16:11 +0000821 fSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
chudy@google.com902ebe52012-06-29 14:21:22 +0000822
chudy@google.comc432f002012-07-10 13:19:25 +0000823 fToolBar.addAction(&fActionRewind);
824 fToolBar.addAction(&fActionStepBack);
chudy@google.come504de02012-07-16 18:35:23 +0000825 fToolBar.addAction(&fActionPause);
chudy@google.comc432f002012-07-10 13:19:25 +0000826 fToolBar.addAction(&fActionStepForward);
827 fToolBar.addAction(&fActionPlay);
828 fToolBar.addSeparator();
chudy@google.come504de02012-07-16 18:35:23 +0000829 fToolBar.addAction(&fActionInspector);
bungeman@google.com2ff6d1d2013-07-01 14:24:12 +0000830 fToolBar.addAction(&fActionSettings);
chudy@google.comc432f002012-07-10 13:19:25 +0000831 fToolBar.addSeparator();
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000832 fToolBar.addAction(&fActionProfile);
833
834 fToolBar.addSeparator();
chudy@google.com0ab03392012-07-28 20:16:11 +0000835 fToolBar.addWidget(&fSpacer);
chudy@google.comc432f002012-07-10 13:19:25 +0000836 fToolBar.addWidget(&fFilter);
837 fToolBar.addAction(&fActionCancel);
chudy@google.com902ebe52012-06-29 14:21:22 +0000838
839 // TODO(chudy): Remove static call.
840 fDirectoryWidgetActive = false;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000841 fFileName = "";
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000842 setupDirectoryWidget("");
chudy@google.com902ebe52012-06-29 14:21:22 +0000843 fDirectoryWidgetActive = true;
844
chudy@google.com902ebe52012-06-29 14:21:22 +0000845 // Menu Bar
chudy@google.comc432f002012-07-10 13:19:25 +0000846 fMenuFile.setTitle("File");
847 fMenuFile.addAction(&fActionOpen);
chudy@google.com0ab03392012-07-28 20:16:11 +0000848 fMenuFile.addAction(&fActionSave);
849 fMenuFile.addAction(&fActionSaveAs);
chudy@google.comc432f002012-07-10 13:19:25 +0000850 fMenuFile.addAction(&fActionClose);
chudy@google.come504de02012-07-16 18:35:23 +0000851
852 fMenuEdit.setTitle("Edit");
853 fMenuEdit.addAction(&fActionDelete);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000854 fMenuEdit.addAction(&fActionClearDeletes);
855 fMenuEdit.addSeparator();
chudy@google.come504de02012-07-16 18:35:23 +0000856 fMenuEdit.addAction(&fActionCreateBreakpoint);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000857 fMenuEdit.addAction(&fActionClearBreakpoints);
chudy@google.come504de02012-07-16 18:35:23 +0000858
chudy@google.comc432f002012-07-10 13:19:25 +0000859 fMenuNavigate.setTitle("Navigate");
chudy@google.come504de02012-07-16 18:35:23 +0000860 fMenuNavigate.addAction(&fActionRewind);
861 fMenuNavigate.addAction(&fActionStepBack);
862 fMenuNavigate.addAction(&fActionStepForward);
863 fMenuNavigate.addAction(&fActionPlay);
864 fMenuNavigate.addAction(&fActionPause);
chudy@google.comc432f002012-07-10 13:19:25 +0000865 fMenuNavigate.addAction(&fActionGoToLine);
chudy@google.come504de02012-07-16 18:35:23 +0000866
chudy@google.comc432f002012-07-10 13:19:25 +0000867 fMenuView.setTitle("View");
chudy@google.come504de02012-07-16 18:35:23 +0000868 fMenuView.addAction(&fActionBreakpoint);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000869 fMenuView.addAction(&fActionShowDeletes);
chudy@google.coma1226312012-07-26 20:26:44 +0000870 fMenuView.addAction(&fActionZoomIn);
871 fMenuView.addAction(&fActionZoomOut);
chudy@google.come504de02012-07-16 18:35:23 +0000872
873 fMenuWindows.setTitle("Window");
874 fMenuWindows.addAction(&fActionInspector);
bungeman@google.com2ff6d1d2013-07-01 14:24:12 +0000875 fMenuWindows.addAction(&fActionSettings);
chudy@google.come504de02012-07-16 18:35:23 +0000876 fMenuWindows.addAction(&fActionDirectory);
chudy@google.comc432f002012-07-10 13:19:25 +0000877
878 fActionGoToLine.setText("Go to Line...");
879 fActionGoToLine.setDisabled(true);
880 fMenuBar.addAction(fMenuFile.menuAction());
chudy@google.come504de02012-07-16 18:35:23 +0000881 fMenuBar.addAction(fMenuEdit.menuAction());
chudy@google.comc432f002012-07-10 13:19:25 +0000882 fMenuBar.addAction(fMenuView.menuAction());
883 fMenuBar.addAction(fMenuNavigate.menuAction());
chudy@google.come504de02012-07-16 18:35:23 +0000884 fMenuBar.addAction(fMenuWindows.menuAction());
chudy@google.com902ebe52012-06-29 14:21:22 +0000885
chudy@google.com7dcae672012-07-09 20:26:53 +0000886 fPause = false;
887
chudy@google.comc432f002012-07-10 13:19:25 +0000888 SkDebuggerGUI->setMenuBar(&fMenuBar);
chudy@google.com902ebe52012-06-29 14:21:22 +0000889 QMetaObject::connectSlotsByName(SkDebuggerGUI);
890}
891
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000892void SkDebuggerGUI::setupDirectoryWidget(const QString& path) {
893 fPath = path;
894 QDir dir(path);
chudy@google.com902ebe52012-06-29 14:21:22 +0000895 QRegExp r(".skp");
chudy@google.comc432f002012-07-10 13:19:25 +0000896 fDirectoryWidget.clear();
897 const QStringList files = dir.entryList();
chudy@google.com902ebe52012-06-29 14:21:22 +0000898 foreach (QString f, files) {
chudy@google.com7dcae672012-07-09 20:26:53 +0000899 if (f.contains(r))
chudy@google.comc432f002012-07-10 13:19:25 +0000900 fDirectoryWidget.addItem(f);
chudy@google.com902ebe52012-06-29 14:21:22 +0000901 }
902}
903
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000904void SkDebuggerGUI::loadPicture(const SkString& fileName) {
905 fFileName = fileName;
chudy@google.comd3058f52012-07-19 13:41:27 +0000906 fLoading = true;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000907 SkStream* stream = SkNEW_ARGS(SkFILEStream, (fileName.c_str()));
robertphillips@google.com2d40ec42013-02-07 20:39:40 +0000908
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000909 SkPicture* picture = SkPicture::CreateFromStream(stream);
robertphillips@google.com2d40ec42013-02-07 20:39:40 +0000910
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000911 if (NULL == picture) {
robertphillips@google.com2d40ec42013-02-07 20:39:40 +0000912 QMessageBox::critical(this, "Error loading file", "Couldn't read file, sorry.");
913 SkSafeUnref(stream);
914 return;
915 }
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000916
chudy@google.com686e6802012-08-14 16:00:32 +0000917 fCanvasWidget.resetWidgetTransform();
chudy@google.com607357f2012-08-07 16:12:23 +0000918 fDebugger.loadPicture(picture);
chudy@google.com4c7962e2012-08-14 19:38:31 +0000919
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000920 fSkipCommands.setCount(fDebugger.getSize());
921 for (int i = 0; i < fSkipCommands.count(); ++i) {
robertphillips@google.com5f971142012-12-07 20:48:56 +0000922 fSkipCommands[i] = false;
923 }
924
chudy@google.com607357f2012-08-07 16:12:23 +0000925 SkSafeUnref(stream);
926 SkSafeUnref(picture);
927
chudy@google.com97cee972012-08-07 20:41:37 +0000928 // Will this automatically clear out due to nature of refcnt?
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000929 SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings();
chudy@google.com607357f2012-08-07 16:12:23 +0000930
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000931 fActionProfile.setDisabled(false);
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000932
chudy@google.com7dcae672012-07-09 20:26:53 +0000933 /* fDebugCanvas is reinitialized every load picture. Need it to retain value
chudy@google.com607357f2012-08-07 16:12:23 +0000934 * of the visibility filter.
935 * TODO(chudy): This should be deprecated since fDebugger is not
936 * recreated.
937 * */
938 fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityButton()->isChecked());
939
chudy@google.com97cee972012-08-07 20:41:37 +0000940 setupListWidget(commands);
941 setupComboBox(commands);
robertphillips@google.come428f9b2013-03-12 15:33:40 +0000942 setupOverviewText(NULL, 0.0, 1);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000943 fInspectorWidget.setDisabled(false);
chudy@google.come606d6e2012-07-12 14:31:25 +0000944 fSettingsWidget.setDisabled(false);
chudy@google.comd3058f52012-07-19 13:41:27 +0000945 fMenuEdit.setDisabled(false);
946 fMenuNavigate.setDisabled(false);
947 fMenuView.setDisabled(false);
chudy@google.com0ab03392012-07-28 20:16:11 +0000948 fActionSave.setDisabled(false);
949 fActionSaveAs.setDisabled(false);
chudy@google.comd3058f52012-07-19 13:41:27 +0000950 fLoading = false;
951 actionPlay();
chudy@google.com902ebe52012-06-29 14:21:22 +0000952}
953
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000954void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* command) {
chudy@google.comc432f002012-07-10 13:19:25 +0000955 fListWidget.clear();
chudy@google.com902ebe52012-06-29 14:21:22 +0000956 int counter = 0;
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000957 int indent = 0;
chudy@google.com97cee972012-08-07 20:41:37 +0000958 for (int i = 0; i < command->count(); i++) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000959 QListWidgetItem *item = new QListWidgetItem();
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000960 item->setData(Qt::DisplayRole, (*command)[i].c_str());
chudy@google.com902ebe52012-06-29 14:21:22 +0000961 item->setData(Qt::UserRole + 1, counter++);
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000962
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000963 if (0 == strcmp("Restore", (*command)[i].c_str()) ||
964 0 == strcmp("EndCommentGroup", (*command)[i].c_str())) {
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000965 indent -= 10;
966 }
967
968 item->setData(Qt::UserRole + 3, indent);
969
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000970 if (0 == strcmp("Save", (*command)[i].c_str()) ||
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000971 0 == strcmp("Save Layer", (*command)[i].c_str()) ||
972 0 == strcmp("BeginCommentGroup", (*command)[i].c_str())) {
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000973 indent += 10;
974 }
975
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000976 item->setData(Qt::UserRole + 4, -1.0);
977
chudy@google.comc432f002012-07-10 13:19:25 +0000978 fListWidget.addItem(item);
chudy@google.com902ebe52012-06-29 14:21:22 +0000979 }
980}
981
skia.committer@gmail.com91274b92013-03-13 07:01:04 +0000982void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes,
robertphillips@google.come428f9b2013-03-12 15:33:40 +0000983 double totTime,
984 int numRuns) {
borenet@google.com2d9dbd42013-03-12 13:07:40 +0000985 SkString overview;
robertphillips@google.come428f9b2013-03-12 15:33:40 +0000986 fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns);
borenet@google.com2d9dbd42013-03-12 13:07:40 +0000987 fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabType);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000988}
989
990void SkDebuggerGUI::setupComboBox(SkTArray<SkString>* command) {
991 fFilter.clear();
992 fFilter.addItem("--Filter By Available Commands--");
993
994 std::map<std::string, int> map;
995 for (int i = 0; i < command->count(); i++) {
996 map[(*command)[i].c_str()]++;
997 }
998
skia.committer@gmail.com34587162012-11-20 02:01:23 +0000999 for (std::map<std::string, int>::iterator it = map.begin(); it != map.end();
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +00001000 ++it) {
1001 fFilter.addItem((it->first).c_str());
1002 }
chudy@google.com902ebe52012-06-29 14:21:22 +00001003
1004 // NOTE(chudy): Makes first item unselectable.
chudy@google.com7dcae672012-07-09 20:26:53 +00001005 QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
chudy@google.comc432f002012-07-10 13:19:25 +00001006 fFilter.model());
1007 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(),
1008 fFilter.rootModelIndex());
chudy@google.com902ebe52012-06-29 14:21:22 +00001009 QStandardItem* firstItem = model->itemFromIndex(firstIndex);
1010 firstItem->setSelectable(false);
1011}