Skip to content

Commit

Permalink
Merge pull request #249 from mahkoh/non-linear-screenshots
Browse files Browse the repository at this point in the history
screenshots: don't force linear modifier
  • Loading branch information
mahkoh authored Sep 2, 2024
2 parents 940aeca + e11548f commit ce5e785
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
4 changes: 0 additions & 4 deletions src/cli/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ pub fn buf_to_bytes(
buf: &DmaBuf,
format: ScreenshotFormat,
) -> Result<Vec<u8>, ScreenshotError> {
match drm_dev {
None => {}
Some(_) => {}
}
let mut allocators =
Vec::<Box<dyn FnOnce() -> Result<Rc<dyn Allocator>, ScreenshotError>>>::new();
match drm_dev {
Expand Down
29 changes: 15 additions & 14 deletions src/screenshoter.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand All @@ -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 {
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tool_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit ce5e785

Please sign in to comment.