OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 Timeline.TimelinePaintProfilerView = class extends UI.SplitWidget { | 5 Timeline.TimelinePaintProfilerView = class extends UI.SplitWidget { |
6 /** | 6 /** |
7 * @param {!TimelineModel.TimelineFrameModel} frameModel | 7 * @param {!TimelineModel.TimelineFrameModel} frameModel |
8 */ | 8 */ |
9 constructor(frameModel) { | 9 constructor(frameModel) { |
10 super(false, false); | 10 super(false, false); |
(...skipping 14 matching lines...) Expand all Loading... |
25 this.setSidebarWidget(this._paintProfilerView); | 25 this.setSidebarWidget(this._paintProfilerView); |
26 | 26 |
27 this._logTreeView = new LayerViewer.PaintProfilerCommandLogView(); | 27 this._logTreeView = new LayerViewer.PaintProfilerCommandLogView(); |
28 this._logAndImageSplitWidget.setSidebarWidget(this._logTreeView); | 28 this._logAndImageSplitWidget.setSidebarWidget(this._logTreeView); |
29 | 29 |
30 this._needsUpdateWhenVisible = false; | 30 this._needsUpdateWhenVisible = false; |
31 /** @type {?SDK.PaintProfilerSnapshot} */ | 31 /** @type {?SDK.PaintProfilerSnapshot} */ |
32 this._pendingSnapshot = null; | 32 this._pendingSnapshot = null; |
33 /** @type {?SDK.TracingModel.Event} */ | 33 /** @type {?SDK.TracingModel.Event} */ |
34 this._event = null; | 34 this._event = null; |
35 /** @type {?SDK.Target} */ | 35 /** @type {?SDK.PaintProfilerModel} */ |
36 this._target = null; | 36 this._paintProfilerModel = null; |
37 /** @type {?SDK.PaintProfilerSnapshot} */ | 37 /** @type {?SDK.PaintProfilerSnapshot} */ |
38 this._lastLoadedSnapshot = null; | 38 this._lastLoadedSnapshot = null; |
39 } | 39 } |
40 | 40 |
41 /** | 41 /** |
42 * @override | 42 * @override |
43 */ | 43 */ |
44 wasShown() { | 44 wasShown() { |
45 if (this._needsUpdateWhenVisible) { | 45 if (this._needsUpdateWhenVisible) { |
46 this._needsUpdateWhenVisible = false; | 46 this._needsUpdateWhenVisible = false; |
47 this._update(); | 47 this._update(); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 /** | 51 /** |
52 * @param {!SDK.PaintProfilerSnapshot} snapshot | 52 * @param {!SDK.PaintProfilerSnapshot} snapshot |
53 */ | 53 */ |
54 setSnapshot(snapshot) { | 54 setSnapshot(snapshot) { |
55 this._releaseSnapshot(); | 55 this._releaseSnapshot(); |
56 this._pendingSnapshot = snapshot; | 56 this._pendingSnapshot = snapshot; |
57 this._event = null; | 57 this._event = null; |
58 this._updateWhenVisible(); | 58 this._updateWhenVisible(); |
59 } | 59 } |
60 | 60 |
61 /** | 61 /** |
62 * @param {!SDK.Target} target | 62 * @param {!SDK.PaintProfilerModel} paintProfilerModel |
63 * @param {!SDK.TracingModel.Event} event | 63 * @param {!SDK.TracingModel.Event} event |
64 * @return {boolean} | 64 * @return {boolean} |
65 */ | 65 */ |
66 setEvent(target, event) { | 66 setEvent(paintProfilerModel, event) { |
67 this._releaseSnapshot(); | 67 this._releaseSnapshot(); |
68 this._target = target; | 68 this._paintProfilerModel = paintProfilerModel; |
69 this._pendingSnapshot = null; | 69 this._pendingSnapshot = null; |
70 this._event = event; | 70 this._event = event; |
71 | 71 |
72 this._updateWhenVisible(); | 72 this._updateWhenVisible(); |
73 if (this._event.name === TimelineModel.TimelineModel.RecordType.Paint) | 73 if (this._event.name === TimelineModel.TimelineModel.RecordType.Paint) |
74 return !!TimelineModel.TimelineData.forEvent(event).picture; | 74 return !!TimelineModel.TimelineData.forEvent(event).picture; |
75 if (this._event.name === TimelineModel.TimelineModel.RecordType.RasterTask) | 75 if (this._event.name === TimelineModel.TimelineModel.RecordType.RasterTask) |
76 return this._frameModel.hasRasterTile(this._event); | 76 return this._frameModel.hasRasterTile(this._event); |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 _updateWhenVisible() { | 80 _updateWhenVisible() { |
81 if (this.isShowing()) | 81 if (this.isShowing()) |
82 this._update(); | 82 this._update(); |
83 else | 83 else |
84 this._needsUpdateWhenVisible = true; | 84 this._needsUpdateWhenVisible = true; |
85 } | 85 } |
86 | 86 |
87 _update() { | 87 _update() { |
88 this._logTreeView.setCommandLog(null, []); | 88 this._logTreeView.setCommandLog([]); |
89 this._paintProfilerView.setSnapshotAndLog(null, [], null); | 89 this._paintProfilerView.setSnapshotAndLog(null, [], null); |
90 | 90 |
91 var snapshotPromise; | 91 var snapshotPromise; |
92 if (this._pendingSnapshot) { | 92 if (this._pendingSnapshot) { |
93 snapshotPromise = Promise.resolve({rect: null, snapshot: this._pendingSnap
shot}); | 93 snapshotPromise = Promise.resolve({rect: null, snapshot: this._pendingSnap
shot}); |
94 } else if (this._event.name === TimelineModel.TimelineModel.RecordType.Paint
) { | 94 } else if (this._event.name === TimelineModel.TimelineModel.RecordType.Paint
) { |
95 var picture = TimelineModel.TimelineData.forEvent(this._event).picture; | 95 var picture = TimelineModel.TimelineData.forEvent(this._event).picture; |
96 snapshotPromise = | 96 snapshotPromise = picture.objectPromise() |
97 picture.objectPromise() | 97 .then(data => this._paintProfilerModel.loadSnapshot(
data['skp64'])) |
98 .then(data => SDK.PaintProfilerSnapshot.load(/** @type {!SDK.Targe
t} */ (this._target), data['skp64'])) | 98 .then(snapshot => snapshot && {rect: null, snapshot:
snapshot}); |
99 .then(snapshot => snapshot && {rect: null, snapshot: snapshot}); | |
100 } else if (this._event.name === TimelineModel.TimelineModel.RecordType.Raste
rTask) { | 99 } else if (this._event.name === TimelineModel.TimelineModel.RecordType.Raste
rTask) { |
101 snapshotPromise = this._frameModel.rasterTilePromise(this._event); | 100 snapshotPromise = this._frameModel.rasterTilePromise(this._event); |
102 } else { | 101 } else { |
103 console.assert(false, 'Unexpected event type or no snapshot'); | 102 console.assert(false, 'Unexpected event type or no snapshot'); |
104 return; | 103 return; |
105 } | 104 } |
106 snapshotPromise.then(snapshotWithRect => { | 105 snapshotPromise.then(snapshotWithRect => { |
107 this._releaseSnapshot(); | 106 this._releaseSnapshot(); |
108 if (!snapshotWithRect) { | 107 if (!snapshotWithRect) { |
109 this._imageView.showImage(); | 108 this._imageView.showImage(); |
110 return; | 109 return; |
111 } | 110 } |
112 var snapshot = snapshotWithRect.snapshot; | 111 var snapshot = snapshotWithRect.snapshot; |
113 this._lastLoadedSnapshot = snapshot; | 112 this._lastLoadedSnapshot = snapshot; |
114 this._imageView.setMask(snapshotWithRect.rect); | 113 this._imageView.setMask(snapshotWithRect.rect); |
115 snapshot.commandLog().then(log => onCommandLogDone.call(this, snapshot, sn
apshotWithRect.rect, log)); | 114 snapshot.commandLog().then(log => onCommandLogDone.call(this, snapshot, sn
apshotWithRect.rect, log)); |
116 }); | 115 }); |
117 | 116 |
118 /** | 117 /** |
119 * @param {!SDK.PaintProfilerSnapshot} snapshot | 118 * @param {!SDK.PaintProfilerSnapshot} snapshot |
120 * @param {?Protocol.DOM.Rect} clipRect | 119 * @param {?Protocol.DOM.Rect} clipRect |
121 * @param {!Array.<!SDK.PaintProfilerLogItem>=} log | 120 * @param {!Array.<!SDK.PaintProfilerLogItem>=} log |
122 * @this {Timeline.TimelinePaintProfilerView} | 121 * @this {Timeline.TimelinePaintProfilerView} |
123 */ | 122 */ |
124 function onCommandLogDone(snapshot, clipRect, log) { | 123 function onCommandLogDone(snapshot, clipRect, log) { |
125 this._logTreeView.setCommandLog(snapshot.target(), log || []); | 124 this._logTreeView.setCommandLog(log || []); |
126 this._paintProfilerView.setSnapshotAndLog(snapshot, log || [], clipRect); | 125 this._paintProfilerView.setSnapshotAndLog(snapshot, log || [], clipRect); |
127 } | 126 } |
128 } | 127 } |
129 | 128 |
130 _releaseSnapshot() { | 129 _releaseSnapshot() { |
131 if (!this._lastLoadedSnapshot) | 130 if (!this._lastLoadedSnapshot) |
132 return; | 131 return; |
133 this._lastLoadedSnapshot.release(); | 132 this._lastLoadedSnapshot.release(); |
134 this._lastLoadedSnapshot = null; | 133 this._lastLoadedSnapshot = null; |
135 } | 134 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 212 } |
214 | 213 |
215 /** | 214 /** |
216 * @param {?Protocol.DOM.Rect} maskRectangle | 215 * @param {?Protocol.DOM.Rect} maskRectangle |
217 */ | 216 */ |
218 setMask(maskRectangle) { | 217 setMask(maskRectangle) { |
219 this._maskRectangle = maskRectangle; | 218 this._maskRectangle = maskRectangle; |
220 this._maskElement.classList.toggle('hidden', !maskRectangle); | 219 this._maskElement.classList.toggle('hidden', !maskRectangle); |
221 } | 220 } |
222 }; | 221 }; |
OLD | NEW |