Skip to content

Commit

Permalink
render: Make Mesh a struct, not just an alias for Vec<Draw>
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone committed Jan 27, 2024
1 parent 6dac495 commit e479d12
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions render/src/tessellator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ impl ShapeTessellator {
self.flush_draw(DrawType::Color);

self.lyon_mesh = VertexBuffers::new();
std::mem::take(&mut self.mesh)
Mesh {
draws: std::mem::take(&mut self.mesh),
}
}

fn flush_draw(&mut self, draw: DrawType) {
Expand Down Expand Up @@ -224,7 +226,9 @@ impl Default for ShapeTessellator {
}
}

type Mesh = Vec<Draw>;
pub struct Mesh {
pub draws: Vec<Draw>,
}

pub struct Draw {
pub draw_type: DrawType,
Expand Down
4 changes: 2 additions & 2 deletions render/webgl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,8 @@ impl WebGlRenderBackend {
.shape_tessellator
.tessellate_shape(shape, bitmap_source);

let mut draws = Vec::with_capacity(lyon_mesh.len());
for draw in lyon_mesh {
let mut draws = Vec::with_capacity(lyon_mesh.draws.len());
for draw in lyon_mesh.draws {
let num_indices = draw.indices.len() as i32;
let num_mask_indices = draw.mask_index_count as i32;

Expand Down
4 changes: 2 additions & 2 deletions render/wgpu/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ impl<T: RenderTarget> WgpuRenderBackend<T> {
.shape_tessellator
.tessellate_shape(shape, bitmap_source);

let mut draws = Vec::with_capacity(lyon_mesh.len());
let mut draws = Vec::with_capacity(lyon_mesh.draws.len());
let mut uniform_buffer = BufferBuilder::new_for_uniform(&self.descriptors.limits);
let mut vertex_buffer = BufferBuilder::new_for_vertices(&self.descriptors.limits);
let mut index_buffer = BufferBuilder::new_for_vertices(&self.descriptors.limits);
for draw in lyon_mesh {
for draw in lyon_mesh.draws {
let draw_id = draws.len();
if let Some(draw) = PendingDraw::new(
self,
Expand Down

0 comments on commit e479d12

Please sign in to comment.