kms/surface: Define a PendingImageCopyData, instead of using tuple

Adding anything else to this tuple is awkward; defining a simple struct
makes this cleaner.

This also adds a `sync` property, which will come in handy later.
Containing simply the same-named argument that was passed to
`submit_buffer`.
This commit is contained in:
Ian Douglas Scott 2025-08-19 12:45:07 -07:00 committed by Victoria Brekenfeld
parent f0e0084608
commit 28e9024681
4 changed files with 34 additions and 24 deletions

View file

@ -8,7 +8,7 @@ use crate::{
config::{AdaptiveSync, EdidProduct, OutputConfig, OutputState, ScreenFilter},
shell::Shell,
utils::{env::dev_list_var, prelude::*},
wayland::protocols::screencopy::Frame,
wayland::handlers::screencopy::PendingImageCopyData,
};
use anyhow::{Context, Result};
@ -39,9 +39,7 @@ use smithay::{
rustix::fs::OFlags,
wayland_server::{protocol::wl_buffer::WlBuffer, DisplayHandle, Weak},
},
utils::{
Buffer as BufferCoords, Clock, DevPath, DeviceFd, Monotonic, Point, Rectangle, Transform,
},
utils::{Clock, DevPath, DeviceFd, Monotonic, Point, Transform},
wayland::drm_lease::{DrmLease, DrmLeaseState},
};
use tracing::{error, info, warn};
@ -71,7 +69,7 @@ pub type LockedGbmDrmOutputManager<'a> = LockedDrmOutputManager<
GbmFramebufferExporter<DrmDeviceFd>,
Option<(
OutputPresentationFeedback,
Receiver<(Frame, Vec<Rectangle<i32, BufferCoords>>)>,
Receiver<PendingImageCopyData>,
Duration,
)>,
DrmDeviceFd,
@ -82,7 +80,7 @@ pub type GbmDrmOutputManager = DrmOutputManager<
GbmFramebufferExporter<DrmDeviceFd>,
Option<(
OutputPresentationFeedback,
Receiver<(Frame, Vec<Rectangle<i32, BufferCoords>>)>,
Receiver<PendingImageCopyData>,
Duration,
)>,
DrmDeviceFd,

View file

@ -13,7 +13,7 @@ use crate::{
wayland::{
handlers::{
compositor::recursive_frame_time_estimation,
screencopy::{submit_buffer, FrameHolder, SessionData},
screencopy::{submit_buffer, FrameHolder, PendingImageCopyData, SessionData},
},
protocols::screencopy::{
FailureReason, Frame as ScreencopyFrame, SessionRef as ScreencopySessionRef,
@ -78,7 +78,7 @@ use smithay::{
},
wayland_server::protocol::wl_surface::WlSurface,
},
utils::{Buffer as BufferCoords, Clock, Monotonic, Physical, Point, Rectangle, Transform},
utils::{Clock, Monotonic, Physical, Point, Rectangle, Transform},
wayland::{
dmabuf::{get_dmabuf, DmabufFeedbackBuilder},
presentation::Refresh,
@ -172,7 +172,7 @@ pub type GbmDrmOutput = DrmOutput<
GbmFramebufferExporter<DrmDeviceFd>,
Option<(
OutputPresentationFeedback,
Receiver<(ScreencopyFrame, Vec<Rectangle<i32, BufferCoords>>)>,
Receiver<PendingImageCopyData>,
Duration,
)>,
DrmDeviceFd,
@ -819,7 +819,7 @@ impl SurfaceThreadState {
self.timings.presented(clock);
while let Ok((frame, damage)) = frames.recv() {
while let Ok(PendingImageCopyData { frame, damage, .. }) = frames.recv() {
frame.success(self.output.current_transform(), damage, clock);
}
}
@ -1635,7 +1635,7 @@ fn send_screencopy_result<'a>(
renderer: &mut GlMultiRenderer<'a>,
output: &Output,
pre_postprocess_data: &mut PrePostprocessData,
tx: &std::sync::mpsc::Sender<(ScreencopyFrame, Vec<Rectangle<i32, BufferCoords>>)>,
tx: &std::sync::mpsc::Sender<PendingImageCopyData>,
frame_result: &RenderFrameResult<GbmBuffer, GbmFramebuffer, CosmicElement<GlMultiRenderer<'a>>>,
elements: &[CosmicElement<GlMultiRenderer>],
(session, frame, res): (
@ -1807,7 +1807,7 @@ fn send_screencopy_result<'a>(
let transform = output.current_transform();
if let Some((frame, damage)) = submit_buffer(
if let Some(data) = submit_buffer(
frame,
renderer,
shm_buffer.then_some(fb.as_mut().unwrap()),
@ -1816,9 +1816,10 @@ fn send_screencopy_result<'a>(
sync,
)? {
if frame_result.is_empty {
frame.success(transform, damage, presentation_time);
data.frame
.success(transform, data.damage, presentation_time);
} else {
let _ = tx.send((frame, damage));
let _ = tx.send(data);
}
}

View file

@ -28,7 +28,7 @@ use crate::{
handlers::{
compositor::FRAME_TIME_FILTER,
data_device::get_dnd_icon,
screencopy::{render_session, FrameHolder, SessionData},
screencopy::{render_session, FrameHolder, PendingImageCopyData, SessionData},
},
protocols::workspace::WorkspaceHandle,
},
@ -1332,7 +1332,11 @@ where
match result {
Ok((res, mut elements)) => {
for (session, frame) in output.take_pending_frames() {
if let Some((frame, damage)) = render_session::<_, _, GlesTexture>(
if let Some(PendingImageCopyData { frame, damage, .. }) = render_session::<
_,
_,
GlesTexture,
>(
renderer,
&session.user_data().get::<SessionData>().unwrap(),
frame,