Chromium Code Reviews| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 this._backgroundCanvas.height = this.element.clientHeight * window.devic ePixelRatio; | 305 this._backgroundCanvas.height = this.element.clientHeight * window.devic ePixelRatio; |
| 306 }, | 306 }, |
| 307 | 307 |
| 308 /** | 308 /** |
| 309 * @override | 309 * @override |
| 310 */ | 310 */ |
| 311 update: function() | 311 update: function() |
| 312 { | 312 { |
| 313 WebInspector.TimelineEventOverview.prototype.update.call(this); | 313 WebInspector.TimelineEventOverview.prototype.update.call(this); |
| 314 var /** @const */ quantSizePx = 4 * window.devicePixelRatio; | 314 var /** @const */ quantSizePx = 4 * window.devicePixelRatio; |
| 315 var width = this._canvas.width; | |
| 315 var height = this._canvas.height; | 316 var height = this._canvas.height; |
| 316 var baseLine = height; | 317 var baseLine = height; |
| 317 var timeOffset = this._model.minimumRecordTime(); | 318 var timeOffset = this._model.minimumRecordTime(); |
| 318 var timeSpan = this._model.maximumRecordTime() - timeOffset; | 319 var timeSpan = this._model.maximumRecordTime() - timeOffset; |
| 319 var scale = this._canvas.width / timeSpan; | 320 var scale = width / timeSpan; |
| 320 var quantTime = quantSizePx / scale; | 321 var quantTime = quantSizePx / scale; |
| 321 var categories = WebInspector.TimelineUIUtils.categories(); | 322 var categories = WebInspector.TimelineUIUtils.categories(); |
| 322 var categoryOrder = ["idle", "loading", "painting", "rendering", "script ing", "other"]; | 323 var categoryOrder = ["idle", "loading", "painting", "rendering", "script ing", "other"]; |
| 323 var otherIndex = categoryOrder.indexOf("other"); | 324 var otherIndex = categoryOrder.indexOf("other"); |
| 324 var idleIndex = 0; | 325 var idleIndex = 0; |
| 325 console.assert(idleIndex === categoryOrder.indexOf("idle")); | 326 console.assert(idleIndex === categoryOrder.indexOf("idle")); |
| 326 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) | 327 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) |
| 327 categories[categoryOrder[i]]._overviewIndex = i; | 328 categories[categoryOrder[i]]._overviewIndex = i; |
| 328 | 329 |
| 329 for (var thread of this._model.virtualThreads()) | 330 for (var thread of this._model.virtualThreads()) |
| 330 drawThreadEvents.call(this, this._backgroundCanvas.getContext("2d"), thread.events); | 331 drawThreadEvents.call(this, this._backgroundCanvas.getContext("2d"), thread.events); |
| 331 drawThreadEvents.call(this, this._context, this._model.mainThreadEvents( )); | 332 drawThreadEvents.call(this, this._context, this._model.mainThreadEvents( )); |
| 332 | 333 |
| 333 /** | 334 /** |
| 334 * @param {!CanvasRenderingContext2D} ctx | 335 * @param {!CanvasRenderingContext2D} ctx |
| 335 * @param {!Array<!WebInspector.TracingModel.Event>} events | 336 * @param {!Array<!WebInspector.TracingModel.Event>} events |
| 336 * @this {WebInspector.TimelineEventOverview} | 337 * @this {WebInspector.TimelineEventOverview} |
| 337 */ | 338 */ |
| 338 function drawThreadEvents(ctx, events) | 339 function drawThreadEvents(ctx, events) |
| 339 { | 340 { |
| 340 var quantizer = new WebInspector.Quantizer(timeOffset, quantTime, dr awSample.bind(this)); | 341 var quantizer = new WebInspector.Quantizer(timeOffset, quantTime, dr awSample); |
| 341 var x = 0; | 342 var x = 0; |
| 342 var categoryIndexStack = []; | 343 var categoryIndexStack = []; |
| 344 var paths = []; | |
| 345 var lastY = []; | |
| 346 for (var i = 0; i < categoryOrder.length; ++i) { | |
| 347 paths[i] = new Path2D(); | |
| 348 paths[i].moveTo(-1, height + 1); | |
|
caseq
2015/08/25 21:35:56
0, height?
alph
2015/08/25 21:36:48
Done.
| |
| 349 lastY[i] = height; | |
| 350 } | |
| 343 | 351 |
| 344 /** | 352 /** |
| 345 * @param {!Array<number>} counters | 353 * @param {!Array<number>} counters |
| 346 * @this {WebInspector.TimelineEventOverview} | |
| 347 */ | 354 */ |
| 348 function drawSample(counters) | 355 function drawSample(counters) |
| 349 { | 356 { |
| 350 var y = baseLine; | 357 var y = baseLine; |
| 351 for (var i = idleIndex + 1; i < counters.length; ++i) { | 358 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) { |
| 352 if (!counters[i]) | 359 var h = (counters[i] || 0) / quantTime * height; |
| 353 continue; | |
| 354 var h = counters[i] / quantTime * height; | |
| 355 ctx.fillStyle = this._categoryColor(categories[categoryOrder [i]]); | |
| 356 ctx.fillRect(x, y - h, quantSizePx, h); | |
| 357 y -= h; | 360 y -= h; |
| 361 paths[i].bezierCurveTo(x, lastY[i], x, y, x + quantSizePx / 2, y); | |
| 362 lastY[i] = y; | |
| 358 } | 363 } |
| 359 x += quantSizePx; | 364 x += quantSizePx; |
| 360 } | 365 } |
| 361 | 366 |
| 362 /** | 367 /** |
| 363 * @param {!WebInspector.TracingModel.Event} e | 368 * @param {!WebInspector.TracingModel.Event} e |
| 364 */ | 369 */ |
| 365 function onEventStart(e) | 370 function onEventStart(e) |
| 366 { | 371 { |
| 367 var index = categoryIndexStack.length ? categoryIndexStack.peekL ast() : idleIndex; | 372 var index = categoryIndexStack.length ? categoryIndexStack.peekL ast() : idleIndex; |
| 368 quantizer.appendInterval(e.startTime, index); | 373 quantizer.appendInterval(e.startTime, index); |
| 369 categoryIndexStack.push(WebInspector.TimelineUIUtils.eventStyle( e).category._overviewIndex || otherIndex); | 374 categoryIndexStack.push(WebInspector.TimelineUIUtils.eventStyle( e).category._overviewIndex || otherIndex); |
| 370 } | 375 } |
| 371 | 376 |
| 372 /** | 377 /** |
| 373 * @param {!WebInspector.TracingModel.Event} e | 378 * @param {!WebInspector.TracingModel.Event} e |
| 374 */ | 379 */ |
| 375 function onEventEnd(e) | 380 function onEventEnd(e) |
| 376 { | 381 { |
| 377 quantizer.appendInterval(e.endTime, categoryIndexStack.pop()); | 382 quantizer.appendInterval(e.endTime, categoryIndexStack.pop()); |
| 378 } | 383 } |
| 379 | 384 |
| 380 WebInspector.TimelineModel.forEachEvent(events, onEventStart, onEven tEnd); | 385 WebInspector.TimelineModel.forEachEvent(events, onEventStart, onEven tEnd); |
| 381 quantizer.appendInterval(timeOffset + timeSpan + quantTime, idleInde x); // Kick drawing the last bucket. | 386 quantizer.appendInterval(timeOffset + timeSpan + quantTime, idleInde x); // Kick drawing the last bucket. |
| 387 for (var i = categoryOrder.length - 1; i > 0; --i) { | |
| 388 paths[i].lineTo(width + 1, height + 1); | |
| 389 ctx.fillStyle = this._categoryColor(categories[categoryOrder[i]] ); | |
| 390 ctx.fill(paths[i]); | |
| 391 } | |
| 382 } | 392 } |
| 383 }, | 393 }, |
| 384 | 394 |
| 385 __proto__: WebInspector.TimelineEventOverview.prototype | 395 __proto__: WebInspector.TimelineEventOverview.prototype |
| 386 } | 396 } |
| 387 | 397 |
| 388 /** | 398 /** |
| 389 * @constructor | 399 * @constructor |
| 390 * @extends {WebInspector.TimelineEventOverview} | 400 * @extends {WebInspector.TimelineEventOverview} |
| 391 * @param {!WebInspector.TimelineModel} model | 401 * @param {!WebInspector.TimelineModel} model |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 counters[group] = this._quantDuration; | 861 counters[group] = this._quantDuration; |
| 852 this._callback(counters); | 862 this._callback(counters); |
| 853 interval -= this._quantDuration; | 863 interval -= this._quantDuration; |
| 854 } | 864 } |
| 855 this._counters = []; | 865 this._counters = []; |
| 856 this._counters[group] = interval; | 866 this._counters[group] = interval; |
| 857 this._lastTime = time; | 867 this._lastTime = time; |
| 858 this._remainder = this._quantDuration - interval; | 868 this._remainder = this._quantDuration - interval; |
| 859 } | 869 } |
| 860 } | 870 } |
| OLD | NEW |