Skip to content

Commit

Permalink
Remove Vec from Shadow::render()
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Jan 18, 2025
1 parent 0584dd2 commit 8182484
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
19 changes: 6 additions & 13 deletions src/layout/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
12 changes: 6 additions & 6 deletions src/layout/tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8182484

Please sign in to comment.