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.VBox} | 9 * @extends {WebInspector.VBox} |
10 */ | 10 */ |
11 WebInspector.TimelineLayersView = function() | 11 WebInspector.TimelineLayersView = function() |
12 { | 12 { |
13 WebInspector.VBox.call(this); | 13 WebInspector.VBox.call(this); |
14 | 14 |
15 this._paintTiles = []; | 15 this._paintTiles = []; |
16 this._layers3DView = new WebInspector.Layers3DView(); | 16 this._layers3DView = new WebInspector.Layers3DView(); |
17 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.ObjectS
elected, this._onObjectSelected, this); | 17 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.ObjectS
elected, this._onObjectSelected, this); |
18 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.ObjectH
overed, this._onObjectHovered, this); | 18 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.ObjectH
overed, this._onObjectHovered, this); |
| 19 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.JumpToP
aintEventRequested, this._jumpToPaintEvent, this); |
19 this._layers3DView.show(this.element); | 20 this._layers3DView.show(this.element); |
20 } | 21 } |
21 | 22 |
22 WebInspector.TimelineLayersView.prototype = { | 23 WebInspector.TimelineLayersView.prototype = { |
23 /** | 24 /** |
24 * @param {!WebInspector.DeferredLayerTree} deferredLayerTree | 25 * @param {!WebInspector.DeferredLayerTree} deferredLayerTree |
25 * @param {?Array.<!WebInspector.LayerPaintEvent>} paints | 26 * @param {?Array.<!WebInspector.LayerPaintEvent>} paints |
26 */ | 27 */ |
27 showLayerTree: function(deferredLayerTree, paints) | 28 showLayerTree: function(deferredLayerTree, paints) |
28 { | 29 { |
29 this._disposeTiles(); | 30 this._disposeTiles(); |
30 this._deferredLayerTree = deferredLayerTree; | 31 this._deferredLayerTree = deferredLayerTree; |
31 this._paints = paints; | 32 this._paints = paints; |
32 if (this.isShowing()) | 33 if (this.isShowing()) |
33 this._update(); | 34 this._update(); |
34 else | 35 else |
35 this._updateWhenVisible = true; | 36 this._updateWhenVisible = true; |
36 }, | 37 }, |
37 | 38 |
38 wasShown: function() | 39 wasShown: function() |
39 { | 40 { |
40 if (this._updateWhenVisible) { | 41 if (this._updateWhenVisible) { |
41 this._updateWhenVisible = false; | 42 this._updateWhenVisible = false; |
42 this._update(); | 43 this._update(); |
43 } | 44 } |
44 }, | 45 }, |
45 | 46 |
| 47 /** |
| 48 * @param {!WebInspector.TimelineModel} model |
| 49 * @param {!WebInspector.TimelineModeViewDelegate} delegate |
| 50 */ |
| 51 setTimelineModelAndDelegate: function(model, delegate) |
| 52 { |
| 53 this._model = model; |
| 54 this._delegate = delegate; |
| 55 }, |
| 56 |
| 57 /** |
| 58 * @param {!WebInspector.Event} event |
| 59 */ |
| 60 _jumpToPaintEvent: function(event) |
| 61 { |
| 62 var traceEvent = event.data; |
| 63 var eventRecord; |
| 64 |
| 65 /** |
| 66 * @param {!WebInspector.TimelineModel.Record} record |
| 67 * @return {boolean} |
| 68 */ |
| 69 function findRecordWithEvent(record) |
| 70 { |
| 71 if (record.traceEvent() === traceEvent) { |
| 72 eventRecord = record; |
| 73 return true; |
| 74 } |
| 75 return false; |
| 76 } |
| 77 |
| 78 this._model.forAllRecords(findRecordWithEvent); |
| 79 if (eventRecord) { |
| 80 var selection = WebInspector.TimelineSelection.fromRecord(eventRecor
d); |
| 81 this._delegate.select(selection); |
| 82 } |
| 83 }, |
| 84 |
46 _update: function() | 85 _update: function() |
47 { | 86 { |
48 var layerTree; | 87 var layerTree; |
49 | 88 |
50 this._target = this._deferredLayerTree.target(); | 89 this._target = this._deferredLayerTree.target(); |
51 var originalTiles = this._paintTiles; | 90 var originalTiles = this._paintTiles; |
52 var tilesReadyBarrier = new CallbackBarrier(); | 91 var tilesReadyBarrier = new CallbackBarrier(); |
53 this._deferredLayerTree.resolve(tilesReadyBarrier.createCallback(onLayer
sReady)); | 92 this._deferredLayerTree.resolve(tilesReadyBarrier.createCallback(onLayer
sReady)); |
54 if (this._target) { | 93 if (this._target) { |
55 for (var i = 0; this._paints && i < this._paints.length; ++i) | 94 for (var i = 0; this._paints && i < this._paints.length; ++i) |
(...skipping 16 matching lines...) Expand all Loading... |
72 */ | 111 */ |
73 function onSnapshotLoaded(paintEvent, snapshot) | 112 function onSnapshotLoaded(paintEvent, snapshot) |
74 { | 113 { |
75 if (!snapshot) | 114 if (!snapshot) |
76 return; | 115 return; |
77 // We're too late and there's a new generation of tiles being loaded
. | 116 // We're too late and there's a new generation of tiles being loaded
. |
78 if (originalTiles !== this._paintTiles) { | 117 if (originalTiles !== this._paintTiles) { |
79 snapshot.dispose(); | 118 snapshot.dispose(); |
80 return; | 119 return; |
81 } | 120 } |
82 this._paintTiles.push({layerId: paintEvent.layerId, rect: paintEvent
.rect, snapshot: snapshot}); | 121 this._paintTiles.push({layerId: paintEvent.layerId, rect: paintEvent
.rect, snapshot: snapshot, traceEvent: paintEvent.traceEvent}); |
83 } | 122 } |
84 | 123 |
85 /** | 124 /** |
86 * @this {WebInspector.TimelineLayersView} | 125 * @this {WebInspector.TimelineLayersView} |
87 */ | 126 */ |
88 function onLayersAndTilesReady() | 127 function onLayersAndTilesReady() |
89 { | 128 { |
90 this._layers3DView.setLayerTree(layerTree); | 129 this._layers3DView.setLayerTree(layerTree); |
91 this._layers3DView.setTiles(this._paintTiles); | 130 this._layers3DView.setTiles(this._paintTiles); |
92 } | 131 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 191 |
153 _disposeTiles: function() | 192 _disposeTiles: function() |
154 { | 193 { |
155 for (var i = 0; i < this._paintTiles.length; ++i) | 194 for (var i = 0; i < this._paintTiles.length; ++i) |
156 this._paintTiles[i].snapshot.dispose(); | 195 this._paintTiles[i].snapshot.dispose(); |
157 this._paintTiles = []; | 196 this._paintTiles = []; |
158 }, | 197 }, |
159 | 198 |
160 __proto__: WebInspector.VBox.prototype | 199 __proto__: WebInspector.VBox.prototype |
161 } | 200 } |
OLD | NEW |