diff --git a/canvas/src/lib.rs b/canvas/src/lib.rs index b3de4f42..a9586b98 100644 --- a/canvas/src/lib.rs +++ b/canvas/src/lib.rs @@ -213,7 +213,7 @@ impl CanvasRenderingContext2D { let paint_id = self.scene.push_paint(&paint); let mut stroke_style = self.current_state.resolve_stroke_style(); - + // The smaller scale is relevant here, as we multiply by it and want to ensure it is always // bigger than `HAIRLINE_STROKE_WIDTH`. let transform_scale = f32::min(self.current_state.transform.m11(), @@ -289,7 +289,7 @@ impl CanvasRenderingContext2D { self.composite_render_target_if_needed(composite_op, render_target_id); } - fn push_render_target_if_needed(&mut self, composite_op: Option) + fn push_render_target_if_needed(&mut self, composite_op: Option) -> Option { if composite_op.is_none() { return None; diff --git a/content/src/effects.rs b/content/src/effects.rs index fd4df276..9141340c 100644 --- a/content/src/effects.rs +++ b/content/src/effects.rs @@ -78,7 +78,7 @@ pub enum CompositeOp { Copy, /// The source that overlaps the destination replaces the destination. SrcIn, - /// Destination which overlaps the source replaces the source. + /// Destination which overlaps the source replaces the source. DestIn, /// Source is placed where it falls outside of the destination. SrcOut, @@ -87,7 +87,7 @@ pub enum CompositeOp { } /// Blend modes that can be applied to individual paths. -/// +/// /// All blend modes preserve parts of the destination that are not overlapped by the source path. /// Other Porter-Duff compositing operations are `CompositeOp`s. #[derive(Clone, Copy, PartialEq, Debug)] diff --git a/content/src/lib.rs b/content/src/lib.rs index 095b40a1..67cd0772 100644 --- a/content/src/lib.rs +++ b/content/src/lib.rs @@ -9,7 +9,7 @@ // except according to those terms. //! Pathfinder's representation of a vector scene. -//! +//! //! This module also contains various path utilities. #[macro_use] diff --git a/content/src/segment.rs b/content/src/segment.rs index 8b0d101e..7cff4cb0 100644 --- a/content/src/segment.rs +++ b/content/src/segment.rs @@ -69,7 +69,7 @@ impl Segment { } /// Approximates an unit-length arc with a cubic Bézier curve. - /// + /// /// The maximum supported sweep angle is π/2 (i.e. 90°). pub fn arc(sweep_angle: f32) -> Segment { Segment::arc_from_cos(f32::cos(sweep_angle)) diff --git a/demo/common/src/lib.rs b/demo/common/src/lib.rs index fabeb13a..d92819cf 100644 --- a/demo/common/src/lib.rs +++ b/demo/common/src/lib.rs @@ -343,7 +343,7 @@ impl DemoApp where W: Window { for (index, eye_transform) in eye_transforms.iter().enumerate().skip(1) { let weight = 1.0 / (index + 1) as f32; scene_transform.perspective.transform = - scene_transform.perspective + scene_transform.perspective .transform .lerp(weight, &eye_transform.perspective.transform); scene_transform.modelview_to_eye = diff --git a/demo/common/src/renderer.rs b/demo/common/src/renderer.rs index f44b0f91..b6934d5f 100644 --- a/demo/common/src/renderer.rs +++ b/demo/common/src/renderer.rs @@ -214,7 +214,7 @@ impl DemoApp where W: Window { let base_transform = perspective.transform * Transform4F::from_translation(offset); // Fill ground. - let transform = base_transform * + let transform = base_transform * Transform4F::from_scale(Vector4F::new(ground_scale, 1.0, ground_scale, 1.0)); // Don't clear the first scene after drawing it. diff --git a/demo/common/src/ui.rs b/demo/common/src/ui.rs index 0f2e500f..69e12b32 100644 --- a/demo/common/src/ui.rs +++ b/demo/common/src/ui.rs @@ -83,7 +83,7 @@ impl DemoUIModel { // Only relevant if in monochrome mode. pub fn foreground_color(&self) -> ColorU { match self.background_color { - BackgroundColor::Light | BackgroundColor::Transparent => ColorU::black(), + BackgroundColor::Light | BackgroundColor::Transparent => ColorU::black(), BackgroundColor::Dark => ColorU::white(), } } diff --git a/demo/magicleap/src/c_api.rs b/demo/magicleap/src/c_api.rs index 52f92244..ee22f6f0 100644 --- a/demo/magicleap/src/c_api.rs +++ b/demo/magicleap/src/c_api.rs @@ -75,7 +75,7 @@ pub struct MLGraphicsRenderBufferInfo { pub color: MLGraphicsRenderTarget, pub depth: MLGraphicsRenderTarget, } - + #[derive(Clone, Copy, Debug)] #[repr(C)] pub struct MLGraphicsRenderTarget { diff --git a/demo/magicleap/src/glwindow.rs b/demo/magicleap/src/glwindow.rs index fb26d467..9f412b92 100644 --- a/demo/magicleap/src/glwindow.rs +++ b/demo/magicleap/src/glwindow.rs @@ -112,7 +112,7 @@ impl Display for GlWindowDisplay { self.handle_events(); Ok(()) } - + fn running(&self) -> bool { self.running } @@ -124,7 +124,7 @@ impl Display for GlWindowDisplay { impl DisplayCamera for GlWindowCamera { type Error = GlWindowError; - + fn make_current(&mut self) -> Result<(), GlWindowError> { let bounds = self.bounds(); unsafe { @@ -176,7 +176,7 @@ impl GlWindowDisplay { let cameras = vec![ GlWindowCamera { gl_window: gl_window.clone(), start, eye: Eye::Left }, GlWindowCamera { gl_window: gl_window.clone(), start, eye: Eye::Right }, - ]; + ]; gl::load_with(|name| gl_window.get_proc_address(name) as *const _); Ok(GlWindowDisplay { resource_loader, @@ -251,4 +251,4 @@ impl From for GlWindowError { } impl DisplayError for GlWindowError { -} \ No newline at end of file +} diff --git a/demo/magicleap/src/lib.rs b/demo/magicleap/src/lib.rs index fad29763..cb448aae 100644 --- a/demo/magicleap/src/lib.rs +++ b/demo/magicleap/src/lib.rs @@ -91,7 +91,7 @@ pub extern "C" fn magicleap_pathfinder_demo_init(egl_display: EGLDisplay, egl_co options.background_color = BackgroundColor::Transparent; options.mode = Mode::VR; options.jobs = Some(3); - + let demo = DemoApp::new(window, window_size, options); info!("Initialized app"); @@ -144,7 +144,7 @@ pub struct MagicLeapPathfinderRenderOptions { surface: EGLSurface, bg_color: [f32; 4], viewport: [u32; 4], - svg_filename: *const c_char, + svg_filename: *const c_char, } #[no_mangle] @@ -159,7 +159,7 @@ pub extern "C" fn magicleap_pathfinder_init() -> *mut c_void { log::set_boxed_logger(Box::new(logger)).unwrap(); log::set_max_level(level); info!("Initialized logging"); - + gl::load_with(|s| egl::get_proc_address(s) as *const c_void); info!("Initialized gl"); @@ -219,7 +219,7 @@ pub unsafe extern "C" fn magicleap_pathfinder_render(pf: *mut c_void, options: * let transform = Transform2F::from_translation(svg.scene.bounds().size().scale(-0.5)) .post_mul(&Transform2F::from_scale(Vector2F::splat(scale))) .post_mul(&Transform2F::from_translation(viewport_size.to_f32().scale(0.5))); - + let render_options = RenderOptions { transform: RenderTransform::Transform2D(transform), dilation: Vector2F::default(), diff --git a/export/src/lib.rs b/export/src/lib.rs index cbd468d9..6422662d 100644 --- a/export/src/lib.rs +++ b/export/src/lib.rs @@ -21,10 +21,10 @@ use pdf::Pdf; pub enum FileFormat { /// Scalable Vector Graphics SVG, - + /// Portable Document Format PDF, - + /// PostScript PS, } @@ -63,18 +63,18 @@ fn export_svg(scene: &Scene, writer: &mut W) -> io::Result<()> { writeln!(writer, "")?; Ok(()) } - + fn export_pdf(scene: &Scene, writer: &mut W) -> io::Result<()> { let mut pdf = Pdf::new(); let view_box = scene.view_box(); pdf.add_page(view_box.size()); - + let height = view_box.size().y(); let tr = |v: Vector2F| -> Vector2F { let r = v - view_box.origin(); Vector2F::new(r.x(), height - r.y()) }; - + for (paint, outline, _) in scene.paths() { match paint { Paint::Color(color) => pdf.set_fill_color(*color), @@ -85,7 +85,7 @@ fn export_pdf(scene: &Scene, writer: &mut W) -> io::Result<()> { // TODO(pcwalton): Patterns. } } - + for contour in outline.contours() { for (segment_index, segment) in contour.iter().enumerate() { if segment_index == 0 { @@ -111,13 +111,13 @@ fn export_pdf(scene: &Scene, writer: &mut W) -> io::Result<()> { pdf.close(); } } - + // closes implicitly pdf.fill(); } pdf.write_to(writer) } - + fn export_ps(scene: &Scene, writer: &mut W) -> io::Result<()> { struct P(Vector2F); impl fmt::Display for P { @@ -138,7 +138,7 @@ fn export_ps(scene: &Scene, writer: &mut W) -> io::Result<()> { )?; writeln!(writer, "0 {} translate", view_box.size().y())?; writeln!(writer, "1 -1 scale")?; - + for (paint, outline, name) in scene.paths() { if !name.is_empty() { writeln!(writer, "newpath % {}", name)?; diff --git a/export/src/pdf.rs b/export/src/pdf.rs index a3b58139..bb85344b 100644 --- a/export/src/pdf.rs +++ b/export/src/pdf.rs @@ -133,22 +133,22 @@ impl Pdf { .extend("/DeviceRGB cs /DeviceRGB CS\n1 j 1 J\n".bytes()); self.page_size = Some(size); } - + pub fn move_to(&mut self, p: Vector2F) { writeln!(self.page_buffer, "{} {} m", p.x(), p.y()).unwrap(); } - + pub fn line_to(&mut self, p: Vector2F) { writeln!(self.page_buffer, "{} {} l", p.x(), p.y()).unwrap(); } - + pub fn cubic_to(&mut self, c1: Vector2F, c2: Vector2F, p: Vector2F) { writeln!(self.page_buffer, "{} {} {} {} {} {} c", c1.x(), c1.y(), c2.x(), c2.y(), p.x(), p.y()).unwrap(); } pub fn fill(&mut self) { writeln!(self.page_buffer, "f").unwrap(); } - + pub fn close(&mut self) { writeln!(self.page_buffer, "h").unwrap(); } @@ -203,7 +203,7 @@ impl Pdf { pub fn write_to(&mut self, writer: W) -> io::Result<()> where W: Write { let mut out = Counter::new(writer); out.write_all(b"%PDF-1.7\n%\xB5\xED\xAE\xFB\n")?; - + if !self.page_buffer.is_empty() { self.end_page(); } @@ -254,7 +254,7 @@ impl Pdf { // Write the PDF EOF out.write_all(b"%%EOF")?; - + Ok(()) } } diff --git a/renderer/src/allocator.rs b/renderer/src/allocator.rs index 1090ae46..ebf49360 100644 --- a/renderer/src/allocator.rs +++ b/renderer/src/allocator.rs @@ -100,7 +100,7 @@ impl TextureAllocator { TextureLocation { page, rect } } - pub fn allocate_render_target(&mut self, requested_size: Vector2I, id: RenderTargetId) + pub fn allocate_render_target(&mut self, requested_size: Vector2I, id: RenderTargetId) -> TextureLocation { let page = PaintPageId(self.pages.len() as u32); let rect = RectI::new(Vector2I::default(), requested_size); diff --git a/renderer/src/gpu/renderer.rs b/renderer/src/gpu/renderer.rs index 493005e4..1748bb29 100644 --- a/renderer/src/gpu/renderer.rs +++ b/renderer/src/gpu/renderer.rs @@ -472,7 +472,7 @@ where } self.stats.path_count = path_count; - self.flags.set(RendererFlags::INTERMEDIATE_DEST_FRAMEBUFFER_NEEDED, + self.flags.set(RendererFlags::INTERMEDIATE_DEST_FRAMEBUFFER_NEEDED, needs_readable_framebuffer); } @@ -857,7 +857,7 @@ where self.set_uniforms_for_overlay_blend_mode(&mut textures, &mut uniforms, blend_mode); } BlendModeProgram::DodgeBurn => { - self.set_uniforms_for_dodge_burn_blend_mode(&mut textures, + self.set_uniforms_for_dodge_burn_blend_mode(&mut textures, &mut uniforms, blend_mode); } diff --git a/renderer/src/gpu/shaders.rs b/renderer/src/gpu/shaders.rs index efc856a3..93faa7fd 100644 --- a/renderer/src/gpu/shaders.rs +++ b/renderer/src/gpu/shaders.rs @@ -466,7 +466,7 @@ pub struct AlphaTileBlendModeProgram where D: Device { } impl AlphaTileBlendModeProgram where D: Device { - pub fn new(device: &D, resources: &dyn ResourceLoader, name: &str) + pub fn new(device: &D, resources: &dyn ResourceLoader, name: &str) -> AlphaTileBlendModeProgram { let alpha_tile_program = AlphaTileProgram::from_fragment_shader_name(device, resources, name); diff --git a/renderer/src/paint.rs b/renderer/src/paint.rs index b7aafc91..6766fe97 100644 --- a/renderer/src/paint.rs +++ b/renderer/src/paint.rs @@ -296,7 +296,7 @@ impl Palette { // Render the actual texels. // // TODO(pcwalton): This is slow. Do more on GPU. - let mut paint_data = PaintData { pages: vec![] }; + let mut paint_data = PaintData { pages: vec![] }; for page_index in 0..allocator.page_count() { let page_index = PaintPageId(page_index); let page_size = allocator.page_size(page_index); diff --git a/renderer/src/scene.rs b/renderer/src/scene.rs index 9ab2204a..d7d48ce6 100644 --- a/renderer/src/scene.rs +++ b/renderer/src/scene.rs @@ -190,7 +190,7 @@ impl Scene { let prepared_options = options.prepare(self.bounds); SceneBuilder::new(self, &prepared_options, listener).build(executor) } - + pub fn paths<'a>(&'a self) -> PathIter { PathIter { scene: self, diff --git a/text/src/lib.rs b/text/src/lib.rs index d8472e73..9f0e4b75 100644 --- a/text/src/lib.rs +++ b/text/src/lib.rs @@ -179,7 +179,7 @@ impl Build for OutlinePathBuilder { self.flush_current_contour(); self.outline } - + fn build_and_reset(&mut self) -> Outline { self.flush_current_contour(); mem::replace(&mut self.outline, Outline::new()) @@ -218,5 +218,4 @@ impl FlatPathBuilder for OutlinePathBuilder { let point = self.current_contour.position_of(point_index); Point2D::new(point.x(), point.y()) } - - } +} diff --git a/ui/src/lib.rs b/ui/src/lib.rs index e8a7907b..c5c925b7 100644 --- a/ui/src/lib.rs +++ b/ui/src/lib.rs @@ -603,7 +603,7 @@ impl DebugTextureVertexArray where D: Device { let position_attr = device.get_vertex_attr(&debug_texture_program.program, "Position") .unwrap(); - let tex_coord_attr = device.get_vertex_attr(&debug_texture_program.program, "TexCoord") + let tex_coord_attr = device.get_vertex_attr(&debug_texture_program.program, "TexCoord") .unwrap(); device.bind_buffer(&vertex_array, &vertex_buffer, BufferTarget::Vertex); diff --git a/utils/convert/src/main.rs b/utils/convert/src/main.rs index 74555b5f..f7923f69 100644 --- a/utils/convert/src/main.rs +++ b/utils/convert/src/main.rs @@ -10,7 +10,7 @@ fn main() -> Result<(), Box> { let mut args = std::env::args_os().skip(1); let input = PathBuf::from(args.next().expect("no input given")); let output = PathBuf::from(args.next().expect("no output given")); - + let mut data = Vec::new(); File::open(input)?.read_to_end(&mut data)?; let svg = BuiltSVG::from_tree(&Tree::from_data(&data, &Options::default()).unwrap());