forge
Explore
Log in

Don't you dare go Hollow

Make clear color a const

Browse files at this commit

d59fe3424374149ef99f7fac651e1425f5c75071Ivan MolodetskikhParent: 29053a8
The damage tracker doesn't understand clear color changes.
src/backend/tty.rsmodified+2 -2
@@ -39,7 +39,7 @@ use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
39 use smithay_drm_extras::edid::EdidInfo;39 use smithay_drm_extras::edid::EdidInfo;
40 40
41 use crate::config::Config;41 use crate::config::Config;
42-use crate::niri::{OutputRenderElements, State, RedrawState};42+use crate::niri::{OutputRenderElements, State, RedrawState, CLEAR_COLOR};
43 use crate::utils::get_monotonic_time;43 use crate::utils::get_monotonic_time;
44 use crate::Niri;44 use crate::Niri;
45 45
@@ -861,7 +861,7 @@ impl Tty {
861 match drm_compositor.render_frame::<_, _, GlesTexture>(861 match drm_compositor.render_frame::<_, _, GlesTexture>(
862 &mut device.gles,862 &mut device.gles,
863 elements,863 elements,
864- niri.clear_color(),864+ CLEAR_COLOR,
865 ) {865 ) {
866 Ok(res) => {866 Ok(res) => {
867 if self867 if self
src/backend/winit.rsmodified+2 -3
@@ -19,7 +19,7 @@ use smithay::utils::Transform;
19 19
20 use super::RenderResult;20 use super::RenderResult;
21 use crate::config::Config;21 use crate::config::Config;
22-use crate::niri::{OutputRenderElements, RedrawState, State};22+use crate::niri::{OutputRenderElements, RedrawState, State, CLEAR_COLOR};
23 use crate::utils::get_monotonic_time;23 use crate::utils::get_monotonic_time;
24 use crate::Niri;24 use crate::Niri;
25 25
@@ -157,10 +157,9 @@ impl Winit {
157 157
158 self.backend.bind().unwrap();158 self.backend.bind().unwrap();
159 let age = self.backend.buffer_age().unwrap();159 let age = self.backend.buffer_age().unwrap();
160- let clear_color = niri.clear_color();
161 let res = self160 let res = self
162 .damage_tracker161 .damage_tracker
163- .render_output(self.backend.renderer(), age, elements, clear_color)162+ .render_output(self.backend.renderer(), age, elements, CLEAR_COLOR)
164 .unwrap();163 .unwrap();
165 164
166 niri.update_primary_scanout_output(output, &res.states);165 niri.update_primary_scanout_output(output, &res.states);
src/niri.rsmodified+4 -10
@@ -84,6 +84,8 @@ use crate::layout::{output_size, Layout, MonitorRenderElement};
84 use crate::pw_utils::{Cast, PipeWire};84 use crate::pw_utils::{Cast, PipeWire};
85 use crate::utils::{center, get_monotonic_time, make_screenshot_path};85 use crate::utils::{center, get_monotonic_time, make_screenshot_path};
86 86
87+pub const CLEAR_COLOR: [f32; 4] = [0.2, 0.2, 0.2, 1.];
88+
87 pub struct Niri {89 pub struct Niri {
88 pub config: Rc<RefCell<Config>>,90 pub config: Rc<RefCell<Config>>,
89 91
@@ -888,10 +890,6 @@ impl Niri {
888 };890 };
889 }891 }
890 892
891- pub fn clear_color(&self) -> [f32; 4] {
892- [0.1, 0.1, 0.1, 1.0]
893- }
894-
895 pub fn pointer_element(893 pub fn pointer_element(
896 &mut self,894 &mut self,
897 renderer: &mut GlesRenderer,895 renderer: &mut GlesRenderer,
@@ -1416,7 +1414,6 @@ impl Niri {
1416 1414
1417 let size = output.current_mode().unwrap().size;1415 let size = output.current_mode().unwrap().size;
1418 let scale = Scale::from(output.current_scale().fractional_scale());1416 let scale = Scale::from(output.current_scale().fractional_scale());
1419- let clear_color = self.clear_color();
1420 1417
1421 for cast in &mut self.casts {1418 for cast in &mut self.casts {
1422 if !cast.is_active.get() {1419 if !cast.is_active.get() {
@@ -1452,9 +1449,7 @@ impl Niri {
1452 let dmabuf = cast.dmabufs.borrow()[&fd].clone();1449 let dmabuf = cast.dmabufs.borrow()[&fd].clone();
1453 1450
1454 // FIXME: Hidden / embedded / metadata cursor1451 // FIXME: Hidden / embedded / metadata cursor
1455- if let Err(err) =1452+ if let Err(err) = render_to_dmabuf(renderer, dmabuf, size, scale, elements) {
1456- render_to_dmabuf(renderer, dmabuf, size, scale, clear_color, elements)
1457- {
1458 error!("error rendering to dmabuf: {err:?}");1453 error!("error rendering to dmabuf: {err:?}");
1459 continue;1454 continue;
1460 }1455 }
@@ -1737,7 +1732,6 @@ fn render_to_dmabuf(
1737 dmabuf: smithay::backend::allocator::dmabuf::Dmabuf,1732 dmabuf: smithay::backend::allocator::dmabuf::Dmabuf,
1738 size: Size<i32, Physical>,1733 size: Size<i32, Physical>,
1739 scale: Scale<f64>,1734 scale: Scale<f64>,
1740- clear_color: [f32; 4],
1741 elements: &[OutputRenderElements<GlesRenderer>],1735 elements: &[OutputRenderElements<GlesRenderer>],
1742 ) -> anyhow::Result<()> {1736 ) -> anyhow::Result<()> {
1743 use smithay::backend::renderer::element::Element;1737 use smithay::backend::renderer::element::Element;
@@ -1752,7 +1746,7 @@ fn render_to_dmabuf(
1752 .context("error starting frame")?;1746 .context("error starting frame")?;
1753 1747
1754 frame1748 frame
1755- .clear(clear_color, &[output_rect])1749+ .clear(CLEAR_COLOR, &[output_rect])
1756 .context("error clearing")?;1750 .context("error clearing")?;
1757 1751
1758 for element in elements.iter().rev() {1752 for element in elements.iter().rev() {