Cull widget draw calls in column and row

This commit is contained in:
Héctor Ramón Jiménez 2024-10-02 15:45:21 +02:00
parent 509a0a574a
commit d40aa6400d
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 16 additions and 26 deletions

View file

@ -334,10 +334,6 @@ pub fn draw<Renderer>(
{ {
let bounds = layout.bounds(); let bounds = layout.bounds();
if !bounds.intersects(viewport) {
return;
}
let x = match paragraph.horizontal_alignment() { let x = match paragraph.horizontal_alignment() {
alignment::Horizontal::Left => bounds.x, alignment::Horizontal::Left => bounds.x,
alignment::Horizontal::Center => bounds.center_x(), alignment::Horizontal::Center => bounds.center_x(),

View file

@ -320,24 +320,21 @@ where
viewport: &Rectangle, viewport: &Rectangle,
) { ) {
if let Some(clipped_viewport) = layout.bounds().intersection(viewport) { if let Some(clipped_viewport) = layout.bounds().intersection(viewport) {
let viewport = if self.clip {
&clipped_viewport
} else {
viewport
};
for ((child, state), layout) in self for ((child, state), layout) in self
.children .children
.iter() .iter()
.zip(&tree.children) .zip(&tree.children)
.zip(layout.children()) .zip(layout.children())
.filter(|(_, layout)| layout.bounds().intersects(viewport))
{ {
child.as_widget().draw( child.as_widget().draw(
state, state, renderer, theme, style, layout, cursor, viewport,
renderer,
theme,
style,
layout,
cursor,
if self.clip {
&clipped_viewport
} else {
viewport
},
); );
} }
} }

View file

@ -316,24 +316,21 @@ where
viewport: &Rectangle, viewport: &Rectangle,
) { ) {
if let Some(clipped_viewport) = layout.bounds().intersection(viewport) { if let Some(clipped_viewport) = layout.bounds().intersection(viewport) {
let viewport = if self.clip {
&clipped_viewport
} else {
viewport
};
for ((child, state), layout) in self for ((child, state), layout) in self
.children .children
.iter() .iter()
.zip(&tree.children) .zip(&tree.children)
.zip(layout.children()) .zip(layout.children())
.filter(|(_, layout)| layout.bounds().intersects(viewport))
{ {
child.as_widget().draw( child.as_widget().draw(
state, state, renderer, theme, style, layout, cursor, viewport,
renderer,
theme,
style,
layout,
cursor,
if self.clip {
&clipped_viewport
} else {
viewport
},
); );
} }
} }