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