| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 var categories = WebInspector.TimelineUIUtils.categories(); | 45 var categories = WebInspector.TimelineUIUtils.categories(); |
| 46 for (var category in categories) { | 46 for (var category in categories) { |
| 47 this._fillStyles[category] = categories[category].fillColorStop1; | 47 this._fillStyles[category] = categories[category].fillColorStop1; |
| 48 categories[category].addEventListener(WebInspector.TimelineCategory.Even
ts.VisibilityChanged, this._onCategoryVisibilityChanged, this); | 48 categories[category].addEventListener(WebInspector.TimelineCategory.Even
ts.VisibilityChanged, this._onCategoryVisibilityChanged, this); |
| 49 } | 49 } |
| 50 | 50 |
| 51 this._disabledCategoryFillStyle = "hsl(0, 0%, 67%)"; | 51 this._disabledCategoryFillStyle = "hsl(0, 0%, 67%)"; |
| 52 } | 52 } |
| 53 | 53 |
| 54 /** @const */ | 54 /** @const */ |
| 55 WebInspector.TimelineEventOverview._fullStripHeight = 20; | 55 WebInspector.TimelineEventOverview._fullStripHeight = 24; |
| 56 /** @const */ | 56 /** @const */ |
| 57 WebInspector.TimelineEventOverview._smallStripHeight = 8; | 57 WebInspector.TimelineEventOverview._smallStripHeight = 8; |
| 58 | 58 |
| 59 WebInspector.TimelineEventOverview.prototype = { | 59 WebInspector.TimelineEventOverview.prototype = { |
| 60 /** | 60 /** |
| 61 * @override | 61 * @override |
| 62 */ | 62 */ |
| 63 dispose: function() | 63 dispose: function() |
| 64 { | 64 { |
| 65 WebInspector.TimelineOverviewBase.prototype.dispose.call(this); | 65 WebInspector.TimelineOverviewBase.prototype.dispose.call(this); |
| 66 var categories = WebInspector.TimelineUIUtils.categories(); | 66 var categories = WebInspector.TimelineUIUtils.categories(); |
| 67 for (var category in categories) | 67 for (var category in categories) |
| 68 categories[category].removeEventListener(WebInspector.TimelineCatego
ry.Events.VisibilityChanged, this._onCategoryVisibilityChanged, this); | 68 categories[category].removeEventListener(WebInspector.TimelineCatego
ry.Events.VisibilityChanged, this._onCategoryVisibilityChanged, this); |
| 69 }, | 69 }, |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * @override | 72 * @override |
| 73 */ | 73 */ |
| 74 update: function() | 74 update: function() |
| 75 { | 75 { |
| 76 var /** @const */ fpsStripHeight = 20; |
| 76 this.resetCanvas(); | 77 this.resetCanvas(); |
| 77 var threads = this._model.virtualThreads(); | 78 var threads = this._model.virtualThreads(); |
| 78 var mainThreadEvents = this._model.mainThreadEvents(); | 79 var mainThreadEvents = this._model.mainThreadEvents(); |
| 79 var networkHeight = this._canvas.clientHeight | 80 var networkHeight = this._canvas.clientHeight |
| 80 - 2 * WebInspector.TimelineEventOverview._fullStripHeight | 81 - WebInspector.TimelineEventOverview._fullStripHeight |
| 81 - 2 * WebInspector.TimelineEventOverview._smallStripHeight; | 82 - fpsStripHeight |
| 83 - 3 * WebInspector.TimelineEventOverview._smallStripHeight; |
| 82 var position = 0; | 84 var position = 0; |
| 83 if (Runtime.experiments.isEnabled("inputEventsOnTimelineOverview")) { | 85 if (Runtime.experiments.isEnabled("inputEventsOnTimelineOverview")) { |
| 84 var inputHeight = this._drawInputEvents(mainThreadEvents, position,
WebInspector.TimelineEventOverview._smallStripHeight); | 86 var inputHeight = this._drawInputEvents(mainThreadEvents, position,
WebInspector.TimelineEventOverview._smallStripHeight); |
| 85 position += inputHeight; | 87 position += inputHeight; |
| 86 networkHeight -= inputHeight; | 88 networkHeight -= inputHeight; |
| 87 } | 89 } |
| 88 position += this._drawNetwork(mainThreadEvents, position, networkHeight)
; | 90 position += this._drawNetwork(mainThreadEvents, position, networkHeight)
; |
| 89 position += this._drawStackedUtilizationChart(mainThreadEvents, position
, WebInspector.TimelineEventOverview._fullStripHeight); | 91 position += this._drawStackedUtilizationChart(mainThreadEvents, position
, WebInspector.TimelineEventOverview._fullStripHeight); |
| 90 for (var thread of threads.filter(function(thread) { return !thread.isWo
rker(); })) | 92 for (var thread of threads.filter(function(thread) { return !thread.isWo
rker(); })) |
| 91 this._drawEvents(thread.events, position, WebInspector.TimelineEvent
Overview._smallStripHeight); | 93 this._drawEvents(thread.events, position, WebInspector.TimelineEvent
Overview._smallStripHeight); |
| 92 position += WebInspector.TimelineEventOverview._smallStripHeight; | 94 position += WebInspector.TimelineEventOverview._smallStripHeight; |
| 93 for (var thread of threads.filter(function(thread) { return thread.isWor
ker(); })) | 95 for (var thread of threads.filter(function(thread) { return thread.isWor
ker(); })) |
| 94 this._drawEvents(thread.events, position, WebInspector.TimelineEvent
Overview._smallStripHeight); | 96 this._drawEvents(thread.events, position, WebInspector.TimelineEvent
Overview._smallStripHeight); |
| 95 position += WebInspector.TimelineEventOverview._smallStripHeight; | 97 position += WebInspector.TimelineEventOverview._smallStripHeight; |
| 96 position += this._drawFrames(position, WebInspector.TimelineEventOvervie
w._fullStripHeight); | 98 position += this._drawResponsivenessStrip(position, WebInspector.Timelin
eEventOverview._smallStripHeight); |
| 99 position += this._drawFrames(position, fpsStripHeight); |
| 97 console.assert(position === this._canvas.clientHeight); | 100 console.assert(position === this._canvas.clientHeight); |
| 98 }, | 101 }, |
| 99 | 102 |
| 100 /** | 103 /** |
| 101 * @param {!Array.<!WebInspector.TracingModel.Event>} events | 104 * @param {!Array.<!WebInspector.TracingModel.Event>} events |
| 102 * @param {number} position | 105 * @param {number} position |
| 103 * @param {number} height | 106 * @param {number} height |
| 104 * @return {number} | 107 * @return {number} |
| 105 */ | 108 */ |
| 106 _drawInputEvents: function(events, position, height) | 109 _drawInputEvents: function(events, position, height) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 }, | 188 }, |
| 186 | 189 |
| 187 /** | 190 /** |
| 188 * @param {!Array.<!WebInspector.TracingModel.Event>} events | 191 * @param {!Array.<!WebInspector.TracingModel.Event>} events |
| 189 * @param {number} position | 192 * @param {number} position |
| 190 * @param {number} height | 193 * @param {number} height |
| 191 * @return {number} | 194 * @return {number} |
| 192 */ | 195 */ |
| 193 _drawStackedUtilizationChart: function(events, position, height) | 196 _drawStackedUtilizationChart: function(events, position, height) |
| 194 { | 197 { |
| 198 if (!events.length) |
| 199 return height; |
| 195 var /** @const */ quantSizePx = 4 * window.devicePixelRatio; | 200 var /** @const */ quantSizePx = 4 * window.devicePixelRatio; |
| 196 var /** @const */ padding = 1; | 201 var /** @const */ padding = 1; |
| 197 var visualHeight = (height - padding) * window.devicePixelRatio; | 202 var visualHeight = (height - padding) * window.devicePixelRatio; |
| 198 var baseLine = (position + height) * window.devicePixelRatio; | 203 var baseLine = (position + height) * window.devicePixelRatio; |
| 199 var timeOffset = this._model.minimumRecordTime(); | 204 var timeOffset = this._model.minimumRecordTime(); |
| 200 var timeSpan = this._model.maximumRecordTime() - timeOffset; | 205 var timeSpan = this._model.maximumRecordTime() - timeOffset; |
| 201 var scale = this._canvas.width / timeSpan; | 206 var scale = this._canvas.width / timeSpan; |
| 202 var quantTime = quantSizePx / scale; | 207 var quantTime = quantSizePx / scale; |
| 203 var quantizer = new WebInspector.Quantizer(timeOffset, quantTime, drawSa
mple.bind(this)); | 208 var quantizer = new WebInspector.Quantizer(timeOffset, quantTime, drawSa
mple.bind(this)); |
| 204 var ctx = this._context; | 209 var ctx = this._context; |
| 205 var x = 0; | 210 var x = 0; |
| 206 var categories = WebInspector.TimelineUIUtils.categories(); | 211 var categories = WebInspector.TimelineUIUtils.categories(); |
| 207 var categoryOrder = ["idle", "scripting", "rendering", "painting", "load
ing", "other"]; | 212 var categoryOrder = ["idle", "scripting", "rendering", "painting", "load
ing", "other"]; |
| 208 var otherIndex = categoryOrder.indexOf("other"); | 213 var otherIndex = categoryOrder.indexOf("other"); |
| 209 var idleIndex = 0; | 214 var idleIndex = 0; |
| 210 console.assert(idleIndex === categoryOrder.indexOf("idle")); | 215 console.assert(idleIndex === categoryOrder.indexOf("idle")); |
| 211 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) | 216 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) |
| 212 categories[categoryOrder[i]]._overviewIndex = i; | 217 categories[categoryOrder[i]]._overviewIndex = i; |
| 213 var categoryIndexStack = []; | 218 var categoryIndexStack = []; |
| 214 | 219 |
| 220 this._drawHorizontalGuide(baseLine - visualHeight + 0.5, WebInspector.UI
String("100%")); |
| 221 |
| 215 /** | 222 /** |
| 216 * @param {!Array<number>} counters | 223 * @param {!Array<number>} counters |
| 217 * @this {WebInspector.TimelineEventOverview} | 224 * @this {WebInspector.TimelineEventOverview} |
| 218 */ | 225 */ |
| 219 function drawSample(counters) | 226 function drawSample(counters) |
| 220 { | 227 { |
| 221 var y = baseLine; | 228 var y = baseLine; |
| 222 for (var i = idleIndex + 1; i < counters.length; ++i) { | 229 for (var i = idleIndex + 1; i < counters.length; ++i) { |
| 223 if (!counters[i]) | 230 if (!counters[i]) |
| 224 continue; | 231 continue; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 _categoryColor: function(category) | 320 _categoryColor: function(category) |
| 314 { | 321 { |
| 315 return category.hidden ? this._disabledCategoryFillStyle : this._fillSty
les[category.name]; | 322 return category.hidden ? this._disabledCategoryFillStyle : this._fillSty
les[category.name]; |
| 316 }, | 323 }, |
| 317 | 324 |
| 318 /** | 325 /** |
| 319 * @param {number} position | 326 * @param {number} position |
| 320 * @param {number} height | 327 * @param {number} height |
| 321 * @return {number} | 328 * @return {number} |
| 322 */ | 329 */ |
| 330 _drawResponsivenessStrip: function(position, height) |
| 331 { |
| 332 var /** @const */ padding = 1; |
| 333 var visualHeight = (height - padding) * window.devicePixelRatio; |
| 334 var timeOffset = this._model.minimumRecordTime(); |
| 335 var timeSpan = this._model.maximumRecordTime() - timeOffset; |
| 336 var scale = this._canvas.width / timeSpan; |
| 337 var frames = this._frameModel.frames(); |
| 338 var ctx = this._context; |
| 339 ctx.beginPath(); |
| 340 var responsivenessStripY = (position + padding) * window.devicePixelRati
o; |
| 341 for (var i = 0; i < frames.length; ++i) { |
| 342 var frame = frames[i]; |
| 343 if (!frame.hasWarnings()) |
| 344 continue; |
| 345 var x = scale * (frame.startTime - timeOffset); |
| 346 var w = scale * frame.duration; |
| 347 ctx.rect(x, responsivenessStripY, w, visualHeight); |
| 348 } |
| 349 ctx.fillStyle = "hsl(0, 80%, 70%)"; |
| 350 ctx.fill(); |
| 351 return height; |
| 352 }, |
| 353 |
| 354 /** |
| 355 * @param {number} position |
| 356 * @param {number} height |
| 357 * @return {number} |
| 358 */ |
| 323 _drawFrames: function(position, height) | 359 _drawFrames: function(position, height) |
| 324 { | 360 { |
| 325 var /** @const */ padding = 2; | 361 var /** @const */ padding = 2; |
| 326 var /** @const */ baseFrameDurationMs = 1e3 / 60; | 362 var /** @const */ baseFrameDurationMs = 1e3 / 60; |
| 327 var visualHeight = (height - padding) * window.devicePixelRatio; | 363 var visualHeight = (height - padding) * window.devicePixelRatio; |
| 328 var timeOffset = this._model.minimumRecordTime(); | 364 var timeOffset = this._model.minimumRecordTime(); |
| 329 var timeSpan = this._model.maximumRecordTime() - timeOffset; | 365 var timeSpan = this._model.maximumRecordTime() - timeOffset; |
| 330 var scale = this._canvas.width / timeSpan; | 366 var scale = this._canvas.width / timeSpan; |
| 331 var frames = this._frameModel.frames(); | 367 var frames = this._frameModel.frames(); |
| 332 var baseY = (position + height) * window.devicePixelRatio; | 368 var baseY = height * window.devicePixelRatio; |
| 369 var ctx = this._context; |
| 333 var y = baseY + 10; | 370 var y = baseY + 10; |
| 334 var ctx = this._context; | 371 if (!frames.length) |
| 372 return height; |
| 373 |
| 335 ctx.save(); | 374 ctx.save(); |
| 375 ctx.translate(0, position * window.devicePixelRatio); |
| 336 ctx.beginPath(); | 376 ctx.beginPath(); |
| 337 ctx.rect(0, position * window.devicePixelRatio, this._canvas.width, heig
ht * window.devicePixelRatio); | 377 ctx.rect(0, 0, this._canvas.width, height * window.devicePixelRatio); |
| 338 ctx.clip(); | 378 ctx.clip(); |
| 379 ctx.lineWidth = window.devicePixelRatio; |
| 380 |
| 381 this._drawHorizontalGuide(baseY - visualHeight - 0.5, WebInspector.UIStr
ing("60\u2009fps")); |
| 382 |
| 339 ctx.beginPath(); | 383 ctx.beginPath(); |
| 340 ctx.lineWidth = 1 * window.devicePixelRatio; | |
| 341 ctx.strokeStyle = "hsl(110, 50%, 60%)"; | |
| 342 ctx.fillStyle = "hsl(110, 50%, 88%)"; | |
| 343 ctx.moveTo(0, y); | 384 ctx.moveTo(0, y); |
| 344 for (var i = 0; i < frames.length; ++i) { | 385 for (var i = 0; i < frames.length; ++i) { |
| 345 var frame = frames[i]; | 386 var frame = frames[i]; |
| 346 var x = Math.round((frame.startTime - timeOffset) * scale) + 0.5; | 387 var x = Math.round((frame.startTime - timeOffset) * scale) + 0.5; |
| 347 ctx.lineTo(x, y); | 388 ctx.lineTo(x, y); |
| 348 ctx.lineTo(x, y + 1.5); | 389 ctx.lineTo(x, y + 1.5); |
| 349 y = frame.idle ? baseY + 0.5 : Math.round(baseY - visualHeight * Mat
h.min(baseFrameDurationMs / frame.duration, 1)) - 0.5; | 390 y = frame.idle ? baseY + 0.5 : Math.round(baseY - visualHeight * Mat
h.min(baseFrameDurationMs / frame.duration, 1)) - 0.5; |
| 350 ctx.lineTo(x, y + 1.5); | 391 ctx.lineTo(x, y + 1.5); |
| 351 ctx.lineTo(x, y); | 392 ctx.lineTo(x, y); |
| 352 } | 393 } |
| 353 if (frames.length) { | 394 if (frames.length) { |
| 354 var lastFrame = frames.peekLast(); | 395 var lastFrame = frames.peekLast(); |
| 355 var x = Math.round((lastFrame.startTime + lastFrame.duration - timeO
ffset) * scale) + 0.5; | 396 var x = Math.round((lastFrame.startTime + lastFrame.duration - timeO
ffset) * scale) + 0.5; |
| 356 ctx.lineTo(x, y); | 397 ctx.lineTo(x, y); |
| 357 } | 398 } |
| 358 ctx.lineTo(x, baseY + 10); | 399 ctx.lineTo(x, baseY + 10); |
| 359 ctx.closePath(); | 400 ctx.fillStyle = "hsl(110, 50%, 88%)"; |
| 401 ctx.strokeStyle = "hsl(110, 50%, 60%)"; |
| 360 ctx.fill(); | 402 ctx.fill(); |
| 361 ctx.stroke(); | 403 ctx.stroke(); |
| 362 ctx.restore(); | 404 ctx.restore(); |
| 363 return height; | 405 return height; |
| 364 }, | 406 }, |
| 365 | 407 |
| 408 /** |
| 409 * @param {number} y |
| 410 * @param {string} label |
| 411 */ |
| 412 _drawHorizontalGuide: function(y, label) |
| 413 { |
| 414 var ctx = this._context; |
| 415 ctx.save(); |
| 416 ctx.beginPath(); |
| 417 ctx.moveTo(0, y); |
| 418 ctx.lineTo(this._canvas.width, y); |
| 419 ctx.strokeStyle = "hsl(0, 0%, 85%)"; |
| 420 ctx.setLineDash([3]); |
| 421 ctx.stroke(); |
| 422 ctx.fillStyle = "hsl(0, 0%, 65%)"; |
| 423 ctx.font = "9px " + WebInspector.fontFamily(); |
| 424 ctx.fillText(label, 4, y + 8); |
| 425 ctx.restore(); |
| 426 }, |
| 427 |
| 366 _onCategoryVisibilityChanged: function() | 428 _onCategoryVisibilityChanged: function() |
| 367 { | 429 { |
| 368 this.update(); | 430 this.update(); |
| 369 }, | 431 }, |
| 370 | 432 |
| 371 /** | 433 /** |
| 372 * @param {number} begin | 434 * @param {number} begin |
| 373 * @param {number} end | 435 * @param {number} end |
| 374 * @param {number} position | 436 * @param {number} position |
| 375 * @param {number} height | 437 * @param {number} height |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 counters[group] = this._quantDuration; | 597 counters[group] = this._quantDuration; |
| 536 this._callback(counters); | 598 this._callback(counters); |
| 537 interval -= this._quantDuration; | 599 interval -= this._quantDuration; |
| 538 } | 600 } |
| 539 this._counters = []; | 601 this._counters = []; |
| 540 this._counters[group] = interval; | 602 this._counters[group] = interval; |
| 541 this._lastTime = time; | 603 this._lastTime = time; |
| 542 this._remainder = this._quantDuration - interval; | 604 this._remainder = this._quantDuration - interval; |
| 543 } | 605 } |
| 544 } | 606 } |
| OLD | NEW |