Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Fix partial dashed border rendering (#38190)
Francisco Gonzaleza22c29c5f9b0
diff --git a/crates/gpui/src/platform/blade/shaders.wgsl b/crates/gpui/src/platform/blade/shaders.wgslindex d00e596c104..1de8ad44201 100644--- a/crates/gpui/src/platform/blade/shaders.wgsl+++ b/crates/gpui/src/platform/blade/shaders.wgsl@@ -683,7 +683,24 @@ fn fs_quad(input: QuadVarying) -> @location(0) vec4<f32> {let is_horizontal =corner_center_to_point.x <corner_center_to_point.y;- let border_width = select(border.y, border.x, is_horizontal);++ // When applying dashed borders to just some, not all, the sides.+ // The way we chose border widths above sometimes comes with a 0 width value.+ // So we choose again to avoid division by zero.+ // TODO: A better solution exists taking a look at the whole file.+ // this does not fix single dashed borders at the corners+ let dashed_border = vec2<f32>(+ max(+ quad.border_widths.bottom,+ quad.border_widths.top,+ ),+ max(+ quad.border_widths.right,+ quad.border_widths.left,+ )+ );++ let border_width = select(dashed_border.y, dashed_border.x, is_horizontal);dash_velocity = dv_numerator / border_width;t = select(point.y, point.x, is_horizontal) * dash_velocity;max_t = select(size.y, size.x, is_horizontal) * dash_velocity;diff --git a/crates/gpui/src/platform/mac/shaders.metal b/crates/gpui/src/platform/mac/shaders.metalindex 37ec7b530a9..7c3886031ab 100644--- a/crates/gpui/src/platform/mac/shaders.metal+++ b/crates/gpui/src/platform/mac/shaders.metal@@ -245,7 +245,15 @@ fragment float4 quad_fragment(QuadFragmentInput input [[stage_in]],// out on each straight line, rather than around the whole// perimeter. This way each line starts and ends with a dash.bool is_horizontal = corner_center_to_point.x < corner_center_to_point.y;- float border_width = is_horizontal ? border.x : border.y;++ // Choosing the right border width for dashed borders.+ // TODO: A better solution exists taking a look at the whole file.+ // this does not fix single dashed borders at the corners+ float2 dashed_border = float2(+ fmax(quad.border_widths.bottom, quad.border_widths.top),+ fmax(quad.border_widths.right, quad.border_widths.left));++ float border_width = is_horizontal ? dashed_border.x : dashed_border.y;dash_velocity = dv_numerator / border_width;t = is_horizontal ? point.x : point.y;t *= dash_velocity;diff --git a/crates/gpui/src/platform/windows/shaders.hlsl b/crates/gpui/src/platform/windows/shaders.hlslindex 1915802d08d..c3ad2952dbf 100644--- a/crates/gpui/src/platform/windows/shaders.hlsl+++ b/crates/gpui/src/platform/windows/shaders.hlsl@@ -660,7 +660,14 @@ float4 quad_fragment(QuadFragmentInput input): SV_Target {// out on each straight line, rather than around the whole// perimeter. This way each line starts and ends with a dash.bool is_horizontal = corner_center_to_point.x < corner_center_to_point.y;- float border_width = is_horizontal ? border.x : border.y;+ // Choosing the right border width for dashed borders.+ // TODO: A better solution exists taking a look at the whole file.+ // this does not fix single dashed borders at the corners+ float2 dashed_border = float2(+ max(quad.border_widths.bottom, quad.border_widths.top),+ max(quad.border_widths.right, quad.border_widths.left)+ );+ float border_width = is_horizontal ? dashed_border.x : dashed_border.y;dash_velocity = dv_numerator / border_width;t = is_horizontal ? the_point.x : the_point.y;t *= dash_velocity;