Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js

Issue 1808063002: Timeline: move SegmentedRange into the WebInspector namespace and a file of its own (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved Segment around Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/TimelineIRModel.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 } 1483 }
1484 }, 1484 },
1485 1485
1486 /** 1486 /**
1487 * @param {number} y 1487 * @param {number} y
1488 * @param {number} startLevel 1488 * @param {number} startLevel
1489 * @param {number} endLevel 1489 * @param {number} endLevel
1490 */ 1490 */
1491 _drawCollapsedOverviewForGroup: function(y, startLevel, endLevel) 1491 _drawCollapsedOverviewForGroup: function(y, startLevel, endLevel)
1492 { 1492 {
1493 var range = new SegmentedRange(mergeCallback); 1493 var range = new WebInspector.SegmentedRange(mergeCallback);
1494 var timeWindowRight = this._timeWindowRight; 1494 var timeWindowRight = this._timeWindowRight;
1495 var timeWindowLeft = this._timeWindowLeft - this._paddingLeft / this._ti meToPixel; 1495 var timeWindowLeft = this._timeWindowLeft - this._paddingLeft / this._ti meToPixel;
1496 var context = this._canvas.getContext("2d"); 1496 var context = this._canvas.getContext("2d");
1497 var barHeight = this._barHeight - 2; 1497 var barHeight = this._barHeight - 2;
1498 var entryStartTimes = this._rawTimelineData.entryStartTimes; 1498 var entryStartTimes = this._rawTimelineData.entryStartTimes;
1499 var entryTotalTimes = this._rawTimelineData.entryTotalTimes; 1499 var entryTotalTimes = this._rawTimelineData.entryTotalTimes;
1500 1500
1501 for (var level = startLevel; level < endLevel; ++level) { 1501 for (var level = startLevel; level < endLevel; ++level) {
1502 var levelIndexes = this._timelineLevels[level]; 1502 var levelIndexes = this._timelineLevels[level];
1503 var rightIndexOnLevel = levelIndexes.lowerBound(timeWindowRight, (ti me, entryIndex) => time - entryStartTimes[entryIndex]) - 1; 1503 var rightIndexOnLevel = levelIndexes.lowerBound(timeWindowRight, (ti me, entryIndex) => time - entryStartTimes[entryIndex]) - 1;
1504 var lastDrawOffset = Infinity; 1504 var lastDrawOffset = Infinity;
1505 1505
1506 for (var entryIndexOnLevel = rightIndexOnLevel; entryIndexOnLevel >= 0; --entryIndexOnLevel) { 1506 for (var entryIndexOnLevel = rightIndexOnLevel; entryIndexOnLevel >= 0; --entryIndexOnLevel) {
1507 var entryIndex = levelIndexes[entryIndexOnLevel]; 1507 var entryIndex = levelIndexes[entryIndexOnLevel];
1508 var entryStartTime = entryStartTimes[entryIndex]; 1508 var entryStartTime = entryStartTimes[entryIndex];
1509 var startPosition = this._timeToPositionClipped(entryStartTime); 1509 var startPosition = this._timeToPositionClipped(entryStartTime);
1510 var entryEndTime = entryStartTime + entryTotalTimes[entryIndex]; 1510 var entryEndTime = entryStartTime + entryTotalTimes[entryIndex];
1511 if (isNaN(entryEndTime) || startPosition >= lastDrawOffset) 1511 if (isNaN(entryEndTime) || startPosition >= lastDrawOffset)
1512 continue; 1512 continue;
1513 if (entryEndTime <= timeWindowLeft) 1513 if (entryEndTime <= timeWindowLeft)
1514 break; 1514 break;
1515 lastDrawOffset = startPosition; 1515 lastDrawOffset = startPosition;
1516 var color = this._dataProvider.entryColor(entryIndex); 1516 var color = this._dataProvider.entryColor(entryIndex);
1517 range.append(new Segment(startPosition, this._timeToPositionClip ped(entryEndTime), color)); 1517 range.append(new WebInspector.Segment(startPosition, this._timeT oPositionClipped(entryEndTime), color));
1518 } 1518 }
1519 } 1519 }
1520 1520
1521 var segments = range.segments().slice().sort((a, b) => a.data.localeComp are(b.data)); 1521 var segments = range.segments().slice().sort((a, b) => a.data.localeComp are(b.data));
1522 var lastColor; 1522 var lastColor;
1523 context.beginPath(); 1523 context.beginPath();
1524 for (var i = 0; i < segments.length; ++i) { 1524 for (var i = 0; i < segments.length; ++i) {
1525 var segment = segments[i]; 1525 var segment = segments[i];
1526 if (lastColor !== segments[i].data) { 1526 if (lastColor !== segments[i].data) {
1527 context.fill(); 1527 context.fill();
1528 context.beginPath(); 1528 context.beginPath();
1529 lastColor = segments[i].data; 1529 lastColor = segments[i].data;
1530 context.fillStyle = lastColor; 1530 context.fillStyle = lastColor;
1531 } 1531 }
1532 context.rect(segment.begin, y, segment.end - segment.begin, barHeigh t); 1532 context.rect(segment.begin, y, segment.end - segment.begin, barHeigh t);
1533 } 1533 }
1534 context.fill(); 1534 context.fill();
1535 1535
1536 /** 1536 /**
1537 * @param {!Segment} a 1537 * @param {!WebInspector.Segment} a
1538 * @param {!Segment} b 1538 * @param {!WebInspector.Segment} b
1539 * @return {?Segment} 1539 * @return {?WebInspector.Segment}
1540 */ 1540 */
1541 function mergeCallback(a, b) 1541 function mergeCallback(a, b)
1542 { 1542 {
1543 return a.data === b.data && a.end + 0.4 > b.end ? a : null; 1543 return a.data === b.data && a.end + 0.4 > b.end ? a : null;
1544 } 1544 }
1545 }, 1545 },
1546 1546
1547 /** 1547 /**
1548 * @param {!CanvasRenderingContext2D} context 1548 * @param {!CanvasRenderingContext2D} context
1549 * @param {number} height 1549 * @param {number} height
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 this.update(); 1962 this.update();
1963 }, 1963 },
1964 1964
1965 _enabled: function() 1965 _enabled: function()
1966 { 1966 {
1967 return this._rawTimelineDataLength !== 0; 1967 return this._rawTimelineDataLength !== 0;
1968 }, 1968 },
1969 1969
1970 __proto__: WebInspector.HBox.prototype 1970 __proto__: WebInspector.HBox.prototype
1971 } 1971 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/TimelineIRModel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698