Index: Source/devtools/front_end/timeline/TimelineEventOverview.js |
diff --git a/Source/devtools/front_end/timeline/TimelineEventOverview.js b/Source/devtools/front_end/timeline/TimelineEventOverview.js |
index fab00196003aa5467adafda490a4ad74443d1c18..0830decad67681bc4706765ad9c719f86f38c467 100644 |
--- a/Source/devtools/front_end/timeline/TimelineEventOverview.js |
+++ b/Source/devtools/front_end/timeline/TimelineEventOverview.js |
@@ -254,13 +254,11 @@ WebInspector.TimelineEventOverview.Network.prototype = { |
/** |
* @constructor |
* @extends {WebInspector.TimelineEventOverview} |
- * @param {string} id |
- * @param {string} title |
* @param {!WebInspector.TimelineModel} model |
*/ |
-WebInspector.TimelineEventOverview.Thread = function(id, title, model) |
+WebInspector.TimelineEventOverview.CPUActivity = function(model) |
{ |
- WebInspector.TimelineEventOverview.call(this, id, title, model) |
+ WebInspector.TimelineEventOverview.call(this, "cpu-activity", WebInspector.UIString("CPU"), model); |
this._fillStyles = {}; |
var categories = WebInspector.TimelineUIUtils.categories(); |
for (var category in categories) { |
@@ -268,9 +266,10 @@ WebInspector.TimelineEventOverview.Thread = function(id, title, model) |
categories[category].addEventListener(WebInspector.TimelineCategory.Events.VisibilityChanged, this._onCategoryVisibilityChanged, this); |
} |
this._disabledCategoryFillStyle = "hsl(0, 0%, 67%)"; |
+ this._backgroundCanvas = this.element.createChild("canvas", "fill background"); |
} |
-WebInspector.TimelineEventOverview.Thread.prototype = { |
+WebInspector.TimelineEventOverview.CPUActivity.prototype = { |
/** |
* @override |
*/ |
@@ -296,29 +295,22 @@ WebInspector.TimelineEventOverview.Thread.prototype = { |
return category.hidden ? this._disabledCategoryFillStyle : this._fillStyles[category.name]; |
}, |
- __proto__: WebInspector.TimelineEventOverview.prototype |
-} |
- |
-/** |
- * @constructor |
- * @extends {WebInspector.TimelineEventOverview.Thread} |
- * @param {!WebInspector.TimelineModel} model |
- */ |
-WebInspector.TimelineEventOverview.MainThread = function(model) |
-{ |
- WebInspector.TimelineEventOverview.Thread.call(this, "main-thread", WebInspector.UIString("CPU"), model) |
-} |
+ /** |
+ * @override |
+ */ |
+ resetCanvas: function() |
+ { |
+ WebInspector.TimelineEventOverview.prototype.resetCanvas.call(this); |
+ this._backgroundCanvas.width = this.element.clientWidth * window.devicePixelRatio; |
+ this._backgroundCanvas.height = this.element.clientHeight * window.devicePixelRatio; |
+ }, |
-WebInspector.TimelineEventOverview.MainThread.prototype = { |
/** |
* @override |
*/ |
update: function() |
{ |
WebInspector.TimelineEventOverview.prototype.update.call(this); |
- var events = this._model.mainThreadEvents(); |
- if (!events.length) |
- return; |
var /** @const */ quantSizePx = 4 * window.devicePixelRatio; |
var height = this._canvas.height; |
var baseLine = height; |
@@ -326,8 +318,7 @@ WebInspector.TimelineEventOverview.MainThread.prototype = { |
var timeSpan = this._model.maximumRecordTime() - timeOffset; |
var scale = this._canvas.width / timeSpan; |
var quantTime = quantSizePx / scale; |
- var quantizer = new WebInspector.Quantizer(timeOffset, quantTime, drawSample.bind(this)); |
- var ctx = this._context; |
+ var quantizer; |
var x = 0; |
var categories = WebInspector.TimelineUIUtils.categories(); |
var categoryOrder = ["idle", "loading", "painting", "rendering", "scripting", "other"]; |
@@ -338,6 +329,11 @@ WebInspector.TimelineEventOverview.MainThread.prototype = { |
categories[categoryOrder[i]]._overviewIndex = i; |
var categoryIndexStack = []; |
+ var ctx = this._backgroundCanvas.getContext("2d"); |
+ this._model.virtualThreads().forEach(function (thread) { drawThreadEvents.call(this, thread.events); }, this); |
caseq
2015/08/25 01:37:56
extract a named function?
alph
2015/08/25 17:29:26
Done.
|
+ ctx = this._context; |
caseq
2015/08/25 01:37:56
can we pass this explicitly rather than swap the c
alph
2015/08/25 17:29:26
Done.
|
+ drawThreadEvents.call(this, this._model.mainThreadEvents()); |
+ |
/** |
* @param {!Array<number>} counters |
* @this {WebInspector.TimelineEventOverview} |
@@ -374,11 +370,21 @@ WebInspector.TimelineEventOverview.MainThread.prototype = { |
quantizer.appendInterval(e.endTime, categoryIndexStack.pop()); |
} |
- WebInspector.TimelineModel.forEachEvent(events, onEventStart, onEventEnd); |
- quantizer.appendInterval(timeOffset + timeSpan + quantTime, idleIndex); // Kick drawing the last bucket. |
+ /** |
+ * @param {!Array<!WebInspector.TracingModel.Event>} events |
+ * @this {WebInspector.TimelineEventOverview} |
+ */ |
+ function drawThreadEvents(events) |
+ { |
+ quantizer = new WebInspector.Quantizer(timeOffset, quantTime, drawSample.bind(this)); |
+ x = 0; |
+ categoryIndexStack = []; |
caseq
2015/08/25 01:37:56
The above three look scary and puzzling, too!
alph
2015/08/25 17:29:26
Done.
|
+ WebInspector.TimelineModel.forEachEvent(events, onEventStart, onEventEnd); |
+ quantizer.appendInterval(timeOffset + timeSpan + quantTime, idleIndex); // Kick drawing the last bucket. |
+ } |
}, |
- __proto__: WebInspector.TimelineEventOverview.Thread.prototype |
+ __proto__: WebInspector.TimelineEventOverview.prototype |
} |
/** |