From ac8c10509aba1c246ebbd781291171ee2373c1d3 Mon Sep 17 00:00:00 2001 From: eth3lbert Date: Wed, 22 Jan 2025 21:20:35 +0800 Subject: [PATCH] Switch pipeline rendering to SVG --- src/cargo/core/compiler/timings.js | 14 +++----------- src/cargo/core/compiler/timings.rs | 10 +++++----- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/cargo/core/compiler/timings.js b/src/cargo/core/compiler/timings.js index 900847da25fa..9d3516a4555b 100644 --- a/src/cargo/core/compiler/timings.js +++ b/src/cargo/core/compiler/timings.js @@ -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 @@ -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 = ``; - 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}` ); diff --git a/src/cargo/core/compiler/timings.rs b/src/cargo/core/compiler/timings.rs index 71470248a4b4..2934447d1439 100644 --- a/src/cargo/core/compiler/timings.rs +++ b/src/cargo/core/compiler/timings.rs @@ -679,6 +679,10 @@ h1 { border-bottom: 1px solid var(--h1-border-bottom); } +#pipeline-graph { + background-color: var(--canvas-background); +} + .graph { display: block; } @@ -838,11 +842,7 @@ static HTML_CANVAS: &str = r#" -
- - - -
+