Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: debugger/QT/SkDebuggerGUI.cpp

Issue 821663003: Change DebugCanvas API to not encourage memory leaks (Closed) Base URL: https://skia.googlesource.com/skia.git@debugger-raster-black-bg
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
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? 776 // Will this automatically clear out due to nature of refcnt?
777 SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings(); 777 SkTArray<SkString> commands;
778 SkTDArray<size_t>* offsets = fDebugger.getDrawCommandOffsets(); 778 fDebugger.getDrawCommandsAsStrings(&commands);
779 SkASSERT(commands->count() == offsets->count()); 779 SkTDArray<size_t> offsets;
780 fDebugger.getDrawCommandOffsets(&offsets);
781 SkASSERT(commands.count() == offsets.count());
780 782
781 fActionProfile.setDisabled(false); 783 fActionProfile.setDisabled(false);
782 784
783 /* fDebugCanvas is reinitialized every load picture. Need it to retain value 785 /* fDebugCanvas is reinitialized every load picture. Need it to retain value
784 * of the visibility filter. 786 * of the visibility filter.
785 * TODO(chudy): This should be deprecated since fDebugger is not 787 * TODO(chudy): This should be deprecated since fDebugger is not
786 * recreated. 788 * recreated.
787 * */ 789 * */
788 fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityFilter()); 790 fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityFilter());
789 791
790 this->setupListWidget(commands, offsets); 792 this->setupListWidget(commands, offsets);
791 this->setupComboBox(commands); 793 this->setupComboBox(commands);
792 this->setupOverviewText(NULL, 0.0, 1); 794 this->setupOverviewText(NULL, 0.0, 1);
793 fInspectorWidget.setDisabled(false); 795 fInspectorWidget.setDisabled(false);
794 fSettingsWidget.setDisabled(false); 796 fSettingsWidget.setDisabled(false);
795 fMenuEdit.setDisabled(false); 797 fMenuEdit.setDisabled(false);
796 fMenuNavigate.setDisabled(false); 798 fMenuNavigate.setDisabled(false);
797 fMenuView.setDisabled(false); 799 fMenuView.setDisabled(false);
798 fActionSave.setDisabled(false); 800 fActionSave.setDisabled(false);
799 fActionSaveAs.setDisabled(false); 801 fActionSaveAs.setDisabled(false);
800 fLoading = false; 802 fLoading = false;
801 actionPlay(); 803 actionPlay();
802 } 804 }
803 805
804 void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* commands, SkTDArray<size _t>* offsets) { 806 void SkDebuggerGUI::setupListWidget(const SkTArray<SkString>& commands, const Sk TDArray<size_t>& offsets) {
805 SkASSERT(commands->count() == offsets->count()); 807 SkASSERT(commands.count() == offsets.count());
806 fListWidget.clear(); 808 fListWidget.clear();
807 int counter = 0; 809 int counter = 0;
808 int indent = 0; 810 int indent = 0;
809 for (int i = 0; i < commands->count(); i++) { 811 for (int i = 0; i < commands.count(); i++) {
810 QListWidgetItem *item = new QListWidgetItem(); 812 QListWidgetItem *item = new QListWidgetItem();
811 item->setData(Qt::DisplayRole, (*commands)[i].c_str()); 813 item->setData(Qt::DisplayRole, commands[i].c_str());
812 item->setData(Qt::UserRole + 1, counter++); 814 item->setData(Qt::UserRole + 1, counter++);
813 815
814 if (0 == strcmp("Restore", (*commands)[i].c_str()) || 816 if (0 == strcmp("Restore", commands[i].c_str()) ||
815 0 == strcmp("EndCommentGroup", (*commands)[i].c_str())) { 817 0 == strcmp("EndCommentGroup", commands[i].c_str())) {
816 indent -= 10; 818 indent -= 10;
817 } 819 }
818 820
819 item->setData(Qt::UserRole + 3, indent); 821 item->setData(Qt::UserRole + 3, indent);
820 822
821 if (0 == strcmp("Save", (*commands)[i].c_str()) || 823 if (0 == strcmp("Save", commands[i].c_str()) ||
822 0 == strcmp("Save Layer", (*commands)[i].c_str()) || 824 0 == strcmp("Save Layer", commands[i].c_str()) ||
823 0 == strcmp("BeginCommentGroup", (*commands)[i].c_str())) { 825 0 == strcmp("BeginCommentGroup", commands[i].c_str())) {
824 indent += 10; 826 indent += 10;
825 } 827 }
826 828
827 item->setData(Qt::UserRole + 4, -1); 829 item->setData(Qt::UserRole + 4, -1);
828 item->setData(Qt::UserRole + 5, (int)(*offsets)[i]); 830 item->setData(Qt::UserRole + 5, (int)offsets[i]);
829 831
830 fListWidget.addItem(item); 832 fListWidget.addItem(item);
831 } 833 }
832 } 834 }
833 835
834 void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes, 836 void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes,
835 double totTime, 837 double totTime,
836 int numRuns) { 838 int numRuns) {
837 SkString overview; 839 SkString overview;
838 fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns); 840 fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns);
839 fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabT ype); 841 fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabT ype);
840 } 842 }
841 843
842 void SkDebuggerGUI::setupClipStackText() { 844 void SkDebuggerGUI::setupClipStackText() {
843 SkString clipStack; 845 SkString clipStack;
844 fDebugger.getClipStackText(&clipStack); 846 fDebugger.getClipStackText(&clipStack);
845 fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_Ta bType); 847 fInspectorWidget.setText(clipStack.c_str(), SkInspectorWidget::kClipStack_Ta bType);
846 } 848 }
847 849
848 void SkDebuggerGUI::setupComboBox(SkTArray<SkString>* command) { 850 void SkDebuggerGUI::setupComboBox(const SkTArray<SkString>& command) {
849 fFilter.clear(); 851 fFilter.clear();
850 fFilter.addItem("--Filter By Available Commands--"); 852 fFilter.addItem("--Filter By Available Commands--");
851 853
852 std::map<std::string, int> map; 854 std::map<std::string, int> map;
853 for (int i = 0; i < command->count(); i++) { 855 for (int i = 0; i < command.count(); i++) {
854 map[(*command)[i].c_str()]++; 856 map[command[i].c_str()]++;
855 } 857 }
856 858
857 for (std::map<std::string, int>::iterator it = map.begin(); it != map.end(); 859 for (std::map<std::string, int>::iterator it = map.begin(); it != map.end();
858 ++it) { 860 ++it) {
859 fFilter.addItem((it->first).c_str()); 861 fFilter.addItem((it->first).c_str());
860 } 862 }
861 863
862 // NOTE(chudy): Makes first item unselectable. 864 // NOTE(chudy): Makes first item unselectable.
863 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( 865 QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
864 fFilter.model()); 866 fFilter.model());
865 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), 867 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(),
866 fFilter.rootModelIndex()); 868 fFilter.rootModelIndex());
867 QStandardItem* firstItem = model->itemFromIndex(firstIndex); 869 QStandardItem* firstItem = model->itemFromIndex(firstIndex);
868 firstItem->setSelectable(false); 870 firstItem->setSelectable(false);
869 } 871 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698