Extract niri.clear_color()

This commit is contained in:
Ivan Molodetskikh
2023-10-13 10:31:30 +04:00
parent b8e6d4b7eb
commit f625dede1a
3 changed files with 13 additions and 5 deletions
+1 -2
View File
@@ -43,7 +43,6 @@ use crate::niri::{OutputRenderElements, State, RedrawState};
use crate::utils::get_monotonic_time;
use crate::Niri;
const BACKGROUND_COLOR: [f32; 4] = [0.1, 0.1, 0.1, 1.];
const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888];
pub struct Tty {
@@ -858,7 +857,7 @@ impl Tty {
match drm_compositor.render_frame::<_, _, GlesTexture>(
&mut device.gles,
elements,
BACKGROUND_COLOR,
niri.clear_color(),
) {
Ok(res) => {
if self
+2 -1
View File
@@ -157,9 +157,10 @@ impl Winit {
self.backend.bind().unwrap();
let age = self.backend.buffer_age().unwrap();
let clear_color = niri.clear_color();
let res = self
.damage_tracker
.render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0])
.render_output(self.backend.renderer(), age, elements, clear_color)
.unwrap();
niri.update_primary_scanout_output(output, &res.states);
+10 -2
View File
@@ -888,6 +888,10 @@ impl Niri {
};
}
pub fn clear_color(&self) -> [f32; 4] {
[0.1, 0.1, 0.1, 1.0]
}
pub fn pointer_element(
&mut self,
renderer: &mut GlesRenderer,
@@ -1417,6 +1421,7 @@ impl Niri {
let size = output.current_mode().unwrap().size;
let scale = Scale::from(output.current_scale().fractional_scale());
let clear_color = self.clear_color();
for cast in &mut self.casts {
if !cast.is_active.get() {
@@ -1452,7 +1457,9 @@ impl Niri {
let dmabuf = cast.dmabufs.borrow()[&fd].clone();
// FIXME: Hidden / embedded / metadata cursor
if let Err(err) = render_to_dmabuf(renderer, dmabuf, size, scale, elements) {
if let Err(err) =
render_to_dmabuf(renderer, dmabuf, size, scale, clear_color, elements)
{
error!("error rendering to dmabuf: {err:?}");
continue;
}
@@ -1735,6 +1742,7 @@ fn render_to_dmabuf(
dmabuf: smithay::backend::allocator::dmabuf::Dmabuf,
size: Size<i32, Physical>,
scale: Scale<f64>,
clear_color: [f32; 4],
elements: &[OutputRenderElements<GlesRenderer>],
) -> anyhow::Result<()> {
use smithay::backend::renderer::element::Element;
@@ -1749,7 +1757,7 @@ fn render_to_dmabuf(
.context("error starting frame")?;
frame
.clear([0.1, 0.1, 0.1, 1.], &[output_rect])
.clear(clear_color, &[output_rect])
.context("error clearing")?;
for element in elements.iter().rev() {