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