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