| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @constructor | 8 * @constructor |
| 9 * @extends {WebInspector.SplitWidget} | 9 * @extends {WebInspector.SplitWidget} |
| 10 * @param {!WebInspector.TimelineModel} model | 10 * @param {!WebInspector.TimelineModel} model |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 */ | 67 */ |
| 68 _jumpToPaintEvent: function(event) | 68 _jumpToPaintEvent: function(event) |
| 69 { | 69 { |
| 70 var traceEvent = /** @type {!WebInspector.TracingModel.Event} */ (event.
data); | 70 var traceEvent = /** @type {!WebInspector.TracingModel.Event} */ (event.
data); |
| 71 this._showEventDetailsCallback(traceEvent); | 71 this._showEventDetailsCallback(traceEvent); |
| 72 }, | 72 }, |
| 73 | 73 |
| 74 _update: function() | 74 _update: function() |
| 75 { | 75 { |
| 76 var layerTree; | 76 var layerTree; |
| 77 | |
| 78 var originalTiles = this._paintTiles; | 77 var originalTiles = this._paintTiles; |
| 79 var tilesReadyBarrier = new CallbackBarrier(); | 78 var snapshotPromises = this._frameLayerTree.paints().map(paint => paint.
snapshotPromise().then(snapshotWithRect => { |
| 80 this._frameLayerTree.resolve(tilesReadyBarrier.createCallback(onLayersRe
ady)); | 79 if (!snapshotWithRect) |
| 81 this._frameLayerTree.paints().forEach(paint => paint.loadSnapshot(tilesR
eadyBarrier.createCallback(onSnapshotLoaded.bind(this, paint)))); | |
| 82 tilesReadyBarrier.callWhenDone(onLayersAndTilesReady.bind(this)); | |
| 83 | |
| 84 /** | |
| 85 * @param {!WebInspector.LayerTreeBase} resolvedLayerTree | |
| 86 */ | |
| 87 function onLayersReady(resolvedLayerTree) | |
| 88 { | |
| 89 layerTree = resolvedLayerTree; | |
| 90 } | |
| 91 | |
| 92 /** | |
| 93 * @param {!WebInspector.LayerPaintEvent} paintEvent | |
| 94 * @param {?Array.<number>} rect | |
| 95 * @param {?WebInspector.PaintProfilerSnapshot} snapshot | |
| 96 * @this {WebInspector.TimelineLayersView} | |
| 97 */ | |
| 98 function onSnapshotLoaded(paintEvent, rect, snapshot) | |
| 99 { | |
| 100 if (!rect || !snapshot) | |
| 101 return; | 80 return; |
| 102 // We're too late and there's a new generation of tiles being loaded
. | 81 // We're too late and there's a new generation of tiles being loaded
. |
| 103 if (originalTiles !== this._paintTiles) { | 82 if (originalTiles !== this._paintTiles) { |
| 104 snapshot.dispose(); | 83 snapshotWithRect.snapshot.dispose(); |
| 105 return; | 84 return; |
| 106 } | 85 } |
| 107 this._paintTiles.push({layerId: paintEvent.layerId(), rect: rect, sn
apshot: snapshot, traceEvent: paintEvent.event()}); | 86 this._paintTiles.push({layerId: paint.layerId(), rect: snapshotWithR
ect.rect, snapshot: snapshotWithRect.snapshot, traceEvent: paint.event()}); |
| 108 } | 87 })); |
| 109 | 88 snapshotPromises.push(this._frameLayerTree.layerTreePromise().then(resol
vedTree => layerTree = resolvedTree)); |
| 110 /** | 89 Promise.all(snapshotPromises).then(() => { |
| 111 * @this {WebInspector.TimelineLayersView} | 90 if (!layerTree) |
| 112 */ | 91 return; |
| 113 function onLayersAndTilesReady() | |
| 114 { | |
| 115 this._layerViewHost.setLayerTree(layerTree); | 92 this._layerViewHost.setLayerTree(layerTree); |
| 116 this._layers3DView.setTiles(this._paintTiles); | 93 this._layers3DView.setTiles(this._paintTiles); |
| 117 } | 94 }); |
| 118 }, | 95 }, |
| 119 | 96 |
| 120 _disposeTiles: function() | 97 _disposeTiles: function() |
| 121 { | 98 { |
| 122 for (var i = 0; i < this._paintTiles.length; ++i) | 99 for (var i = 0; i < this._paintTiles.length; ++i) |
| 123 this._paintTiles[i].snapshot.dispose(); | 100 this._paintTiles[i].snapshot.dispose(); |
| 124 this._paintTiles = []; | 101 this._paintTiles = []; |
| 125 }, | 102 }, |
| 126 | 103 |
| 127 __proto__: WebInspector.SplitWidget.prototype | 104 __proto__: WebInspector.SplitWidget.prototype |
| 128 } | 105 } |
| OLD | NEW |