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:
parent
f0e0084608
commit
28e9024681
4 changed files with 34 additions and 24 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -54,6 +54,12 @@ use crate::{
|
|||
|
||||
use super::{super::data_device::get_dnd_icon, user_data::SessionHolder};
|
||||
|
||||
pub struct PendingImageCopyData {
|
||||
pub frame: Frame,
|
||||
pub damage: Vec<smithay::utils::Rectangle<i32, BufferCoords>>,
|
||||
pub sync: SyncPoint,
|
||||
}
|
||||
|
||||
pub fn submit_buffer<R>(
|
||||
frame: Frame,
|
||||
renderer: &mut R,
|
||||
|
|
@ -61,7 +67,7 @@ pub fn submit_buffer<R>(
|
|||
transform: Transform,
|
||||
damage: Option<&[Rectangle<i32, Physical>]>,
|
||||
sync: SyncPoint,
|
||||
) -> Result<Option<(Frame, Vec<Rectangle<i32, BufferCoords>>)>, R::Error>
|
||||
) -> Result<Option<PendingImageCopyData>, R::Error>
|
||||
where
|
||||
R: ExportMem,
|
||||
R::Error: FromGlesError,
|
||||
|
|
@ -124,16 +130,17 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
Ok(Some((
|
||||
Ok(Some(PendingImageCopyData {
|
||||
frame,
|
||||
damage
|
||||
damage: damage
|
||||
.into_iter()
|
||||
.map(|rect| {
|
||||
let logical = rect.to_logical(1);
|
||||
logical.to_buffer(1, transform, &logical.size)
|
||||
})
|
||||
.collect(),
|
||||
)))
|
||||
sync,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn render_session<F, R, T>(
|
||||
|
|
@ -142,7 +149,7 @@ pub fn render_session<F, R, T>(
|
|||
frame: Frame,
|
||||
transform: Transform,
|
||||
render_fn: F,
|
||||
) -> Result<Option<(Frame, Vec<Rectangle<i32, BufferCoords>>)>, DTError<R::Error>>
|
||||
) -> Result<Option<PendingImageCopyData>, DTError<R::Error>>
|
||||
where
|
||||
R: ExportMem + Offscreen<T>,
|
||||
R::Error: FromGlesError,
|
||||
|
|
@ -430,7 +437,7 @@ pub fn render_workspace_to_buffer(
|
|||
}
|
||||
};
|
||||
|
||||
if let Some((frame, damage)) = result {
|
||||
if let Some(PendingImageCopyData { frame, damage, .. }) = result {
|
||||
frame.success(transform, damage, common.clock.now())
|
||||
}
|
||||
}
|
||||
|
|
@ -661,7 +668,7 @@ pub fn render_window_to_buffer(
|
|||
},
|
||||
};
|
||||
|
||||
if let Some((frame, damage)) = result {
|
||||
if let Some(PendingImageCopyData { frame, damage, .. }) = result {
|
||||
frame.success(Transform::Normal, damage, common.clock.now())
|
||||
}
|
||||
}
|
||||
|
|
@ -817,7 +824,7 @@ pub fn render_cursor_to_buffer(
|
|||
}
|
||||
};
|
||||
|
||||
if let Some((frame, damage)) = result {
|
||||
if let Some(PendingImageCopyData { frame, damage, .. }) = result {
|
||||
frame.success(Transform::Normal, damage, common.clock.now())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue