summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2025-01-26 03:53:18 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2025-01-26 03:55:23 +0100
commit3428a3d2afb766c264453a58e15d33953d438238 (patch)
tree7d70332dd6477182d9ec642ce292c70c95590678 /wgpu
parentc0db7b8e1f6a9d5042530a5b98ec95f492ff6bf7 (diff)
downloadiced-3428a3d2afb766c264453a58e15d33953d438238.tar.gz
iced-3428a3d2afb766c264453a58e15d33953d438238.tar.bz2
iced-3428a3d2afb766c264453a58e15d33953d438238.zip
Avoid preparing layers outside physical bounds in `iced_wgpu`
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/src/lib.rs32
-rw-r--r--wgpu/src/text.rs7
-rw-r--r--wgpu/src/triangle.rs7
3 files changed, 13 insertions, 33 deletions
diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs
index e6e435af..8e099af1 100644
--- a/wgpu/src/lib.rs
+++ b/wgpu/src/lib.rs
@@ -145,7 +145,19 @@ impl Renderer {
self.text_viewport.update(queue, viewport.physical_size());
+ let physical_bounds = Rectangle::<f32>::from(Rectangle::with_size(
+ viewport.physical_size(),
+ ));
+
for layer in self.layers.iter_mut() {
+ if physical_bounds
+ .intersection(&(layer.bounds * scale_factor))
+ .and_then(Rectangle::snap)
+ .is_none()
+ {
+ continue;
+ }
+
if !layer.quads.is_empty() {
engine.quad_pipeline.prepare(
device,
@@ -269,27 +281,9 @@ impl Renderer {
for layer in self.layers.iter() {
let Some(scissor_rect) = physical_bounds
- .intersection(&(layer.bounds * scale))
+ .intersection(&(layer.bounds * scale_factor))
.and_then(Rectangle::snap)
else {
- 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;
- }
-
continue;
};
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs
index d7e2e2ae..591bc0b7 100644
--- a/wgpu/src/text.rs
+++ b/wgpu/src/text.rs
@@ -302,13 +302,6 @@ 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,
diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs
index ac0b2215..ab88be3b 100644
--- a/wgpu/src/triangle.rs
+++ b/wgpu/src/triangle.rs
@@ -177,13 +177,6 @@ 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,