export_dmabuf: Initial support
This commit is contained in:
parent
52507f25bc
commit
944af9ab85
11 changed files with 733 additions and 32 deletions
|
|
@ -52,7 +52,7 @@ use std::{
|
|||
collections::{HashMap, HashSet},
|
||||
path::PathBuf,
|
||||
rc::Rc,
|
||||
time::Duration,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
mod drm_helpers;
|
||||
|
|
@ -86,6 +86,7 @@ pub struct Surface {
|
|||
surface: Option<GbmBufferedSurface<Rc<RefCell<GbmDevice<SessionFd>>>, SessionFd>>,
|
||||
connector: connector::Handle,
|
||||
output: Output,
|
||||
last_render: Option<(Dmabuf, Instant)>,
|
||||
last_submit: Option<DrmEventTime>,
|
||||
refresh_rate: u32,
|
||||
vrr: bool,
|
||||
|
|
@ -679,6 +680,7 @@ impl Device {
|
|||
vrr,
|
||||
refresh_rate,
|
||||
last_submit: None,
|
||||
last_render: None,
|
||||
pending: false,
|
||||
render_timer_token: None,
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -755,7 +757,7 @@ impl Surface {
|
|||
.with_context(|| "Failed to allocate buffer")?;
|
||||
|
||||
renderer
|
||||
.bind(buffer)
|
||||
.bind(buffer.clone())
|
||||
.with_context(|| "Failed to bind buffer")?;
|
||||
|
||||
match render::render_output(
|
||||
|
|
@ -769,6 +771,7 @@ impl Surface {
|
|||
Some(&mut self.fps),
|
||||
) {
|
||||
Ok(_) => {
|
||||
self.last_render = Some((buffer, Instant::now()));
|
||||
surface
|
||||
.queue_buffer()
|
||||
.with_context(|| "Failed to submit buffer for display")?;
|
||||
|
|
@ -1008,4 +1011,14 @@ impl KmsState {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn capture_output(&self, output: &Output) -> Option<(DrmNode, Dmabuf, Instant)> {
|
||||
self.devices
|
||||
.values()
|
||||
.find_map(|dev| dev.surfaces.values().find(|s| &s.output == output)
|
||||
.and_then(|s| s.last_render.clone()
|
||||
.map(|(buf, time)| (dev.render_node.clone(), buf, time))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use smithay::{
|
|||
wayland::{output::Output, shell::wlr_layer::Layer as WlrLayer},
|
||||
};
|
||||
|
||||
mod cursor;
|
||||
pub mod cursor;
|
||||
use self::cursor::PointerElement;
|
||||
|
||||
pub type GlMultiRenderer<'a> =
|
||||
|
|
@ -152,6 +152,33 @@ pub fn render_output<R>(
|
|||
hardware_cursor: bool,
|
||||
#[cfg(feature = "debug")] mut fps: Option<&mut Fps>,
|
||||
) -> Result<Option<Vec<Rectangle<i32, Physical>>>, RenderError<R>>
|
||||
where
|
||||
R: Renderer + ImportAll + AsGles2Renderer,
|
||||
<R as Renderer>::TextureId: Clone + 'static,
|
||||
CustomElem: RenderElement<R>,
|
||||
{
|
||||
let workspace = state.shell.active_space(output).idx;
|
||||
render_workspace(
|
||||
gpu,
|
||||
renderer,
|
||||
age,
|
||||
state,
|
||||
workspace,
|
||||
output,
|
||||
hardware_cursor,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn render_workspace<R>(
|
||||
gpu: Option<&DrmNode>,
|
||||
renderer: &mut R,
|
||||
age: u8,
|
||||
state: &mut Common,
|
||||
space_idx: u8,
|
||||
output: &Output,
|
||||
hardware_cursor: bool,
|
||||
#[cfg(feature = "debug")] mut fps: Option<&mut Fps>,
|
||||
) -> Result<Option<Vec<Rectangle<i32, Physical>>>, RenderError<R>>
|
||||
where
|
||||
R: Renderer + ImportAll + AsGles2Renderer,
|
||||
<R as Renderer>::TextureId: Clone + 'static,
|
||||
|
|
@ -161,8 +188,11 @@ where
|
|||
if let Some(ref mut fps) = fps {
|
||||
fps.start();
|
||||
}
|
||||
let workspace = state.shell.active_space(output);
|
||||
|
||||
let space_idx = space_idx as usize;
|
||||
let workspace = &mut state.shell.spaces[space_idx];
|
||||
let maybe_fullscreen_window = workspace.get_fullscreen(output).cloned();
|
||||
|
||||
let res = if let Some(window) = maybe_fullscreen_window {
|
||||
#[cfg(not(feature = "debug"))]
|
||||
{
|
||||
|
|
@ -175,11 +205,11 @@ where
|
|||
} else {
|
||||
#[cfg(not(feature = "debug"))]
|
||||
{
|
||||
render_desktop(gpu, renderer, age, state, output, hardware_cursor)
|
||||
render_desktop(gpu, renderer, age, state, space_idx, output, hardware_cursor)
|
||||
}
|
||||
#[cfg(feature = "debug")]
|
||||
{
|
||||
render_desktop(gpu, renderer, age, state, output, hardware_cursor, fps.as_deref_mut())
|
||||
render_desktop(gpu, renderer, age, state, space_idx, output, hardware_cursor, fps.as_deref_mut())
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -196,6 +226,7 @@ fn render_desktop<R>(
|
|||
renderer: &mut R,
|
||||
age: u8,
|
||||
state: &mut Common,
|
||||
space_idx: usize,
|
||||
output: &Output,
|
||||
hardware_cursor: bool,
|
||||
#[cfg(feature = "debug")] fps: Option<&mut Fps>,
|
||||
|
|
@ -209,7 +240,7 @@ where
|
|||
|
||||
#[cfg(feature = "debug")]
|
||||
{
|
||||
let workspace = state.shell.active_space(output);
|
||||
let workspace = &state.shell.spaces[space_idx];
|
||||
let output_geo = workspace
|
||||
.space
|
||||
.output_geometry(output)
|
||||
|
|
@ -268,7 +299,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
state.shell.active_space_mut(output).space.render_output(
|
||||
state.shell.spaces[space_idx].space.render_output(
|
||||
renderer,
|
||||
&output,
|
||||
age as usize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue