OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 } | 425 } |
426 }, | 426 }, |
427 | 427 |
428 __proto__: WebInspector.TimelineEventOverview.prototype | 428 __proto__: WebInspector.TimelineEventOverview.prototype |
429 } | 429 } |
430 | 430 |
431 /** | 431 /** |
432 * @constructor | 432 * @constructor |
433 * @extends {WebInspector.TimelineEventOverview} | 433 * @extends {WebInspector.TimelineEventOverview} |
434 * @param {!WebInspector.TimelineModel} model | 434 * @param {!WebInspector.TimelineModel} model |
435 * @param {!WebInspector.TracingModel} tracingModel | 435 * @param {!WebInspector.FilmStripModel} filmStripModel |
436 */ | 436 */ |
437 WebInspector.TimelineFilmStripOverview = function(model, tracingModel) | 437 WebInspector.TimelineFilmStripOverview = function(model, filmStripModel) |
438 { | 438 { |
439 WebInspector.TimelineEventOverview.call(this, "filmstrip", null, model); | 439 WebInspector.TimelineEventOverview.call(this, "filmstrip", null, model); |
440 this._tracingModel = tracingModel; | 440 this._filmStripModel = filmStripModel; |
441 this.reset(); | 441 this.reset(); |
442 } | 442 } |
443 | 443 |
444 WebInspector.TimelineFilmStripOverview.Padding = 2; | 444 WebInspector.TimelineFilmStripOverview.Padding = 2; |
445 | 445 |
446 WebInspector.TimelineFilmStripOverview.prototype = { | 446 WebInspector.TimelineFilmStripOverview.prototype = { |
447 /** | 447 /** |
448 * @override | 448 * @override |
449 */ | 449 */ |
450 update: function() | 450 update: function() |
451 { | 451 { |
452 WebInspector.TimelineEventOverview.prototype.update.call(this); | 452 WebInspector.TimelineEventOverview.prototype.update.call(this); |
453 if (!this._filmStripModel) | |
454 return; | |
455 var frames = this._filmStripModel.frames(); | 453 var frames = this._filmStripModel.frames(); |
456 if (!frames.length) | 454 if (!frames.length) |
457 return; | 455 return; |
458 | 456 |
459 var drawGeneration = Symbol("drawGeneration"); | 457 var drawGeneration = Symbol("drawGeneration"); |
460 this._drawGeneration = drawGeneration; | 458 this._drawGeneration = drawGeneration; |
461 this._imageByFrame(frames[0]).then(image => { | 459 this._imageByFrame(frames[0]).then(image => { |
462 if (this._drawGeneration !== drawGeneration) | 460 if (this._drawGeneration !== drawGeneration) |
463 return; | 461 return; |
464 if (!image.naturalWidth || !image.naturalHeight) | 462 if (!image.naturalWidth || !image.naturalHeight) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 return image.completePromise(); | 494 return image.completePromise(); |
497 } | 495 } |
498 }, | 496 }, |
499 | 497 |
500 /** | 498 /** |
501 * @param {number} imageWidth | 499 * @param {number} imageWidth |
502 * @param {number} imageHeight | 500 * @param {number} imageHeight |
503 */ | 501 */ |
504 _drawFrames: function(imageWidth, imageHeight) | 502 _drawFrames: function(imageWidth, imageHeight) |
505 { | 503 { |
506 if (!this._filmStripModel || !imageWidth) | 504 if (!imageWidth) |
507 return; | 505 return; |
508 if (!this._filmStripModel.frames().length) | 506 if (!this._filmStripModel.frames().length) |
509 return; | 507 return; |
510 var padding = WebInspector.TimelineFilmStripOverview.Padding; | 508 var padding = WebInspector.TimelineFilmStripOverview.Padding; |
511 var width = this._canvas.width; | 509 var width = this._canvas.width; |
512 var zeroTime = this._tracingModel.minimumRecordTime(); | 510 var zeroTime = this._filmStripModel.zeroTime(); |
513 var spanTime = this._tracingModel.maximumRecordTime() - zeroTime; | 511 var spanTime = this._filmStripModel.spanTime(); |
514 var scale = spanTime / width; | 512 var scale = spanTime / width; |
515 var context = this._canvas.getContext("2d"); | 513 var context = this._canvas.getContext("2d"); |
516 var drawGeneration = this._drawGeneration; | 514 var drawGeneration = this._drawGeneration; |
517 | 515 |
518 context.beginPath(); | 516 context.beginPath(); |
519 for (var x = padding; x < width; x += imageWidth + 2 * padding) { | 517 for (var x = padding; x < width; x += imageWidth + 2 * padding) { |
520 var time = zeroTime + (x + imageWidth / 2) * scale; | 518 var time = zeroTime + (x + imageWidth / 2) * scale; |
521 var frame = this._filmStripModel.frameByTimestamp(time); | 519 var frame = this._filmStripModel.frameByTimestamp(time); |
522 if (!frame) | 520 if (!frame) |
523 continue; | 521 continue; |
(...skipping 17 matching lines...) Expand all Loading... |
541 } | 539 } |
542 }, | 540 }, |
543 | 541 |
544 /** | 542 /** |
545 * @override | 543 * @override |
546 * @param {number} x | 544 * @param {number} x |
547 * @return {!Promise<?Element>} | 545 * @return {!Promise<?Element>} |
548 */ | 546 */ |
549 popoverElementPromise: function(x) | 547 popoverElementPromise: function(x) |
550 { | 548 { |
551 if (!this._filmStripModel || !this._filmStripModel.frames().length) | 549 if (!this._filmStripModel.frames().length) |
552 return Promise.resolve(/** @type {?Element} */ (null)); | 550 return Promise.resolve(/** @type {?Element} */ (null)); |
553 | 551 |
554 var time = this._calculator.positionToTime(x); | 552 var time = this._calculator.positionToTime(x); |
555 var frame = this._filmStripModel.frameByTimestamp(time); | 553 var frame = this._filmStripModel.frameByTimestamp(time); |
556 if (frame === this._lastFrame) | 554 if (frame === this._lastFrame) |
557 return Promise.resolve(this._lastElement); | 555 return Promise.resolve(this._lastElement); |
558 var imagePromise = frame ? this._imageByFrame(frame) : Promise.resolve(t
his._emptyImage); | 556 var imagePromise = frame ? this._imageByFrame(frame) : Promise.resolve(t
his._emptyImage); |
559 return imagePromise.then(createFrameElement.bind(this)); | 557 return imagePromise.then(createFrameElement.bind(this)); |
560 | 558 |
561 /** | 559 /** |
(...skipping 12 matching lines...) Expand all Loading... |
574 } | 572 } |
575 }, | 573 }, |
576 | 574 |
577 /** | 575 /** |
578 * @override | 576 * @override |
579 */ | 577 */ |
580 reset: function() | 578 reset: function() |
581 { | 579 { |
582 this._lastFrame = undefined; | 580 this._lastFrame = undefined; |
583 this._lastElement = null; | 581 this._lastElement = null; |
584 this._filmStripModel = new WebInspector.FilmStripModel(this._tracingMode
l); | |
585 /** @type {!Map<!WebInspector.FilmStripModel.Frame,!Promise<!HTMLImageEl
ement>>} */ | 582 /** @type {!Map<!WebInspector.FilmStripModel.Frame,!Promise<!HTMLImageEl
ement>>} */ |
586 this._frameToImagePromise = new Map(); | 583 this._frameToImagePromise = new Map(); |
587 this._imageWidth = 0; | 584 this._imageWidth = 0; |
588 }, | 585 }, |
589 | 586 |
590 __proto__: WebInspector.TimelineEventOverview.prototype | 587 __proto__: WebInspector.TimelineEventOverview.prototype |
591 } | 588 } |
592 | 589 |
593 /** | 590 /** |
594 * @constructor | 591 * @constructor |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 counters[group] = this._quantDuration; | 809 counters[group] = this._quantDuration; |
813 this._callback(counters); | 810 this._callback(counters); |
814 interval -= this._quantDuration; | 811 interval -= this._quantDuration; |
815 } | 812 } |
816 this._counters = []; | 813 this._counters = []; |
817 this._counters[group] = interval; | 814 this._counters[group] = interval; |
818 this._lastTime = time; | 815 this._lastTime = time; |
819 this._remainder = this._quantDuration - interval; | 816 this._remainder = this._quantDuration - interval; |
820 } | 817 } |
821 } | 818 } |
OLD | NEW |