Merge pull request #2701 from edwloef/2700-fix

always increment quad, mesh, text and image layer counts in wgpu layer rendering
This commit is contained in:
Héctor 2025-01-26 03:50:22 +01:00 committed by GitHub
commit c0db7b8e1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 5 deletions

View file

@ -268,13 +268,28 @@ impl Renderer {
let scale = Transformation::scale(scale_factor);
for layer in self.layers.iter() {
let Some(physical_bounds) =
physical_bounds.intersection(&(layer.bounds * scale))
let Some(scissor_rect) = physical_bounds
.intersection(&(layer.bounds * scale))
.and_then(Rectangle::snap)
else {
continue;
};
if !layer.quads.is_empty() {
quad_layer += 1;
}
if !layer.triangles.is_empty() {
mesh_layer +=
triangle::Pipeline::layer_count(&layer.triangles);
}
if !layer.text.is_empty() {
text_layer += text::Pipeline::layer_count(&layer.text);
}
#[cfg(any(feature = "svg", feature = "image"))]
if !layer.images.is_empty() {
image_layer += 1;
}
let Some(scissor_rect) = physical_bounds.snap() else {
continue;
};

View file

@ -302,6 +302,13 @@ impl Pipeline {
}
}
pub fn layer_count(batch: &Batch) -> usize {
batch
.iter()
.filter(|item| matches!(item, Item::Group { .. }))
.count()
}
pub fn prepare(
&mut self,
device: &wgpu::Device,

View file

@ -177,6 +177,13 @@ impl Pipeline {
}
}
pub fn layer_count(items: &[Item]) -> usize {
items
.iter()
.filter(|item| matches!(item, Item::Group { .. }))
.count()
}
pub fn prepare(
&mut self,
device: &wgpu::Device,