aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-01-18 17:42:11 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-01-18 17:43:58 +0300
commit818248457210f5101459ea7d7066d12c456c8a97 (patch)
tree942ad497f54a0b59b55938ed1a9b95acb405275b /src
parent0584dd2f1e82417bdabcc0d8cb20fddc2e8cc5e7 (diff)
downloadniri-818248457210f5101459ea7d7066d12c456c8a97.tar.gz
niri-818248457210f5101459ea7d7066d12c456c8a97.tar.bz2
niri-818248457210f5101459ea7d7066d12c456c8a97.zip
Remove Vec from Shadow::render()
Diffstat (limited to 'src')
-rw-r--r--src/layout/mod.rs6
-rw-r--r--src/layout/shadow.rs19
-rw-r--r--src/layout/tile.rs12
3 files changed, 15 insertions, 22 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 34f64993..91e53c8c 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -3994,12 +3994,12 @@ impl<W: LayoutElement> Layout<W> {
}
}
- pub fn render_floating_for_output<R: NiriRenderer>(
- &self,
+ pub fn render_floating_for_output<'a, R: NiriRenderer + 'a>(
+ &'a self,
renderer: &mut R,
output: &Output,
target: RenderTarget,
- ) -> impl Iterator<Item = TileRenderElement<R>> {
+ ) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
if self.update_render_elements_time != self.clock.now() {
error!("clock moved between updating render elements and rendering");
}
diff --git a/src/layout/shadow.rs b/src/layout/shadow.rs
index 1600e333..3e0605c4 100644
--- a/src/layout/shadow.rs
+++ b/src/layout/shadow.rs
@@ -157,26 +157,19 @@ impl Shadow {
&self,
renderer: &mut impl NiriRenderer,
location: Point<f64, Logical>,
- ) -> impl Iterator<Item = ShadowRenderElement> {
- let mut rv = Vec::new();
-
+ ) -> impl Iterator<Item = ShadowRenderElement> + '_ {
if !self.config.on {
- return rv.into_iter();
+ return None.into_iter().flatten();
}
let has_shadow_shader = ShadowRenderElement::has_shader(renderer);
if !has_shadow_shader {
- return rv.into_iter();
+ return None.into_iter().flatten();
}
- let mut push = |shader: &ShadowRenderElement, location: Point<f64, Logical>| {
- rv.push(shader.clone().with_location(location));
- };
-
- for (shader, rect) in zip(&self.shaders, &self.shader_rects) {
- push(shader, location + rect.loc);
- }
+ let rv = zip(&self.shaders, &self.shader_rects)
+ .map(move |(shader, rect)| shader.clone().with_location(location + rect.loc));
- rv.into_iter()
+ Some(rv).into_iter().flatten()
}
}
diff --git a/src/layout/tile.rs b/src/layout/tile.rs
index a9fd8e13..529ffc0f 100644
--- a/src/layout/tile.rs
+++ b/src/layout/tile.rs
@@ -710,14 +710,14 @@ impl<W: LayoutElement> Tile<W> {
.unwrap_or_else(|| !self.window.has_ssd())
}
- fn render_inner<R: NiriRenderer>(
- &self,
+ fn render_inner<'a, R: NiriRenderer + 'a>(
+ &'a self,
renderer: &mut R,
location: Point<f64, Logical>,
scale: Scale<f64>,
focus_ring: bool,
target: RenderTarget,
- ) -> impl Iterator<Item = TileRenderElement<R>> {
+ ) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
let _span = tracy_client::span!("Tile::render_inner");
let alpha = if self.is_fullscreen {
@@ -926,14 +926,14 @@ impl<W: LayoutElement> Tile<W> {
rv.chain(self.shadow.render(renderer, location).map(Into::into))
}
- pub fn render<R: NiriRenderer>(
- &self,
+ pub fn render<'a, R: NiriRenderer + 'a>(
+ &'a self,
renderer: &mut R,
location: Point<f64, Logical>,
scale: Scale<f64>,
focus_ring: bool,
target: RenderTarget,
- ) -> impl Iterator<Item = TileRenderElement<R>> {
+ ) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
let _span = tracy_client::span!("Tile::render");
let mut open_anim_elem = None;