diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout/focus_ring.rs | 15 | ||||
| -rw-r--r-- | src/layout/tile.rs | 7 | ||||
| -rw-r--r-- | src/render_helpers/border.rs | 43 | ||||
| -rw-r--r-- | src/render_helpers/shaders/border.frag | 174 | ||||
| -rw-r--r-- | src/render_helpers/shaders/mod.rs | 2 | ||||
| -rw-r--r-- | src/window/mapped.rs | 7 |
6 files changed, 226 insertions, 22 deletions
diff --git a/src/layout/focus_ring.rs b/src/layout/focus_ring.rs index 97a1b75a..7cd73760 100644 --- a/src/layout/focus_ring.rs +++ b/src/layout/focus_ring.rs @@ -1,7 +1,7 @@ use std::iter::zip; use arrayvec::ArrayVec; -use niri_config::{CornerRadius, Gradient, GradientRelativeTo}; +use niri_config::{CornerRadius, Gradient, GradientInterpolation, GradientRelativeTo}; use smithay::backend::renderer::element::Kind; use smithay::utils::{Logical, Point, Rectangle, Size}; @@ -72,7 +72,7 @@ impl FocusRing { }; for buf in &mut self.buffers { - buf.set_color(color.into()); + buf.set_color(color.to_array_premul()); } let radius = radius.fit_to(self.full_size.w as f32, self.full_size.h as f32); @@ -91,6 +91,7 @@ impl FocusRing { to: color, angle: 0, relative_to: GradientRelativeTo::Window, + in_: GradientInterpolation::default(), }); let full_rect = Rectangle::from_loc_and_size((-width, -width), self.full_size); @@ -178,8 +179,9 @@ impl FocusRing { border.update( size, Rectangle::from_loc_and_size(gradient_area.loc - loc, gradient_area.size), - gradient.from.into(), - gradient.to.into(), + gradient.in_, + gradient.from, + gradient.to, ((gradient.angle as f32) - 90.).to_radians(), Rectangle::from_loc_and_size(full_rect.loc - loc, full_rect.size), rounded_corner_border_width, @@ -198,8 +200,9 @@ impl FocusRing { gradient_area.loc - self.locations[0], gradient_area.size, ), - gradient.from.into(), - gradient.to.into(), + gradient.in_, + gradient.from, + gradient.to, ((gradient.angle as f32) - 90.).to_radians(), Rectangle::from_loc_and_size(full_rect.loc - self.locations[0], full_rect.size), rounded_corner_border_width, diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 710add83..167ff2c6 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -1,7 +1,7 @@ use std::rc::Rc; use std::time::Duration; -use niri_config::CornerRadius; +use niri_config::{Color, CornerRadius, GradientInterpolation}; use smithay::backend::allocator::Fourcc; use smithay::backend::renderer::element::{Element, Kind}; use smithay::backend::renderer::gles::GlesRenderer; @@ -757,8 +757,9 @@ impl<W: LayoutElement> Tile<W> { return BorderRenderElement::new( geo.size, Rectangle::from_loc_and_size((0., 0.), geo.size), - elem.color(), - elem.color(), + GradientInterpolation::default(), + Color::from_array_premul(elem.color()), + Color::from_array_premul(elem.color()), 0., Rectangle::from_loc_and_size((0., 0.), geo.size), 0., diff --git a/src/render_helpers/border.rs b/src/render_helpers/border.rs index c3442425..c0ab6663 100644 --- a/src/render_helpers/border.rs +++ b/src/render_helpers/border.rs @@ -1,7 +1,9 @@ use std::collections::HashMap; use glam::{Mat3, Vec2}; -use niri_config::CornerRadius; +use niri_config::{ + Color, CornerRadius, GradientColorSpace, GradientInterpolation, HueInterpolation, +}; use smithay::backend::renderer::element::{Element, Id, Kind, RenderElement, UnderlyingStorage}; use smithay::backend::renderer::gles::{GlesError, GlesFrame, GlesRenderer, Uniform}; use smithay::backend::renderer::utils::{CommitCounter, DamageSet, OpaqueRegions}; @@ -28,8 +30,9 @@ pub struct BorderRenderElement { struct Parameters { size: Size<f64, Logical>, gradient_area: Rectangle<f64, Logical>, - color_from: [f32; 4], - color_to: [f32; 4], + gradient_format: GradientInterpolation, + color_from: Color, + color_to: Color, angle: f32, geometry: Rectangle<f64, Logical>, border_width: f32, @@ -43,8 +46,9 @@ impl BorderRenderElement { pub fn new( size: Size<f64, Logical>, gradient_area: Rectangle<f64, Logical>, - color_from: [f32; 4], - color_to: [f32; 4], + gradient_format: GradientInterpolation, + color_from: Color, + color_to: Color, angle: f32, geometry: Rectangle<f64, Logical>, border_width: f32, @@ -57,6 +61,7 @@ impl BorderRenderElement { params: Parameters { size, gradient_area, + gradient_format, color_from, color_to, angle, @@ -77,6 +82,7 @@ impl BorderRenderElement { params: Parameters { size: Default::default(), gradient_area: Default::default(), + gradient_format: GradientInterpolation::default(), color_from: Default::default(), color_to: Default::default(), angle: 0., @@ -97,8 +103,9 @@ impl BorderRenderElement { &mut self, size: Size<f64, Logical>, gradient_area: Rectangle<f64, Logical>, - color_from: [f32; 4], - color_to: [f32; 4], + gradient_format: GradientInterpolation, + color_from: Color, + color_to: Color, angle: f32, geometry: Rectangle<f64, Logical>, border_width: f32, @@ -108,6 +115,7 @@ impl BorderRenderElement { let params = Parameters { size, gradient_area, + gradient_format, color_from, color_to, angle, @@ -128,6 +136,7 @@ impl BorderRenderElement { let Parameters { size, gradient_area, + gradient_format, color_from, color_to, angle, @@ -162,13 +171,29 @@ impl BorderRenderElement { let input_to_geo = Mat3::from_scale(area_size) * Mat3::from_translation(-geo_loc / area_size); + let colorspace = match gradient_format.color_space { + GradientColorSpace::Srgb => 0., + GradientColorSpace::SrgbLinear => 1., + GradientColorSpace::Oklab => 2., + GradientColorSpace::Oklch => 3., + }; + + let hue_interpolation = match gradient_format.hue_interpolation { + HueInterpolation::Shorter => 0., + HueInterpolation::Longer => 1., + HueInterpolation::Increasing => 2., + HueInterpolation::Decreasing => 3., + }; + self.inner.update( size, None, scale, vec