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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 fDebugger.loadPicture(picture); | 766 fDebugger.loadPicture(picture); |
767 | 767 |
768 fSkipCommands.setCount(fDebugger.getSize()); | 768 fSkipCommands.setCount(fDebugger.getSize()); |
769 for (int i = 0; i < fSkipCommands.count(); ++i) { | 769 for (int i = 0; i < fSkipCommands.count(); ++i) { |
770 fSkipCommands[i] = false; | 770 fSkipCommands[i] = false; |
771 } | 771 } |
772 | 772 |
773 SkSafeUnref(stream); | 773 SkSafeUnref(stream); |
774 SkSafeUnref(picture); | 774 SkSafeUnref(picture); |
775 | 775 |
776 // Will this automatically clear out due to nature of refcnt? | |
777 SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings(); | |
778 SkTDArray<size_t>* offsets = fDebugger.getDrawCommandOffsets(); | |
779 SkASSERT(commands->count() == offsets->count()); | |
780 | |
781 fActionProfile.setDisabled(false); | 776 fActionProfile.setDisabled(false); |
782 | 777 |
783 /* fDebugCanvas is reinitialized every load picture. Need it to retain value | 778 /* fDebugCanvas is reinitialized every load picture. Need it to retain value |
784 * of the visibility filter. | 779 * of the visibility filter. |
785 * TODO(chudy): This should be deprecated since fDebugger is not | 780 * TODO(chudy): This should be deprecated since fDebugger is not |
786 * recreated. | 781 * recreated. |
787 * */ | 782 * */ |
788 fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityFilter()); | 783 fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityFilter()); |
789 | 784 |
790 this->setupListWidget(commands, offsets); | 785 this->setupListWidget(); |
791 this->setupComboBox(commands); | 786 this->setupComboBox(); |
792 this->setupOverviewText(NULL, 0.0, 1); | 787 this->setupOverviewText(NULL, 0.0, 1); |
793 fInspectorWidget.setDisabled(false); | 788 fInspectorWidget.setDisabled(false); |
794 fSettingsWidget.setDisabled(false); | 789 fSettingsWidget.setDisabled(false); |
795 fMenuEdit.setDisabled(false); | 790 fMenuEdit.setDisabled(false); |
796 fMenuNavigate.setDisabled(false); | 791 fMenuNavigate.setDisabled(false); |
797 fMenuView.setDisabled(false); | 792 fMenuView.setDisabled(false); |
798 fActionSave.setDisabled(false); | 793 fActionSave.setDisabled(false); |
799 fActionSaveAs.setDisabled(false); | 794 fActionSaveAs.setDisabled(false); |
800 fLoading = false; | 795 fLoading = false; |
801 actionPlay(); | 796 actionPlay(); |
802 } | 797 } |
803 | 798 |
804 void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* commands, SkTDArray<size
_t>* offsets) { | 799 void SkDebuggerGUI::setupListWidget() { |
805 SkASSERT(commands->count() == offsets->count()); | |
806 fListWidget.clear(); | 800 fListWidget.clear(); |
807 int counter = 0; | 801 int counter = 0; |
808 int indent = 0; | 802 int indent = 0; |
809 for (int i = 0; i < commands->count(); i++) { | 803 for (int i = 0; i < fDebugger.getSize(); i++) { |
810 QListWidgetItem *item = new QListWidgetItem(); | 804 QListWidgetItem *item = new QListWidgetItem(); |
811 item->setData(Qt::DisplayRole, (*commands)[i].c_str()); | 805 SkDrawCommand* command = fDebugger.getDrawCommandAt(i); |
| 806 SkString commandString = command->toString(); |
| 807 item->setData(Qt::DisplayRole, commandString.c_str()); |
812 item->setData(Qt::UserRole + 1, counter++); | 808 item->setData(Qt::UserRole + 1, counter++); |
813 | 809 |
814 if (0 == strcmp("Restore", (*commands)[i].c_str()) || | 810 if (0 == strcmp("Restore", commandString.c_str()) || |
815 0 == strcmp("EndCommentGroup", (*commands)[i].c_str())) { | 811 0 == strcmp("EndCommentGroup", commandString.c_str())) { |
816 indent -= 10; | 812 indent -= 10; |
817 } | 813 } |
818 | 814 |
819 item->setData(Qt::UserRole + 3, indent); | 815 item->setData(Qt::UserRole + 3, indent); |
820 | 816 |
821 if (0 == strcmp("Save", (*commands)[i].c_str()) || | 817 if (0 == strcmp("Save", commandString.c_str()) || |
822 0 == strcmp("Save Layer", (*commands)[i].c_str()) || | 818 0 == strcmp("Save Layer", commandString.c_str()) || |
823 0 == strcmp("BeginCommentGroup", (*commands)[i].c_str())) { | 819 0 == strcmp("BeginCommentGroup", commandString.c_str())) { |
824 indent += 10; | 820 indent += 10; |
825 } | 821 } |
826 | 822 |
827 item->setData(Qt::UserRole + 4, -1); | 823 item->setData(Qt::UserRole + 4, -1); |
828 item->setData(Qt::UserRole + 5, (int)(*offsets)[i]); | 824 item->setData(Qt::UserRole + 5, (int) command->offset()); |
829 | 825 |
830 fListWidget.addItem(item); | 826 fListWidget.addItem(item); |
831 } | 827 } |
832 } | 828 } |
833 | 829 |
834 void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes, | 830 void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes, |
835 double totTime, | 831 double totTime, |
836 int numRuns) { | 832 int numRuns) { |
837 SkString overview; | 833 SkString overview; |
838 fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns); | 834 fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns); |
839 fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabT
ype); | 835 fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabT
ype); |
840 } | 836 } |
841 | 837 |
842 void SkDebuggerGUI::setupClipStackText() { | 838 void SkDebuggerGUI::setupClipStackText() { |
843 SkString clipStack; | 839 SkString clipStack; |
844 fDebugger.getClipStackText(&clipStack); | 840 fDebugger.getClipStackText(&clipStack); |
845 fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_Ta
bType); | 841 fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_Ta
bType); |
846 } | 842 } |
847 | 843 |
848 void SkDebuggerGUI::setupComboBox(SkTArray<SkString>* command) { | 844 void SkDebuggerGUI::setupComboBox() { |
849 fFilter.clear(); | 845 fFilter.clear(); |
850 fFilter.addItem("--Filter By Available Commands--"); | 846 fFilter.addItem("--Filter By Available Commands--"); |
851 | 847 |
852 std::map<std::string, int> map; | 848 std::map<std::string, int> map; |
853 for (int i = 0; i < command->count(); i++) { | 849 for (int i = 0; i < fDebugger.getSize(); i++) { |
854 map[(*command)[i].c_str()]++; | 850 map[fDebugger.getDrawCommandAt(i)->toString().c_str()]++; |
855 } | 851 } |
856 | 852 |
857 for (std::map<std::string, int>::iterator it = map.begin(); it != map.end(); | 853 for (std::map<std::string, int>::iterator it = map.begin(); it != map.end(); |
858 ++it) { | 854 ++it) { |
859 fFilter.addItem((it->first).c_str()); | 855 fFilter.addItem((it->first).c_str()); |
860 } | 856 } |
861 | 857 |
862 // NOTE(chudy): Makes first item unselectable. | 858 // NOTE(chudy): Makes first item unselectable. |
863 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( | 859 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( |
864 fFilter.model()); | 860 fFilter.model()); |
865 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), | 861 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), |
866 fFilter.rootModelIndex()); | 862 fFilter.rootModelIndex()); |
867 QStandardItem* firstItem = model->itemFromIndex(firstIndex); | 863 QStandardItem* firstItem = model->itemFromIndex(firstIndex); |
868 firstItem->setSelectable(false); | 864 firstItem->setSelectable(false); |
869 } | 865 } |
OLD | NEW |