| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 5 |
| 6 /** | 6 /** |
| 7 * @fileoverview Renders an array of slices into the provided div, | 7 * @fileoverview Renders an array of slices into the provided div, |
| 8 * using a child canvas element. Uses a FastRectRenderer to draw only | 8 * using a child canvas element. Uses a FastRectRenderer to draw only |
| 9 * the visible slices. | 9 * the visible slices. |
| 10 */ | 10 */ |
| 11 cr.define('gpu', function() { | 11 cr.define('tracing', function() { |
| 12 | 12 |
| 13 const palletteBase = [ | 13 const palletteBase = [ |
| 14 {r: 138, g: 113, b: 152}, | 14 {r: 138, g: 113, b: 152}, |
| 15 {r: 175, g: 112, b: 133}, | 15 {r: 175, g: 112, b: 133}, |
| 16 {r: 127, g: 135, b: 225}, | 16 {r: 127, g: 135, b: 225}, |
| 17 {r: 93, g: 81, b: 137}, | 17 {r: 93, g: 81, b: 137}, |
| 18 {r: 116, g: 143, b: 119}, | 18 {r: 116, g: 143, b: 119}, |
| 19 {r: 178, g: 214, b: 122}, | 19 {r: 178, g: 214, b: 122}, |
| 20 {r: 87, g: 109, b: 147}, | 20 {r: 87, g: 109, b: 147}, |
| 21 {r: 119, g: 155, b: 95}, | 21 {r: 119, g: 155, b: 95}, |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 } | 277 } |
| 278 ctx.strokeStyle = 'rgba(255,0,0,0.25)'; | 278 ctx.strokeStyle = 'rgba(255,0,0,0.25)'; |
| 279 ctx.stroke(); | 279 ctx.stroke(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 // begin rendering in world space | 282 // begin rendering in world space |
| 283 ctx.save(); | 283 ctx.save(); |
| 284 vp.applyTransformToCanavs(ctx); | 284 vp.applyTransformToCanavs(ctx); |
| 285 | 285 |
| 286 // tracks | 286 // tracks |
| 287 var tr = new gpu.FastRectRenderer(ctx, viewLWorld, 2 * pixWidth, | 287 var tr = new tracing.FastRectRenderer(ctx, viewLWorld, 2 * pixWidth, |
| 288 2 * pixWidth, viewRWorld, pallette); | 288 2 * pixWidth, viewRWorld, pallette); |
| 289 tr.setYandH(0, canvasH); | 289 tr.setYandH(0, canvasH); |
| 290 var slices = this.slices_; | 290 var slices = this.slices_; |
| 291 for (var i = 0; i < slices.length; ++i) { | 291 for (var i = 0; i < slices.length; ++i) { |
| 292 var slice = slices[i]; | 292 var slice = slices[i]; |
| 293 var x = slice.start; | 293 var x = slice.start; |
| 294 // Less than 0.001 causes short events to disappear when zoomed in. | 294 // Less than 0.001 causes short events to disappear when zoomed in. |
| 295 var w = Math.max(slice.duration, 0.001); | 295 var w = Math.max(slice.duration, 0.001); |
| 296 var colorId; | 296 var colorId; |
| 297 colorId = slice.selected ? | 297 colorId = slice.selected ? |
| 298 slice.colorId + selectedIdBoost : | 298 slice.colorId + selectedIdBoost : |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 * @param {number} wY Y location to search at, in offset space. | 360 * @param {number} wY Y location to search at, in offset space. |
| 361 * offset space. | 361 * offset space. |
| 362 * @param {function():*} onHitCallback Callback to call with the slice, | 362 * @param {function():*} onHitCallback Callback to call with the slice, |
| 363 * if one is found. | 363 * if one is found. |
| 364 * @return {boolean} true if a slice was found, otherwise false. | 364 * @return {boolean} true if a slice was found, otherwise false. |
| 365 */ | 365 */ |
| 366 pick: function(wX, wY, onHitCallback) { | 366 pick: function(wX, wY, onHitCallback) { |
| 367 var clientRect = this.getBoundingClientRect(); | 367 var clientRect = this.getBoundingClientRect(); |
| 368 if (wY < clientRect.top || wY >= clientRect.bottom) | 368 if (wY < clientRect.top || wY >= clientRect.bottom) |
| 369 return false; | 369 return false; |
| 370 var x = gpu.findLowIndexInSortedIntervals(this.slices_, | 370 var x = tracing.findLowIndexInSortedIntervals(this.slices_, |
| 371 function(x) { return x.start; }, | 371 function(x) { return x.start; }, |
| 372 function(x) { return x.duration; }, | 372 function(x) { return x.duration; }, |
| 373 wX); | 373 wX); |
| 374 if (x >= 0 && x < this.slices_.length) { | 374 if (x >= 0 && x < this.slices_.length) { |
| 375 onHitCallback('slice', this, this.slices_[x]); | 375 onHitCallback('slice', this, this.slices_[x]); |
| 376 return true; | 376 return true; |
| 377 } | 377 } |
| 378 return false; | 378 return false; |
| 379 }, | 379 }, |
| 380 | 380 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 395 var clientRect = this.getBoundingClientRect(); | 395 var clientRect = this.getBoundingClientRect(); |
| 396 var a = Math.max(loY, clientRect.top); | 396 var a = Math.max(loY, clientRect.top); |
| 397 var b = Math.min(hiY, clientRect.bottom); | 397 var b = Math.min(hiY, clientRect.bottom); |
| 398 if (a > b) | 398 if (a > b) |
| 399 return; | 399 return; |
| 400 | 400 |
| 401 var that = this; | 401 var that = this; |
| 402 function onPickHit(slice) { | 402 function onPickHit(slice) { |
| 403 onHitCallback('slice', that, slice); | 403 onHitCallback('slice', that, slice); |
| 404 } | 404 } |
| 405 gpu.iterateOverIntersectingIntervals(this.slices_, | 405 tracing.iterateOverIntersectingIntervals(this.slices_, |
| 406 function(x) { return x.start; }, | 406 function(x) { return x.start; }, |
| 407 function(x) { return x.duration; }, | 407 function(x) { return x.duration; }, |
| 408 loWX, hiWX, | 408 loWX, hiWX, |
| 409 onPickHit); | 409 onPickHit); |
| 410 }, | 410 }, |
| 411 | 411 |
| 412 /** | 412 /** |
| 413 * Find the index for the given slice. | 413 * Find the index for the given slice. |
| 414 * @return {index} Index of the given slice, or undefined. | 414 * @return {index} Index of the given slice, or undefined. |
| 415 * @private | 415 * @private |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 return index != undefined ? this.slices_[index] : undefined; | 457 return index != undefined ? this.slices_[index] : undefined; |
| 458 }, | 458 }, |
| 459 | 459 |
| 460 }; | 460 }; |
| 461 | 461 |
| 462 return { | 462 return { |
| 463 TimelineSliceTrack: TimelineSliceTrack, | 463 TimelineSliceTrack: TimelineSliceTrack, |
| 464 TimelineThreadTrack: TimelineThreadTrack | 464 TimelineThreadTrack: TimelineThreadTrack |
| 465 }; | 465 }; |
| 466 }); | 466 }); |
| OLD | NEW |