OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2013 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="stylesheet" href="/tracing/ui/tracks/object_instance_track.css"> | 8 <link rel="stylesheet" href="/tracing/ui/tracks/object_instance_track.css"> |
9 | 9 |
10 <link rel="import" href="/tracing/base/extension_registry.html"> | 10 <link rel="import" href="/tracing/base/extension_registry.html"> |
11 <link rel="import" href="/tracing/base/sorted_array_utils.html"> | 11 <link rel="import" href="/tracing/base/math/sorted_array_utils.html"> |
12 <link rel="import" href="/tracing/model/event.html"> | 12 <link rel="import" href="/tracing/model/event.html"> |
13 <link rel="import" href="/tracing/ui/base/event_presenter.html"> | 13 <link rel="import" href="/tracing/ui/base/event_presenter.html"> |
14 <link rel="import" href="/tracing/ui/base/heading.html"> | 14 <link rel="import" href="/tracing/ui/base/heading.html"> |
15 <link rel="import" href="/tracing/ui/base/ui.html"> | 15 <link rel="import" href="/tracing/ui/base/ui.html"> |
16 <link rel="import" href="/tracing/ui/tracks/track.html"> | 16 <link rel="import" href="/tracing/ui/tracks/track.html"> |
17 | 17 |
18 <script> | 18 <script> |
19 'use strict'; | 19 'use strict'; |
20 | 20 |
21 tr.exportTo('tr.ui.tracks', function() { | 21 tr.exportTo('tr.ui.tracks', function() { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 var snapshotRadiusView = this.snapshotRadiusView; | 112 var snapshotRadiusView = this.snapshotRadiusView; |
113 var snapshotRadiusWorld = dt.xViewVectorToWorld(height); | 113 var snapshotRadiusWorld = dt.xViewVectorToWorld(height); |
114 var loI; | 114 var loI; |
115 | 115 |
116 // Begin rendering in world space. | 116 // Begin rendering in world space. |
117 ctx.save(); | 117 ctx.save(); |
118 dt.applyTransformToCanvas(ctx); | 118 dt.applyTransformToCanvas(ctx); |
119 | 119 |
120 // Instances | 120 // Instances |
121 var objectInstances = this.objectInstances_; | 121 var objectInstances = this.objectInstances_; |
122 var loI = tr.b.findLowIndexInSortedArray( | 122 var loI = tr.b.math.findLowIndexInSortedArray( |
123 objectInstances, | 123 objectInstances, |
124 function(instance) { | 124 function(instance) { |
125 return instance.deletionTs; | 125 return instance.deletionTs; |
126 }, | 126 }, |
127 viewLWorld); | 127 viewLWorld); |
128 ctx.strokeStyle = 'rgb(0,0,0)'; | 128 ctx.strokeStyle = 'rgb(0,0,0)'; |
129 for (var i = loI; i < objectInstances.length; ++i) { | 129 for (var i = loI; i < objectInstances.length; ++i) { |
130 var instance = objectInstances[i]; | 130 var instance = objectInstances[i]; |
131 var x = instance.creationTs; | 131 var x = instance.creationTs; |
132 if (x > viewRWorld) | 132 if (x > viewRWorld) |
133 break; | 133 break; |
134 | 134 |
135 var right = instance.deletionTs === Number.MAX_VALUE ? | 135 var right = instance.deletionTs === Number.MAX_VALUE ? |
136 viewRWorld : instance.deletionTs; | 136 viewRWorld : instance.deletionTs; |
137 ctx.fillStyle = EventPresenter.getObjectInstanceColor(instance); | 137 ctx.fillStyle = EventPresenter.getObjectInstanceColor(instance); |
138 ctx.fillRect(x, pixelRatio, right - x, height - 2 * pixelRatio); | 138 ctx.fillRect(x, pixelRatio, right - x, height - 2 * pixelRatio); |
139 } | 139 } |
140 ctx.restore(); | 140 ctx.restore(); |
141 | 141 |
142 // Snapshots. Has to run in worldspace because ctx.arc gets transformed. | 142 // Snapshots. Has to run in worldspace because ctx.arc gets transformed. |
143 var objectSnapshots = this.objectSnapshots_; | 143 var objectSnapshots = this.objectSnapshots_; |
144 loI = tr.b.findLowIndexInSortedArray( | 144 loI = tr.b.math.findLowIndexInSortedArray( |
145 objectSnapshots, | 145 objectSnapshots, |
146 function(snapshot) { | 146 function(snapshot) { |
147 return snapshot.ts + snapshotRadiusWorld; | 147 return snapshot.ts + snapshotRadiusWorld; |
148 }, | 148 }, |
149 viewLWorld); | 149 viewLWorld); |
150 for (var i = loI; i < objectSnapshots.length; ++i) { | 150 for (var i = loI; i < objectSnapshots.length; ++i) { |
151 var snapshot = objectSnapshots[i]; | 151 var snapshot = objectSnapshots[i]; |
152 var x = snapshot.ts; | 152 var x = snapshot.ts; |
153 if (x - snapshotRadiusWorld > viewRWorld) | 153 if (x - snapshotRadiusWorld > viewRWorld) |
154 break; | 154 break; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 addIntersectingEventsInRangeToSelectionInWorldSpace: function( | 211 addIntersectingEventsInRangeToSelectionInWorldSpace: function( |
212 loWX, hiWX, viewPixWidthWorld, selection) { | 212 loWX, hiWX, viewPixWidthWorld, selection) { |
213 // Pick snapshots first. | 213 // Pick snapshots first. |
214 var foundSnapshot = false; | 214 var foundSnapshot = false; |
215 function onSnapshot(snapshot) { | 215 function onSnapshot(snapshot) { |
216 selection.push(snapshot); | 216 selection.push(snapshot); |
217 foundSnapshot = true; | 217 foundSnapshot = true; |
218 } | 218 } |
219 var snapshotRadiusView = this.snapshotRadiusView; | 219 var snapshotRadiusView = this.snapshotRadiusView; |
220 var snapshotRadiusWorld = viewPixWidthWorld * snapshotRadiusView; | 220 var snapshotRadiusWorld = viewPixWidthWorld * snapshotRadiusView; |
221 tr.b.iterateOverIntersectingIntervals( | 221 tr.b.math.iterateOverIntersectingIntervals( |
222 this.objectSnapshots_, | 222 this.objectSnapshots_, |
223 function(x) { return x.ts - snapshotRadiusWorld; }, | 223 function(x) { return x.ts - snapshotRadiusWorld; }, |
224 function(x) { return 2 * snapshotRadiusWorld; }, | 224 function(x) { return 2 * snapshotRadiusWorld; }, |
225 loWX, hiWX, | 225 loWX, hiWX, |
226 onSnapshot); | 226 onSnapshot); |
227 if (foundSnapshot) | 227 if (foundSnapshot) |
228 return; | 228 return; |
229 | 229 |
230 // Try picking instances. | 230 // Try picking instances. |
231 tr.b.iterateOverIntersectingIntervals( | 231 tr.b.math.iterateOverIntersectingIntervals( |
232 this.objectInstances_, | 232 this.objectInstances_, |
233 function(x) { return x.creationTs; }, | 233 function(x) { return x.creationTs; }, |
234 function(x) { return x.deletionTs - x.creationTs; }, | 234 function(x) { return x.deletionTs - x.creationTs; }, |
235 loWX, hiWX, | 235 loWX, hiWX, |
236 (value) => { selection.push(value); }); | 236 (value) => { selection.push(value); }); |
237 }, | 237 }, |
238 | 238 |
239 /** | 239 /** |
240 * Add the item to the left or right of the provided event, if any, to the | 240 * Add the item to the left or right of the provided event, if any, to the |
241 * selection. | 241 * selection. |
(...skipping 20 matching lines...) Expand all Loading... |
262 return true; | 262 return true; |
263 } | 263 } |
264 return false; | 264 return false; |
265 }, | 265 }, |
266 | 266 |
267 addAllEventsMatchingFilterToSelection: function(filter, selection) { | 267 addAllEventsMatchingFilterToSelection: function(filter, selection) { |
268 }, | 268 }, |
269 | 269 |
270 addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, | 270 addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, |
271 selection) { | 271 selection) { |
272 var snapshot = tr.b.findClosestElementInSortedArray( | 272 var snapshot = tr.b.math.findClosestElementInSortedArray( |
273 this.objectSnapshots_, | 273 this.objectSnapshots_, |
274 function(x) { return x.ts; }, | 274 function(x) { return x.ts; }, |
275 worldX, | 275 worldX, |
276 worldMaxDist); | 276 worldMaxDist); |
277 | 277 |
278 if (!snapshot) | 278 if (!snapshot) |
279 return; | 279 return; |
280 | 280 |
281 selection.push(snapshot); | 281 selection.push(snapshot); |
282 | 282 |
283 // TODO(egraether): Search for object instances as well, which was not | 283 // TODO(egraether): Search for object instances as well, which was not |
284 // implemented because it makes little sense with the current visual and | 284 // implemented because it makes little sense with the current visual and |
285 // needs to take care of overlapping intervals. | 285 // needs to take care of overlapping intervals. |
286 } | 286 } |
287 }; | 287 }; |
288 | 288 |
289 | 289 |
290 var options = new tr.b.ExtensionRegistryOptions( | 290 var options = new tr.b.ExtensionRegistryOptions( |
291 tr.b.TYPE_BASED_REGISTRY_MODE); | 291 tr.b.TYPE_BASED_REGISTRY_MODE); |
292 tr.b.decorateExtensionRegistry(ObjectInstanceTrack, options); | 292 tr.b.decorateExtensionRegistry(ObjectInstanceTrack, options); |
293 | 293 |
294 return { | 294 return { |
295 ObjectInstanceTrack, | 295 ObjectInstanceTrack, |
296 }; | 296 }; |
297 }); | 297 }); |
298 </script> | 298 </script> |
OLD | NEW |