Cull widget draw calls in column and row
This commit is contained in:
parent
509a0a574a
commit
d40aa6400d
3 changed files with 16 additions and 26 deletions
|
|
@ -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(),
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue