OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDebuggerGUI.h" | 8 #include "SkDebuggerGUI.h" |
9 #include "SkForceLinking.h" | 9 #include "SkForceLinking.h" |
10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #endif | 27 #endif |
28 | 28 |
29 | 29 |
30 SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : | 30 SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : |
31 QMainWindow(parent) | 31 QMainWindow(parent) |
32 , fCentralSplitter(this) | 32 , fCentralSplitter(this) |
33 , fStatusBar(this) | 33 , fStatusBar(this) |
34 , fToolBar(this) | 34 , fToolBar(this) |
35 , fActionOpen(this) | 35 , fActionOpen(this) |
36 , fActionBreakpoint(this) | 36 , fActionBreakpoint(this) |
| 37 , fActionToggleIndexStyle(this) |
37 , fActionProfile(this) | 38 , fActionProfile(this) |
38 , fActionCancel(this) | 39 , fActionCancel(this) |
39 , fActionClearBreakpoints(this) | 40 , fActionClearBreakpoints(this) |
40 , fActionClearDeletes(this) | 41 , fActionClearDeletes(this) |
41 , fActionClose(this) | 42 , fActionClose(this) |
42 , fActionCreateBreakpoint(this) | 43 , fActionCreateBreakpoint(this) |
43 , fActionDelete(this) | 44 , fActionDelete(this) |
44 , fActionDirectory(this) | 45 , fActionDirectory(this) |
45 , fActionGoToLine(this) | 46 , fActionGoToLine(this) |
46 , fActionInspector(this) | 47 , fActionInspector(this) |
(...skipping 11 matching lines...) Expand all Loading... |
58 , fMapper(this) | 59 , fMapper(this) |
59 , fListWidget(&fCentralSplitter) | 60 , fListWidget(&fCentralSplitter) |
60 , fDirectoryWidget(&fCentralSplitter) | 61 , fDirectoryWidget(&fCentralSplitter) |
61 , fCanvasWidget(this, &fDebugger) | 62 , fCanvasWidget(this, &fDebugger) |
62 , fImageWidget(&fDebugger) | 63 , fImageWidget(&fDebugger) |
63 , fMenuBar(this) | 64 , fMenuBar(this) |
64 , fMenuFile(this) | 65 , fMenuFile(this) |
65 , fMenuNavigate(this) | 66 , fMenuNavigate(this) |
66 , fMenuView(this) | 67 , fMenuView(this) |
67 , fBreakpointsActivated(false) | 68 , fBreakpointsActivated(false) |
| 69 , fIndexStyleToggle(false) |
68 , fDeletesActivated(false) | 70 , fDeletesActivated(false) |
69 , fPause(false) | 71 , fPause(false) |
70 , fLoading(false) | 72 , fLoading(false) |
71 { | 73 { |
72 setupUi(this); | 74 setupUi(this); |
73 fListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection); | 75 fListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection); |
74 connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidge
tItem*)), this, SLOT(registerListClick(QListWidgetItem *))); | 76 connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidge
tItem*)), this, SLOT(registerListClick(QListWidgetItem *))); |
75 connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile())); | 77 connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile())); |
76 connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory()
)); | 78 connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory()
)); |
77 connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QList
WidgetItem*)), this, SLOT(loadFile(QListWidgetItem *))); | 79 connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QList
WidgetItem*)), this, SLOT(loadFile(QListWidgetItem *))); |
78 connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete())); | 80 connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete())); |
79 connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLO
T(toggleBreakpoint())); | 81 connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLO
T(toggleBreakpoint())); |
80 connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind())); | 82 connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind())); |
81 connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay())); | 83 connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay())); |
82 connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()))
; | 84 connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()))
; |
83 connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForwa
rd())); | 85 connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForwa
rd())); |
84 connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoint
s())); | 86 connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoint
s())); |
| 87 connect(&fActionToggleIndexStyle, SIGNAL(triggered()), this, SLOT(actionTogg
leIndexStyle())); |
85 connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()
)); | 88 connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()
)); |
86 connect(&fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings()))
; | 89 connect(&fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings()))
; |
87 connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QStrin
g))); | 90 connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QStrin
g))); |
88 connect(&fActionProfile, SIGNAL(triggered()), this, SLOT(actionProfile())); | 91 connect(&fActionProfile, SIGNAL(triggered()), this, SLOT(actionProfile())); |
89 connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel())); | 92 connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel())); |
90 connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClea
rBreakpoints())); | 93 connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClea
rBreakpoints())); |
91 connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDel
etes())); | 94 connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDel
etes())); |
92 connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose())); | 95 connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose())); |
93 connect(&fSettingsWidget, SIGNAL(visibilityFilterChanged()), this, SLOT(acti
onCommandFilter())); | 96 connect(&fSettingsWidget, SIGNAL(visibilityFilterChanged()), this, SLOT(acti
onCommandFilter())); |
94 #if SK_SUPPORT_GPU | 97 #if SK_SUPPORT_GPU |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 131 } |
129 | 132 |
130 void SkDebuggerGUI::actionBreakpoints() { | 133 void SkDebuggerGUI::actionBreakpoints() { |
131 fBreakpointsActivated = !fBreakpointsActivated; | 134 fBreakpointsActivated = !fBreakpointsActivated; |
132 for (int row = 0; row < fListWidget.count(); row++) { | 135 for (int row = 0; row < fListWidget.count(); row++) { |
133 QListWidgetItem *item = fListWidget.item(row); | 136 QListWidgetItem *item = fListWidget.item(row); |
134 item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActiv
ated); | 137 item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActiv
ated); |
135 } | 138 } |
136 } | 139 } |
137 | 140 |
| 141 void SkDebuggerGUI::actionToggleIndexStyle() { |
| 142 fIndexStyleToggle = !fIndexStyleToggle; |
| 143 SkListWidget* list = (SkListWidget*) fListWidget.itemDelegate(); |
| 144 list->setIndexStyle(fIndexStyleToggle ? SkListWidget::kIndex_IndexStyle : |
| 145 SkListWidget::kOffset_IndexStyle); |
| 146 fListWidget.update(); |
| 147 } |
| 148 |
138 void SkDebuggerGUI::showDeletes() { | 149 void SkDebuggerGUI::showDeletes() { |
139 fDeletesActivated = !fDeletesActivated; | 150 fDeletesActivated = !fDeletesActivated; |
140 for (int row = 0; row < fListWidget.count(); row++) { | 151 for (int row = 0; row < fListWidget.count(); row++) { |
141 QListWidgetItem *item = fListWidget.item(row); | 152 QListWidgetItem *item = fListWidget.item(row); |
142 item->setHidden(fDebugger.isCommandVisible(row) | 153 item->setHidden(fDebugger.isCommandVisible(row) && fDeletesActivated); |
143 && fDeletesActivated); | |
144 } | 154 } |
145 } | 155 } |
146 | 156 |
147 // The timed picture playback uses the SkPicturePlayback's profiling stubs | 157 // The timed picture playback uses the SkPicturePlayback's profiling stubs |
148 // to time individual commands. The offsets are needed to map SkPicture | 158 // to time individual commands. The offsets are needed to map SkPicture |
149 // offsets to individual commands. | 159 // offsets to individual commands. |
150 class SkTimedPicturePlayback : public SkPicturePlayback { | 160 class SkTimedPicturePlayback : public SkPicturePlayback { |
151 public: | 161 public: |
152 static SkTimedPicturePlayback* CreateFromStream(SkStream* stream, const SkPi
ctInfo& info, | 162 static SkTimedPicturePlayback* CreateFromStream(SkStream* stream, const SkPi
ctInfo& info, |
153 SkPicture::InstallPixelRefPr
oc proc, | 163 SkPicture::InstallPixelRefPr
oc proc, |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 fActionOpen.setShortcuts(QKeySequence::Open); | 712 fActionOpen.setShortcuts(QKeySequence::Open); |
703 fActionOpen.setText("Open"); | 713 fActionOpen.setText("Open"); |
704 | 714 |
705 QIcon breakpoint; | 715 QIcon breakpoint; |
706 breakpoint.addFile(QString::fromUtf8(":/breakpoint.png"), | 716 breakpoint.addFile(QString::fromUtf8(":/breakpoint.png"), |
707 QSize(), QIcon::Normal, QIcon::Off); | 717 QSize(), QIcon::Normal, QIcon::Off); |
708 fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B"))); | 718 fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B"))); |
709 fActionBreakpoint.setIcon(breakpoint); | 719 fActionBreakpoint.setIcon(breakpoint); |
710 fActionBreakpoint.setText("Breakpoints"); | 720 fActionBreakpoint.setText("Breakpoints"); |
711 | 721 |
| 722 fActionToggleIndexStyle.setShortcut(QKeySequence(tr("Ctrl+T"))); |
| 723 fActionToggleIndexStyle.setText("Toggle Index Style"); |
| 724 |
712 QIcon cancel; | 725 QIcon cancel; |
713 cancel.addFile(QString::fromUtf8(":/reload.png"), QSize(), | 726 cancel.addFile(QString::fromUtf8(":/reload.png"), QSize(), |
714 QIcon::Normal, QIcon::Off); | 727 QIcon::Normal, QIcon::Off); |
715 fActionCancel.setIcon(cancel); | 728 fActionCancel.setIcon(cancel); |
716 fActionCancel.setText("Clear Filter"); | 729 fActionCancel.setText("Clear Filter"); |
717 | 730 |
718 fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B"))); | 731 fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B"))); |
719 fActionClearBreakpoints.setText("Clear Breakpoints"); | 732 fActionClearBreakpoints.setText("Clear Breakpoints"); |
720 | 733 |
721 fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X"))); | 734 fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X"))); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 fMenuNavigate.addAction(&fActionRewind); | 912 fMenuNavigate.addAction(&fActionRewind); |
900 fMenuNavigate.addAction(&fActionStepBack); | 913 fMenuNavigate.addAction(&fActionStepBack); |
901 fMenuNavigate.addAction(&fActionStepForward); | 914 fMenuNavigate.addAction(&fActionStepForward); |
902 fMenuNavigate.addAction(&fActionPlay); | 915 fMenuNavigate.addAction(&fActionPlay); |
903 fMenuNavigate.addAction(&fActionPause); | 916 fMenuNavigate.addAction(&fActionPause); |
904 fMenuNavigate.addAction(&fActionGoToLine); | 917 fMenuNavigate.addAction(&fActionGoToLine); |
905 | 918 |
906 fMenuView.setTitle("View"); | 919 fMenuView.setTitle("View"); |
907 fMenuView.addAction(&fActionBreakpoint); | 920 fMenuView.addAction(&fActionBreakpoint); |
908 fMenuView.addAction(&fActionShowDeletes); | 921 fMenuView.addAction(&fActionShowDeletes); |
| 922 fMenuView.addAction(&fActionToggleIndexStyle); |
909 fMenuView.addAction(&fActionZoomIn); | 923 fMenuView.addAction(&fActionZoomIn); |
910 fMenuView.addAction(&fActionZoomOut); | 924 fMenuView.addAction(&fActionZoomOut); |
911 | 925 |
912 fMenuWindows.setTitle("Window"); | 926 fMenuWindows.setTitle("Window"); |
913 fMenuWindows.addAction(&fActionInspector); | 927 fMenuWindows.addAction(&fActionInspector); |
914 fMenuWindows.addAction(&fActionSettings); | 928 fMenuWindows.addAction(&fActionSettings); |
915 fMenuWindows.addAction(&fActionDirectory); | 929 fMenuWindows.addAction(&fActionDirectory); |
916 | 930 |
917 fActionGoToLine.setText("Go to Line..."); | 931 fActionGoToLine.setText("Go to Line..."); |
918 fActionGoToLine.setDisabled(true); | 932 fActionGoToLine.setDisabled(true); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 fSkipCommands.setCount(fDebugger.getSize()); | 973 fSkipCommands.setCount(fDebugger.getSize()); |
960 for (int i = 0; i < fSkipCommands.count(); ++i) { | 974 for (int i = 0; i < fSkipCommands.count(); ++i) { |
961 fSkipCommands[i] = false; | 975 fSkipCommands[i] = false; |
962 } | 976 } |
963 | 977 |
964 SkSafeUnref(stream); | 978 SkSafeUnref(stream); |
965 SkSafeUnref(picture); | 979 SkSafeUnref(picture); |
966 | 980 |
967 // Will this automatically clear out due to nature of refcnt? | 981 // Will this automatically clear out due to nature of refcnt? |
968 SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings(); | 982 SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings(); |
| 983 SkTDArray<size_t>* offsets = fDebugger.getDrawCommandOffsets(); |
| 984 SkASSERT(commands->count() == offsets->count()); |
969 | 985 |
970 fActionProfile.setDisabled(false); | 986 fActionProfile.setDisabled(false); |
971 | 987 |
972 /* fDebugCanvas is reinitialized every load picture. Need it to retain value | 988 /* fDebugCanvas is reinitialized every load picture. Need it to retain value |
973 * of the visibility filter. | 989 * of the visibility filter. |
974 * TODO(chudy): This should be deprecated since fDebugger is not | 990 * TODO(chudy): This should be deprecated since fDebugger is not |
975 * recreated. | 991 * recreated. |
976 * */ | 992 * */ |
977 fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityFilter()); | 993 fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityFilter()); |
978 | 994 |
979 setupListWidget(commands); | 995 this->setupListWidget(commands, offsets); |
980 setupComboBox(commands); | 996 this->setupComboBox(commands); |
981 setupOverviewText(NULL, 0.0, 1); | 997 this->setupOverviewText(NULL, 0.0, 1); |
982 fInspectorWidget.setDisabled(false); | 998 fInspectorWidget.setDisabled(false); |
983 fSettingsWidget.setDisabled(false); | 999 fSettingsWidget.setDisabled(false); |
984 fMenuEdit.setDisabled(false); | 1000 fMenuEdit.setDisabled(false); |
985 fMenuNavigate.setDisabled(false); | 1001 fMenuNavigate.setDisabled(false); |
986 fMenuView.setDisabled(false); | 1002 fMenuView.setDisabled(false); |
987 fActionSave.setDisabled(false); | 1003 fActionSave.setDisabled(false); |
988 fActionSaveAs.setDisabled(false); | 1004 fActionSaveAs.setDisabled(false); |
989 fLoading = false; | 1005 fLoading = false; |
990 actionPlay(); | 1006 actionPlay(); |
991 } | 1007 } |
992 | 1008 |
993 void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* command) { | 1009 void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* commands, SkTDArray<size
_t>* offsets) { |
| 1010 SkASSERT(commands->count() == offsets->count()); |
994 fListWidget.clear(); | 1011 fListWidget.clear(); |
995 int counter = 0; | 1012 int counter = 0; |
996 int indent = 0; | 1013 int indent = 0; |
997 for (int i = 0; i < command->count(); i++) { | 1014 for (int i = 0; i < commands->count(); i++) { |
998 QListWidgetItem *item = new QListWidgetItem(); | 1015 QListWidgetItem *item = new QListWidgetItem(); |
999 item->setData(Qt::DisplayRole, (*command)[i].c_str()); | 1016 item->setData(Qt::DisplayRole, (*commands)[i].c_str()); |
1000 item->setData(Qt::UserRole + 1, counter++); | 1017 item->setData(Qt::UserRole + 1, counter++); |
1001 | 1018 |
1002 if (0 == strcmp("Restore", (*command)[i].c_str()) || | 1019 if (0 == strcmp("Restore", (*commands)[i].c_str()) || |
1003 0 == strcmp("EndCommentGroup", (*command)[i].c_str()) || | 1020 0 == strcmp("EndCommentGroup", (*commands)[i].c_str()) || |
1004 0 == strcmp("PopCull", (*command)[i].c_str())) { | 1021 0 == strcmp("PopCull", (*commands)[i].c_str())) { |
1005 indent -= 10; | 1022 indent -= 10; |
1006 } | 1023 } |
1007 | 1024 |
1008 item->setData(Qt::UserRole + 3, indent); | 1025 item->setData(Qt::UserRole + 3, indent); |
1009 | 1026 |
1010 if (0 == strcmp("Save", (*command)[i].c_str()) || | 1027 if (0 == strcmp("Save", (*commands)[i].c_str()) || |
1011 0 == strcmp("Save Layer", (*command)[i].c_str()) || | 1028 0 == strcmp("Save Layer", (*commands)[i].c_str()) || |
1012 0 == strcmp("BeginCommentGroup", (*command)[i].c_str()) || | 1029 0 == strcmp("BeginCommentGroup", (*commands)[i].c_str()) || |
1013 0 == strcmp("PushCull", (*command)[i].c_str())) { | 1030 0 == strcmp("PushCull", (*commands)[i].c_str())) { |
1014 indent += 10; | 1031 indent += 10; |
1015 } | 1032 } |
1016 | 1033 |
1017 item->setData(Qt::UserRole + 4, -1.0); | 1034 item->setData(Qt::UserRole + 4, -1); |
| 1035 item->setData(Qt::UserRole + 5, (int)(*offsets)[i]); |
1018 | 1036 |
1019 fListWidget.addItem(item); | 1037 fListWidget.addItem(item); |
1020 } | 1038 } |
1021 } | 1039 } |
1022 | 1040 |
1023 void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes, | 1041 void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes, |
1024 double totTime, | 1042 double totTime, |
1025 int numRuns) { | 1043 int numRuns) { |
1026 SkString overview; | 1044 SkString overview; |
1027 fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns); | 1045 fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns); |
(...skipping 15 matching lines...) Expand all Loading... |
1043 } | 1061 } |
1044 | 1062 |
1045 // NOTE(chudy): Makes first item unselectable. | 1063 // NOTE(chudy): Makes first item unselectable. |
1046 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( | 1064 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( |
1047 fFilter.model()); | 1065 fFilter.model()); |
1048 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), | 1066 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), |
1049 fFilter.rootModelIndex()); | 1067 fFilter.rootModelIndex()); |
1050 QStandardItem* firstItem = model->itemFromIndex(firstIndex); | 1068 QStandardItem* firstItem = model->itemFromIndex(firstIndex); |
1051 firstItem->setSelectable(false); | 1069 firstItem->setSelectable(false); |
1052 } | 1070 } |
OLD | NEW |