Make clear color a const

The damage tracker doesn't understand clear color changes.
This commit is contained in:
Ivan Molodetskikh
2023-10-13 13:18:50 +04:00
parent 29053a807b
commit d59fe34243
3 changed files with 8 additions and 15 deletions
+2 -2
View File
@@ -39,7 +39,7 @@ use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
use smithay_drm_extras::edid::EdidInfo; use smithay_drm_extras::edid::EdidInfo;
use crate::config::Config; use crate::config::Config;
use crate::niri::{OutputRenderElements, State, RedrawState}; use crate::niri::{OutputRenderElements, State, RedrawState, CLEAR_COLOR};
use crate::utils::get_monotonic_time; use crate::utils::get_monotonic_time;
use crate::Niri; use crate::Niri;
@@ -861,7 +861,7 @@ impl Tty {
match drm_compositor.render_frame::<_, _, GlesTexture>( match drm_compositor.render_frame::<_, _, GlesTexture>(
&mut device.gles, &mut device.gles,
elements, elements,
niri.clear_color(), CLEAR_COLOR,
) { ) {
Ok(res) => { Ok(res) => {
if self if self
+2 -3
View File
@@ -19,7 +19,7 @@ use smithay::utils::Transform;
use super::RenderResult; use super::RenderResult;
use crate::config::Config; use crate::config::Config;
use crate::niri::{OutputRenderElements, RedrawState, State}; use crate::niri::{OutputRenderElements, RedrawState, State, CLEAR_COLOR};
use crate::utils::get_monotonic_time; use crate::utils::get_monotonic_time;
use crate::Niri; use crate::Niri;
@@ -157,10 +157,9 @@ impl Winit {
self.backend.bind().unwrap(); self.backend.bind().unwrap();
let age = self.backend.buffer_age().unwrap(); let age = self.backend.buffer_age().unwrap();
let clear_color = niri.clear_color();
let res = self let res = self
.damage_tracker .damage_tracker
.render_output(self.backend.renderer(), age, elements, clear_color) .render_output(self.backend.renderer(), age, elements, CLEAR_COLOR)
.unwrap(); .unwrap();
niri.update_primary_scanout_output(output, &res.states); niri.update_primary_scanout_output(output, &res.states);
+4 -10
View File
@@ -84,6 +84,8 @@ use crate::layout::{output_size, Layout, MonitorRenderElement};
use crate::pw_utils::{Cast, PipeWire}; use crate::pw_utils::{Cast, PipeWire};
use crate::utils::{center, get_monotonic_time, make_screenshot_path}; use crate::utils::{center, get_monotonic_time, make_screenshot_path};
pub const CLEAR_COLOR: [f32; 4] = [0.2, 0.2, 0.2, 1.];
pub struct Niri { pub struct Niri {
pub config: Rc<RefCell<Config>>, pub config: Rc<RefCell<Config>>,
@@ -888,10 +890,6 @@ impl Niri {
}; };
} }
pub fn clear_color(&self) -> [f32; 4] {
[0.1, 0.1, 0.1, 1.0]
}
pub fn pointer_element( pub fn pointer_element(
&mut self, &mut self,
renderer: &mut GlesRenderer, renderer: &mut GlesRenderer,
@@ -1416,7 +1414,6 @@ impl Niri {
let size = output.current_mode().unwrap().size; let size = output.current_mode().unwrap().size;
let scale = Scale::from(output.current_scale().fractional_scale()); let scale = Scale::from(output.current_scale().fractional_scale());
let clear_color = self.clear_color();
for cast in &mut self.casts { for cast in &mut self.casts {
if !cast.is_active.get() { if !cast.is_active.get() {
@@ -1452,9 +1449,7 @@ impl Niri {
let dmabuf = cast.dmabufs.borrow()[&fd].clone(); let dmabuf = cast.dmabufs.borrow()[&fd].clone();
// FIXME: Hidden / embedded / metadata cursor // FIXME: Hidden / embedded / metadata cursor
if let Err(err) = if let Err(err) = render_to_dmabuf(renderer, dmabuf, size, scale, elements) {
render_to_dmabuf(renderer, dmabuf, size, scale, clear_color, elements)
{
error!("error rendering to dmabuf: {err:?}"); error!("error rendering to dmabuf: {err:?}");
continue; continue;
} }
@@ -1737,7 +1732,6 @@ fn render_to_dmabuf(
dmabuf: smithay::backend::allocator::dmabuf::Dmabuf, dmabuf: smithay::backend::allocator::dmabuf::Dmabuf,
size: Size<i32, Physical>, size: Size<i32, Physical>,
scale: Scale<f64>, scale: Scale<f64>,
clear_color: [f32; 4],
elements: &[OutputRenderElements<GlesRenderer>], elements: &[OutputRenderElements<GlesRenderer>],
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
use smithay::backend::renderer::element::Element; use smithay::backend::renderer::element::Element;
@@ -1752,7 +1746,7 @@ fn render_to_dmabuf(
.context("error starting frame")?; .context("error starting frame")?;
frame frame
.clear(clear_color, &[output_rect]) .clear(CLEAR_COLOR, &[output_rect])
.context("error clearing")?; .context("error clearing")?;
for element in elements.iter().rev() { for element in elements.iter().rev() {