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

Side by Side Diff: Source/devtools/front_end/timeline/TimelineFrameModel.js

Issue 709423002: DevTools: remove old Timeline front-end implementation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated LayoutTests/inspector/layers/layer-canvas-log.html Created 6 years, 1 month 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return result; 210 return result;
211 } 211 }
212 return null; 212 return null;
213 } 213 }
214 } 214 }
215 215
216 /** 216 /**
217 * @constructor 217 * @constructor
218 * @extends {WebInspector.TimelineFrameModelBase} 218 * @extends {WebInspector.TimelineFrameModelBase}
219 */ 219 */
220 WebInspector.TimelineFrameModel = function()
221 {
222 WebInspector.TimelineFrameModelBase.call(this);
223 }
224
225 WebInspector.TimelineFrameModel._mainFrameMarkers = [
226 WebInspector.TimelineModel.RecordType.ScheduleStyleRecalculation,
227 WebInspector.TimelineModel.RecordType.InvalidateLayout,
228 WebInspector.TimelineModel.RecordType.BeginFrame,
229 WebInspector.TimelineModel.RecordType.ScrollLayer
230 ];
231
232 WebInspector.TimelineFrameModel.prototype = {
233 reset: function()
234 {
235 this._mergeRecords = true;
236 this._mergingBuffer = new WebInspector.TimelineMergingRecordBuffer();
237 WebInspector.TimelineFrameModelBase.prototype.reset.call(this);
238 },
239
240 /**
241 * @param {boolean} value
242 */
243 setMergeRecords: function(value)
244 {
245 this._mergeRecords = value;
246 },
247
248 /**
249 * @param {!Array.<!WebInspector.TimelineModel.Record>} records
250 */
251 addRecords: function(records)
252 {
253 if (!records.length)
254 return;
255 if (records[0].startTime() < this._minimumRecordTime)
256 this._minimumRecordTime = records[0].startTime();
257 for (var i = 0; i < records.length; ++i)
258 this.addRecord(records[i]);
259 },
260
261 /**
262 * @param {!WebInspector.TimelineModel.Record} record
263 */
264 addRecord: function(record)
265 {
266 var recordTypes = WebInspector.TimelineModel.RecordType;
267 var programRecord = record.type() === recordTypes.Program ? record : nul l;
268
269 // Start collecting main frame
270 if (programRecord) {
271 if (!this._framePendingCommit && this._findRecordRecursively(WebInsp ector.TimelineFrameModel._mainFrameMarkers, programRecord))
272 this._framePendingCommit = new WebInspector.PendingFrame();
273 }
274 /** type {Array.<!WebInspector.TimelineModel.Record>} */
275 var records = [];
276 if (!this._mergeRecords)
277 records = [record];
278 else
279 records = this._mergingBuffer.process(record.thread(), /** type {Arr ay.<!WebInspector.TimelineModel.Record>} */(programRecord ? record.children() || [] : [record]));
280 for (var i = 0; i < records.length; ++i) {
281 if (records[i].thread() === WebInspector.TimelineModel.MainThreadNam e)
282 this._addMainThreadRecord(programRecord, records[i]);
283 else
284 this._addBackgroundRecord(records[i]);
285 }
286 },
287
288 /**
289 * @param {!WebInspector.TimelineModel.Record} record
290 */
291 _addBackgroundRecord: function(record)
292 {
293 var recordTypes = WebInspector.TimelineModel.RecordType;
294 if (record.type() === recordTypes.BeginFrame)
295 this.handleBeginFrame(record.startTime());
296 else if (record.type() === recordTypes.DrawFrame)
297 this.handleDrawFrame(record.startTime());
298 else if (record.type() === recordTypes.RequestMainThreadFrame)
299 this.handleRequestMainThreadFrame();
300 else if (record.type() === recordTypes.ActivateLayerTree)
301 this.handleActivateLayerTree();
302
303 if (this._lastFrame)
304 this._lastFrame._addTimeFromRecord(record);
305 },
306
307 /**
308 * @param {?WebInspector.TimelineModel.Record} programRecord
309 * @param {!WebInspector.TimelineModel.Record} record
310 */
311 _addMainThreadRecord: function(programRecord, record)
312 {
313 var recordTypes = WebInspector.TimelineModel.RecordType;
314 if (record.type() === recordTypes.UpdateLayerTree && record.data()["laye rTree"])
315 this.handleLayerTreeSnapshot(new WebInspector.DeferredAgentLayerTree (record.target(), record.data()["layerTree"]));
316 if (!this._hasThreadedCompositing) {
317 if (record.type() === recordTypes.BeginFrame)
318 this._startMainThreadFrame(record.startTime());
319
320 if (!this._lastFrame)
321 return;
322
323 this._lastFrame._addTimeFromRecord(record);
324
325 // Account for "other" time at the same time as the first child.
326 if (programRecord.children()[0] === record)
327 this._lastFrame._addTimeForCategory("other", this._deriveOtherTi me(programRecord));
328 return;
329 }
330
331 if (!this._framePendingCommit)
332 return;
333
334 WebInspector.TimelineUIUtilsImpl.aggregateTimeForRecord(this._framePendi ngCommit.timeByCategory, record);
335 if (programRecord.children()[0] === record)
336 this._framePendingCommit.timeByCategory["other"] = (this._framePendi ngCommit.timeByCategory["other"] || 0) + this._deriveOtherTime(programRecord);
337
338 if (record.type() === recordTypes.CompositeLayers)
339 this.handleCompositeLayers();
340 },
341
342 /**
343 * @param {!WebInspector.TimelineModel.Record} programRecord
344 * @return {number}
345 */
346 _deriveOtherTime: function(programRecord)
347 {
348 var accounted = 0;
349 for (var i = 0; i < programRecord.children().length; ++i)
350 accounted += programRecord.children()[i].endTime() - programRecord.c hildren()[i].startTime();
351 return programRecord.endTime() - programRecord.startTime() - accounted;
352 },
353
354 __proto__: WebInspector.TimelineFrameModelBase.prototype,
355 };
356
357 /**
358 * @constructor
359 * @extends {WebInspector.TimelineFrameModelBase}
360 */
361 WebInspector.TracingTimelineFrameModel = function() 220 WebInspector.TracingTimelineFrameModel = function()
362 { 221 {
363 WebInspector.TimelineFrameModelBase.call(this); 222 WebInspector.TimelineFrameModelBase.call(this);
364 } 223 }
365 224
366 WebInspector.TracingTimelineFrameModel._mainFrameMarkers = [ 225 WebInspector.TracingTimelineFrameModel._mainFrameMarkers = [
367 WebInspector.TracingTimelineModel.RecordType.ScheduleStyleRecalculation, 226 WebInspector.TracingTimelineModel.RecordType.ScheduleStyleRecalculation,
368 WebInspector.TracingTimelineModel.RecordType.InvalidateLayout, 227 WebInspector.TracingTimelineModel.RecordType.InvalidateLayout,
369 WebInspector.TracingTimelineModel.RecordType.BeginMainThreadFrame, 228 WebInspector.TracingTimelineModel.RecordType.BeginMainThreadFrame,
370 WebInspector.TracingTimelineModel.RecordType.ScrollLayer 229 WebInspector.TracingTimelineModel.RecordType.ScrollLayer
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 442
584 /** 443 /**
585 * @param {?WebInspector.DeferredLayerTree} layerTree 444 * @param {?WebInspector.DeferredLayerTree} layerTree
586 */ 445 */
587 _setLayerTree: function(layerTree) 446 _setLayerTree: function(layerTree)
588 { 447 {
589 this.layerTree = layerTree; 448 this.layerTree = layerTree;
590 }, 449 },
591 450
592 /** 451 /**
593 * @param {!WebInspector.TimelineModel.Record} record
594 */
595 _addTimeFromRecord: function(record)
596 {
597 if (!record.endTime())
598 return;
599 var timeByCategory = {};
600 WebInspector.TimelineUIUtilsImpl.aggregateTimeForRecord(timeByCategory, record);
601 this._addTimeForCategories(timeByCategory);
602 },
603
604 /**
605 * @param {!Object} timeByCategory 452 * @param {!Object} timeByCategory
606 */ 453 */
607 _addTimeForCategories: function(timeByCategory) 454 _addTimeForCategories: function(timeByCategory)
608 { 455 {
609 for (var category in timeByCategory) 456 for (var category in timeByCategory)
610 this._addTimeForCategory(category, timeByCategory[category]); 457 this._addTimeForCategory(category, timeByCategory[category]);
611 }, 458 },
612 459
613 /** 460 /**
614 * @param {string} category 461 * @param {string} category
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 /** 519 /**
673 * @constructor 520 * @constructor
674 */ 521 */
675 WebInspector.PendingFrame = function() 522 WebInspector.PendingFrame = function()
676 { 523 {
677 /** @type {!Object.<string, number>} */ 524 /** @type {!Object.<string, number>} */
678 this.timeByCategory = {}; 525 this.timeByCategory = {};
679 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ 526 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */
680 this.paints = []; 527 this.paints = [];
681 } 528 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sdk/module.json ('k') | Source/devtools/front_end/timeline/TimelineModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698