Merge pull request #470 from PolyMeilex/fix/desktop-output-damage
This commit is contained in:
commit
0ffc9db923
|
@ -28,6 +28,7 @@ where
|
||||||
/// Returns the bounding box of this element including its position in the space.
|
/// Returns the bounding box of this element including its position in the space.
|
||||||
fn geometry(&self) -> Rectangle<i32, Logical>;
|
fn geometry(&self) -> Rectangle<i32, Logical>;
|
||||||
/// Returns the damage of the element since it's last update.
|
/// Returns the damage of the element since it's last update.
|
||||||
|
/// It should be relative to the elements coordinates.
|
||||||
///
|
///
|
||||||
/// If you receive `Some(_)` for `for_values` you may cache that you
|
/// If you receive `Some(_)` for `for_values` you may cache that you
|
||||||
/// send the damage for this `Space` and `Output` combination once
|
/// send the damage for this `Space` and `Output` combination once
|
||||||
|
|
|
@ -454,7 +454,8 @@ impl Space {
|
||||||
/// trait and use `custom_elements` to provide them to this function. `custom_elements are rendered
|
/// trait and use `custom_elements` to provide them to this function. `custom_elements are rendered
|
||||||
/// after every other element.
|
/// after every other element.
|
||||||
///
|
///
|
||||||
/// Returns a list of updated regions (or `None` if that list would be empty) in case of success.
|
/// Returns a list of updated regions relative to the rendered output
|
||||||
|
/// (or `None` if that list would be empty) in case of success.
|
||||||
pub fn render_output<R>(
|
pub fn render_output<R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
renderer: &mut R,
|
renderer: &mut R,
|
||||||
|
@ -603,6 +604,9 @@ impl Space {
|
||||||
clear_color,
|
clear_color,
|
||||||
&damage
|
&damage
|
||||||
.iter()
|
.iter()
|
||||||
|
// Map from global space to output space
|
||||||
|
.map(|geo| Rectangle::from_loc_and_size(geo.loc - output_geo.loc, geo.size))
|
||||||
|
// Map from logical to physical
|
||||||
.map(|geo| geo.to_f64().to_physical(state.render_scale).to_i32_round())
|
.map(|geo| geo.to_f64().to_physical(state.render_scale).to_i32_round())
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
)?;
|
)?;
|
||||||
|
@ -624,16 +628,17 @@ impl Space {
|
||||||
{
|
{
|
||||||
let geo = element.geometry(self.id);
|
let geo = element.geometry(self.id);
|
||||||
if damage.iter().any(|d| d.overlaps(geo)) {
|
if damage.iter().any(|d| d.overlaps(geo)) {
|
||||||
let loc = element.location(self.id) - output_geo.loc;
|
let loc = element.location(self.id);
|
||||||
let damage = damage
|
let damage = damage
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|d| d.intersection(geo))
|
.flat_map(|d| d.intersection(geo))
|
||||||
|
// Map from output space to surface-relative coordinates
|
||||||
.map(|geo| Rectangle::from_loc_and_size(geo.loc - loc, geo.size))
|
.map(|geo| Rectangle::from_loc_and_size(geo.loc - loc, geo.size))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
slog::trace!(
|
slog::trace!(
|
||||||
self.logger,
|
self.logger,
|
||||||
"Rendering toplevel at {:?} with damage {:#?}",
|
"Rendering toplevel at {:?} with damage {:#?}",
|
||||||
geo,
|
Rectangle::from_loc_and_size(geo.loc - output_geo.loc, geo.size),
|
||||||
damage
|
damage
|
||||||
);
|
);
|
||||||
element.draw(
|
element.draw(
|
||||||
|
@ -641,7 +646,7 @@ impl Space {
|
||||||
renderer,
|
renderer,
|
||||||
frame,
|
frame,
|
||||||
state.render_scale,
|
state.render_scale,
|
||||||
loc,
|
loc - output_geo.loc,
|
||||||
&damage,
|
&damage,
|
||||||
&self.logger,
|
&self.logger,
|
||||||
)?;
|
)?;
|
||||||
|
@ -676,7 +681,15 @@ impl Space {
|
||||||
.collect();
|
.collect();
|
||||||
state.old_damage.push_front(new_damage.clone());
|
state.old_damage.push_front(new_damage.clone());
|
||||||
|
|
||||||
Ok(Some(new_damage))
|
Ok(Some(
|
||||||
|
new_damage
|
||||||
|
.into_iter()
|
||||||
|
.map(|mut geo| {
|
||||||
|
geo.loc -= output_geo.loc;
|
||||||
|
geo
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends the frame callback to mapped [`Window`]s and [`LayerSurface`]s.
|
/// Sends the frame callback to mapped [`Window`]s and [`LayerSurface`]s.
|
||||||
|
|
Loading…
Reference in New Issue