element: Refactor element acquisition to be push based
This commit is contained in:
parent
178c6593dc
commit
e4c0716951
18 changed files with 1096 additions and 1137 deletions
|
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use calloop::LoopHandle;
|
||||
use smallvec::SmallVec;
|
||||
use smithay::{
|
||||
backend::{
|
||||
allocator::{Buffer, Fourcc, format::get_transparent},
|
||||
|
|
@ -39,7 +40,8 @@ use tracing::warn;
|
|||
|
||||
use crate::{
|
||||
backend::render::{
|
||||
CursorMode, ElementFilter, RendererRef, cursor,
|
||||
CursorMode, ElementFilter, RendererRef,
|
||||
cursor::{self, CursorRenderElement},
|
||||
element::{AsGlowRenderer, CosmicElement, DamageElement},
|
||||
render_workspace,
|
||||
wayland::SurfaceRenderElement,
|
||||
|
|
@ -591,44 +593,49 @@ pub fn render_window_to_buffer(
|
|||
|
||||
if let Some(location) = location {
|
||||
if draw_cursor {
|
||||
elements.extend(
|
||||
cursor::draw_cursor(
|
||||
renderer,
|
||||
&seat,
|
||||
location,
|
||||
1.0.into(),
|
||||
1.0,
|
||||
common.clock.now(),
|
||||
true,
|
||||
)
|
||||
.into_iter()
|
||||
.map(|(elem, hotspot)| {
|
||||
WindowCaptureElement::CursorElement(RelocateRenderElement::from_element(
|
||||
elem,
|
||||
Point::from((-hotspot.x, -hotspot.y)),
|
||||
Relocate::Relative,
|
||||
))
|
||||
}),
|
||||
cursor::draw_cursor(
|
||||
renderer,
|
||||
&seat,
|
||||
location,
|
||||
1.0.into(),
|
||||
1.0,
|
||||
common.clock.now(),
|
||||
true,
|
||||
&mut |elem, hotspot| {
|
||||
elements.push(WindowCaptureElement::CursorElement(
|
||||
RelocateRenderElement::from_element(
|
||||
elem,
|
||||
Point::from((-hotspot.x, -hotspot.y)),
|
||||
Relocate::Relative,
|
||||
),
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// TODO cosmic-workspaces wants to omit, but metadata cursor capture in portal should
|
||||
// still include dnd surface in window capture buffer?
|
||||
if draw_cursor && let Some(dnd_icon) = get_dnd_icon(&seat) {
|
||||
elements.extend(
|
||||
cursor::draw_dnd_icon(
|
||||
renderer,
|
||||
&dnd_icon.surface,
|
||||
(location + dnd_icon.offset.to_f64()).to_i32_round(),
|
||||
1.0,
|
||||
)
|
||||
.into_iter()
|
||||
.map(WindowCaptureElement::from),
|
||||
cursor::draw_dnd_icon(
|
||||
renderer,
|
||||
&dnd_icon.surface,
|
||||
(location + dnd_icon.offset.to_f64()).to_i32_round(),
|
||||
1.0,
|
||||
&mut |elem| {
|
||||
elements.push(
|
||||
RelocateRenderElement::from_element(
|
||||
CursorRenderElement::Surface(elem),
|
||||
Point::new(0, 0),
|
||||
Relocate::Relative,
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
elements.extend(toplevel.render_elements::<R, WindowCaptureElement<R>>(
|
||||
toplevel.push_render_elements(
|
||||
renderer,
|
||||
(-geometry.loc.x, -geometry.loc.y).into(),
|
||||
Scale::from(1.0),
|
||||
|
|
@ -637,7 +644,9 @@ pub fn render_window_to_buffer(
|
|||
None,
|
||||
false,
|
||||
[0; 4],
|
||||
));
|
||||
&mut |elem| elements.push(elem.into()),
|
||||
None,
|
||||
);
|
||||
|
||||
if let Ok(dmabuf) = get_dmabuf(buffer) {
|
||||
let mut dmabuf_clone = dmabuf.clone();
|
||||
|
|
@ -803,7 +812,8 @@ pub fn render_cursor_to_buffer(
|
|||
.collect();
|
||||
dt.damage_output(age, &additional_damage_elements)?;
|
||||
|
||||
let elements = cursor::draw_cursor(
|
||||
let mut elements = SmallVec::<[WindowCaptureElement<R>; 4]>::new_const();
|
||||
cursor::draw_cursor(
|
||||
renderer,
|
||||
seat,
|
||||
Point::from((0.0, 0.0)),
|
||||
|
|
@ -811,11 +821,12 @@ pub fn render_cursor_to_buffer(
|
|||
1.0,
|
||||
common.clock.now(),
|
||||
true,
|
||||
)
|
||||
.into_iter()
|
||||
.map(|(elem, _)| RelocateRenderElement::from_element(elem, (0, 0), Relocate::Relative))
|
||||
.map(WindowCaptureElement::from)
|
||||
.collect::<Vec<_>>();
|
||||
&mut |elem, _| {
|
||||
elements.push(
|
||||
RelocateRenderElement::from_element(elem, (0, 0), Relocate::Relative).into(),
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
if let Ok(dmabuf) = get_dmabuf(buffer) {
|
||||
let mut dmabuf_clone = dmabuf.clone();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue