From bb300b629015229d3137eba522a9a3ca05efb625 Mon Sep 17 00:00:00 2001 From: K's Thinkpad Date: Fri, 12 Jul 2024 20:23:18 +0200 Subject: [PATCH] fixed the problem with 0 alpha would cause information loss --- niri-config/src/lib.rs | 7 ++++++- src/render_helpers/shaders/border.frag | 11 +++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index 80612ff..879b2c9 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -529,7 +529,8 @@ impl Color { impl From for [f32; 4] { fn from(c: Color) -> Self { let [r, g, b, a] = [c.r, c.g, c.b, c.a].map(|x| x as f32 / 255.); - [r * a, g * a, b * a, a] + //[r * a, g * a, b * a, a] + [r, g, b, a] } } @@ -2853,6 +2854,10 @@ mod tests { to: Color::new(0, 128, 255, 255), angle: 180, relative_to: GradientRelativeTo::WorkspaceView, + in_ : GradientInterpolation { + color_space: GradientColorSpace::Srgb, + hue_interpol: HueInterpolation::Shorter, + } }), inactive_gradient: None, }, diff --git a/src/render_helpers/shaders/border.frag b/src/render_helpers/shaders/border.frag index d665797..3f92554 100644 --- a/src/render_helpers/shaders/border.frag +++ b/src/render_helpers/shaders/border.frag @@ -98,16 +98,15 @@ vec3 oklab_to_linear(vec3 color){ vec4 color_mix(vec4 color1, vec4 color2, float color_ratio) { // srgb + + vec4 color_out; if (colorspace == 0.0) { - return mix(color1, color2, color_ratio); + color_out = mix(color1, color2, color_ratio); + color_out.rgb = color_out.rgb * color_out.a; + return color_out; } - - vec4 color_out; - color1.rgb /= color1.a != 0.0 ? color1.a : 1.0; - color2.rgb /= color2.a != 0.0 ? color2.a : 1.0; - color1.rgb = vec3( srgb_to_linear(color1.r), srgb_to_linear(color1.g),