Chromium Code Reviews| Index: Source/devtools/front_end/TimelinePanel.js |
| diff --git a/Source/devtools/front_end/TimelinePanel.js b/Source/devtools/front_end/TimelinePanel.js |
| index 6fa3dcf729ee63a96485b8cca52a5afdef223f53..b3241ed5ac0a6ccc69d318ee96770bbb4d936d0a 100644 |
| --- a/Source/devtools/front_end/TimelinePanel.js |
| +++ b/Source/devtools/front_end/TimelinePanel.js |
| @@ -134,7 +134,11 @@ WebInspector.TimelinePanel = function() |
| this._adjustHeaderHeight(); |
| this._mainThreadTasks = /** @type {!Array.<{startTime: number, endTime: number}>} */ ([]); |
| - this._cpuBarsElement = this._timelineGrid.gridHeaderElement.createChild("div", "timeline-cpu-bars"); |
| + this._gpuTasks = /** @type {!Array.<{startTime: number, endTime: number, pid: number}>} */ ([]); |
| + var utilizationStripsElement = this._timelineGrid.gridHeaderElement.createChild("div", "timeline-utilization-strips"); |
| + this._cpuBarsElement = utilizationStripsElement.createChild("div", "timeline-utilization-strip"); |
| + if (WebInspector.experimentsSettings.gpuTimeline.isEnabled()) |
| + this._gpuBarsElement = utilizationStripsElement.createChild("div", "timeline-utilization-strip gpu"); |
| this._mainThreadMonitoringEnabled = WebInspector.settings.showCpuOnTimelineRuler.get(); |
| WebInspector.settings.showCpuOnTimelineRuler.addChangeListener(this._showCpuOnTimelineRulerChanged, this); |
| @@ -150,7 +154,7 @@ WebInspector.TimelinePanel = function() |
| this._allRecordsCount = 0; |
| this._presentationModel.addFilter(new WebInspector.TimelineWindowFilter(this._overviewPane)); |
| - this._presentationModel.addFilter(new WebInspector.TimelineCategoryFilter()); |
| + this._presentationModel.addFilter(new WebInspector.TimelineCategoryFilter()); |
| this._presentationModel.addFilter(this._durationFilter); |
| } |
| @@ -166,7 +170,7 @@ WebInspector.TimelinePanel.prototype = { |
| var mainThreadMonitoringEnabled = WebInspector.settings.showCpuOnTimelineRuler.get(); |
| if (this._mainThreadMonitoringEnabled !== mainThreadMonitoringEnabled) { |
| this._mainThreadMonitoringEnabled = mainThreadMonitoringEnabled; |
| - this._refreshMainThreadBars(); |
| + this._refreshAllUtilizationBars(); |
| } |
| }, |
| @@ -652,6 +656,16 @@ WebInspector.TimelinePanel.prototype = { |
| }); |
| } |
| + if (record.type === WebInspector.TimelineModel.RecordType.GPUTask) { |
| + this._gpuTasks.push({ |
| + startTime: WebInspector.TimelineModel.startTimeInSeconds(record), |
| + endTime: WebInspector.TimelineModel.endTimeInSeconds(record), |
| + pid: record.data["ownerPid"], |
| + name: record.data["name"] |
| + }); |
| + return WebInspector.TimelineModel.startTimeInSeconds(record) < this._overviewPane.windowEndTime(); |
| + } |
| + |
| var records = this._presentationModel.addRecord(record); |
| this._allRecordsCount += records.length; |
| var hasVisibleRecords = false; |
| @@ -728,6 +742,8 @@ WebInspector.TimelinePanel.prototype = { |
| this._allRecordsCount = 0; |
| this._automaticallySizeWindow = true; |
| this._mainThreadTasks = []; |
| + this._gpuTasks = []; |
| + this._pidToHue = {}; |
| }, |
| elementsToRestoreScrollPositionsFor: function() |
| @@ -818,8 +834,7 @@ WebInspector.TimelinePanel.prototype = { |
| this._timelineGrid.updateDividers(this._calculator); |
| } else |
| this._timelineGrid.updateDividers(this._calculator); |
| - if (this._mainThreadMonitoringEnabled) |
| - this._refreshMainThreadBars(); |
| + this._refreshAllUtilizationBars(); |
| } |
| if (this._memoryStatistics.visible()) |
| this._memoryStatistics.refresh(); |
| @@ -979,8 +994,23 @@ WebInspector.TimelinePanel.prototype = { |
| return recordsInWindow.length; |
| }, |
| - _refreshMainThreadBars: function() |
| + _refreshAllUtilizationBars: function() |
| + { |
| + this._refreshUtilizationBars(WebInspector.UIString("CPU"), this._mainThreadMonitoringEnabled ? this._mainThreadTasks : [], this._cpuBarsElement); |
| + if (WebInspector.experimentsSettings.gpuTimeline.isEnabled()) |
| + this._refreshUtilizationBars(WebInspector.UIString("GPU"), this._gpuTasks, this._gpuBarsElement); |
| + }, |
| + |
| + /** |
| + * @param {string} name |
| + * @param {!Array.<{startTime: number, endTime: number, pid: number}>} tasks |
| + * @param {Element} container |
|
caseq
2013/11/05 14:26:58
?Element I guess?
alph
2013/11/05 14:59:16
Done.
|
| + */ |
| + _refreshUtilizationBars: function(name, tasks, container) |
| { |
| + if (!container) |
| + return; |
| + |
| const barOffset = 3; |
| const minGap = 3; |
| @@ -993,8 +1023,6 @@ WebInspector.TimelinePanel.prototype = { |
| var startTime = this._overviewPane.windowStartTime() - this._timelinePaddingLeft * scale; |
| var endTime = startTime + width * scale; |
| - var tasks = this._mainThreadMonitoringEnabled ? this._mainThreadTasks : []; |
| - |
| /** |
| * @param {number} value |
| * @param {{startTime: number, endTime: number}} task |
| @@ -1007,12 +1035,15 @@ WebInspector.TimelinePanel.prototype = { |
| var taskIndex = insertionIndexForObjectInListSortedByFunction(startTime, tasks, compareEndTime); |
| - var container = this._cpuBarsElement; |
| var element = container.firstChild; |
| var lastElement; |
| var lastLeft; |
| var lastRight; |
| + if (!this._pidToHue) |
| + this._pidToHue = {}; |
| + var pidToHue = this._pidToHue; |
| + |
| for (; taskIndex < tasks.length; ++taskIndex) { |
| var task = tasks[taskIndex]; |
| if (task.startTime > endTime) |
| @@ -1023,7 +1054,8 @@ WebInspector.TimelinePanel.prototype = { |
| if (lastElement) { |
| var gap = Math.floor(left) - Math.ceil(lastRight); |
| - if (gap < minGap) { |
| + if (gap < minGap |
| + && (!task.pid || tasks[lastElement._tasksInfo.firstTaskIndex].pid === task.pid)) { |
| lastRight = right; |
| lastElement._tasksInfo.lastTaskIndex = taskIndex; |
| continue; |
| @@ -1034,8 +1066,14 @@ WebInspector.TimelinePanel.prototype = { |
| if (!element) |
| element = container.createChild("div", "timeline-graph-bar"); |
| + if (task.pid) { |
| + if (!(task.pid in pidToHue)) |
| + pidToHue[task.pid] = (Object.keys(pidToHue).length * 113) % 360; |
| + var hue = pidToHue[task.pid]; |
| + element.style.backgroundColor = "hsla(" + hue + ",50%,50%,0.2)"; |
| + } |
| element.style.left = left + "px"; |
| - element._tasksInfo = {tasks: tasks, firstTaskIndex: taskIndex, lastTaskIndex: taskIndex}; |
| + element._tasksInfo = {name: name, tasks: tasks, firstTaskIndex: taskIndex, lastTaskIndex: taskIndex}; |
| lastLeft = left; |
| lastRight = right; |