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

Side by Side Diff: Source/devtools/front_end/TimelineFlameChart.js

Issue 187473005: DevTools: remove color generator from timeline flame chart. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months 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 | Annotate | Revision Log
OLDNEW
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 24 matching lines...) Expand all
35 * @param {!WebInspector.TimelineFrameModel} frameModel 35 * @param {!WebInspector.TimelineFrameModel} frameModel
36 * @param {boolean} mainThread 36 * @param {boolean} mainThread
37 */ 37 */
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 = "bold 12px " + WebInspector.fontFamily(); 44 this._font = "bold 12px " + WebInspector.fontFamily();
45
46 this._colorGenerator = new WebInspector.FlameChart.ColorGenerator();
47 var categories = WebInspector.TimelineUIUtils.categories();
48 for (var category in categories) {
49 this._colorGenerator.setColorForID(category, categories[category].fillCo lorStop1);
50 this._colorGenerator.setColorForID(category + " child", categories[categ ory].fillColorStop0);
51 }
52 } 45 }
53 46
54 WebInspector.TimelineFlameChartDataProvider.prototype = { 47 WebInspector.TimelineFlameChartDataProvider.prototype = {
55 /** 48 /**
56 * @return {number} 49 * @return {number}
57 */ 50 */
58 barHeight: function() 51 barHeight: function()
59 { 52 {
60 return 20; 53 return 20;
61 }, 54 },
(...skipping 22 matching lines...) Expand all
84 { 77 {
85 return this._font; 78 return this._font;
86 }, 79 },
87 80
88 /** 81 /**
89 * @param {number} entryIndex 82 * @param {number} entryIndex
90 * @return {?string} 83 * @return {?string}
91 */ 84 */
92 entryTitle: function(entryIndex) 85 entryTitle: function(entryIndex)
93 { 86 {
94 return this._entryTitles[entryIndex]; 87 return this._isSelfSegment[entryIndex] ? this._records[entryIndex].title () : null;
95 }, 88 },
96 89
97 /** 90 /**
98 * @param {number} startTime 91 * @param {number} startTime
99 * @param {number} endTime 92 * @param {number} endTime
100 * @return {?Array.<number>} 93 * @return {?Array.<number>}
101 */ 94 */
102 dividerOffsets: function(startTime, endTime) 95 dividerOffsets: function(startTime, endTime)
103 { 96 {
104 var frames = this._frameModel.filteredFrames(this._model.minimumRecordTi me() + startTime, this._model.minimumRecordTime() + endTime); 97 var frames = this._frameModel.filteredFrames(this._model.minimumRecordTi me() + startTime, this._model.minimumRecordTime() + endTime);
(...skipping 12 matching lines...) Expand all
117 110
118 /** 111 /**
119 * @param {!WebInspector.TimelineModel.Record} record 112 * @param {!WebInspector.TimelineModel.Record} record
120 */ 113 */
121 addRecord: function(record) 114 addRecord: function(record)
122 { 115 {
123 this._appendRecord(record, 0); 116 this._appendRecord(record, 0);
124 }, 117 },
125 118
126 /** 119 /**
127 * @return {!WebInspector.FlameChart.ColorGenerator}
128 */
129 colorGenerator: function()
130 {
131 return this._colorGenerator;
132 },
133
134 /**
135 * @return {!WebInspector.FlameChart.TimelineData} 120 * @return {!WebInspector.FlameChart.TimelineData}
136 */ 121 */
137 timelineData: function() 122 timelineData: function()
138 { 123 {
139 if (!this._timelineData) { 124 if (!this._timelineData) {
140 this._resetData(); 125 this._resetData();
141 var records = this._model.records(); 126 var records = this._model.records();
142 for (var i = 0; i < records.length; ++i) 127 for (var i = 0; i < records.length; ++i)
143 this._appendRecord(records[i], 0); 128 this._appendRecord(records[i], 0);
144 this._zeroTime = this._model.minimumRecordTime(); 129 this._zeroTime = this._model.minimumRecordTime();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 165
181 /** 166 /**
182 * @type {?WebInspector.FlameChart.TimelineData} 167 * @type {?WebInspector.FlameChart.TimelineData}
183 */ 168 */
184 this._timelineData = { 169 this._timelineData = {
185 entryLevels: [], 170 entryLevels: [],
186 entryTotalTimes: [], 171 entryTotalTimes: [],
187 entryOffsets: [], 172 entryOffsets: [],
188 }; 173 };
189 174
190 /** @type {!Array.<string>} */ 175 this._records = [];
191 this._entryTitles = []; 176 this._isSelfSegment = [];
192
193 /** @type {!Array.<string>} */
194 this._entryColors = [];
195 }, 177 },
196 178
197 /** 179 /**
198 * @param {!WebInspector.TimelineModel.Record} record 180 * @param {!WebInspector.TimelineModel.Record} record
199 * @param {number} level 181 * @param {number} level
200 */ 182 */
201 _appendRecord: function(record, level) 183 _appendRecord: function(record, level)
202 { 184 {
203 var timelineData = this.timelineData(); 185 var timelineData = this.timelineData();
204 186
205 this._startTime = this._startTime ? Math.min(this._startTime, record.sta rtTime) : record.startTime; 187 this._startTime = this._startTime ? Math.min(this._startTime, record.sta rtTime) : record.startTime;
206 this._zeroTime = this._startTime; 188 this._zeroTime = this._startTime;
207 var recordEndTime = record.endTime || record.startTime; 189 var recordEndTime = record.endTime || record.startTime;
208 this._endTime = Math.max(this._endTime, recordEndTime); 190 this._endTime = Math.max(this._endTime, recordEndTime);
209 this._totalTime = Math.max(1000, this._endTime - this._startTime); 191 this._totalTime = Math.max(1000, this._endTime - this._startTime);
210 192
211 if (this._mainThread) { 193 if (this._mainThread) {
212 if (record.type === WebInspector.TimelineModel.RecordType.GPUTask || !!record.thread) 194 if (record.type === WebInspector.TimelineModel.RecordType.GPUTask || !!record.thread)
213 return; 195 return;
214 } else { 196 } else {
215 if (record.type === WebInspector.TimelineModel.RecordType.Program || !record.thread) 197 if (record.type === WebInspector.TimelineModel.RecordType.Program || !record.thread)
216 return; 198 return;
217 } 199 }
218 200
219 var color = this._colorGenerator.colorForID(WebInspector.TimelineUIUtils .categoryForRecord(record).name);
220 var colorChild = this._colorGenerator.colorForID(WebInspector.TimelineUI Utils.categoryForRecord(record).name + " child");
221
222 var currentTime = record.startTime; 201 var currentTime = record.startTime;
223 for (var i = 0; i < record.children.length; ++i) { 202 for (var i = 0; i < record.children.length; ++i) {
224 var childRecord = record.children[i]; 203 var childRecord = record.children[i];
225 var childStartTime = childRecord.startTime; 204 var childStartTime = childRecord.startTime;
226 if (currentTime !== childStartTime) 205 if (currentTime !== childStartTime)
227 this._pushRecord(record, level, color, currentTime, childStartTi me); 206 this._pushRecord(record, true, level, currentTime, childStartTim e);
228 var childEndTime = childRecord.endTime || childRecord.startTime; 207 var childEndTime = childRecord.endTime || childRecord.startTime;
229 this._pushRecord(record, level, colorChild, childStartTime, childEnd Time); 208 this._pushRecord(record, false, level, childStartTime, childEndTime) ;
230 this._appendRecord(childRecord, level + 1); 209 this._appendRecord(childRecord, level + 1);
231 currentTime = childEndTime; 210 currentTime = childEndTime;
232 } 211 }
233 if (recordEndTime !== currentTime || record.children.length === 0) 212 if (recordEndTime !== currentTime || record.children.length === 0)
234 this._pushRecord(record, level, color, currentTime, recordEndTime); 213 this._pushRecord(record, true, level, currentTime, recordEndTime);
235 214
236 this._maxStackDepth = Math.max(this._maxStackDepth, level + 2); 215 this._maxStackDepth = Math.max(this._maxStackDepth, level + 2);
237 }, 216 },
238 217
239 /** 218 /**
240 * @param {!WebInspector.TimelineModel.Record} record 219 * @param {!WebInspector.TimelineModel.Record} record
220 * @param {boolean} isSelfSegment
241 * @param {number} level 221 * @param {number} level
242 * @param {string} color
243 * @param {number} startTime 222 * @param {number} startTime
244 * @param {number} endTime 223 * @param {number} endTime
245 */ 224 */
246 _pushRecord: function(record, level, color, startTime, endTime) 225 _pushRecord: function(record, isSelfSegment, level, startTime, endTime)
247 { 226 {
248 var index = this._entryTitles.length; 227 var index = this._records.length;
249 this._entryTitles[index] = record.type; 228 this._records.push(record);
250 this._timelineData.entryOffsets[index] = startTime - this._zeroTime; 229 this._timelineData.entryOffsets[index] = startTime - this._zeroTime;
251 this._timelineData.entryLevels[index] = level; 230 this._timelineData.entryLevels[index] = level;
252 this._timelineData.entryTotalTimes[index] = endTime - startTime; 231 this._timelineData.entryTotalTimes[index] = endTime - startTime;
253 this._entryColors[index] = color; 232 this._isSelfSegment[index] = isSelfSegment;
254 }, 233 },
255 234
256 /** 235 /**
257 * @param {number} entryIndex 236 * @param {number} entryIndex
258 * @return {?Array.<!{title: string, text: string}>} 237 * @return {?Array.<!{title: string, text: string}>}
259 */ 238 */
260 prepareHighlightedEntryInfo: function(entryIndex) 239 prepareHighlightedEntryInfo: function(entryIndex)
261 { 240 {
262 return null; 241 return null;
263 }, 242 },
(...skipping 15 matching lines...) Expand all
279 { 258 {
280 return null; 259 return null;
281 }, 260 },
282 261
283 /** 262 /**
284 * @param {number} entryIndex 263 * @param {number} entryIndex
285 * @return {!string} 264 * @return {!string}
286 */ 265 */
287 entryColor: function(entryIndex) 266 entryColor: function(entryIndex)
288 { 267 {
289 return this._entryColors[entryIndex]; 268 var category = WebInspector.TimelineUIUtils.categoryForRecord(this._reco rds[entryIndex]);
269 return this._isSelfSegment[entryIndex] ? category.fillColorStop1 : categ ory.backgroundColor;
290 }, 270 },
291 271
292 /** 272 /**
293 * @param {number} entryIndex 273 * @param {number} entryIndex
294 * @return {!string} 274 * @return {!string}
295 */ 275 */
296 textColor: function(entryIndex) 276 textColor: function(entryIndex)
297 { 277 {
298 return "white"; 278 return "white";
299 } 279 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 386
407 /** 387 /**
408 * @param {?WebInspector.TimelineModel.Record} record 388 * @param {?WebInspector.TimelineModel.Record} record
409 */ 389 */
410 setSelectedRecord: function(record) 390 setSelectedRecord: function(record)
411 { 391 {
412 }, 392 },
413 393
414 __proto__: WebInspector.View.prototype 394 __proto__: WebInspector.View.prototype
415 } 395 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/TimelineEventOverview.js ('k') | Source/devtools/front_end/TimelineUIUtils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698