Skip to content

Commit

Permalink
Switch pipeline rendering to SVG
Browse files Browse the repository at this point in the history
  • Loading branch information
eth3lbert committed Jan 22, 2025
1 parent 2bc3266 commit ac8c105
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
14 changes: 3 additions & 11 deletions src/cargo/core/compiler/timings.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ function render_pipeline_graph() {

const graph_height = Y_TICK_DIST * units.length;
let { canvas_width, canvas_height, graph_width, px_per_sec } = resize_graph(graph_height);
let ctx = init_canvas('pipeline-graph', canvas_width, canvas_height);
const container = document.getElementById('pipeline-container');
container.style.width = canvas_width;
container.style.height = canvas_height;

ctx.strokeStyle = AXES_COLOR;

// Draw the graph.
ctx.save();
ctx.translate(X_LINE, MARGIN);

// Compute x,y coordinate of each block.
// We also populate a map with the count of each unit name to disambiguate if necessary
Expand All @@ -81,8 +71,10 @@ function render_pipeline_graph() {
const dep_lines = create_dep_lines(units);
const boxes = create_boxes(units, unitCount, canvas_width, px_per_sec);
const dep_lines_hl_container = `<g id="hl-pipeline" transform="translate(${X_LINE}, ${MARGIN})"></g>`;
const svg = document.getElementById(`pipeline-graph-svg`);
const svg = document.getElementById(`pipeline-graph`);
if (svg) {
svg.style.width = canvas_width;
svg.style.height = canvas_height;
svg.innerHTML = (
`${axis_bottom}${axis_left}${dep_lines}${boxes}${dep_lines_hl_container}`
);
Expand Down
10 changes: 5 additions & 5 deletions src/cargo/core/compiler/timings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,10 @@ h1 {
border-bottom: 1px solid var(--h1-border-bottom);
}
#pipeline-graph {
background-color: var(--canvas-background);
}
.graph {
display: block;
}
Expand Down Expand Up @@ -838,11 +842,7 @@ static HTML_CANVAS: &str = r#"
</tr>
</table>
<div id="pipeline-container" class="canvas-container">
<canvas id="pipeline-graph" class="graph" style="position: absolute; left: 0; top: 0; z-index: 0;"></canvas>
<canvas id="pipeline-graph-lines" style="position: absolute; left: 0; top: 0; z-index: 1; pointer-events:none;"></canvas>
<svg id="pipeline-graph-svg" class="graph" style="position: absolute; left: 0; top: 0; height: 100%; width: 100%;"></svg>
</div>
<svg id="pipeline-graph" class="graph"></svg>
<div class="canvas-container">
<canvas id="timing-graph" class="graph"></canvas>
</div>
Expand Down

0 comments on commit ac8c105

Please sign in to comment.