| 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 var unclippedBarX = this._timeToPosition(entryStartTime); | 651 var unclippedBarX = this._timeToPosition(entryStartTime); |
| 652 if (this._dataProvider.decorateEntry( | 652 if (this._dataProvider.decorateEntry( |
| 653 entryIndex, context, text, barX, barY, barWidth, barHeight, unclip
pedBarX, this._timeToPixel)) | 653 entryIndex, context, text, barX, barY, barWidth, barHeight, unclip
pedBarX, this._timeToPixel)) |
| 654 continue; | 654 continue; |
| 655 if (!text || !text.length) | 655 if (!text || !text.length) |
| 656 continue; | 656 continue; |
| 657 context.fillStyle = this._dataProvider.textColor(entryIndex); | 657 context.fillStyle = this._dataProvider.textColor(entryIndex); |
| 658 context.fillText(text, barX + textPadding, barY + textBaseHeight); | 658 context.fillText(text, barX + textPadding, barY + textBaseHeight); |
| 659 } | 659 } |
| 660 | 660 |
| 661 this._drawFlowEvents(context, width, height); | |
| 662 | |
| 663 context.restore(); | 661 context.restore(); |
| 664 | 662 |
| 665 UI.TimelineGrid.drawCanvasGrid(context, this._calculator, 3); | 663 UI.TimelineGrid.drawCanvasGrid(context, this._calculator, 3); |
| 666 this._drawMarkers(); | 664 this._drawMarkers(); |
| 667 this._drawGroupHeaders(width, height); | 665 this._drawGroupHeaders(width, height); |
| 668 | 666 |
| 669 this._updateElementPosition(this._highlightElement, this._highlightedEntryIn
dex); | 667 this._updateElementPosition(this._highlightElement, this._highlightedEntryIn
dex); |
| 670 this._updateElementPosition(this._selectedElement, this._selectedEntryIndex)
; | 668 this._updateElementPosition(this._selectedElement, this._selectedEntryIndex)
; |
| 671 this._updateMarkerHighlight(); | 669 this._updateMarkerHighlight(); |
| 672 } | 670 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 /** | 878 /** |
| 881 * @param {!Common.Segment} a | 879 * @param {!Common.Segment} a |
| 882 * @param {!Common.Segment} b | 880 * @param {!Common.Segment} b |
| 883 * @return {?Common.Segment} | 881 * @return {?Common.Segment} |
| 884 */ | 882 */ |
| 885 function mergeCallback(a, b) { | 883 function mergeCallback(a, b) { |
| 886 return a.data === b.data && a.end + 0.4 > b.end ? a : null; | 884 return a.data === b.data && a.end + 0.4 > b.end ? a : null; |
| 887 } | 885 } |
| 888 } | 886 } |
| 889 | 887 |
| 890 /** | |
| 891 * @param {!CanvasRenderingContext2D} context | |
| 892 * @param {number} height | |
| 893 * @param {number} width | |
| 894 */ | |
| 895 _drawFlowEvents(context, width, height) { | |
| 896 var timelineData = this._timelineData(); | |
| 897 var timeWindowRight = this._timeWindowRight; | |
| 898 var timeWindowLeft = this._timeWindowLeft; | |
| 899 var flowStartTimes = timelineData.flowStartTimes; | |
| 900 var flowEndTimes = timelineData.flowEndTimes; | |
| 901 var flowStartLevels = timelineData.flowStartLevels; | |
| 902 var flowEndLevels = timelineData.flowEndLevels; | |
| 903 var flowCount = flowStartTimes.length; | |
| 904 var endIndex = flowStartTimes.lowerBound(timeWindowRight); | |
| 905 | |
| 906 var color = []; | |
| 907 var fadeColorsCount = 8; | |
| 908 for (var i = 0; i <= fadeColorsCount; ++i) | |
| 909 color[i] = 'rgba(128, 0, 0, ' + i / fadeColorsCount + ')'; | |
| 910 var fadeColorsRange = color.length; | |
| 911 var minimumFlowDistancePx = 15; | |
| 912 var flowArcHeight = 4 * this._barHeight; | |
| 913 var colorIndex = 0; | |
| 914 context.lineWidth = 0.5; | |
| 915 for (var i = 0; i < endIndex; ++i) { | |
| 916 if (flowEndTimes[i] < timeWindowLeft) | |
| 917 continue; | |
| 918 var startX = this._timeToPosition(flowStartTimes[i]); | |
| 919 var endX = this._timeToPosition(flowEndTimes[i]); | |
| 920 if (endX - startX < minimumFlowDistancePx) | |
| 921 continue; | |
| 922 if (startX < -minimumFlowDistancePx && endX > width + minimumFlowDistanceP
x) | |
| 923 continue; | |
| 924 // Assign a trasparent color if the flow is small enough or if the previou
s color was a transparent color. | |
| 925 if (endX - startX < minimumFlowDistancePx + fadeColorsRange || colorIndex
!== color.length - 1) { | |
| 926 colorIndex = Math.min(fadeColorsRange - 1, Math.floor(endX - startX - mi
nimumFlowDistancePx)); | |
| 927 context.strokeStyle = color[colorIndex]; | |
| 928 } | |
| 929 var startY = this._levelToHeight(flowStartLevels[i]) + this._barHeight; | |
| 930 var endY = this._levelToHeight(flowEndLevels[i]); | |
| 931 context.beginPath(); | |
| 932 context.moveTo(startX, startY); | |
| 933 var arcHeight = Math.max(Math.sqrt(Math.abs(startY - endY)), flowArcHeight
) + 5; | |
| 934 context.bezierCurveTo(startX, startY + arcHeight, endX, endY + arcHeight,
endX, endY + this._barHeight); | |
| 935 context.stroke(); | |
| 936 } | |
| 937 } | |
| 938 | |
| 939 _drawMarkers() { | 888 _drawMarkers() { |
| 940 var markers = this._timelineData().markers; | 889 var markers = this._timelineData().markers; |
| 941 var left = this._markerIndexBeforeTime(this._calculator.minimumBoundary()); | 890 var left = this._markerIndexBeforeTime(this._calculator.minimumBoundary()); |
| 942 var rightBoundary = this._calculator.maximumBoundary(); | 891 var rightBoundary = this._calculator.maximumBoundary(); |
| 943 | 892 |
| 944 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont
ext('2d')); | 893 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont
ext('2d')); |
| 945 context.save(); | 894 context.save(); |
| 946 var ratio = window.devicePixelRatio; | 895 var ratio = window.devicePixelRatio; |
| 947 context.scale(ratio, ratio); | 896 context.scale(ratio, ratio); |
| 948 var height = UI.FlameChart.DividersBarHeight - 1; | 897 var height = UI.FlameChart.DividersBarHeight - 1; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 * @param {!Array<number>|!Float64Array} entryStartTimes | 1196 * @param {!Array<number>|!Float64Array} entryStartTimes |
| 1248 * @param {?Array<!UI.FlameChart.Group>} groups | 1197 * @param {?Array<!UI.FlameChart.Group>} groups |
| 1249 */ | 1198 */ |
| 1250 constructor(entryLevels, entryTotalTimes, entryStartTimes, groups) { | 1199 constructor(entryLevels, entryTotalTimes, entryStartTimes, groups) { |
| 1251 this.entryLevels = entryLevels; | 1200 this.entryLevels = entryLevels; |
| 1252 this.entryTotalTimes = entryTotalTimes; | 1201 this.entryTotalTimes = entryTotalTimes; |
| 1253 this.entryStartTimes = entryStartTimes; | 1202 this.entryStartTimes = entryStartTimes; |
| 1254 this.groups = groups; | 1203 this.groups = groups; |
| 1255 /** @type {!Array.<!UI.FlameChartMarker>} */ | 1204 /** @type {!Array.<!UI.FlameChartMarker>} */ |
| 1256 this.markers = []; | 1205 this.markers = []; |
| 1257 this.flowStartTimes = []; | |
| 1258 this.flowStartLevels = []; | |
| 1259 this.flowEndTimes = []; | |
| 1260 this.flowEndLevels = []; | |
| 1261 } | 1206 } |
| 1262 }; | 1207 }; |
| 1263 | 1208 |
| 1264 UI.FlameChartDataProvider.prototype = { | 1209 UI.FlameChartDataProvider.prototype = { |
| 1265 /** | 1210 /** |
| 1266 * @return {number} | 1211 * @return {number} |
| 1267 */ | 1212 */ |
| 1268 barHeight: function() {}, | 1213 barHeight: function() {}, |
| 1269 | 1214 |
| 1270 /** | 1215 /** |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 } | 1491 } |
| 1547 | 1492 |
| 1548 /** | 1493 /** |
| 1549 * @override | 1494 * @override |
| 1550 * @return {number} | 1495 * @return {number} |
| 1551 */ | 1496 */ |
| 1552 boundarySpan() { | 1497 boundarySpan() { |
| 1553 return this._maximumBoundaries - this._minimumBoundaries; | 1498 return this._maximumBoundaries - this._minimumBoundaries; |
| 1554 } | 1499 } |
| 1555 }; | 1500 }; |
| OLD | NEW |