chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | /* |
| 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.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 8 | #include "SkDebuggerGUI.h" |
chudy@google.com | bbad34d | 2012-08-13 14:26:36 +0000 | [diff] [blame] | 9 | #include "SkGraphics.h" |
scroggo@google.com | b4467e6 | 2012-11-06 23:10:09 +0000 | [diff] [blame] | 10 | #include "SkImageDecoder.h" |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 11 | #include <QListWidgetItem> |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 12 | #include "PictureRenderer.h" |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 13 | #include "SkPictureRecord.h" |
| 14 | #include "SkPicturePlayback.h" |
robertphillips@google.com | e174a8b | 2012-11-27 16:04:42 +0000 | [diff] [blame] | 15 | |
| 16 | #if defined(SK_BUILD_FOR_WIN32) |
| 17 | #include "BenchSysTimer_windows.h" |
| 18 | #elif defined(SK_BUILD_FOR_MAC) |
| 19 | #include "BenchSysTimer_mach.h" |
| 20 | #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) |
| 21 | #include "BenchSysTimer_posix.h" |
| 22 | #else |
| 23 | #include "BenchSysTimer_c.h" |
| 24 | #endif |
| 25 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 26 | |
| 27 | SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 28 | QMainWindow(parent) |
chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 29 | , fCentralWidget(this) |
| 30 | , fStatusBar(this) |
| 31 | , fToolBar(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 32 | , fActionOpen(this) |
| 33 | , fActionBreakpoint(this) |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 34 | , fActionProfile(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 35 | , fActionCancel(this) |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 36 | , fActionClearBreakpoints(this) |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 37 | , fActionClearDeletes(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 38 | , fActionClose(this) |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 39 | , fActionCreateBreakpoint(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 40 | , fActionDelete(this) |
| 41 | , fActionDirectory(this) |
| 42 | , fActionGoToLine(this) |
| 43 | , fActionInspector(this) |
| 44 | , fActionPlay(this) |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 45 | , fActionPause(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 46 | , fActionRewind(this) |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 47 | , fActionSave(this) |
| 48 | , fActionSaveAs(this) |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 49 | , fActionShowDeletes(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 50 | , fActionStepBack(this) |
| 51 | , fActionStepForward(this) |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 52 | , fActionZoomIn(this) |
| 53 | , fActionZoomOut(this) |
| 54 | , fMapper(this) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 55 | , fListWidget(&fCentralWidget) |
| 56 | , fDirectoryWidget(&fCentralWidget) |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 57 | , fCanvasWidget(this, &fDebugger) |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 58 | , fImageWidget(&fDebugger) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 59 | , fMenuBar(this) |
| 60 | , fMenuFile(this) |
| 61 | , fMenuNavigate(this) |
| 62 | , fMenuView(this) |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 63 | , fBreakpointsActivated(false) |
| 64 | , fDeletesActivated(false) |
| 65 | , fPause(false) |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 66 | , fLoading(false) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 67 | { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 68 | setupUi(this); |
robertphillips@google.com | dd4b745 | 2013-01-22 19:38:46 +0000 | [diff] [blame] | 69 | fListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 70 | connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(registerListClick(QListWidgetItem *))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 71 | connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 72 | connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory())); |
| 73 | connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(loadFile(QListWidgetItem *))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 74 | connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 75 | connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(toggleBreakpoint())); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 76 | connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind())); |
| 77 | connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay())); |
| 78 | connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 79 | connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForward())); |
| 80 | connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoints())); |
| 81 | connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector())); |
| 82 | connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionSettings())); |
| 83 | connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QString))); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 84 | connect(&fActionProfile, SIGNAL(triggered()), this, SLOT(actionProfile())); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 85 | connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel())); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 86 | connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints())); |
| 87 | connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes())); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 88 | connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 89 | connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this, SLOT(actionCommandFilter())); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 90 | #if SK_SUPPORT_GPU |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 91 | connect(fSettingsWidget.getGLCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionGLWidget(bool))); |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 92 | #endif |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 93 | connect(fSettingsWidget.getRasterCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionRasterWidget(bool))); |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 94 | connect(fSettingsWidget.getOverdrawVizCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionOverdrawVizWidget(bool))); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 95 | connect(&fActionPause, SIGNAL(toggled(bool)), this, SLOT(pauseDrawing(bool))); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 96 | connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint())); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 97 | connect(&fActionShowDeletes, SIGNAL(triggered()), this, SLOT(showDeletes())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 98 | connect(&fCanvasWidget, SIGNAL(hitChanged(int)), this, SLOT(selectCommand(int))); |
| 99 | connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget, SLOT(updateHit(int))); |
| 100 | connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this, SLOT(actionScale(float))); |
| 101 | connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fSettingsWidget, SLOT(updateCommand(int))); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 102 | connect(&fActionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs())); |
| 103 | connect(&fActionSave, SIGNAL(triggered()), this, SLOT(actionSave())); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 104 | |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 105 | fMapper.setMapping(&fActionZoomIn, SkCanvasWidget::kIn_ZoomCommand); |
| 106 | fMapper.setMapping(&fActionZoomOut, SkCanvasWidget::kOut_ZoomCommand); |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 107 | |
| 108 | connect(&fActionZoomIn, SIGNAL(triggered()), &fMapper, SLOT(map())); |
| 109 | connect(&fActionZoomOut, SIGNAL(triggered()), &fMapper, SLOT(map())); |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 110 | connect(&fMapper, SIGNAL(mapped(int)), &fCanvasWidget, SLOT(zoom(int))); |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 111 | |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 112 | fInspectorWidget.setDisabled(true); |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 113 | fMenuEdit.setDisabled(true); |
| 114 | fMenuNavigate.setDisabled(true); |
| 115 | fMenuView.setDisabled(true); |
chudy@google.com | bbad34d | 2012-08-13 14:26:36 +0000 | [diff] [blame] | 116 | |
| 117 | SkGraphics::Init(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 118 | } |
| 119 | |
chudy@google.com | bbad34d | 2012-08-13 14:26:36 +0000 | [diff] [blame] | 120 | SkDebuggerGUI::~SkDebuggerGUI() { |
| 121 | SkGraphics::Term(); |
| 122 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 123 | |
| 124 | void SkDebuggerGUI::actionBreakpoints() { |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 125 | fBreakpointsActivated = !fBreakpointsActivated; |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 126 | for (int row = 0; row < fListWidget.count(); row++) { |
| 127 | QListWidgetItem *item = fListWidget.item(row); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 128 | item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated); |
| 129 | } |
| 130 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 131 | |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 132 | void SkDebuggerGUI::showDeletes() { |
| 133 | fDeletesActivated = !fDeletesActivated; |
| 134 | for (int row = 0; row < fListWidget.count(); row++) { |
| 135 | QListWidgetItem *item = fListWidget.item(row); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 136 | item->setHidden(fDebugger.isCommandVisible(row) |
| 137 | && fDeletesActivated); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 138 | } |
| 139 | } |
| 140 | |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 141 | // The timed picture playback uses the SkPicturePlayback's profiling stubs |
| 142 | // to time individual commands. The offsets are needed to map SkPicture |
| 143 | // offsets to individual commands. |
| 144 | class SkTimedPicturePlayback : public SkPicturePlayback { |
| 145 | public: |
scroggo@google.com | 12d588a | 2013-02-25 16:05:00 +0000 | [diff] [blame] | 146 | SkTimedPicturePlayback(SkStream* stream, const SkPictInfo& info, |
skia.committer@gmail.com | 3e2345a | 2013-05-24 07:01:26 +0000 | [diff] [blame] | 147 | SkPicture::InstallPixelRefProc proc, |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 148 | const SkTDArray<bool>& deletedCommands) |
scroggo@google.com | 12d588a | 2013-02-25 16:05:00 +0000 | [diff] [blame] | 149 | : INHERITED(stream, info, proc) |
bungeman@google.com | e8cc6e8 | 2013-01-17 16:30:56 +0000 | [diff] [blame] | 150 | , fSkipCommands(deletedCommands) |
| 151 | , fTot(0.0) |
| 152 | , fCurCommand(0) { |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 153 | fTimes.setCount(deletedCommands.count()); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 154 | fTypeTimes.setCount(LAST_DRAWTYPE_ENUM+1); |
| 155 | this->resetTimes(); |
| 156 | } |
| 157 | |
| 158 | void resetTimes() { |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 159 | for (int i = 0; i < fTimes.count(); ++i) { |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 160 | fTimes[i] = 0.0; |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 161 | } |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 162 | for (int i = 0; i < fTypeTimes.count(); ++i) { |
| 163 | fTypeTimes[i] = 0.0f; |
| 164 | } |
| 165 | fTot = 0.0; |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | int count() const { return fTimes.count(); } |
| 169 | |
| 170 | double time(int index) const { return fTimes[index] / fTot; } |
| 171 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 172 | const SkTDArray<double>* typeTimes() const { return &fTypeTimes; } |
| 173 | |
| 174 | double totTime() const { return fTot; } |
| 175 | |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 176 | protected: |
robertphillips@google.com | e174a8b | 2012-11-27 16:04:42 +0000 | [diff] [blame] | 177 | BenchSysTimer fTimer; |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 178 | SkTDArray<bool> fSkipCommands; // has the command been deleted in the GUI? |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 179 | SkTDArray<double> fTimes; // sum of time consumed for each command |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 180 | SkTDArray<double> fTypeTimes; // sum of time consumed for each type of command (e.g., drawPath) |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 181 | double fTot; // total of all times in 'fTimes' |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 182 | int fCurType; |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 183 | int fCurCommand; // the current command being executed/timed |
| 184 | |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 185 | #ifdef SK_DEVELOPER |
| 186 | virtual bool preDraw(int opIndex, int type) SK_OVERRIDE { |
| 187 | fCurCommand = opIndex; |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 188 | |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 189 | if (fSkipCommands[fCurCommand]) { |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 190 | return true; |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 191 | } |
| 192 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 193 | fCurType = type; |
| 194 | // The SkDebugCanvas doesn't recognize these types. This class needs to |
| 195 | // convert or else we'll wind up with a mismatch between the type counts |
| 196 | // the debugger displays and the profile times. |
| 197 | if (DRAW_POS_TEXT_TOP_BOTTOM == type) { |
| 198 | fCurType = DRAW_POS_TEXT; |
| 199 | } else if (DRAW_POS_TEXT_H_TOP_BOTTOM == type) { |
| 200 | fCurType = DRAW_POS_TEXT_H; |
| 201 | } |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 202 | |
robertphillips@google.com | e174a8b | 2012-11-27 16:04:42 +0000 | [diff] [blame] | 203 | #if defined(SK_BUILD_FOR_WIN32) |
| 204 | // CPU timer doesn't work well on Windows |
| 205 | fTimer.startWall(); |
| 206 | #else |
| 207 | fTimer.startCpu(); |
| 208 | #endif |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 209 | |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 210 | return false; |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 211 | } |
| 212 | |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 213 | virtual void postDraw(int opIndex) SK_OVERRIDE { |
robertphillips@google.com | e174a8b | 2012-11-27 16:04:42 +0000 | [diff] [blame] | 214 | #if defined(SK_BUILD_FOR_WIN32) |
| 215 | // CPU timer doesn't work well on Windows |
| 216 | double time = fTimer.endWall(); |
| 217 | #else |
| 218 | double time = fTimer.endCpu(); |
| 219 | #endif |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 220 | |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 221 | SkASSERT(opIndex == fCurCommand); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 222 | SkASSERT(fCurType <= LAST_DRAWTYPE_ENUM); |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 223 | |
robertphillips@google.com | e174a8b | 2012-11-27 16:04:42 +0000 | [diff] [blame] | 224 | fTimes[fCurCommand] += time; |
| 225 | fTypeTimes[fCurType] += time; |
| 226 | fTot += time; |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 227 | } |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 228 | #endif |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 229 | |
| 230 | private: |
| 231 | typedef SkPicturePlayback INHERITED; |
| 232 | }; |
| 233 | |
| 234 | // Wrap SkPicture to allow installation of an SkTimedPicturePlayback object |
| 235 | class SkTimedPicture : public SkPicture { |
| 236 | public: |
scroggo@google.com | 9f12316 | 2013-02-22 22:37:31 +0000 | [diff] [blame] | 237 | explicit SkTimedPicture(SkStream* stream, bool* success, SkPicture::InstallPixelRefProc proc, |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 238 | const SkTDArray<bool>& deletedCommands) { |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 239 | if (success) { |
| 240 | *success = false; |
| 241 | } |
| 242 | fRecord = NULL; |
| 243 | fPlayback = NULL; |
| 244 | fWidth = fHeight = 0; |
| 245 | |
| 246 | SkPictInfo info; |
| 247 | |
| 248 | if (!stream->read(&info, sizeof(info))) { |
| 249 | return; |
| 250 | } |
| 251 | if (SkPicture::PICTURE_VERSION != info.fVersion) { |
| 252 | return; |
| 253 | } |
| 254 | |
| 255 | if (stream->readBool()) { |
skia.committer@gmail.com | 884e60b | 2012-11-16 02:01:17 +0000 | [diff] [blame] | 256 | fPlayback = SkNEW_ARGS(SkTimedPicturePlayback, |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 257 | (stream, info, proc, deletedCommands)); |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | // do this at the end, so that they will be zero if we hit an error. |
| 261 | fWidth = info.fWidth; |
| 262 | fHeight = info.fHeight; |
| 263 | if (success) { |
| 264 | *success = true; |
| 265 | } |
| 266 | } |
| 267 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 268 | void resetTimes() { ((SkTimedPicturePlayback*) fPlayback)->resetTimes(); } |
| 269 | |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 270 | int count() const { return ((SkTimedPicturePlayback*) fPlayback)->count(); } |
| 271 | |
| 272 | // return the fraction of the total time this command consumed |
| 273 | double time(int index) const { return ((SkTimedPicturePlayback*) fPlayback)->time(index); } |
| 274 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 275 | const SkTDArray<double>* typeTimes() const { return ((SkTimedPicturePlayback*) fPlayback)->typeTimes(); } |
| 276 | |
| 277 | double totTime() const { return ((SkTimedPicturePlayback*) fPlayback)->totTime(); } |
| 278 | |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 279 | private: |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 280 | // disallow default ctor b.c. we don't have a good way to setup the fPlayback ptr |
| 281 | SkTimedPicture(); |
| 282 | // disallow the copy ctor - enabling would require copying code from SkPicture |
| 283 | SkTimedPicture(const SkTimedPicture& src); |
| 284 | |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 285 | typedef SkPicture INHERITED; |
| 286 | }; |
| 287 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 288 | // This is a simplification of PictureBenchmark's run with the addition of |
| 289 | // clearing of the times after the first pass (in resetTimes) |
skia.committer@gmail.com | 3458716 | 2012-11-20 02:01:23 +0000 | [diff] [blame] | 290 | void SkDebuggerGUI::run(SkTimedPicture* pict, |
| 291 | sk_tools::PictureRenderer* renderer, |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 292 | int repeats) { |
| 293 | SkASSERT(pict); |
| 294 | if (NULL == pict) { |
| 295 | return; |
| 296 | } |
| 297 | |
| 298 | SkASSERT(renderer != NULL); |
| 299 | if (NULL == renderer) { |
| 300 | return; |
| 301 | } |
| 302 | |
| 303 | renderer->init(pict); |
| 304 | |
| 305 | renderer->setup(); |
| 306 | renderer->render(NULL); |
jvanverth@google.com | ade3266 | 2013-01-28 21:09:05 +0000 | [diff] [blame] | 307 | renderer->resetState(true); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 308 | |
| 309 | // We throw this away the first batch of times to remove first time effects (such as paging in this program) |
| 310 | pict->resetTimes(); |
| 311 | |
| 312 | for (int i = 0; i < repeats; ++i) { |
| 313 | renderer->setup(); |
| 314 | renderer->render(NULL); |
jvanverth@google.com | ade3266 | 2013-01-28 21:09:05 +0000 | [diff] [blame] | 315 | renderer->resetState(true); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | renderer->end(); |
| 319 | } |
| 320 | |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 321 | void SkDebuggerGUI::actionProfile() { |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 322 | // In order to profile we pass the command offsets (that were read-in |
| 323 | // in loadPicture by the SkOffsetPicture) to an SkTimedPlaybackPicture. |
skia.committer@gmail.com | 884e60b | 2012-11-16 02:01:17 +0000 | [diff] [blame] | 324 | // The SkTimedPlaybackPicture in turn passes the offsets to an |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 325 | // SkTimedPicturePlayback object which uses them to track the performance |
| 326 | // of individual commands. |
| 327 | if (fFileName.isEmpty()) { |
| 328 | return; |
| 329 | } |
| 330 | |
| 331 | SkFILEStream inputStream; |
| 332 | |
| 333 | inputStream.setPath(fFileName.c_str()); |
| 334 | if (!inputStream.isValid()) { |
| 335 | return; |
| 336 | } |
| 337 | |
| 338 | bool success = false; |
scroggo@google.com | f8d7d27 | 2013-02-22 21:38:35 +0000 | [diff] [blame] | 339 | SkTimedPicture picture(&inputStream, &success, &SkImageDecoder::DecodeMemory, |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 340 | fSkipCommands); |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 341 | if (!success) { |
| 342 | return; |
| 343 | } |
| 344 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 345 | // For now this #if allows switching between tiled and simple rendering |
| 346 | // modes. Eventually this will be accomplished via the GUI |
robertphillips@google.com | e174a8b | 2012-11-27 16:04:42 +0000 | [diff] [blame] | 347 | #if 0 |
| 348 | // With the current batch of SysTimers, profiling in tiled mode |
| 349 | // gets swamped by the timing overhead: |
| 350 | // |
| 351 | // tile mode simple mode |
| 352 | // debugger 64.2ms 12.8ms |
| 353 | // bench_pictures 16.9ms 12.4ms |
| 354 | // |
| 355 | // This is b.c. in tiled mode each command is called many more times |
| 356 | // but typically does less work on each invocation (due to clipping) |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 357 | sk_tools::TiledPictureRenderer* renderer = NULL; |
| 358 | |
| 359 | renderer = SkNEW(sk_tools::TiledPictureRenderer); |
| 360 | renderer->setTileWidth(256); |
| 361 | renderer->setTileHeight(256); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 362 | #else |
| 363 | sk_tools::SimplePictureRenderer* renderer = NULL; |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 364 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 365 | renderer = SkNEW(sk_tools::SimplePictureRenderer); |
robertphillips@google.com | 1447aa3 | 2013-01-30 21:09:09 +0000 | [diff] [blame] | 366 | |
| 367 | #if SK_SUPPORT_GPU |
| 368 | if (Qt::Checked == fSettingsWidget.getGLCheckBox()->checkState()) { |
| 369 | renderer->setDeviceType(sk_tools::PictureRenderer::kGPU_DeviceType); |
| 370 | } |
| 371 | #endif |
| 372 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 373 | #endif |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 374 | |
robertphillips@google.com | e174a8b | 2012-11-27 16:04:42 +0000 | [diff] [blame] | 375 | static const int kNumRepeats = 10; |
| 376 | |
| 377 | run(&picture, renderer, kNumRepeats); |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 378 | |
| 379 | SkASSERT(picture.count() == fListWidget.count()); |
| 380 | |
| 381 | // extract the individual command times from the SkTimedPlaybackPicture |
| 382 | for (int i = 0; i < picture.count(); ++i) { |
| 383 | double temp = picture.time(i); |
| 384 | |
| 385 | QListWidgetItem* item = fListWidget.item(i); |
| 386 | |
| 387 | item->setData(Qt::UserRole + 4, 100.0*temp); |
| 388 | } |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 389 | |
robertphillips@google.com | e428f9b | 2013-03-12 15:33:40 +0000 | [diff] [blame] | 390 | setupOverviewText(picture.typeTimes(), picture.totTime(), kNumRepeats); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 391 | } |
| 392 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 393 | void SkDebuggerGUI::actionCancel() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 394 | for (int row = 0; row < fListWidget.count(); row++) { |
| 395 | fListWidget.item(row)->setHidden(false); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 396 | } |
| 397 | } |
| 398 | |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 399 | void SkDebuggerGUI::actionClearBreakpoints() { |
| 400 | for (int row = 0; row < fListWidget.count(); row++) { |
| 401 | QListWidgetItem* item = fListWidget.item(row); |
| 402 | item->setCheckState(Qt::Unchecked); |
| 403 | item->setData(Qt::DecorationRole, |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 404 | QPixmap(":/blank.png")); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 405 | } |
| 406 | } |
| 407 | |
| 408 | void SkDebuggerGUI::actionClearDeletes() { |
| 409 | for (int row = 0; row < fListWidget.count(); row++) { |
| 410 | QListWidgetItem* item = fListWidget.item(row); |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 411 | item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 412 | fDebugger.setCommandVisible(row, true); |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 413 | fSkipCommands[row] = false; |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 414 | } |
| 415 | if (fPause) { |
| 416 | fCanvasWidget.drawTo(fPausedRow); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 417 | fImageWidget.draw(); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 418 | } else { |
| 419 | fCanvasWidget.drawTo(fListWidget.currentRow()); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 420 | fImageWidget.draw(); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 421 | } |
| 422 | } |
| 423 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 424 | void SkDebuggerGUI::actionCommandFilter() { |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 425 | fDebugger.highlightCurrentCommand( |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 426 | fSettingsWidget.getVisibilityButton()->isChecked()); |
| 427 | fCanvasWidget.drawTo(fListWidget.currentRow()); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 428 | fImageWidget.draw(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | void SkDebuggerGUI::actionClose() { |
| 432 | this->close(); |
| 433 | } |
| 434 | |
| 435 | void SkDebuggerGUI::actionDelete() { |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 436 | |
robertphillips@google.com | dd4b745 | 2013-01-22 19:38:46 +0000 | [diff] [blame] | 437 | for (int row = 0; row < fListWidget.count(); ++row) { |
| 438 | QListWidgetItem* item = fListWidget.item(row); |
| 439 | |
| 440 | if (!item->isSelected()) { |
| 441 | continue; |
| 442 | } |
| 443 | |
| 444 | if (fDebugger.isCommandVisible(row)) { |
| 445 | item->setData(Qt::UserRole + 2, QPixmap(":/delete.png")); |
| 446 | fDebugger.setCommandVisible(row, false); |
| 447 | fSkipCommands[row] = true; |
| 448 | } else { |
| 449 | item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); |
| 450 | fDebugger.setCommandVisible(row, true); |
| 451 | fSkipCommands[row] = false; |
| 452 | } |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 453 | } |
| 454 | |
robertphillips@google.com | dd4b745 | 2013-01-22 19:38:46 +0000 | [diff] [blame] | 455 | int currentRow = fListWidget.currentRow(); |
| 456 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 457 | if (fPause) { |
| 458 | fCanvasWidget.drawTo(fPausedRow); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 459 | fImageWidget.draw(); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 460 | } else { |
| 461 | fCanvasWidget.drawTo(currentRow); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 462 | fImageWidget.draw(); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 463 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 464 | } |
| 465 | |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 466 | #if SK_SUPPORT_GPU |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 467 | void SkDebuggerGUI::actionGLWidget(bool isToggled) { |
| 468 | fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggled); |
| 469 | } |
robertphillips@google.com | e8fe4bc | 2013-02-13 13:26:13 +0000 | [diff] [blame] | 470 | #endif |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 471 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 472 | void SkDebuggerGUI::actionInspector() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 473 | if (fInspectorWidget.isHidden()) { |
| 474 | fInspectorWidget.setHidden(false); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 475 | fImageWidget.setHidden(false); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 476 | } else { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 477 | fInspectorWidget.setHidden(true); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 478 | fImageWidget.setHidden(true); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 479 | } |
| 480 | } |
| 481 | |
| 482 | void SkDebuggerGUI::actionPlay() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 483 | for (int row = fListWidget.currentRow() + 1; row < fListWidget.count(); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 484 | row++) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 485 | QListWidgetItem *item = fListWidget.item(row); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 486 | if (item->checkState() == Qt::Checked) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 487 | fListWidget.setCurrentItem(item); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 488 | return; |
| 489 | } |
| 490 | } |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 491 | fListWidget.setCurrentRow(fListWidget.count() - 1); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 492 | } |
| 493 | |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 494 | void SkDebuggerGUI::actionRasterWidget(bool isToggled) { |
| 495 | fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType, !isToggled); |
| 496 | } |
| 497 | |
robertphillips@google.com | f4741c1 | 2013-02-06 20:13:54 +0000 | [diff] [blame] | 498 | void SkDebuggerGUI::actionOverdrawVizWidget(bool isToggled) { |
| 499 | fDebugger.setOverdrawViz(isToggled); |
| 500 | fCanvasWidget.update(); |
| 501 | } |
| 502 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 503 | void SkDebuggerGUI::actionRewind() { |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 504 | fListWidget.setCurrentRow(0); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 505 | } |
| 506 | |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 507 | void SkDebuggerGUI::actionSave() { |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 508 | fFileName = fPath.toAscii().data(); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 509 | fFileName.append("/"); |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 510 | fFileName.append(fDirectoryWidget.currentItem()->text().toAscii().data()); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 511 | saveToFile(fFileName); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | void SkDebuggerGUI::actionSaveAs() { |
| 515 | QString filename = QFileDialog::getSaveFileName(this, "Save File", "", |
| 516 | "Skia Picture (*skp)"); |
chudy@google.com | 38b08ce | 2012-07-28 23:26:10 +0000 | [diff] [blame] | 517 | if (!filename.endsWith(".skp", Qt::CaseInsensitive)) { |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 518 | filename.append(".skp"); |
| 519 | } |
djsollen@google.com | c3c8216 | 2012-11-13 18:35:10 +0000 | [diff] [blame] | 520 | saveToFile(SkString(filename.toAscii().data())); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 521 | } |
| 522 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 523 | void SkDebuggerGUI::actionScale(float scaleFactor) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 524 | fSettingsWidget.setZoomText(scaleFactor); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 525 | } |
| 526 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 527 | void SkDebuggerGUI::actionSettings() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 528 | if (fSettingsWidget.isHidden()) { |
| 529 | fSettingsWidget.setHidden(false); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 530 | } else { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 531 | fSettingsWidget.setHidden(true); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 532 | } |
| 533 | } |
| 534 | |
| 535 | void SkDebuggerGUI::actionStepBack() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 536 | int currentRow = fListWidget.currentRow(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 537 | if (currentRow != 0) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 538 | fListWidget.setCurrentRow(currentRow - 1); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 539 | } |
| 540 | } |
| 541 | |
| 542 | void SkDebuggerGUI::actionStepForward() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 543 | int currentRow = fListWidget.currentRow(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 544 | QString curRow = QString::number(currentRow); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 545 | QString curCount = QString::number(fListWidget.count()); |
| 546 | if (currentRow < fListWidget.count() - 1) { |
| 547 | fListWidget.setCurrentRow(currentRow + 1); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 548 | } |
| 549 | } |
| 550 | |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 551 | void SkDebuggerGUI::drawComplete() { |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 552 | fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix()); |
| 553 | fInspectorWidget.setClip(fDebugger.getCurrentClip()); |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 554 | } |
| 555 | |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 556 | void SkDebuggerGUI::saveToFile(const SkString& filename) { |
| 557 | SkFILEWStream file(filename.c_str()); |
robertphillips@google.com | 25bc2f8 | 2013-01-22 18:03:56 +0000 | [diff] [blame] | 558 | SkAutoTUnref<SkPicture> copy(fDebugger.copyPicture()); |
| 559 | |
| 560 | copy->serialize(&file); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 561 | } |
| 562 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 563 | void SkDebuggerGUI::loadFile(QListWidgetItem *item) { |
| 564 | if (fDirectoryWidgetActive) { |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 565 | fFileName = fPath.toAscii().data(); |
jvanverth@google.com | 0ac6f16 | 2013-02-05 19:44:07 +0000 | [diff] [blame] | 566 | // don't add a '/' to files in the local directory |
| 567 | if (fFileName.size() > 0) { |
| 568 | fFileName.append("/"); |
| 569 | } |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 570 | fFileName.append(item->text().toAscii().data()); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 571 | loadPicture(fFileName); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 572 | } |
| 573 | } |
| 574 | |
| 575 | void SkDebuggerGUI::openFile() { |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 576 | QString temp = QFileDialog::getOpenFileName(this, tr("Open File"), "", |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 577 | tr("Files (*.*)")); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 578 | openFile(temp); |
| 579 | } |
| 580 | |
| 581 | void SkDebuggerGUI::openFile(const QString &filename) { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 582 | fDirectoryWidgetActive = false; |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 583 | if (!filename.isEmpty()) { |
| 584 | QFileInfo pathInfo(filename); |
| 585 | loadPicture(SkString(filename.toAscii().data())); |
| 586 | setupDirectoryWidget(pathInfo.path()); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 587 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 588 | fDirectoryWidgetActive = true; |
| 589 | } |
| 590 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 591 | void SkDebuggerGUI::pauseDrawing(bool isPaused) { |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 592 | fPause = isPaused; |
| 593 | fPausedRow = fListWidget.currentRow(); |
| 594 | fCanvasWidget.drawTo(fPausedRow); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 595 | fImageWidget.draw(); |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 596 | } |
| 597 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 598 | void SkDebuggerGUI::registerListClick(QListWidgetItem *item) { |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 599 | if(!fLoading) { |
| 600 | int currentRow = fListWidget.currentRow(); |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 601 | |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 602 | if (currentRow != -1) { |
| 603 | if (!fPause) { |
| 604 | fCanvasWidget.drawTo(currentRow); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 605 | fImageWidget.draw(); |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 606 | } |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 607 | SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo( |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 608 | currentRow); |
| 609 | |
| 610 | /* TODO(chudy): Add command type before parameters. Rename v |
| 611 | * to something more informative. */ |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 612 | if (currInfo) { |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 613 | QString info; |
| 614 | info.append("<b>Parameters: </b><br/>"); |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 615 | for (int i = 0; i < currInfo->count(); i++) { |
| 616 | |
| 617 | info.append(QString((*currInfo)[i]->c_str())); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 618 | info.append("<br/>"); |
| 619 | } |
chudy@google.com | 6bd109a | 2012-08-14 19:34:13 +0000 | [diff] [blame] | 620 | fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 621 | fInspectorWidget.setDisabled(false); |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 622 | } |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 623 | } |
chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 624 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 625 | } |
| 626 | } |
| 627 | |
chudy@google.com | 9ca9bfe | 2012-07-12 21:58:14 +0000 | [diff] [blame] | 628 | void SkDebuggerGUI::selectCommand(int command) { |
| 629 | if (fPause) { |
| 630 | fListWidget.setCurrentRow(command); |
| 631 | } |
| 632 | } |
| 633 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 634 | void SkDebuggerGUI::toggleBreakpoint() { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 635 | QListWidgetItem* item = fListWidget.currentItem(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 636 | if (item->checkState() == Qt::Unchecked) { |
| 637 | item->setCheckState(Qt::Checked); |
chudy@google.com | e565de4 | 2012-07-12 14:15:54 +0000 | [diff] [blame] | 638 | item->setData(Qt::DecorationRole, |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 639 | QPixmap(":/breakpoint_16x16.png")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 640 | } else { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 641 | item->setCheckState(Qt::Unchecked); |
chudy@google.com | e565de4 | 2012-07-12 14:15:54 +0000 | [diff] [blame] | 642 | item->setData(Qt::DecorationRole, |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 643 | QPixmap(":/blank.png")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 644 | } |
| 645 | } |
| 646 | |
| 647 | void SkDebuggerGUI::toggleDirectory() { |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 648 | fDirectoryWidget.setHidden(!fDirectoryWidget.isHidden()); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | void SkDebuggerGUI::toggleFilter(QString string) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 652 | for (int row = 0; row < fListWidget.count(); row++) { |
| 653 | QListWidgetItem *item = fListWidget.item(row); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 654 | item->setHidden(item->text() != string); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 655 | } |
| 656 | } |
| 657 | |
| 658 | void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) { |
| 659 | QIcon windowIcon; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 660 | windowIcon.addFile(QString::fromUtf8(":/skia.png"), QSize(), |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 661 | QIcon::Normal, QIcon::Off); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 662 | SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI")); |
| 663 | SkDebuggerGUI->resize(1200, 1000); |
| 664 | SkDebuggerGUI->setWindowIcon(windowIcon); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 665 | SkDebuggerGUI->setWindowTitle("Skia Debugger"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 666 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 667 | fActionOpen.setShortcuts(QKeySequence::Open); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 668 | fActionOpen.setText("Open"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 669 | |
| 670 | QIcon breakpoint; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 671 | breakpoint.addFile(QString::fromUtf8(":/breakpoint.png"), |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 672 | QSize(), QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 673 | fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 674 | fActionBreakpoint.setIcon(breakpoint); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 675 | fActionBreakpoint.setText("Breakpoints"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 676 | |
| 677 | QIcon cancel; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 678 | cancel.addFile(QString::fromUtf8(":/reload.png"), QSize(), |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 679 | QIcon::Normal, QIcon::Off); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 680 | fActionCancel.setIcon(cancel); |
| 681 | fActionCancel.setText("Clear Filter"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 682 | |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 683 | fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B"))); |
| 684 | fActionClearBreakpoints.setText("Clear Breakpoints"); |
| 685 | |
| 686 | fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X"))); |
| 687 | fActionClearDeletes.setText("Clear Deletes"); |
| 688 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 689 | fActionClose.setShortcuts(QKeySequence::Quit); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 690 | fActionClose.setText("Exit"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 691 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 692 | fActionCreateBreakpoint.setShortcut(QKeySequence(tr("B"))); |
| 693 | fActionCreateBreakpoint.setText("Set Breakpoint"); |
| 694 | |
| 695 | fActionDelete.setShortcut(QKeySequence(tr("X"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 696 | fActionDelete.setText("Delete Command"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 697 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 698 | fActionDirectory.setShortcut(QKeySequence(tr("Ctrl+D"))); |
| 699 | fActionDirectory.setText("Directory"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 700 | |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 701 | QIcon profile; |
robertphillips@google.com | d163636 | 2012-11-19 18:25:09 +0000 | [diff] [blame] | 702 | profile.addFile(QString::fromUtf8(":/profile.png"), QSize(), |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 703 | QIcon::Normal, QIcon::Off); |
| 704 | fActionProfile.setIcon(profile); |
| 705 | fActionProfile.setText("Profile"); |
robertphillips@google.com | e099bc4 | 2012-11-19 16:26:40 +0000 | [diff] [blame] | 706 | fActionProfile.setDisabled(true); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 707 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 708 | QIcon inspector; |
robertphillips@google.com | d163636 | 2012-11-19 18:25:09 +0000 | [diff] [blame] | 709 | inspector.addFile(QString::fromUtf8(":/inspector.png"), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 710 | QSize(), QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 711 | fActionInspector.setShortcut(QKeySequence(tr("Ctrl+I"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 712 | fActionInspector.setIcon(inspector); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 713 | fActionInspector.setText("Inspector"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 714 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 715 | QIcon play; |
robertphillips@google.com | d163636 | 2012-11-19 18:25:09 +0000 | [diff] [blame] | 716 | play.addFile(QString::fromUtf8(":/play.png"), QSize(), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 717 | QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 718 | fActionPlay.setShortcut(QKeySequence(tr("Ctrl+P"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 719 | fActionPlay.setIcon(play); |
| 720 | fActionPlay.setText("Play"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 721 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 722 | QIcon pause; |
robertphillips@google.com | d163636 | 2012-11-19 18:25:09 +0000 | [diff] [blame] | 723 | pause.addFile(QString::fromUtf8(":/pause.png"), QSize(), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 724 | QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 725 | fActionPause.setShortcut(QKeySequence(tr("Space"))); |
| 726 | fActionPause.setCheckable(true); |
| 727 | fActionPause.setIcon(pause); |
| 728 | fActionPause.setText("Pause"); |
| 729 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 730 | QIcon rewind; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 731 | rewind.addFile(QString::fromUtf8(":/rewind.png"), QSize(), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 732 | QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 733 | fActionRewind.setShortcut(QKeySequence(tr("Ctrl+R"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 734 | fActionRewind.setIcon(rewind); |
| 735 | fActionRewind.setText("Rewind"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 736 | |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 737 | fActionSave.setShortcut(QKeySequence::Save); |
| 738 | fActionSave.setText("Save"); |
| 739 | fActionSave.setDisabled(true); |
| 740 | fActionSaveAs.setShortcut(QKeySequence::SaveAs); |
| 741 | fActionSaveAs.setText("Save As"); |
| 742 | fActionSaveAs.setDisabled(true); |
| 743 | |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 744 | fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X"))); |
| 745 | fActionShowDeletes.setText("Deleted Commands"); |
| 746 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 747 | QIcon stepBack; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 748 | stepBack.addFile(QString::fromUtf8(":/previous.png"), QSize(), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 749 | QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 750 | fActionStepBack.setShortcut(QKeySequence(tr("["))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 751 | fActionStepBack.setIcon(stepBack); |
| 752 | fActionStepBack.setText("Step Back"); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 753 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 754 | QIcon stepForward; |
robertphillips@google.com | 8e41a16 | 2012-11-19 17:39:18 +0000 | [diff] [blame] | 755 | stepForward.addFile(QString::fromUtf8(":/next.png"), |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 756 | QSize(), QIcon::Normal, QIcon::Off); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 757 | fActionStepForward.setShortcut(QKeySequence(tr("]"))); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 758 | fActionStepForward.setIcon(stepForward); |
| 759 | fActionStepForward.setText("Step Forward"); |
| 760 | |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 761 | fActionZoomIn.setShortcut(QKeySequence(tr("Ctrl+="))); |
| 762 | fActionZoomIn.setText("Zoom In"); |
| 763 | fActionZoomOut.setShortcut(QKeySequence(tr("Ctrl+-"))); |
| 764 | fActionZoomOut.setText("Zoom Out"); |
| 765 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 766 | fListWidget.setItemDelegate(new SkListWidget(&fListWidget)); |
| 767 | fListWidget.setObjectName(QString::fromUtf8("listWidget")); |
| 768 | fListWidget.setMaximumWidth(250); |
| 769 | |
| 770 | fFilter.addItem("--Filter By Available Commands--"); |
| 771 | |
| 772 | fDirectoryWidget.setMaximumWidth(250); |
| 773 | fDirectoryWidget.setStyleSheet("QListWidget::Item {padding: 5px;}"); |
| 774 | |
| 775 | fCanvasWidget.setSizePolicy(QSizePolicy::Expanding, |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 776 | QSizePolicy::Expanding); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 777 | |
skia.committer@gmail.com | 1c9c0d3 | 2012-11-22 02:02:41 +0000 | [diff] [blame] | 778 | fImageWidget.setFixedSize(SkImageWidget::kImageWidgetWidth, |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 779 | SkImageWidget::kImageWidgetHeight); |
| 780 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 781 | fInspectorWidget.setSizePolicy(QSizePolicy::Expanding, |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 782 | QSizePolicy::Expanding); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 783 | fInspectorWidget.setMaximumHeight(300); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 784 | |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 785 | fSettingsAndImageLayout.setSpacing(6); |
| 786 | fSettingsAndImageLayout.addWidget(&fSettingsWidget); |
| 787 | fSettingsAndImageLayout.addWidget(&fImageWidget); |
| 788 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 789 | fSettingsWidget.setSizePolicy(QSizePolicy::Expanding, |
| 790 | QSizePolicy::Expanding); |
| 791 | fSettingsWidget.setMaximumWidth(250); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 792 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 793 | fLeftColumnLayout.setSpacing(6); |
| 794 | fLeftColumnLayout.addWidget(&fListWidget); |
| 795 | fLeftColumnLayout.addWidget(&fDirectoryWidget); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 796 | |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 797 | fCanvasSettingsAndImageLayout.setSpacing(6); |
| 798 | fCanvasSettingsAndImageLayout.addWidget(&fCanvasWidget); |
| 799 | fCanvasSettingsAndImageLayout.addLayout(&fSettingsAndImageLayout); |
| 800 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 801 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 802 | fMainAndRightColumnLayout.setSpacing(6); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 803 | fMainAndRightColumnLayout.addLayout(&fCanvasSettingsAndImageLayout); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 804 | fMainAndRightColumnLayout.addWidget(&fInspectorWidget); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 805 | |
chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 806 | fCentralWidget.setLayout(&fContainerLayout); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 807 | fContainerLayout.setSpacing(6); |
| 808 | fContainerLayout.setContentsMargins(11, 11, 11, 11); |
| 809 | fContainerLayout.addLayout(&fLeftColumnLayout); |
| 810 | fContainerLayout.addLayout(&fMainAndRightColumnLayout); |
| 811 | |
| 812 | SkDebuggerGUI->setCentralWidget(&fCentralWidget); |
| 813 | SkDebuggerGUI->setStatusBar(&fStatusBar); |
| 814 | |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 815 | fToolBar.setIconSize(QSize(32, 32)); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 816 | fToolBar.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); |
| 817 | SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, &fToolBar); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 818 | |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 819 | fSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 820 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 821 | fToolBar.addAction(&fActionRewind); |
| 822 | fToolBar.addAction(&fActionStepBack); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 823 | fToolBar.addAction(&fActionPause); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 824 | fToolBar.addAction(&fActionStepForward); |
| 825 | fToolBar.addAction(&fActionPlay); |
| 826 | fToolBar.addSeparator(); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 827 | fToolBar.addAction(&fActionInspector); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 828 | fToolBar.addSeparator(); |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 829 | fToolBar.addAction(&fActionProfile); |
| 830 | |
| 831 | fToolBar.addSeparator(); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 832 | fToolBar.addWidget(&fSpacer); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 833 | fToolBar.addWidget(&fFilter); |
| 834 | fToolBar.addAction(&fActionCancel); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 835 | |
| 836 | // TODO(chudy): Remove static call. |
| 837 | fDirectoryWidgetActive = false; |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 838 | fFileName = ""; |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 839 | setupDirectoryWidget(""); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 840 | fDirectoryWidgetActive = true; |
| 841 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 842 | // Menu Bar |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 843 | fMenuFile.setTitle("File"); |
| 844 | fMenuFile.addAction(&fActionOpen); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 845 | fMenuFile.addAction(&fActionSave); |
| 846 | fMenuFile.addAction(&fActionSaveAs); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 847 | fMenuFile.addAction(&fActionClose); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 848 | |
| 849 | fMenuEdit.setTitle("Edit"); |
| 850 | fMenuEdit.addAction(&fActionDelete); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 851 | fMenuEdit.addAction(&fActionClearDeletes); |
| 852 | fMenuEdit.addSeparator(); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 853 | fMenuEdit.addAction(&fActionCreateBreakpoint); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 854 | fMenuEdit.addAction(&fActionClearBreakpoints); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 855 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 856 | fMenuNavigate.setTitle("Navigate"); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 857 | fMenuNavigate.addAction(&fActionRewind); |
| 858 | fMenuNavigate.addAction(&fActionStepBack); |
| 859 | fMenuNavigate.addAction(&fActionStepForward); |
| 860 | fMenuNavigate.addAction(&fActionPlay); |
| 861 | fMenuNavigate.addAction(&fActionPause); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 862 | fMenuNavigate.addAction(&fActionGoToLine); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 863 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 864 | fMenuView.setTitle("View"); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 865 | fMenuView.addAction(&fActionBreakpoint); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 866 | fMenuView.addAction(&fActionShowDeletes); |
chudy@google.com | a122631 | 2012-07-26 20:26:44 +0000 | [diff] [blame] | 867 | fMenuView.addAction(&fActionZoomIn); |
| 868 | fMenuView.addAction(&fActionZoomOut); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 869 | |
| 870 | fMenuWindows.setTitle("Window"); |
| 871 | fMenuWindows.addAction(&fActionInspector); |
| 872 | fMenuWindows.addAction(&fActionDirectory); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 873 | |
| 874 | fActionGoToLine.setText("Go to Line..."); |
| 875 | fActionGoToLine.setDisabled(true); |
| 876 | fMenuBar.addAction(fMenuFile.menuAction()); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 877 | fMenuBar.addAction(fMenuEdit.menuAction()); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 878 | fMenuBar.addAction(fMenuView.menuAction()); |
| 879 | fMenuBar.addAction(fMenuNavigate.menuAction()); |
chudy@google.com | e504de0 | 2012-07-16 18:35:23 +0000 | [diff] [blame] | 880 | fMenuBar.addAction(fMenuWindows.menuAction()); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 881 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 882 | fPause = false; |
| 883 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 884 | SkDebuggerGUI->setMenuBar(&fMenuBar); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 885 | QMetaObject::connectSlotsByName(SkDebuggerGUI); |
| 886 | } |
| 887 | |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 888 | void SkDebuggerGUI::setupDirectoryWidget(const QString& path) { |
| 889 | fPath = path; |
| 890 | QDir dir(path); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 891 | QRegExp r(".skp"); |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 892 | fDirectoryWidget.clear(); |
| 893 | const QStringList files = dir.entryList(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 894 | foreach (QString f, files) { |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 895 | if (f.contains(r)) |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 896 | fDirectoryWidget.addItem(f); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 897 | } |
| 898 | } |
| 899 | |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 900 | void SkDebuggerGUI::loadPicture(const SkString& fileName) { |
| 901 | fFileName = fileName; |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 902 | fLoading = true; |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 903 | SkStream* stream = SkNEW_ARGS(SkFILEStream, (fileName.c_str())); |
robertphillips@google.com | 2d40ec4 | 2013-02-07 20:39:40 +0000 | [diff] [blame] | 904 | |
| 905 | bool success = false; |
| 906 | |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 907 | SkPicture* picture = SkNEW_ARGS(SkPicture, |
| 908 | (stream, &success, &SkImageDecoder::DecodeMemory)); |
robertphillips@google.com | 2d40ec4 | 2013-02-07 20:39:40 +0000 | [diff] [blame] | 909 | |
| 910 | if (!success) { |
| 911 | QMessageBox::critical(this, "Error loading file", "Couldn't read file, sorry."); |
| 912 | SkSafeUnref(stream); |
| 913 | return; |
| 914 | } |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 915 | |
chudy@google.com | 686e680 | 2012-08-14 16:00:32 +0000 | [diff] [blame] | 916 | fCanvasWidget.resetWidgetTransform(); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 917 | fDebugger.loadPicture(picture); |
chudy@google.com | 4c7962e | 2012-08-14 19:38:31 +0000 | [diff] [blame] | 918 | |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 919 | fSkipCommands.setCount(fDebugger.getSize()); |
| 920 | for (int i = 0; i < fSkipCommands.count(); ++i) { |
robertphillips@google.com | 5f97114 | 2012-12-07 20:48:56 +0000 | [diff] [blame] | 921 | fSkipCommands[i] = false; |
| 922 | } |
| 923 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 924 | SkSafeUnref(stream); |
| 925 | SkSafeUnref(picture); |
| 926 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 927 | // Will this automatically clear out due to nature of refcnt? |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 928 | SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings(); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 929 | |
robertphillips@google.com | 6d9c92b | 2013-05-23 13:21:18 +0000 | [diff] [blame] | 930 | fActionProfile.setDisabled(false); |
robertphillips@google.com | 2bde91d | 2012-11-15 14:57:57 +0000 | [diff] [blame] | 931 | |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 932 | /* fDebugCanvas is reinitialized every load picture. Need it to retain value |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 933 | * of the visibility filter. |
| 934 | * TODO(chudy): This should be deprecated since fDebugger is not |
| 935 | * recreated. |
| 936 | * */ |
| 937 | fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityButton()->isChecked()); |
| 938 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 939 | setupListWidget(commands); |
| 940 | setupComboBox(commands); |
robertphillips@google.com | e428f9b | 2013-03-12 15:33:40 +0000 | [diff] [blame] | 941 | setupOverviewText(NULL, 0.0, 1); |
chudy@google.com | 7e4cfbf | 2012-07-17 15:40:51 +0000 | [diff] [blame] | 942 | fInspectorWidget.setDisabled(false); |
chudy@google.com | e606d6e | 2012-07-12 14:31:25 +0000 | [diff] [blame] | 943 | fSettingsWidget.setDisabled(false); |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 944 | fMenuEdit.setDisabled(false); |
| 945 | fMenuNavigate.setDisabled(false); |
| 946 | fMenuView.setDisabled(false); |
chudy@google.com | 0ab0339 | 2012-07-28 20:16:11 +0000 | [diff] [blame] | 947 | fActionSave.setDisabled(false); |
| 948 | fActionSaveAs.setDisabled(false); |
chudy@google.com | d3058f5 | 2012-07-19 13:41:27 +0000 | [diff] [blame] | 949 | fLoading = false; |
| 950 | actionPlay(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 951 | } |
| 952 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 953 | void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* command) { |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 954 | fListWidget.clear(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 955 | int counter = 0; |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame] | 956 | int indent = 0; |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 957 | for (int i = 0; i < command->count(); i++) { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 958 | QListWidgetItem *item = new QListWidgetItem(); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 959 | item->setData(Qt::DisplayRole, (*command)[i].c_str()); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 960 | item->setData(Qt::UserRole + 1, counter++); |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame] | 961 | |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame^] | 962 | if (0 == strcmp("Restore", (*command)[i].c_str()) || |
| 963 | 0 == strcmp("EndCommentGroup", (*command)[i].c_str())) { |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame] | 964 | indent -= 10; |
| 965 | } |
| 966 | |
| 967 | item->setData(Qt::UserRole + 3, indent); |
| 968 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 969 | if (0 == strcmp("Save", (*command)[i].c_str()) || |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame^] | 970 | 0 == strcmp("Save Layer", (*command)[i].c_str()) || |
| 971 | 0 == strcmp("BeginCommentGroup", (*command)[i].c_str())) { |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame] | 972 | indent += 10; |
| 973 | } |
| 974 | |
robertphillips@google.com | d26c706 | 2012-11-12 20:42:12 +0000 | [diff] [blame] | 975 | item->setData(Qt::UserRole + 4, -1.0); |
| 976 | |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 977 | fListWidget.addItem(item); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 978 | } |
| 979 | } |
| 980 | |
skia.committer@gmail.com | 91274b9 | 2013-03-13 07:01:04 +0000 | [diff] [blame] | 981 | void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes, |
robertphillips@google.com | e428f9b | 2013-03-12 15:33:40 +0000 | [diff] [blame] | 982 | double totTime, |
| 983 | int numRuns) { |
borenet@google.com | 2d9dbd4 | 2013-03-12 13:07:40 +0000 | [diff] [blame] | 984 | SkString overview; |
robertphillips@google.com | e428f9b | 2013-03-12 15:33:40 +0000 | [diff] [blame] | 985 | fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns); |
borenet@google.com | 2d9dbd4 | 2013-03-12 13:07:40 +0000 | [diff] [blame] | 986 | fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabType); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 987 | } |
| 988 | |
| 989 | void SkDebuggerGUI::setupComboBox(SkTArray<SkString>* command) { |
| 990 | fFilter.clear(); |
| 991 | fFilter.addItem("--Filter By Available Commands--"); |
| 992 | |
| 993 | std::map<std::string, int> map; |
| 994 | for (int i = 0; i < command->count(); i++) { |
| 995 | map[(*command)[i].c_str()]++; |
| 996 | } |
| 997 | |
skia.committer@gmail.com | 3458716 | 2012-11-20 02:01:23 +0000 | [diff] [blame] | 998 | for (std::map<std::string, int>::iterator it = map.begin(); it != map.end(); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 999 | ++it) { |
| 1000 | fFilter.addItem((it->first).c_str()); |
| 1001 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1002 | |
| 1003 | // NOTE(chudy): Makes first item unselectable. |
chudy@google.com | 7dcae67 | 2012-07-09 20:26:53 +0000 | [diff] [blame] | 1004 | QStandardItemModel* model = qobject_cast<QStandardItemModel*>( |
chudy@google.com | c432f00 | 2012-07-10 13:19:25 +0000 | [diff] [blame] | 1005 | fFilter.model()); |
| 1006 | QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), |
| 1007 | fFilter.rootModelIndex()); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1008 | QStandardItem* firstItem = model->itemFromIndex(firstIndex); |
| 1009 | firstItem->setSelectable(false); |
| 1010 | } |