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 "SkGraphics.h" | 9 #include "SkGraphics.h" |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 indent += 10; | 1064 indent += 10; |
1065 } | 1065 } |
1066 | 1066 |
1067 item->setData(Qt::UserRole + 4, -1.0); | 1067 item->setData(Qt::UserRole + 4, -1.0); |
1068 | 1068 |
1069 fListWidget.addItem(item); | 1069 fListWidget.addItem(item); |
1070 } | 1070 } |
1071 } | 1071 } |
1072 | 1072 |
1073 void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes, double
totTime) { | 1073 void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes, double
totTime) { |
1074 | 1074 SkString overview; |
1075 const SkTDArray<SkDrawCommand*>& commands = fDebugger.getDrawCommands(); | 1075 fDebugger.getOverviewText(typeTimes, totTime, &overview); |
1076 | 1076 fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabT
ype); |
1077 SkTDArray<int> counts; | |
1078 counts.setCount(LAST_DRAWTYPE_ENUM+1); | |
1079 for (int i = 0; i < LAST_DRAWTYPE_ENUM+1; ++i) { | |
1080 counts[i] = 0; | |
1081 } | |
1082 | |
1083 for (int i = 0; i < commands.count(); i++) { | |
1084 counts[commands[i]->getType()]++; | |
1085 } | |
1086 | |
1087 QString overview; | |
1088 int total = 0; | |
1089 #ifdef SK_DEBUG | |
1090 double totPercent = 0, tempSum = 0; | |
1091 #endif | |
1092 for (int i = 0; i < LAST_DRAWTYPE_ENUM+1; ++i) { | |
1093 if (0 == counts[i]) { | |
1094 // if there were no commands of this type then they should've consum
ed no time | |
1095 SkASSERT(NULL == typeTimes || 0.0 == (*typeTimes)[i]); | |
1096 continue; | |
1097 } | |
1098 | |
1099 overview.append(SkDrawCommand::GetCommandString((DrawType) i)); | |
1100 overview.append(": "); | |
1101 overview.append(QString::number(counts[i])); | |
1102 if (NULL != typeTimes) { | |
1103 overview.append(" - "); | |
1104 overview.append(QString::number((*typeTimes)[i], 'f', 1)); | |
1105 overview.append("ms"); | |
1106 overview.append(" - "); | |
1107 double percent = 100.0*(*typeTimes)[i]/totTime; | |
1108 overview.append(QString::number(percent, 'f', 1)); | |
1109 overview.append("%"); | |
1110 #ifdef SK_DEBUG | |
1111 totPercent += percent; | |
1112 tempSum += (*typeTimes)[i]; | |
1113 #endif | |
1114 } | |
1115 overview.append("<br/>"); | |
1116 total += counts[i]; | |
1117 } | |
1118 #ifdef SK_DEBUG | |
1119 if (NULL != typeTimes) { | |
1120 SkASSERT(SkScalarNearlyEqual(totPercent, 100.0)); | |
1121 SkASSERT(SkScalarNearlyEqual(tempSum, totTime)); | |
1122 } | |
1123 #endif | |
1124 | |
1125 if (totTime > 0.0) { | |
1126 overview.append("Total Time: "); | |
1127 overview.append(QString::number(totTime, 'f', 2)); | |
1128 overview.append("ms"); | |
1129 #ifdef SK_DEBUG | |
1130 overview.append(" "); | |
1131 overview.append(QString::number(totPercent)); | |
1132 overview.append("% "); | |
1133 #endif | |
1134 overview.append("<br/>"); | |
1135 } | |
1136 | |
1137 QString totalStr; | |
1138 totalStr.append("Total Draw Commands: "); | |
1139 totalStr.append(QString::number(total)); | |
1140 totalStr.append("<br/>"); | |
1141 overview.insert(0, totalStr); | |
1142 | |
1143 overview.append("<br/>"); | |
1144 overview.append("SkPicture Width: "); | |
1145 // NOTE(chudy): This is where we can pull out the SkPictures width. | |
1146 overview.append(QString::number(fDebugger.pictureWidth())); | |
1147 overview.append("px<br/>"); | |
1148 overview.append("SkPicture Height: "); | |
1149 overview.append(QString::number(fDebugger.pictureHeight())); | |
1150 overview.append("px"); | |
1151 fInspectorWidget.setText(overview, SkInspectorWidget::kOverview_TabType); | |
1152 } | 1077 } |
1153 | 1078 |
1154 void SkDebuggerGUI::setupComboBox(SkTArray<SkString>* command) { | 1079 void SkDebuggerGUI::setupComboBox(SkTArray<SkString>* command) { |
1155 fFilter.clear(); | 1080 fFilter.clear(); |
1156 fFilter.addItem("--Filter By Available Commands--"); | 1081 fFilter.addItem("--Filter By Available Commands--"); |
1157 | 1082 |
1158 std::map<std::string, int> map; | 1083 std::map<std::string, int> map; |
1159 for (int i = 0; i < command->count(); i++) { | 1084 for (int i = 0; i < command->count(); i++) { |
1160 map[(*command)[i].c_str()]++; | 1085 map[(*command)[i].c_str()]++; |
1161 } | 1086 } |
1162 | 1087 |
1163 for (std::map<std::string, int>::iterator it = map.begin(); it != map.end(); | 1088 for (std::map<std::string, int>::iterator it = map.begin(); it != map.end(); |
1164 ++it) { | 1089 ++it) { |
1165 fFilter.addItem((it->first).c_str()); | 1090 fFilter.addItem((it->first).c_str()); |
1166 } | 1091 } |
1167 | 1092 |
1168 // NOTE(chudy): Makes first item unselectable. | 1093 // NOTE(chudy): Makes first item unselectable. |
1169 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( | 1094 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( |
1170 fFilter.model()); | 1095 fFilter.model()); |
1171 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), | 1096 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), |
1172 fFilter.rootModelIndex()); | 1097 fFilter.rootModelIndex()); |
1173 QStandardItem* firstItem = model->itemFromIndex(firstIndex); | 1098 QStandardItem* firstItem = model->itemFromIndex(firstIndex); |
1174 firstItem->setSelectable(false); | 1099 firstItem->setSelectable(false); |
1175 } | 1100 } |
OLD | NEW |