| OLD | NEW |
| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return false; | 96 return false; |
| 97 var frameId = data["sourceFrameNumber"]; | 97 var frameId = data["sourceFrameNumber"]; |
| 98 var frame = frameId && this._frameById[frameId]; | 98 var frame = frameId && this._frameById[frameId]; |
| 99 if (!frame || !frame.layerTree) | 99 if (!frame || !frame.layerTree) |
| 100 return false; | 100 return false; |
| 101 return true; | 101 return true; |
| 102 }, | 102 }, |
| 103 | 103 |
| 104 /** | 104 /** |
| 105 * @param {!WebInspector.TracingModel.Event} rasterTask | 105 * @param {!WebInspector.TracingModel.Event} rasterTask |
| 106 * @param {function(?DOMAgent.Rect, ?WebInspector.PaintProfilerSnapshot)} ca
llback | 106 * @return Promise<?{rect: !DOMAgent.Rect, snapshot: !WebInspector.PaintProf
ilerSnapshot}>} |
| 107 */ | 107 */ |
| 108 requestRasterTile: function(rasterTask, callback) | 108 rasterTilePromise: function(rasterTask) |
| 109 { | 109 { |
| 110 var target = this._target; | 110 if (!this._target) |
| 111 if (!target) { | 111 return Promise.resolve(null); |
| 112 callback(null, null); | |
| 113 return; | |
| 114 } | |
| 115 var data = rasterTask.args["tileData"]; | 112 var data = rasterTask.args["tileData"]; |
| 116 var frameId = data["sourceFrameNumber"]; | 113 var frameId = data["sourceFrameNumber"]; |
| 117 var tileId = data["tileId"] && data["tileId"]["id_ref"]; | 114 var tileId = data["tileId"] && data["tileId"]["id_ref"]; |
| 118 var frame = frameId && this._frameById[frameId]; | 115 var frame = frameId && this._frameById[frameId]; |
| 119 if (!frame || !frame.layerTree || !tileId) { | 116 if (!frame || !frame.layerTree || !tileId) |
| 120 callback(null, null); | 117 return Promise.resolve(null); |
| 121 return; | |
| 122 } | |
| 123 | 118 |
| 124 frame.layerTree.resolve(layerTree => layerTree.pictureForRasterTile(tile
Id, callback)); | 119 return frame.layerTree.layerTreePromise().then(layerTree => layerTree &&
layerTree.pictureForRasterTile(tileId)); |
| 125 }, | 120 }, |
| 126 | 121 |
| 127 reset: function() | 122 reset: function() |
| 128 { | 123 { |
| 129 this._minimumRecordTime = Infinity; | 124 this._minimumRecordTime = Infinity; |
| 130 this._frames = []; | 125 this._frames = []; |
| 131 this._frameById = {}; | 126 this._frameById = {}; |
| 132 this._lastFrame = null; | 127 this._lastFrame = null; |
| 133 this._lastLayerTree = null; | 128 this._lastLayerTree = null; |
| 134 this._mainFrameCommitted = false; | 129 this._mainFrameCommitted = false; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 WebInspector.TracingFrameLayerTree = function(target, snapshot) | 389 WebInspector.TracingFrameLayerTree = function(target, snapshot) |
| 395 { | 390 { |
| 396 this._target = target; | 391 this._target = target; |
| 397 this._snapshot = snapshot; | 392 this._snapshot = snapshot; |
| 398 /** @type {!Array<!WebInspector.LayerPaintEvent>|undefined} */ | 393 /** @type {!Array<!WebInspector.LayerPaintEvent>|undefined} */ |
| 399 this._paints; | 394 this._paints; |
| 400 } | 395 } |
| 401 | 396 |
| 402 WebInspector.TracingFrameLayerTree.prototype = { | 397 WebInspector.TracingFrameLayerTree.prototype = { |
| 403 /** | 398 /** |
| 404 * @param {function(!WebInspector.LayerTreeBase)} callback | 399 * @return {!Promise<?WebInspector.TracingLayerTree>} |
| 405 */ | 400 */ |
| 406 resolve: function(callback) | 401 layerTreePromise: function() |
| 407 { | 402 { |
| 408 this._snapshot.requestObject(onGotObject.bind(this)); | 403 return this._snapshot.objectPromise().then(result => { |
| 409 /** | |
| 410 * @this {WebInspector.TracingFrameLayerTree} | |
| 411 * @param {?Object} result | |
| 412 */ | |
| 413 function onGotObject(result) | |
| 414 { | |
| 415 if (!result) | 404 if (!result) |
| 416 return; | 405 return null; |
| 417 var viewport = result["device_viewport_size"]; | 406 var viewport = result["device_viewport_size"]; |
| 418 var tiles = result["active_tiles"]; | 407 var tiles = result["active_tiles"]; |
| 419 var rootLayer = result["active_tree"]["root_layer"]; | 408 var rootLayer = result["active_tree"]["root_layer"]; |
| 420 var layers = result["active_tree"]["layers"]; | 409 var layers = result["active_tree"]["layers"]; |
| 421 var layerTree = new WebInspector.TracingLayerTree(this._target); | 410 var layerTree = new WebInspector.TracingLayerTree(this._target); |
| 422 layerTree.setViewportSize(viewport); | 411 layerTree.setViewportSize(viewport); |
| 423 layerTree.setTiles(tiles); | 412 layerTree.setTiles(tiles); |
| 424 layerTree.setLayers(rootLayer, layers, this._paints || [], callback.
bind(null, layerTree)); | 413 return new Promise(resolve => layerTree.setLayers(rootLayer, layers,
this._paints || [], () => resolve(layerTree))); |
| 425 } | 414 }); |
| 426 }, | 415 }, |
| 427 | 416 |
| 428 /** | 417 /** |
| 429 * @return {!Array<!WebInspector.LayerPaintEvent>} | 418 * @return {!Array<!WebInspector.LayerPaintEvent>} |
| 430 */ | 419 */ |
| 431 paints: function() | 420 paints: function() |
| 432 { | 421 { |
| 433 return this._paints || []; | 422 return this._paints || []; |
| 434 }, | 423 }, |
| 435 | 424 |
| 436 /** | 425 /** |
| 437 * @param {!Array<!WebInspector.LayerPaintEvent>} paints | 426 * @param {!Array<!WebInspector.LayerPaintEvent>} paints |
| 438 */ | 427 */ |
| 439 _setPaints: function(paints) | 428 _setPaints: function(paints) |
| 440 { | 429 { |
| 441 this._paints = paints; | 430 this._paints = paints; |
| 442 }, | 431 } |
| 443 }; | 432 }; |
| 444 | 433 |
| 445 | 434 |
| 446 /** | 435 /** |
| 447 * @constructor | 436 * @constructor |
| 448 * @param {number} startTime | 437 * @param {number} startTime |
| 449 * @param {number} startTimeOffset | 438 * @param {number} startTimeOffset |
| 450 */ | 439 */ |
| 451 WebInspector.TimelineFrame = function(startTime, startTimeOffset) | 440 WebInspector.TimelineFrame = function(startTime, startTimeOffset) |
| 452 { | 441 { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 523 |
| 535 /** | 524 /** |
| 536 * @return {!WebInspector.TracingModel.Event} | 525 * @return {!WebInspector.TracingModel.Event} |
| 537 */ | 526 */ |
| 538 event: function() | 527 event: function() |
| 539 { | 528 { |
| 540 return this._event; | 529 return this._event; |
| 541 }, | 530 }, |
| 542 | 531 |
| 543 /** | 532 /** |
| 544 * @param {function(?Array.<number>, ?string)} callback | 533 * @return {!Promise<?{rect: !Array<number>, serializedPicture: string}>} |
| 545 */ | 534 */ |
| 546 loadPicture: function(callback) | 535 picturePromise: function() |
| 547 { | 536 { |
| 548 this._event.picture.requestObject(onGotObject); | 537 return this._event.picture.objectPromise().then(result => { |
| 549 /** | 538 if (!result) |
| 550 * @param {?Object} result | 539 return null; |
| 551 */ | |
| 552 function onGotObject(result) | |
| 553 { | |
| 554 if (!result || !result["skp64"]) { | |
| 555 callback(null, null); | |
| 556 return; | |
| 557 } | |
| 558 var rect = result["params"] && result["params"]["layer_rect"]; | 540 var rect = result["params"] && result["params"]["layer_rect"]; |
| 559 callback(rect, result["skp64"]); | 541 var picture = result["skp64"]; |
| 560 } | 542 return rect && picture ? {rect: rect, serializedPicture: picture} :
null; |
| 543 }); |
| 561 }, | 544 }, |
| 562 | 545 |
| 563 /** | 546 /** |
| 564 * @param {function(?Array.<number>, ?WebInspector.PaintProfilerSnapshot)} c
allback | 547 * @return !Promise<?{rect: Array<number>, snapshot: !WebInspector.PaintProf
ilerSnapshot}>} |
| 565 */ | 548 */ |
| 566 loadSnapshot: function(callback) | 549 snapshotPromise: function() |
| 567 { | 550 { |
| 568 this.loadPicture(onGotPicture.bind(this)); | 551 return this.picturePromise().then(picture => { |
| 569 /** | 552 if (!picture || !this._target) |
| 570 * @param {?Array.<number>} rect | 553 return null; |
| 571 * @param {?string} picture | 554 return WebInspector.PaintProfilerSnapshot.load(this._target, picture
.serializedPicture).then(snapshot => snapshot ? {rect: picture.rect, snapshot: s
napshot} : null); |
| 572 * @this {WebInspector.LayerPaintEvent} | 555 }); |
| 573 */ | |
| 574 function onGotPicture(rect, picture) | |
| 575 { | |
| 576 if (!rect || !picture || !this._target) { | |
| 577 callback(null, null); | |
| 578 return; | |
| 579 } | |
| 580 WebInspector.PaintProfilerSnapshot.load(this._target, picture, callb
ack.bind(null, rect)); | |
| 581 } | |
| 582 } | 556 } |
| 583 }; | 557 }; |
| 584 | 558 |
| 585 /** | 559 /** |
| 586 * @constructor | 560 * @constructor |
| 587 * @param {number} triggerTime | 561 * @param {number} triggerTime |
| 588 * @param {!Object.<string, number>} timeByCategory | 562 * @param {!Object.<string, number>} timeByCategory |
| 589 */ | 563 */ |
| 590 WebInspector.PendingFrame = function(triggerTime, timeByCategory) | 564 WebInspector.PendingFrame = function(triggerTime, timeByCategory) |
| 591 { | 565 { |
| 592 /** @type {!Object.<string, number>} */ | 566 /** @type {!Object.<string, number>} */ |
| 593 this.timeByCategory = timeByCategory; | 567 this.timeByCategory = timeByCategory; |
| 594 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ | 568 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ |
| 595 this.paints = []; | 569 this.paints = []; |
| 596 /** @type {number|undefined} */ | 570 /** @type {number|undefined} */ |
| 597 this.mainFrameId = undefined; | 571 this.mainFrameId = undefined; |
| 598 this.triggerTime = triggerTime; | 572 this.triggerTime = triggerTime; |
| 599 } | 573 } |
| OLD | NEW |