From e11548fd8ad77a6823260145127b140a10544bff Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Mon, 2 Sep 2024 18:01:56 +0200 Subject: [PATCH] screenshots: don't force linear modifier --- src/cli/screenshot.rs | 4 ---- src/screenshoter.rs | 29 +++++++++++++++-------------- src/tools/tool_client.rs | 2 +- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/cli/screenshot.rs b/src/cli/screenshot.rs index c3c2dec1..b0d20522 100644 --- a/src/cli/screenshot.rs +++ b/src/cli/screenshot.rs @@ -161,10 +161,6 @@ pub fn buf_to_bytes( buf: &DmaBuf, format: ScreenshotFormat, ) -> Result, ScreenshotError> { - match drm_dev { - None => {} - Some(_) => {} - } let mut allocators = Vec:: Result, ScreenshotError>>>::new(); match drm_dev { diff --git a/src/screenshoter.rs b/src/screenshoter.rs index f0211d76..f03ed088 100644 --- a/src/screenshoter.rs +++ b/src/screenshoter.rs @@ -1,11 +1,11 @@ use { crate::{ - allocator::{AllocatorError, BufferObject, BO_USE_LINEAR, BO_USE_RENDERING}, + allocator::{AllocatorError, BufferObject, BO_USE_RENDERING}, format::XRGB8888, gfx_api::GfxError, scale::Scale, state::State, - video::{drm::DrmError, INVALID_MODIFIER, LINEAR_MODIFIER}, + video::drm::DrmError, }, jay_config::video::Transform, std::{ops::Deref, rc::Rc}, @@ -27,8 +27,8 @@ pub enum ScreenshooterError { DrmError(#[from] DrmError), #[error("Render context does not support XRGB8888")] XRGB8888, - #[error("Render context supports neither linear nor invalid modifier for XRGB8888 rendering")] - Linear, + #[error("Render context supports no modifiers for XRGB8888 rendering")] + Modifiers, } pub struct Screenshot { @@ -49,24 +49,25 @@ pub fn take_screenshot( return Err(ScreenshooterError::EmptyDisplay); } let formats = ctx.formats(); - let mut usage = BO_USE_RENDERING; - let modifiers = match formats.get(&XRGB8888.drm) { + let modifiers: Vec<_> = match formats.get(&XRGB8888.drm) { None => return Err(ScreenshooterError::XRGB8888), - Some(f) if f.write_modifiers.contains(&LINEAR_MODIFIER) => &[LINEAR_MODIFIER], - Some(f) if f.write_modifiers.contains(&INVALID_MODIFIER) => { - usage |= BO_USE_LINEAR; - &[INVALID_MODIFIER] - } - Some(_) => return Err(ScreenshooterError::Linear), + Some(f) => f + .write_modifiers + .intersection(&f.read_modifiers) + .copied() + .collect(), }; + if modifiers.is_empty() { + return Err(ScreenshooterError::Modifiers); + } let allocator = ctx.allocator(); let bo = allocator.create_bo( &state.dma_buf_ids, extents.width(), extents.height(), XRGB8888, - modifiers, - usage, + &modifiers, + BO_USE_RENDERING, )?; let fb = ctx.clone().dmabuf_fb(bo.dmabuf())?; fb.render_node( diff --git a/src/tools/tool_client.rs b/src/tools/tool_client.rs index 5468132a..1b489374 100644 --- a/src/tools/tool_client.rs +++ b/src/tools/tool_client.rs @@ -330,7 +330,7 @@ impl ToolClient { self_id: s.registry, name: s.jay_compositor.0, interface: JayCompositor.name(), - version: s.jay_compositor.1.min(4), + version: s.jay_compositor.1.min(6), id: id.into(), }); self.jay_compositor.set(Some(id));