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

Unified Diff: tools/turbolizer/graph-layout.js

Issue 2168713005: [turbolizer] Redetermine graph bounding box after dragging a node. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@t-p1
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/turbolizer/graph-view.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/turbolizer/graph-layout.js
diff --git a/tools/turbolizer/graph-layout.js b/tools/turbolizer/graph-layout.js
index 8e411b7635e3afbf72a4fa86cb51e3a67150bbbd..9986639a6330fb0879e6791dc110dfe16a816a71 100644
--- a/tools/turbolizer/graph-layout.js
+++ b/tools/turbolizer/graph-layout.js
@@ -247,12 +247,6 @@ function newGraphOccupation(graph){
}
function layoutNodeGraph(graph) {
- graph.minGraphX = 0;
- graph.maxGraphNodeX = 1;
- graph.maxGraphX = 1;
- graph.minGraphY = 0;
- graph.maxGraphY = 1;
-
// First determine the set of nodes that have no outputs. Those are the
// basis for bottom-up DFS to determine rank and node placement.
var endNodesHasNoOutputs = [];
@@ -422,19 +416,6 @@ function layoutNodeGraph(graph) {
} else {
nodeToPlace.x = 0;
}
-
- if (nodeToPlace.x < graph.minGraphX) {
- graph.minGraphX = nodeToPlace.x;
- }
- if ((nodeToPlace.y - 50) < graph.minGraphY) {
- graph.minGraphY = nodeToPlace.y - 50;
- }
- if ((nodeToPlace.x + nodeToPlace.getTotalNodeWidth()) > graph.maxGraphNodeX) {
- graph.maxGraphNodeX = nodeToPlace.x + nodeToPlace.getTotalNodeWidth();
- }
- if ((nodeToPlace.y + graph.getNodeHeight() + 50) > graph.maxGraphY) {
- graph.maxGraphY = nodeToPlace.y + graph.getNodeHeight() + 50;
- }
}
if (traceLayout) {
@@ -458,17 +439,55 @@ function layoutNodeGraph(graph) {
console.log("After occupying inputs");
occupation.print();
}
+
+ if (traceLayout) {
+ console.log("After determining bounding box");
+ occupation.print();
+ }
});
- var backEdgeNumber = 0;
+ graph.maxBackEdgeNumber = 0;
graph.visibleEdges.each(function (e) {
if (e.isBackEdge()) {
- e.backEdgeNumber = ++backEdgeNumber;
+ e.backEdgeNumber = ++graph.maxBackEdgeNumber;
} else {
e.backEdgeNumber = 0;
}
});
+ redetermineGraphBoundingBox(graph);
+
+}
+
+function redetermineGraphBoundingBox(graph) {
+ graph.minGraphX = 0;
+ graph.maxGraphNodeX = 1;
+ graph.maxGraphX = undefined; // see below
+ graph.minGraphY = 0;
+ graph.maxGraphY = 1;
+
+ for (var i = 0; i < graph.nodes.length; ++i) {
+ var node = graph.nodes[i];
+
+ if (!node.visible) {
+ continue;
+ }
+
+ if (node.x < graph.minGraphX) {
+ graph.minGraphX = node.x;
+ }
+ if ((node.x + node.getTotalNodeWidth()) > graph.maxGraphNodeX) {
+ graph.maxGraphNodeX = node.x + node.getTotalNodeWidth();
+ }
+ if ((node.y - 50) < graph.minGraphY) {
+ graph.minGraphY = node.y - 50;
+ }
+ if ((node.y + graph.getNodeHeight() + 50) > graph.maxGraphY) {
+ graph.maxGraphY = node.y + graph.getNodeHeight() + 50;
+ }
+ }
+
graph.maxGraphX = graph.maxGraphNodeX +
- backEdgeNumber * MINIMUM_EDGE_SEPARATION;
+ graph.maxBackEdgeNumber * MINIMUM_EDGE_SEPARATION;
+
}
« no previous file with comments | « no previous file | tools/turbolizer/graph-view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698