OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 27 matching lines...) Expand all Loading... |
38 WebInspector.TimelineFlameChartDataProvider = function(model, frameModel, mainTh
read) | 38 WebInspector.TimelineFlameChartDataProvider = function(model, frameModel, mainTh
read) |
39 { | 39 { |
40 WebInspector.FlameChartDataProvider.call(this); | 40 WebInspector.FlameChartDataProvider.call(this); |
41 this._model = model; | 41 this._model = model; |
42 this._frameModel = frameModel; | 42 this._frameModel = frameModel; |
43 this._mainThread = mainThread; | 43 this._mainThread = mainThread; |
44 this._font = (this.barHeight() - 4) + "px " + WebInspector.fontFamily(); | 44 this._font = (this.barHeight() - 4) + "px " + WebInspector.fontFamily(); |
45 | 45 |
46 this._colorGenerator = new WebInspector.FlameChart.ColorGenerator(); | 46 this._colorGenerator = new WebInspector.FlameChart.ColorGenerator(); |
47 var categories = WebInspector.TimelineUIUtils.categories(); | 47 var categories = WebInspector.TimelineUIUtils.categories(); |
48 for (var category in categories) | 48 for (var category in categories) { |
49 this._colorGenerator.setColorForID(category, categories[category].fillCo
lorStop1); | 49 this._colorGenerator.setColorForID(category, categories[category].fillCo
lorStop1); |
| 50 this._colorGenerator.setColorForID(category + " child", categories[categ
ory].fillColorStop0); |
| 51 } |
50 } | 52 } |
51 | 53 |
52 WebInspector.TimelineFlameChartDataProvider.prototype = { | 54 WebInspector.TimelineFlameChartDataProvider.prototype = { |
53 /** | 55 /** |
54 * @return {number} | 56 * @return {number} |
55 */ | 57 */ |
56 barHeight: function() | 58 barHeight: function() |
57 { | 59 { |
58 return 15; | 60 return 15; |
59 }, | 61 }, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 reset: function() | 97 reset: function() |
96 { | 98 { |
97 this._timelineData = null; | 99 this._timelineData = null; |
98 }, | 100 }, |
99 | 101 |
100 /** | 102 /** |
101 * @param {!WebInspector.TimelineModel.Record} record | 103 * @param {!WebInspector.TimelineModel.Record} record |
102 */ | 104 */ |
103 addRecord: function(record) | 105 addRecord: function(record) |
104 { | 106 { |
105 WebInspector.TimelineModel.forAllRecords([record], this._appendRecord.bi
nd(this)); | 107 this._appendRecord(record, 0); |
106 }, | 108 }, |
107 | 109 |
108 /** | 110 /** |
109 * @return {!WebInspector.FlameChart.ColorGenerator} | 111 * @return {!WebInspector.FlameChart.ColorGenerator} |
110 */ | 112 */ |
111 colorGenerator: function() | 113 colorGenerator: function() |
112 { | 114 { |
113 return this._colorGenerator; | 115 return this._colorGenerator; |
114 }, | 116 }, |
115 | 117 |
116 /** | 118 /** |
117 * @return {!WebInspector.FlameChart.TimelineData} | 119 * @return {!WebInspector.FlameChart.TimelineData} |
118 */ | 120 */ |
119 timelineData: function() | 121 timelineData: function() |
120 { | 122 { |
121 if (!this._timelineData) { | 123 if (!this._timelineData) { |
122 this._resetData(); | 124 this._resetData(); |
123 this._model.forAllRecords(this._appendRecord.bind(this)); | 125 var records = this._model.records(); |
| 126 for (var i = 0; i < records.length; ++i) |
| 127 this._appendRecord(records[i], 0); |
124 this._zeroTime = this._model.minimumRecordTime(); | 128 this._zeroTime = this._model.minimumRecordTime(); |
125 } | 129 } |
126 return /** @type {!WebInspector.FlameChart.TimelineData} */(this._timeli
neData); | 130 return /** @type {!WebInspector.FlameChart.TimelineData} */(this._timeli
neData); |
127 }, | 131 }, |
128 | 132 |
129 /** | 133 /** |
130 * @return {number} | 134 * @return {number} |
131 */ | 135 */ |
132 zeroTime: function() | 136 zeroTime: function() |
133 { | 137 { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 173 |
170 /** @type {!Array.<string>} */ | 174 /** @type {!Array.<string>} */ |
171 this._entryTitles = []; | 175 this._entryTitles = []; |
172 | 176 |
173 /** @type {!Array.<string>} */ | 177 /** @type {!Array.<string>} */ |
174 this._entryColors = []; | 178 this._entryColors = []; |
175 }, | 179 }, |
176 | 180 |
177 /** | 181 /** |
178 * @param {!WebInspector.TimelineModel.Record} record | 182 * @param {!WebInspector.TimelineModel.Record} record |
179 * @param {number} depth | 183 * @param {number} level |
180 */ | 184 */ |
181 _appendRecord: function(record, depth) | 185 _appendRecord: function(record, level) |
182 { | 186 { |
183 var timelineData = this.timelineData(); | 187 var timelineData = this.timelineData(); |
184 | 188 |
185 this._startTime = this._startTime ? Math.min(this._startTime, record.sta
rtTime) : record.startTime; | 189 this._startTime = this._startTime ? Math.min(this._startTime, record.sta
rtTime) : record.startTime; |
186 var startTime = this._startTime; | 190 this._zeroTime = this._startTime; |
187 this._zeroTime = startTime; | 191 var recordEndTime = record.endTime || record.startTime; |
188 var endTime = record.endTime || record.startTime - startTime; | 192 this._endTime = Math.max(this._endTime, recordEndTime); |
189 this._endTime = Math.max(this._endTime, endTime); | |
190 this._totalTime = Math.max(1000, this._endTime - this._startTime); | 193 this._totalTime = Math.max(1000, this._endTime - this._startTime); |
191 | 194 |
192 if (this._mainThread) { | 195 if (this._mainThread) { |
193 if (record.type === WebInspector.TimelineModel.RecordType.GPUTask ||
!!record.thread) | 196 if (record.type === WebInspector.TimelineModel.RecordType.GPUTask ||
!!record.thread) |
194 return; | 197 return; |
195 } else { | 198 } else { |
196 if (record.type === WebInspector.TimelineModel.RecordType.Program ||
!record.thread) | 199 if (record.type === WebInspector.TimelineModel.RecordType.Program ||
!record.thread) |
197 return; | 200 return; |
198 } | 201 } |
199 | 202 |
200 var index = this._entryTitles.length; | 203 var color = this._colorGenerator.colorForID(WebInspector.TimelineUIUtils
.categoryForRecord(record).name); |
201 this._entryTitles[index] = record.type; | 204 var colorChild = this._colorGenerator.colorForID(WebInspector.TimelineUI
Utils.categoryForRecord(record).name + " child"); |
202 timelineData.entryOffsets[index] = record.startTime - startTime; | 205 |
203 timelineData.entryLevels[index] = depth; | 206 var currentTime = record.startTime; |
204 timelineData.entryTotalTimes[index] = endTime - record.startTime; | 207 for (var i = 0; i < record.children.length; ++i) { |
205 this._entryColors[index] = this._colorGenerator.colorForID(WebInspector.
TimelineUIUtils.categoryForRecord(record).name); | 208 var childRecord = record.children[i]; |
206 this._maxStackDepth = Math.max(this._maxStackDepth, depth + 1); | 209 var childStartTime = childRecord.startTime; |
| 210 if (currentTime !== childStartTime) |
| 211 this._pushRecord(record, level, color, currentTime, childStartTi
me); |
| 212 var childEndTime = childRecord.endTime || childRecord.startTime; |
| 213 this._pushRecord(record, level, colorChild, childStartTime, childEnd
Time); |
| 214 this._appendRecord(childRecord, level + 1); |
| 215 currentTime = childEndTime; |
| 216 } |
| 217 if (recordEndTime !== currentTime || record.children.length === 0) |
| 218 this._pushRecord(record, level, color, currentTime, recordEndTime); |
| 219 |
| 220 this._maxStackDepth = Math.max(this._maxStackDepth, level + 2); |
207 }, | 221 }, |
208 | 222 |
209 /** | 223 /** |
| 224 * @param {!WebInspector.TimelineModel.Record} record |
| 225 * @param {number} level |
| 226 * @param {string} color |
| 227 * @param {number} startTime |
| 228 * @param {number} endTime |
| 229 */ |
| 230 _pushRecord: function(record, level, color, startTime, endTime) |
| 231 { |
| 232 var index = this._entryTitles.length; |
| 233 this._entryTitles[index] = record.type; |
| 234 this._timelineData.entryOffsets[index] = startTime - this._zeroTime; |
| 235 this._timelineData.entryLevels[index] = level; |
| 236 this._timelineData.entryTotalTimes[index] = endTime - startTime; |
| 237 this._entryColors[index] = color; |
| 238 }, |
| 239 |
| 240 /** |
210 * @param {number} entryIndex | 241 * @param {number} entryIndex |
211 * @return {?Array.<!{title: string, text: string}>} | 242 * @return {?Array.<!{title: string, text: string}>} |
212 */ | 243 */ |
213 prepareHighlightedEntryInfo: function(entryIndex) | 244 prepareHighlightedEntryInfo: function(entryIndex) |
214 { | 245 { |
215 return null; | 246 return null; |
216 }, | 247 }, |
217 | 248 |
218 /** | 249 /** |
219 * @param {number} entryIndex | 250 * @param {number} entryIndex |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 | 381 |
351 /** | 382 /** |
352 * @param {?WebInspector.TimelineModel.Record} record | 383 * @param {?WebInspector.TimelineModel.Record} record |
353 */ | 384 */ |
354 setSelectedRecord: function(record) | 385 setSelectedRecord: function(record) |
355 { | 386 { |
356 }, | 387 }, |
357 | 388 |
358 __proto__: WebInspector.View.prototype | 389 __proto__: WebInspector.View.prototype |
359 } | 390 } |
OLD | NEW |