From 9727b57dd7cabfde76f69b0896e32596f5bb2647 Mon Sep 17 00:00:00 2001 From: Malte Veerman Date: Wed, 11 Dec 2019 21:36:00 +0100 Subject: [PATCH] Ran cargo_fmt over changed files. --- native/src/icon_loader/icon_loader.rs | 13 ++++--- native/src/widget/icon.rs | 14 ++----- src/native.rs | 4 +- wgpu/src/renderer.rs | 12 +++--- wgpu/src/renderer/widget/icon.rs | 13 +++---- wgpu/src/svg.rs | 54 +++++++++++++++------------ 6 files changed, 54 insertions(+), 56 deletions(-) diff --git a/native/src/icon_loader/icon_loader.rs b/native/src/icon_loader/icon_loader.rs index 76247a5a97..4bb2c9b1b4 100644 --- a/native/src/icon_loader/icon_loader.rs +++ b/native/src/icon_loader/icon_loader.rs @@ -84,9 +84,7 @@ impl IconLoader { /// Returns the name of the system icon theme. pub fn system_theme_name() -> Option { //TODO: System theme logic - Some(String::from( - "hicolor", - )) + Some(String::from("hicolor")) } fn find_icon( @@ -210,19 +208,22 @@ impl IconTheme { "Threshold" => { if let Ok(threshold) = value.parse() { - dir_info.threshold = Some(threshold); + dir_info.threshold = + Some(threshold); } } "MinSize" => { if let Ok(min_size) = value.parse() { - dir_info.min_size = Some(min_size); + dir_info.min_size = + Some(min_size); } } "MaxSize" => { if let Ok(max_size) = value.parse() { - dir_info.max_size = Some(max_size); + dir_info.max_size = + Some(max_size); } } "Scale" => { diff --git a/native/src/widget/icon.rs b/native/src/widget/icon.rs index 2631e802f5..1dd1bac168 100644 --- a/native/src/widget/icon.rs +++ b/native/src/widget/icon.rs @@ -4,8 +4,7 @@ use crate::{ Widget, ICON_LOADER, }; -use std::hash::Hash; -use std::path::PathBuf; +use std::{hash::Hash, path::PathBuf}; /// A simple icon_loader widget. #[derive(Debug, Clone)] @@ -82,10 +81,7 @@ where ) -> Renderer::Output { let bounds = layout.bounds(); - renderer.draw( - bounds, - &self.handle, - ) + renderer.draw(bounds, &self.handle) } fn hash_layout(&self, state: &mut Hasher) { @@ -134,11 +130,7 @@ pub trait Renderer: crate::Renderer { /// Draws an [`Icon`]. /// /// [`Icon`]: struct.Icon.html - fn draw( - &mut self, - bounds: Rectangle, - handle: &Handle, - ) -> Self::Output; + fn draw(&mut self, bounds: Rectangle, handle: &Handle) -> Self::Output; } impl<'a, Message, Renderer> From for Element<'a, Message, Renderer> diff --git a/src/native.rs b/src/native.rs index b24518a2a6..e52b63d3e0 100644 --- a/src/native.rs +++ b/src/native.rs @@ -89,8 +89,8 @@ pub mod widget { #[doc(no_inline)] pub use { - button::Button, icon::Icon, image::Image, scrollable::Scrollable, slider::Slider, - text_input::TextInput, + button::Button, icon::Icon, image::Image, scrollable::Scrollable, + slider::Slider, text_input::TextInput, }; /// A container that distributes its contents vertically. diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index 9895e1c4f8..92e249337d 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -243,13 +243,11 @@ impl Renderer { scale: [bounds.width, bounds.height], }); } - Primitive::Svg { handle, bounds } => { - layer.svgs.push(Svg { - handle: handle.clone(), - position: [bounds.x, bounds.y], - scale: [bounds.width, bounds.height], - }) - }, + Primitive::Svg { handle, bounds } => layer.svgs.push(Svg { + handle: handle.clone(), + position: [bounds.x, bounds.y], + scale: [bounds.width, bounds.height], + }), Primitive::Clip { bounds, offset, diff --git a/wgpu/src/renderer/widget/icon.rs b/wgpu/src/renderer/widget/icon.rs index 54ac136203..b29612b56c 100644 --- a/wgpu/src/renderer/widget/icon.rs +++ b/wgpu/src/renderer/widget/icon.rs @@ -1,7 +1,5 @@ use crate::{svg, Primitive, Renderer}; -use iced_native::{ - icon, image, MouseCursor, Rectangle, -}; +use iced_native::{icon, image, MouseCursor, Rectangle}; use std::path::PathBuf; impl icon::Renderer for Renderer { @@ -12,9 +10,10 @@ impl icon::Renderer for Renderer { ) -> Self::Output { let path = match handle { icon::Handle::Simple(path) => path.clone(), - icon::Handle::Theme(icon_info) => { - icon_info.file_for_size(bounds.width as u16).file_path().to_path_buf() - }, + icon::Handle::Theme(icon_info) => icon_info + .file_for_size(bounds.width as u16) + .file_path() + .to_path_buf(), icon::Handle::None => PathBuf::new(), }; @@ -38,4 +37,4 @@ impl icon::Renderer for Renderer { MouseCursor::OutOfBounds, ) } -} \ No newline at end of file +} diff --git a/wgpu/src/svg.rs b/wgpu/src/svg.rs index 1b8f14b074..755303a591 100644 --- a/wgpu/src/svg.rs +++ b/wgpu/src/svg.rs @@ -12,7 +12,6 @@ use std::{ u32, }; - #[derive(Debug)] pub struct Pipeline { cache: RefCell, @@ -220,10 +219,11 @@ impl Pipeline { opt.usvg.dpi = handle.dpi as f64; opt.usvg.font_size = handle.font_size as f64; - let mem = match resvg::usvg::Tree::from_file(&handle.path, &opt.usvg) { - Ok(tree) => Memory::Host { tree }, - Err(_) => Memory::Invalid - }; + let mem = + match resvg::usvg::Tree::from_file(&handle.path, &opt.usvg) { + Ok(tree) => Memory::Host { tree }, + Err(_) => Memory::Invalid, + }; let _ = self.cache.borrow_mut().insert(&handle, mem); } @@ -265,12 +265,14 @@ impl Pipeline { self.load(&handle); - if let Some(texture) = self - .cache - .borrow_mut() - .get(&handle) - .unwrap() - .upload(device, encoder, &self.texture_layout, svg.scale[0] as u32, svg.scale[1] as u32) + if let Some(texture) = + self.cache.borrow_mut().get(&handle).unwrap().upload( + device, + encoder, + &self.texture_layout, + svg.scale[0] as u32, + svg.scale[1] as u32, + ) { let instance_buffer = device .create_buffer_mapped(1, wgpu::BufferUsage::COPY_SRC) @@ -409,12 +411,8 @@ impl Hash for Handle { } enum Memory { - Host { - tree: resvg::usvg::Tree, - }, - Device { - bind_group: Rc, - }, + Host { tree: resvg::usvg::Tree }, + Device { bind_group: Rc }, NotFound, Invalid, } @@ -426,7 +424,7 @@ impl Memory { encoder: &mut wgpu::CommandEncoder, texture_layout: &wgpu::BindGroupLayout, width: u32, - height: u32 + height: u32, ) -> Option> { match self { Memory::Host { tree } => { @@ -447,10 +445,17 @@ impl Memory { | wgpu::TextureUsage::SAMPLED, }); - let mut canvas = resvg::raqote::DrawTarget::new(width as i32, height as i32); + let mut canvas = + resvg::raqote::DrawTarget::new(width as i32, height as i32); let opt = resvg::Options::default(); - let screen_size = resvg::ScreenSize::new(width, height).unwrap(); - resvg::backend_raqote::render_to_canvas(tree, &opt, screen_size, &mut canvas); + let screen_size = + resvg::ScreenSize::new(width, height).unwrap(); + resvg::backend_raqote::render_to_canvas( + tree, + &opt, + screen_size, + &mut canvas, + ); let slice = canvas.get_data(); let temp_buf = device .create_buffer_mapped( @@ -506,7 +511,10 @@ impl Memory { } impl Debug for Memory { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + fn fmt( + &self, + f: &mut std::fmt::Formatter<'_>, + ) -> Result<(), std::fmt::Error> { match self { Memory::Host { .. } => write!(f, "Memory::Host"), Memory::Device { .. } => write!(f, "Memory::Device"), @@ -593,4 +601,4 @@ struct Instance { #[derive(Debug, Clone, Copy)] struct Uniforms { transform: [f32; 16], -} \ No newline at end of file +}