diff --git a/src/cli/screenshot.rs b/src/cli/screenshot.rs index 047f30b3..eeeae8e9 100644 --- a/src/cli/screenshot.rs +++ b/src/cli/screenshot.rs @@ -7,7 +7,7 @@ use { video::{ dmabuf::{DmaBuf, DmaBufIds, DmaBufPlane, PlaneVec}, drm::Drm, - gbm::{GbmDevice, GBM_BO_USE_LINEAR, GBM_BO_USE_RENDERING}, + gbm::GbmDevice, }, wire::{ jay_compositor::TakeScreenshot, @@ -137,7 +137,7 @@ pub fn buf_to_bytes(dev: &Rc<OwnedFd>, buf: &DmaBuf, format: ScreenshotFormat) - fatal!("Could not create a gbm device: {}", ErrorFmt(e)); } }; - let bo = match gbm.import_dmabuf(&buf, GBM_BO_USE_LINEAR | GBM_BO_USE_RENDERING) { + let bo = match gbm.import_dmabuf(&buf, 0) { Ok(bo) => Rc::new(bo), Err(e) => { fatal!("Could not import screenshot dmabuf: {}", ErrorFmt(e)); diff --git a/src/it/test_gfx_api.rs b/src/it/test_gfx_api.rs index 4dd2f5b4..b4f8d2c9 100644 --- a/src/it/test_gfx_api.rs +++ b/src/it/test_gfx_api.rs @@ -11,7 +11,7 @@ use { dmabuf::DmaBuf, drm::{sync_obj::SyncObjCtx, Drm, DrmError}, gbm::{GbmBo, GbmDevice, GbmError}, - LINEAR_MODIFIER, + INVALID_MODIFIER, }, }, ahash::AHashMap, @@ -65,7 +65,7 @@ impl TestGfxCtx { let gbm = GbmDevice::new(drm).map_err(TestGfxError::CreateGbmDevice)?; let ctx = Rc::new(SyncObjCtx::new(drm.fd())); let mut modifiers = IndexSet::new(); - modifiers.insert(LINEAR_MODIFIER); + modifiers.insert(INVALID_MODIFIER); let mut formats = AHashMap::new(); for f in [XRGB8888, ARGB8888] { formats.insert( diff --git a/src/screenshoter.rs b/src/screenshoter.rs index 4f9454c9..52c6b678 100644 --- a/src/screenshoter.rs +++ b/src/screenshoter.rs @@ -6,8 +6,7 @@ use { state::State, video::{ drm::DrmError, - gbm::{GbmBo, GbmError, GBM_BO_USE_LINEAR, GBM_BO_USE_RENDERING}, - INVALID_MODIFIER, LINEAR_MODIFIER, + gbm::{GbmBo, GbmError, GBM_BO_USE_RENDERING}, }, }, jay_config::video::Transform, @@ -30,8 +29,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 cannot render to XRGB8888")] + NoModifiers, } pub struct Screenshot { @@ -52,16 +51,13 @@ pub fn take_screenshot( return Err(ScreenshooterError::EmptyDisplay); } let formats = ctx.formats(); - let mut usage = GBM_BO_USE_RENDERING; let modifiers = 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 |= GBM_BO_USE_LINEAR; - &[INVALID_MODIFIER] - } - Some(_) => return Err(ScreenshooterError::Linear), + Some(f) => &f.write_modifiers, }; + if modifiers.is_empty() { + return Err(ScreenshooterError::NoModifiers); + } let gbm = ctx.gbm(); let bo = gbm.create_bo( &state.dma_buf_ids, @@ -69,7 +65,7 @@ pub fn take_screenshot( extents.height(), XRGB8888, modifiers, - usage, + GBM_BO_USE_RENDERING, )?; let fb = ctx.clone().dmabuf_fb(bo.dmabuf())?; fb.render_node(