Add a no-subsurfaces feature for debugging
This commit is contained in:
parent
1fc416bb2e
commit
bf2cd273f9
5 changed files with 24 additions and 3 deletions
|
|
@ -38,6 +38,7 @@ default = ["wgpu"]
|
|||
wgpu = ["libcosmic/wgpu"]
|
||||
# Debugging features
|
||||
force-shm-screencopy = []
|
||||
no-subsurfaces = ["force-shm-screencopy"]
|
||||
|
||||
[profile.dev]
|
||||
# Not usable at opt-level 0, at least with software renderer
|
||||
|
|
|
|||
|
|
@ -284,7 +284,14 @@ fn toplevel_previews<'a>(
|
|||
|
||||
fn capture_image(image: Option<&CaptureImage>) -> cosmic::Element<'_, Msg> {
|
||||
if let Some(image) = image {
|
||||
Subsurface::new(image.width, image.height, &image.wl_buffer).into()
|
||||
#[cfg(feature = "no-subsurfaces")]
|
||||
{
|
||||
widget::Image::new(image.image.clone()).into()
|
||||
}
|
||||
#[cfg(not(feature = "no-subsurfaces"))]
|
||||
{
|
||||
Subsurface::new(image.width, image.height, &image.wl_buffer).into()
|
||||
}
|
||||
} else {
|
||||
widget::Image::new(widget::image::Handle::from_pixels(1, 1, vec![0, 0, 0, 255])).into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ pub struct Buffer {
|
|||
pub buffer: wl_buffer::WlBuffer,
|
||||
node: Option<PathBuf>,
|
||||
pub size: (u32, u32),
|
||||
#[cfg(feature = "no-subsurfaces")]
|
||||
pub mmap: memmap2::Mmap,
|
||||
}
|
||||
|
||||
impl AppData {
|
||||
|
|
@ -96,6 +98,9 @@ impl AppData {
|
|||
|
||||
pool.destroy();
|
||||
|
||||
#[cfg(feature = "no-subsurfaces")]
|
||||
let mmap = unsafe { memmap2::Mmap::map(&fd).unwrap() };
|
||||
|
||||
Buffer {
|
||||
backing: Arc::new(
|
||||
Shmbuf {
|
||||
|
|
@ -109,6 +114,8 @@ impl AppData {
|
|||
.into(),
|
||||
),
|
||||
buffer,
|
||||
#[cfg(feature = "no-subsurfaces")]
|
||||
mmap,
|
||||
node: None,
|
||||
size: (width, height),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@ pub struct CaptureImage {
|
|||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub wl_buffer: SubsurfaceBuffer,
|
||||
#[cfg(feature = "no-subsurfaces")]
|
||||
pub image: cosmic::widget::image::Handle,
|
||||
}
|
||||
|
||||
pub fn subscription(conn: Connection) -> iced::Subscription<Event> {
|
||||
|
|
|
|||
|
|
@ -208,12 +208,16 @@ impl ScreencopyHandler for AppData {
|
|||
let front = session.buffers.as_mut().unwrap().first_mut().unwrap();
|
||||
let (buffer, release) = SubsurfaceBuffer::new(front.backing.clone());
|
||||
session.release = Some(release);
|
||||
// let img = unsafe { front.to_image() };
|
||||
// let image = CaptureImage { img };
|
||||
let image = CaptureImage {
|
||||
wl_buffer: buffer,
|
||||
width: front.size.0,
|
||||
height: front.size.1,
|
||||
#[cfg(feature = "no-subsurfaces")]
|
||||
image: cosmic::widget::image::Handle::from_pixels(
|
||||
front.size.0,
|
||||
front.size.1,
|
||||
front.mmap.to_vec(),
|
||||
),
|
||||
};
|
||||
match &capture.source {
|
||||
CaptureSource::Toplevel(toplevel) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue