diff options
author | 2022-10-04 18:24:46 -0700 | |
---|---|---|
committer | 2022-10-04 18:24:46 -0700 | |
commit | 6e7b3ced0b1daf368e44e181ecdb4ae529877eb6 (patch) | |
tree | e530025c737d509b640172d595cff0a0809f5a40 /graphics/src/layer.rs | |
parent | 5d0fffc626928177239336757507b986b081b878 (diff) | |
download | iced-6e7b3ced0b1daf368e44e181ecdb4ae529877eb6.tar.gz iced-6e7b3ced0b1daf368e44e181ecdb4ae529877eb6.tar.bz2 iced-6e7b3ced0b1daf368e44e181ecdb4ae529877eb6.zip |
Reworked wgpu buffers, updated glow side to have proper transform location storage, attempting to fix visibility modifiers, implemented some of the feedback received in initial PR.
Diffstat (limited to '')
-rw-r--r-- | graphics/src/layer.rs | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/graphics/src/layer.rs b/graphics/src/layer.rs index b7731922..096c50dc 100644 --- a/graphics/src/layer.rs +++ b/graphics/src/layer.rs @@ -19,7 +19,7 @@ pub struct Layer<'a> { pub quads: Vec<Quad>, /// The triangle meshes of the [`Layer`]. - pub meshes: Meshes<'a>, + pub meshes: Vec<Mesh<'a>>, /// The text of the [`Layer`]. pub text: Vec<Text<'a>>, @@ -34,7 +34,7 @@ impl<'a> Layer<'a> { Self { bounds, quads: Vec::new(), - meshes: Meshes(Vec::new()), + meshes: Vec::new(), text: Vec::new(), images: Vec::new(), } @@ -174,7 +174,7 @@ impl<'a> Layer<'a> { // Only draw visible content if let Some(clip_bounds) = layer.bounds.intersection(&bounds) { - layer.meshes.0.push( + layer.meshes.push( Mesh { origin: Point::new(translation.x, translation.y), buffers, @@ -335,20 +335,14 @@ unsafe impl bytemuck::Zeroable for Quad {} #[allow(unsafe_code)] unsafe impl bytemuck::Pod for Quad {} -#[derive(Debug)] -/// A collection of meshes. -pub struct Meshes<'a>(pub Vec<Mesh<'a>>); - -impl<'a> Meshes<'a> { - /// Returns the number of total vertices & total indices of all [`Mesh`]es. - pub fn attribute_count(&self) -> (usize, usize) { - self.0 - .iter() - .map(|Mesh { buffers, .. }| { - (buffers.vertices.len(), buffers.indices.len()) - }) - .fold((0, 0), |(total_v, total_i), (v, i)| { - (total_v + v, total_i + i) - }) - } +/// Returns the number of total vertices & total indices of all [`Mesh`]es. +pub fn attribute_count_of<'a>(meshes: &'a [Mesh<'a>]) -> (usize, usize) { + meshes + .iter() + .map(|Mesh { buffers, .. }| { + (buffers.vertices.len(), buffers.indices.len()) + }) + .fold((0, 0), |(total_v, total_i), (v, i)| { + (total_v + v, total_i + i) + }) }
\ No newline at end of file |