image-copy: Use damage_output() for additional damage
The important change here is that we now apply the additional damage first, instead of using `.extend()` to add it after other elements. This is important since `OutputDamageTracker` will ignore our damage elements if there are behind an element with an opaque region. This also makes things a bit simpler, especially `take_screencopy_frames()`, which no longer needs a mutable references to extend then truncate. The implementation of `OutputDamageTracker` isn't entirely clear, but as far as I can tell this is intended to work, and it seems to work in some testing.
This commit is contained in:
parent
cac7a5aca6
commit
9bc1b6e1ee
4 changed files with 74 additions and 113 deletions
|
|
@ -32,7 +32,6 @@ where
|
|||
Cursor(RescaleRenderElement<RelocateRenderElement<CursorRenderElement<R>>>),
|
||||
Dnd(WaylandSurfaceRenderElement<R>),
|
||||
MoveGrab(RescaleRenderElement<CosmicMappedRenderElement<R>>),
|
||||
AdditionalDamage(DamageElement),
|
||||
Postprocess(
|
||||
CropRenderElement<RelocateRenderElement<RescaleRenderElement<TextureShaderElement>>>,
|
||||
),
|
||||
|
|
@ -53,7 +52,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.id(),
|
||||
CosmicElement::Dnd(elem) => elem.id(),
|
||||
CosmicElement::MoveGrab(elem) => elem.id(),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.id(),
|
||||
CosmicElement::Postprocess(elem) => elem.id(),
|
||||
CosmicElement::Zoom(elem) => elem.id(),
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -67,7 +65,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.current_commit(),
|
||||
CosmicElement::Dnd(elem) => elem.current_commit(),
|
||||
CosmicElement::MoveGrab(elem) => elem.current_commit(),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.current_commit(),
|
||||
CosmicElement::Postprocess(elem) => elem.current_commit(),
|
||||
CosmicElement::Zoom(elem) => elem.current_commit(),
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -81,7 +78,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.src(),
|
||||
CosmicElement::Dnd(elem) => elem.src(),
|
||||
CosmicElement::MoveGrab(elem) => elem.src(),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.src(),
|
||||
CosmicElement::Postprocess(elem) => elem.src(),
|
||||
CosmicElement::Zoom(elem) => elem.src(),
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -95,7 +91,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.geometry(scale),
|
||||
CosmicElement::Dnd(elem) => elem.geometry(scale),
|
||||
CosmicElement::MoveGrab(elem) => elem.geometry(scale),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.geometry(scale),
|
||||
CosmicElement::Postprocess(elem) => elem.geometry(scale),
|
||||
CosmicElement::Zoom(elem) => elem.geometry(scale),
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -109,7 +104,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.location(scale),
|
||||
CosmicElement::Dnd(elem) => elem.location(scale),
|
||||
CosmicElement::MoveGrab(elem) => elem.location(scale),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.location(scale),
|
||||
CosmicElement::Postprocess(elem) => elem.location(scale),
|
||||
CosmicElement::Zoom(elem) => elem.location(scale),
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -123,7 +117,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.transform(),
|
||||
CosmicElement::Dnd(elem) => elem.transform(),
|
||||
CosmicElement::MoveGrab(elem) => elem.transform(),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.transform(),
|
||||
CosmicElement::Postprocess(elem) => elem.transform(),
|
||||
CosmicElement::Zoom(elem) => elem.transform(),
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -141,7 +134,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.damage_since(scale, commit),
|
||||
CosmicElement::Dnd(elem) => elem.damage_since(scale, commit),
|
||||
CosmicElement::MoveGrab(elem) => elem.damage_since(scale, commit),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.damage_since(scale, commit),
|
||||
CosmicElement::Postprocess(elem) => elem.damage_since(scale, commit),
|
||||
CosmicElement::Zoom(elem) => elem.damage_since(scale, commit),
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -155,7 +147,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.opaque_regions(scale),
|
||||
CosmicElement::Dnd(elem) => elem.opaque_regions(scale),
|
||||
CosmicElement::MoveGrab(elem) => elem.opaque_regions(scale),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.opaque_regions(scale),
|
||||
CosmicElement::Postprocess(elem) => elem.opaque_regions(scale),
|
||||
CosmicElement::Zoom(elem) => elem.opaque_regions(scale),
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -169,7 +160,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.alpha(),
|
||||
CosmicElement::Dnd(elem) => elem.alpha(),
|
||||
CosmicElement::MoveGrab(elem) => elem.alpha(),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.alpha(),
|
||||
CosmicElement::Postprocess(elem) => elem.alpha(),
|
||||
CosmicElement::Zoom(elem) => elem.alpha(),
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -183,7 +173,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.kind(),
|
||||
CosmicElement::Dnd(elem) => elem.kind(),
|
||||
CosmicElement::MoveGrab(elem) => elem.kind(),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.kind(),
|
||||
CosmicElement::Postprocess(elem) => elem.kind(),
|
||||
CosmicElement::Zoom(elem) => elem.kind(),
|
||||
#[cfg(feature = "debug")]
|
||||
|
|
@ -212,9 +201,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.draw(frame, src, dst, damage, opaque_regions),
|
||||
CosmicElement::Dnd(elem) => elem.draw(frame, src, dst, damage, opaque_regions),
|
||||
CosmicElement::MoveGrab(elem) => elem.draw(frame, src, dst, damage, opaque_regions),
|
||||
CosmicElement::AdditionalDamage(elem) => {
|
||||
RenderElement::<R>::draw(elem, frame, src, dst, damage, opaque_regions)
|
||||
}
|
||||
CosmicElement::Postprocess(elem) => {
|
||||
let glow_frame = R::glow_frame_mut(frame);
|
||||
RenderElement::<GlowRenderer>::draw(
|
||||
|
|
@ -250,7 +236,6 @@ where
|
|||
CosmicElement::Cursor(elem) => elem.underlying_storage(renderer),
|
||||
CosmicElement::Dnd(elem) => elem.underlying_storage(renderer),
|
||||
CosmicElement::MoveGrab(elem) => elem.underlying_storage(renderer),
|
||||
CosmicElement::AdditionalDamage(elem) => elem.underlying_storage(renderer),
|
||||
CosmicElement::Postprocess(elem) => {
|
||||
let glow_renderer = renderer.glow_renderer_mut();
|
||||
elem.underlying_storage(glow_renderer)
|
||||
|
|
@ -281,17 +266,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<R> From<DamageElement> for CosmicElement<R>
|
||||
where
|
||||
R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
|
||||
R::TextureId: 'static,
|
||||
CosmicMappedRenderElement<R>: RenderElement<R>,
|
||||
{
|
||||
fn from(elem: DamageElement) -> Self {
|
||||
Self::AdditionalDamage(elem)
|
||||
}
|
||||
}
|
||||
|
||||
impl<R> From<MemoryRenderBufferRenderElement<R>> for CosmicElement<R>
|
||||
where
|
||||
R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
|
||||
|
|
|
|||
|
|
@ -1393,21 +1393,20 @@ where
|
|||
)?;
|
||||
|
||||
let old_len = elements.len();
|
||||
elements.extend(
|
||||
additional_damage
|
||||
.into_iter()
|
||||
.map(|rect| {
|
||||
rect.to_f64()
|
||||
.to_logical(
|
||||
output.current_scale().fractional_scale(),
|
||||
output.current_transform(),
|
||||
&area,
|
||||
)
|
||||
.to_i32_round()
|
||||
})
|
||||
.map(DamageElement::new)
|
||||
.map(Into::into),
|
||||
);
|
||||
let additional_damage_elements: Vec<_> = additional_damage
|
||||
.into_iter()
|
||||
.map(|rect| {
|
||||
rect.to_f64()
|
||||
.to_logical(
|
||||
output.current_scale().fractional_scale(),
|
||||
output.current_transform(),
|
||||
&area,
|
||||
)
|
||||
.to_i32_round()
|
||||
})
|
||||
.map(DamageElement::new)
|
||||
.collect();
|
||||
dt.damage_output(age, &additional_damage_elements)?;
|
||||
|
||||
Some(old_len)
|
||||
} else {
|
||||
|
|
@ -1513,7 +1512,7 @@ where
|
|||
CosmicMappedRenderElement<R>: RenderElement<R>,
|
||||
WorkspaceRenderElement<R>: RenderElement<R>,
|
||||
{
|
||||
let mut elements: Vec<CosmicElement<R>> = workspace_elements(
|
||||
let elements: Vec<CosmicElement<R>> = workspace_elements(
|
||||
gpu,
|
||||
renderer,
|
||||
shell,
|
||||
|
|
@ -1528,13 +1527,12 @@ where
|
|||
|
||||
if let Some(additional_damage) = additional_damage {
|
||||
let output_geo = output.geometry().to_local(output).as_logical();
|
||||
elements.extend(
|
||||
additional_damage
|
||||
.into_iter()
|
||||
.filter_map(|rect| rect.intersection(output_geo))
|
||||
.map(DamageElement::new)
|
||||
.map(Into::<CosmicElement<R>>::into),
|
||||
);
|
||||
let additional_damage_elements: Vec<_> = additional_damage
|
||||
.into_iter()
|
||||
.filter_map(|rect| rect.intersection(output_geo))
|
||||
.map(DamageElement::new)
|
||||
.collect();
|
||||
damage_tracker.damage_output(age, &additional_damage_elements)?;
|
||||
}
|
||||
|
||||
let res = damage_tracker.render_output(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue