diff options
author | 2025-01-26 03:42:26 +0100 | |
---|---|---|
committer | 2025-01-26 03:42:26 +0100 | |
commit | 2c733d96acd4b5ee5ca2ddeac1646d584f7fe112 (patch) | |
tree | 02664a2da1438abe4f8e37a470ebb533d94841de /wgpu | |
parent | c90d15397667bab261686cfdaae8c8e085a4574c (diff) | |
download | iced-2c733d96acd4b5ee5ca2ddeac1646d584f7fe112.tar.gz iced-2c733d96acd4b5ee5ca2ddeac1646d584f7fe112.tar.bz2 iced-2c733d96acd4b5ee5ca2ddeac1646d584f7fe112.zip |
Delegate `layer_count` logic to primitive pipelines
Diffstat (limited to 'wgpu')
-rw-r--r-- | wgpu/src/lib.rs | 15 | ||||
-rw-r--r-- | wgpu/src/text.rs | 7 | ||||
-rw-r--r-- | wgpu/src/triangle.rs | 7 |
3 files changed, 17 insertions, 12 deletions
diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index a138ed15..e6e435af 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -277,21 +277,12 @@ impl Renderer { } if !layer.triangles.is_empty() { - mesh_layer += layer - .triangles - .iter() - .filter(|item| { - matches!(item, triangle::Item::Group { .. }) - }) - .count(); + mesh_layer += + triangle::Pipeline::layer_count(&layer.triangles); } if !layer.text.is_empty() { - text_layer += layer - .text - .iter() - .filter(|item| matches!(item, text::Item::Group { .. })) - .count(); + text_layer += text::Pipeline::layer_count(&layer.text); } #[cfg(any(feature = "svg", feature = "image"))] diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index 591bc0b7..d7e2e2ae 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -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, diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index ab88be3b..ac0b2215 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -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, |