Skip to content

Commit

Permalink
always increment quad, mesh, text and image layer counts in wgpu laye…
Browse files Browse the repository at this point in the history
…r rendering
  • Loading branch information
edwloef committed Dec 19, 2024
1 parent a687a83 commit c90d153
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit c90d153

Please sign in to comment.