diff --git a/canvas/src/lib.rs b/canvas/src/lib.rs index 6e751cb6..49cbd3f2 100644 --- a/canvas/src/lib.rs +++ b/canvas/src/lib.rs @@ -144,7 +144,7 @@ impl CanvasRenderingContext2D { #[inline] pub fn fill_path(&mut self, path: Path2D) { let paint_id = self.scene.push_paint(&self.current_state.fill_paint); - self.scene.push_object(PathObject::new(path.into_outline(), paint_id, String::new())) + self.scene.push_path(PathObject::new(path.into_outline(), paint_id, String::new())) } #[inline] @@ -153,7 +153,7 @@ impl CanvasRenderingContext2D { let stroke_width = f32::max(self.current_state.line_width, HAIRLINE_STROKE_WIDTH); let mut stroke_to_fill = OutlineStrokeToFill::new(path.into_outline(), stroke_width); stroke_to_fill.offset(); - self.scene.push_object(PathObject::new(stroke_to_fill.outline, paint_id, String::new())) + self.scene.push_path(PathObject::new(stroke_to_fill.outline, paint_id, String::new())) } #[inline] diff --git a/renderer/src/builder.rs b/renderer/src/builder.rs index 4494e481..a8c409e3 100644 --- a/renderer/src/builder.rs +++ b/renderer/src/builder.rs @@ -56,14 +56,14 @@ impl<'a> SceneBuilder<'a> { let start_time = Instant::now(); let bounding_quad = self.built_options.bounding_quad(); - let object_count = self.scene.objects.len(); - self.listener.send(RenderCommand::Start { bounding_quad, object_count }); + let path_count = self.scene.paths.len(); + self.listener.send(RenderCommand::Start { bounding_quad, path_count }); self.listener.send(RenderCommand::AddShaders(self.scene.build_shaders())); let effective_view_box = self.scene.effective_view_box(self.built_options); - let alpha_tiles = executor.flatten_into_vector(object_count, |object_index| { - self.build_object(object_index, effective_view_box, &self.built_options, &self.scene) + let alpha_tiles = executor.flatten_into_vector(path_count, |path_index| { + self.build_path(path_index, effective_view_box, &self.built_options, &self.scene) }); self.finish_building(alpha_tiles); @@ -72,17 +72,17 @@ impl<'a> SceneBuilder<'a> { self.listener.send(RenderCommand::Finish { build_time }); } - fn build_object( + fn build_path( &self, - object_index: usize, + path_index: usize, view_box: RectF32, built_options: &PreparedRenderOptions, scene: &Scene, ) -> Vec { - let object = &scene.objects[object_index]; - let outline = scene.apply_render_options(object.outline(), built_options); + let path_object = &scene.paths[path_index]; + let outline = scene.apply_render_options(path_object.outline(), built_options); - let mut tiler = Tiler::new(self, &outline, view_box, object_index as u16); + let mut tiler = Tiler::new(self, &outline, view_box, path_index as u16); tiler.generate_tiles(); self.listener.send(RenderCommand::AddFills(tiler.built_object.fills)); @@ -107,8 +107,8 @@ impl<'a> SceneBuilder<'a> { } fn pack_alpha_tiles(&mut self, alpha_tiles: Vec) { - let object_count = self.scene.objects.len() as u32; - let solid_tiles = self.z_buffer.build_solid_tiles(0..object_count); + let path_count = self.scene.paths.len() as u32; + let solid_tiles = self.z_buffer.build_solid_tiles(0..path_count); if !solid_tiles.is_empty() { self.listener.send(RenderCommand::SolidTile(solid_tiles)); } diff --git a/renderer/src/gpu/debug.rs b/renderer/src/gpu/debug.rs index 247e39e6..d23082b1 100644 --- a/renderer/src/gpu/debug.rs +++ b/renderer/src/gpu/debug.rs @@ -97,7 +97,7 @@ where let origin = window_rect.origin() + Point2DI32::new(PADDING, PADDING + FONT_ASCENT); self.ui_presenter.draw_text( device, - &format!("Objects: {}", mean_cpu_sample.stats.object_count), + &format!("Paths: {}", mean_cpu_sample.stats.path_count), origin, false, ); diff --git a/renderer/src/gpu/renderer.rs b/renderer/src/gpu/renderer.rs index bdc94011..e08d35d7 100644 --- a/renderer/src/gpu/renderer.rs +++ b/renderer/src/gpu/renderer.rs @@ -236,11 +236,11 @@ where pub fn render_command(&mut self, command: &RenderCommand) { match *command { - RenderCommand::Start { bounding_quad, object_count } => { + RenderCommand::Start { bounding_quad, path_count } => { if self.use_depth { self.draw_stencil(&bounding_quad); } - self.stats.object_count = object_count; + self.stats.path_count = path_count; } RenderCommand::AddShaders(ref shaders) => self.upload_shaders(shaders), RenderCommand::AddFills(ref fills) => self.add_fills(fills), @@ -1545,7 +1545,7 @@ impl Default for RenderMode { #[derive(Clone, Copy, Debug, Default)] pub struct RenderStats { - pub object_count: usize, + pub path_count: usize, pub fill_count: usize, pub alpha_tile_count: usize, pub solid_tile_count: usize, @@ -1555,7 +1555,7 @@ impl Add for RenderStats { type Output = RenderStats; fn add(self, other: RenderStats) -> RenderStats { RenderStats { - object_count: self.object_count + other.object_count, + path_count: self.path_count + other.path_count, solid_tile_count: self.solid_tile_count + other.solid_tile_count, alpha_tile_count: self.alpha_tile_count + other.alpha_tile_count, fill_count: self.fill_count + other.fill_count, @@ -1567,7 +1567,7 @@ impl Div for RenderStats { type Output = RenderStats; fn div(self, divisor: usize) -> RenderStats { RenderStats { - object_count: self.object_count / divisor, + path_count: self.path_count / divisor, solid_tile_count: self.solid_tile_count / divisor, alpha_tile_count: self.alpha_tile_count / divisor, fill_count: self.fill_count / divisor, diff --git a/renderer/src/gpu_data.rs b/renderer/src/gpu_data.rs index 68d12efa..c130abd6 100644 --- a/renderer/src/gpu_data.rs +++ b/renderer/src/gpu_data.rs @@ -27,7 +27,7 @@ pub(crate) struct BuiltObject { } pub enum RenderCommand { - Start { object_count: usize, bounding_quad: BoundingQuad }, + Start { path_count: usize, bounding_quad: BoundingQuad }, AddShaders(Vec), AddFills(Vec), FlushFills, diff --git a/renderer/src/scene.rs b/renderer/src/scene.rs index 77f272b2..2e3549ef 100644 --- a/renderer/src/scene.rs +++ b/renderer/src/scene.rs @@ -24,7 +24,7 @@ use std::io::{self, Write}; #[derive(Clone)] pub struct Scene { - pub(crate) objects: Vec, + pub(crate) paths: Vec, paints: Vec, paint_cache: HashMap, bounds: RectF32, @@ -35,7 +35,7 @@ impl Scene { #[inline] pub fn new() -> Scene { Scene { - objects: vec![], + paths: vec![], paints: vec![], paint_cache: HashMap::new(), bounds: RectF32::default(), @@ -43,9 +43,9 @@ impl Scene { } } - pub fn push_object(&mut self, object: PathObject) { - self.bounds = self.bounds.union_rect(object.outline.bounds()); - self.objects.push(object); + pub fn push_path(&mut self, path: PathObject) { + self.bounds = self.bounds.union_rect(path.outline.bounds()); + self.paths.push(path); } #[allow(clippy::trivially_copy_pass_by_ref)] @@ -61,8 +61,8 @@ impl Scene { } #[inline] - pub fn object_count(&self) -> usize { - self.objects.len() + pub fn path_count(&self) -> usize { + self.paths.len() } #[inline] @@ -86,13 +86,10 @@ impl Scene { } pub fn build_shaders(&self) -> Vec { - self.objects + self.paths .iter() - .map(|object| { - let paint = &self.paints[object.paint.0 as usize]; - ObjectShader { - fill_color: paint.color, - } + .map(|path_object| { + ObjectShader { fill_color: self.paints[path_object.paint.0 as usize].color } }) .collect() } @@ -151,16 +148,16 @@ impl Scene { } pub fn monochrome_color(&self) -> Option { - if self.objects.is_empty() { + if self.paths.is_empty() { return None; } - let first_paint_id = self.objects[0].paint; + + let first_paint_id = self.paths[0].paint; if self - .objects + .paths .iter() .skip(1) - .any(|object| object.paint != first_paint_id) - { + .any(|path_object| path_object.paint != first_paint_id) { return None; } Some(self.paints[first_paint_id.0 as usize].color) @@ -194,16 +191,16 @@ impl Scene { self.view_box.size().x(), self.view_box.size().y() )?; - for object in &self.objects { - let paint = &self.paints[object.paint.0 as usize]; + for path_object in &self.paths { + let paint = &self.paints[path_object.paint.0 as usize]; write!(writer, " ", - paint.color, object.outline + paint.color, path_object.outline )?; } writeln!(writer, "")?; diff --git a/svg/src/lib.rs b/svg/src/lib.rs index 941892ae..90f5a172 100644 --- a/svg/src/lib.rs +++ b/svg/src/lib.rs @@ -122,11 +122,8 @@ impl BuiltSVG { let path = Transform2DF32PathIter::new(path, &transform); let outline = Outline::from_segments(path); - self.scene.push_object(PathObject::new( - outline, - style, - format!("Fill({})", node.id()), - )); + let name = format!("Fill({})", node.id()); + self.scene.push_path(PathObject::new(outline, style, name)); } if let Some(ref stroke) = path.stroke { @@ -144,11 +141,8 @@ impl BuiltSVG { let mut outline = stroke_to_fill.outline; outline.transform(&transform); - self.scene.push_object(PathObject::new( - outline, - style, - format!("Stroke({})", node.id()), - )); + let name = format!("Stroke({})", node.id()); + self.scene.push_path(PathObject::new(outline, style, name)); } } NodeKind::Path(..) => {} diff --git a/text/src/lib.rs b/text/src/lib.rs index 9a8cb5b8..f210f4bc 100644 --- a/text/src/lib.rs +++ b/text/src/lib.rs @@ -74,7 +74,7 @@ impl SceneExt for Scene { outline = stroke_to_fill.outline; } - self.push_object(PathObject::new(outline, paint_id, String::new())); + self.push_path(PathObject::new(outline, paint_id, String::new())); Ok(()) }