Skip to content

Commit a03b762

Browse files
authored
Revert "gpui & ui: Use shader for dashed dividers" (zed-industries#23850)
Reverts zed-industries#23839 getting some reports of linux crashes – will investigate later today Release Notes: - N/A
1 parent 8603a90 commit a03b762

File tree

8 files changed

+72
-176
lines changed

8 files changed

+72
-176
lines changed

.zed/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
}
4040
},
4141
"file_types": {
42-
"C": ["metal"],
4342
"Dockerfile": ["Dockerfile*[!dockerignore]"],
4443
"Git Ignore": ["dockerignore"]
4544
},

crates/gpui/examples/pattern.rs

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use gpui::{
2-
div, linear_color_stop, linear_gradient, pattern_horizontal_dash, pattern_slash,
3-
pattern_vertical_dash, prelude::*, px, rgb, size, App, AppContext, Application, Bounds,
4-
Context, Window, WindowBounds, WindowOptions,
2+
div, linear_color_stop, linear_gradient, pattern_slash, prelude::*, px, rgb, size, App,
3+
AppContext, Application, Bounds, Context, Window, WindowBounds, WindowOptions,
54
};
65

76
struct PatternExample;
@@ -20,58 +19,6 @@ impl Render for PatternExample {
2019
.text_xl()
2120
.text_color(rgb(0x000000))
2221
.child("Pattern Example")
23-
.child(
24-
div()
25-
.flex()
26-
.gap_4()
27-
.child(
28-
div()
29-
.flex()
30-
.flex_col()
31-
.gap_1()
32-
.child(
33-
div()
34-
.w(px(160.0))
35-
.h(px(1.0))
36-
.bg(pattern_horizontal_dash(gpui::red())),
37-
)
38-
.child(
39-
div()
40-
.w(px(160.0))
41-
.h(px(4.0))
42-
.bg(pattern_horizontal_dash(gpui::red())),
43-
)
44-
.child(
45-
div()
46-
.w(px(160.0))
47-
.h(px(8.0))
48-
.bg(pattern_horizontal_dash(gpui::red())),
49-
),
50-
)
51-
.child(
52-
div()
53-
.flex()
54-
.gap_1()
55-
.child(
56-
div()
57-
.w(px(1.0))
58-
.h(px(160.0))
59-
.bg(pattern_vertical_dash(gpui::blue())),
60-
)
61-
.child(
62-
div()
63-
.w(px(4.0))
64-
.h(px(160.0))
65-
.bg(pattern_vertical_dash(gpui::blue())),
66-
)
67-
.child(
68-
div()
69-
.w(px(8.0))
70-
.h(px(160.0))
71-
.bg(pattern_vertical_dash(gpui::blue())),
72-
),
73-
),
74-
)
7522
.child(
7623
div()
7724
.flex()

crates/gpui/src/color.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -548,33 +548,12 @@ impl<'de> Deserialize<'de> for Hsla {
548548
}
549549
}
550550

551-
/// The orientation of a background.
552-
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
553-
#[repr(C)]
554-
pub enum BackgroundOrientation {
555-
/// The background is oriented horizontally.
556-
#[default]
557-
Horizontal = 0,
558-
/// The background is oriented vertically.
559-
Vertical = 1,
560-
}
561-
562-
impl Display for BackgroundOrientation {
563-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
564-
match self {
565-
BackgroundOrientation::Horizontal => write!(f, "Horizontal"),
566-
BackgroundOrientation::Vertical => write!(f, "Vertical"),
567-
}
568-
}
569-
}
570-
571551
#[derive(Debug, Clone, Copy, PartialEq)]
572552
#[repr(C)]
573553
pub(crate) enum BackgroundTag {
574554
Solid = 0,
575555
LinearGradient = 1,
576556
PatternSlash = 2,
577-
PatternDash = 3,
578557
}
579558

580559
/// A color space for color interpolation.
@@ -610,7 +589,6 @@ pub struct Background {
610589
pub(crate) solid: Hsla,
611590
pub(crate) angle: f32,
612591
pub(crate) colors: [LinearColorStop; 2],
613-
pub(crate) orientation: BackgroundOrientation,
614592
/// Padding for alignment for repr(C) layout.
615593
pad: u32,
616594
}
@@ -624,7 +602,6 @@ impl Default for Background {
624602
color_space: ColorSpace::default(),
625603
angle: 0.0,
626604
colors: [LinearColorStop::default(), LinearColorStop::default()],
627-
orientation: BackgroundOrientation::default(),
628605
pad: 0,
629606
}
630607
}
@@ -639,26 +616,6 @@ pub fn pattern_slash(color: Hsla) -> Background {
639616
}
640617
}
641618

642-
/// Creates a dash pattern background
643-
pub fn pattern_horizontal_dash(color: Hsla) -> Background {
644-
Background {
645-
tag: BackgroundTag::PatternDash,
646-
orientation: BackgroundOrientation::Horizontal,
647-
solid: color,
648-
..Default::default()
649-
}
650-
}
651-
652-
/// Creates a vertical dash pattern background
653-
pub fn pattern_vertical_dash(color: Hsla) -> Background {
654-
Background {
655-
tag: BackgroundTag::PatternDash,
656-
solid: color,
657-
orientation: BackgroundOrientation::Vertical,
658-
..Default::default()
659-
}
660-
}
661-
662619
/// Creates a LinearGradient background color.
663620
///
664621
/// The gradient line's angle of direction. A value of `0.` is equivalent to to top; increasing values rotate clockwise from there.
@@ -737,7 +694,6 @@ impl Background {
737694
BackgroundTag::Solid => self.solid.is_transparent(),
738695
BackgroundTag::LinearGradient => self.colors.iter().all(|c| c.color.is_transparent()),
739696
BackgroundTag::PatternSlash => self.solid.is_transparent(),
740-
BackgroundTag::PatternDash => self.solid.is_transparent(),
741697
}
742698
}
743699
}

crates/gpui/src/platform/blade/shaders.wgsl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ fn gradient_color(background: Background, position: vec2<f32>, bounds: Bounds,
359359
}
360360
}
361361
case 2u: {
362-
// Slash pattern
363362
let base_pattern_size = bounds.size.y / 5.0;
364363
let width = base_pattern_size * 0.5;
365364
let slash_spacing = 0.89;
@@ -375,21 +374,6 @@ fn gradient_color(background: Background, position: vec2<f32>, bounds: Bounds,
375374
background_color = sold_color;
376375
background_color.a *= saturate(0.5 - distance);
377376
}
378-
case 3u: {
379-
// Dash pattern
380-
let dash_width = 8.0;
381-
let gap_width = 8.0;
382-
let pattern_width = dash_width + gap_width;
383-
let relative_position = position - bounds.origin;
384-
385-
// Use a dot product to select x or y based on orientation
386-
let orientation_vector = vec2<f32>(1.0 - f32(background.angle != 0.0), f32(background.angle != 0.0));
387-
let pattern_position = fmod(dot(relative_position, orientation_vector), pattern_width);
388-
389-
let distance = pattern_position - dash_width;
390-
background_color = sold_color;
391-
background_color.a *= step(-distance, 0.0);
392-
}
393377
}
394378

395379
return background_color;

crates/gpui/src/platform/mac/shaders.metal

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ float4 over(float4 below, float4 above) {
797797
GradientColor prepare_fill_color(uint tag, uint color_space, Hsla solid,
798798
Hsla color0, Hsla color1) {
799799
GradientColor out;
800-
if (tag == 0 || tag == 2 || tag == 3) {
800+
if (tag == 0 || tag == 2) {
801801
out.solid = hsla_to_rgba(solid);
802802
} else if (tag == 1) {
803803
out.color0 = hsla_to_rgba(color0);
@@ -874,10 +874,13 @@ float4 fill_color(Background background,
874874
break;
875875
}
876876
case 2: {
877-
// Slash pattern
877+
// This pattern is full of magic numbers to make it line up perfectly
878+
// when vertically stacked. Make sure you know what you are doing
879+
// if you change this!
880+
878881
float base_pattern_size = bounds.size.height / 5;
879882
float width = base_pattern_size * 0.5;
880-
float slash_spacing = .89; // exact number to make vertical elements line up
883+
float slash_spacing = .89;
881884
float radians = M_PI_F / 4.0;
882885
float2x2 rotation = rotate2d(radians);
883886
float2 relative_position = position - float2(bounds.origin.x, bounds.origin.y);
@@ -888,22 +891,6 @@ float4 fill_color(Background background,
888891
color.a *= saturate(0.5 - distance);
889892
break;
890893
}
891-
case 3: {
892-
// Dash pattern
893-
float dash_width = 8.0;
894-
float gap_width = 8.0;
895-
float pattern_width = dash_width + gap_width;
896-
float2 relative_position = position - float2(bounds.origin.x, bounds.origin.y);
897-
898-
// Use a dot product to select x or y based on orientation
899-
float2 orientation_vector = float2(1.0 - background.orientation, background.orientation);
900-
float pattern_position = fmod(dot(relative_position, orientation_vector), pattern_width);
901-
902-
float distance = pattern_position - dash_width;
903-
color = solid_color;
904-
color.a *= step(-distance, 0.0);
905-
break;
906-
}
907894
}
908895

909896
return color;

crates/gpui/src/style.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,6 @@ impl Style {
583583
.map(|stop| stop.color)
584584
.unwrap_or_default(),
585585
BackgroundTag::PatternSlash => color.solid,
586-
BackgroundTag::PatternDash => color.solid,
587586
},
588587
None => Hsla::default(),
589588
};

0 commit comments

Comments
 (0)