From c90d15397667bab261686cfdaae8c8e085a4574c Mon Sep 17 00:00:00 2001 From: edwloef Date: Thu, 19 Dec 2024 15:21:39 +0100 Subject: [PATCH] always increment quad, mesh, text and image layer counts in wgpu layer rendering --- wgpu/src/lib.rs | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index d79f0dc85f..a138ed159b 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -268,13 +268,37 @@ 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 += layer + .triangles + .iter() + .filter(|item| { + matches!(item, triangle::Item::Group { .. }) + }) + .count(); + } + + if !layer.text.is_empty() { + text_layer += layer + .text + .iter() + .filter(|item| matches!(item, text::Item::Group { .. })) + .count(); + } + + #[cfg(any(feature = "svg", feature = "image"))] + if !layer.images.is_empty() { + image_layer += 1; + } - let Some(scissor_rect) = physical_bounds.snap() else { continue; };