Avoid generating empty Frame geometry in iced_wgpu

This commit is contained in:
Héctor Ramón Jiménez 2024-04-06 00:57:59 +02:00
parent 6d3e1d835e
commit 7eb16452f3
No known key found for this signature in database
GPG key ID: 4C07CEC81AFA161F

View file

@ -422,23 +422,30 @@ impl BufferStack {
} }
fn into_meshes(self, clip_bounds: Rectangle) -> impl Iterator<Item = Mesh> { fn into_meshes(self, clip_bounds: Rectangle) -> impl Iterator<Item = Mesh> {
self.stack.into_iter().map(move |buffer| match buffer { self.stack
Buffer::Solid(buffer) => Mesh::Solid { .into_iter()
.filter_map(move |buffer| match buffer {
Buffer::Solid(buffer) if !buffer.indices.is_empty() => {
Some(Mesh::Solid {
buffers: mesh::Indexed { buffers: mesh::Indexed {
vertices: buffer.vertices, vertices: buffer.vertices,
indices: buffer.indices, indices: buffer.indices,
}, },
clip_bounds, clip_bounds,
transformation: Transformation::IDENTITY, transformation: Transformation::IDENTITY,
}, })
Buffer::Gradient(buffer) => Mesh::Gradient { }
Buffer::Gradient(buffer) if !buffer.indices.is_empty() => {
Some(Mesh::Gradient {
buffers: mesh::Indexed { buffers: mesh::Indexed {
vertices: buffer.vertices, vertices: buffer.vertices,
indices: buffer.indices, indices: buffer.indices,
}, },
clip_bounds, clip_bounds,
transformation: Transformation::IDENTITY, transformation: Transformation::IDENTITY,
}, })
}
_ => None,
}) })
} }
} }