forge
Explore
Log in

Don't you dare go Hollow

Remove Vec from Shadow::render()

Browse files at this commit

818248457210f5101459ea7d7066d12c456c8a97Ivan MolodetskikhParent: 0584dd2
src/layout/mod.rsmodified+3 -3
@@ -3994,12 +3994,12 @@ impl<W: LayoutElement> Layout<W> {
3994 }3994 }
3995 }3995 }
3996 3996
3997- pub fn render_floating_for_output<R: NiriRenderer>(3997+ pub fn render_floating_for_output<'a, R: NiriRenderer + 'a>(
3998- &self,3998+ &'a self,
3999 renderer: &mut R,3999 renderer: &mut R,
4000 output: &Output,4000 output: &Output,
4001 target: RenderTarget,4001 target: RenderTarget,
4002- ) -> impl Iterator<Item = TileRenderElement<R>> {4002+ ) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
4003 if self.update_render_elements_time != self.clock.now() {4003 if self.update_render_elements_time != self.clock.now() {
4004 error!("clock moved between updating render elements and rendering");4004 error!("clock moved between updating render elements and rendering");
4005 }4005 }
src/layout/shadow.rsmodified+6 -13
@@ -157,26 +157,19 @@ impl Shadow {
157 &self,157 &self,
158 renderer: &mut impl NiriRenderer,158 renderer: &mut impl NiriRenderer,
159 location: Point<f64, Logical>,159 location: Point<f64, Logical>,
160- ) -> impl Iterator<Item = ShadowRenderElement> {160+ ) -> impl Iterator<Item = ShadowRenderElement> + '_ {
161- let mut rv = Vec::new();
162-
163 if !self.config.on {161 if !self.config.on {
164- return rv.into_iter();162+ return None.into_iter().flatten();
165 }163 }
166 164
167 let has_shadow_shader = ShadowRenderElement::has_shader(renderer);165 let has_shadow_shader = ShadowRenderElement::has_shader(renderer);
168 if !has_shadow_shader {166 if !has_shadow_shader {
169- return rv.into_iter();167+ return None.into_iter().flatten();
170 }168 }
171 169
172- let mut push = |shader: &ShadowRenderElement, location: Point<f64, Logical>| {170+ let rv = zip(&self.shaders, &self.shader_rects)
173- rv.push(shader.clone().with_location(location));171+ .map(move |(shader, rect)| shader.clone().with_location(location + rect.loc));
174- };
175-
176- for (shader, rect) in zip(&self.shaders, &self.shader_rects) {
177- push(shader, location + rect.loc);
178- }
179 172
180- rv.into_iter()173+ Some(rv).into_iter().flatten()
181 }174 }
182 }175 }
src/layout/tile.rsmodified+6 -6
@@ -710,14 +710,14 @@ impl<W: LayoutElement> Tile<W> {
710 .unwrap_or_else(|| !self.window.has_ssd())710 .unwrap_or_else(|| !self.window.has_ssd())
711 }711 }
712 712
713- fn render_inner<R: NiriRenderer>(713+ fn render_inner<'a, R: NiriRenderer + 'a>(
714- &self,714+ &'a self,
715 renderer: &mut R,715 renderer: &mut R,
716 location: Point<f64, Logical>,716 location: Point<f64, Logical>,
717 scale: Scale<f64>,717 scale: Scale<f64>,
718 focus_ring: bool,718 focus_ring: bool,
719 target: RenderTarget,719 target: RenderTarget,
720- ) -> impl Iterator<Item = TileRenderElement<R>> {720+ ) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
721 let _span = tracy_client::span!("Tile::render_inner");721 let _span = tracy_client::span!("Tile::render_inner");
722 722
723 let alpha = if self.is_fullscreen {723 let alpha = if self.is_fullscreen {
@@ -926,14 +926,14 @@ impl<W: LayoutElement> Tile<W> {
926 rv.chain(self.shadow.render(renderer, location).map(Into::into))926 rv.chain(self.shadow.render(renderer, location).map(Into::into))
927 }927 }
928 928
929- pub fn render<R: NiriRenderer>(929+ pub fn render<'a, R: NiriRenderer + 'a>(
930- &self,930+ &'a self,
931 renderer: &mut R,931 renderer: &mut R,
932 location: Point<f64, Logical>,932 location: Point<f64, Logical>,
933 scale: Scale<f64>,933 scale: Scale<f64>,
934 focus_ring: bool,934 focus_ring: bool,
935 target: RenderTarget,935 target: RenderTarget,
936- ) -> impl Iterator<Item = TileRenderElement<R>> {936+ ) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
937 let _span = tracy_client::span!("Tile::render");937 let _span = tracy_client::span!("Tile::render");
938 938
939 let mut open_anim_elem = None;939 let mut open_anim_elem = None;