diff options
author | 2020-02-09 03:36:59 +0100 | |
---|---|---|
committer | 2020-02-09 03:36:59 +0100 | |
commit | 8f0b59a4b28bee028a879b0705eeeaa0b2e82df6 (patch) | |
tree | 6a59a0c0aa04279390845d6beebd994442533223 | |
parent | 8edb04fddd55519ebebeee32a79dac99eef9e174 (diff) | |
download | iced-8f0b59a4b28bee028a879b0705eeeaa0b2e82df6.tar.gz iced-8f0b59a4b28bee028a879b0705eeeaa0b2e82df6.tar.bz2 iced-8f0b59a4b28bee028a879b0705eeeaa0b2e82df6.zip |
Remove `scale_factor` from `iced_wgpu::Viewport`
-rw-r--r-- | native/src/window/backend.rs | 2 | ||||
-rw-r--r-- | wgpu/src/renderer.rs | 3 | ||||
-rw-r--r-- | wgpu/src/viewport.rs | 11 | ||||
-rw-r--r-- | wgpu/src/window/backend.rs | 5 | ||||
-rw-r--r-- | wgpu/src/window/swap_chain.rs | 3 | ||||
-rw-r--r-- | winit/src/application.rs | 3 |
6 files changed, 12 insertions, 15 deletions
diff --git a/native/src/window/backend.rs b/native/src/window/backend.rs index 690dbdab..3bc691cd 100644 --- a/native/src/window/backend.rs +++ b/native/src/window/backend.rs @@ -38,7 +38,6 @@ pub trait Backend: Sized { surface: &Self::Surface, width: u32, height: u32, - scale_factor: f64, ) -> Self::SwapChain; /// Draws the output primitives to the next frame of the given [`SwapChain`]. @@ -50,6 +49,7 @@ pub trait Backend: Sized { renderer: &mut Self::Renderer, swap_chain: &mut Self::SwapChain, output: &<Self::Renderer as crate::Renderer>::Output, + scale_factor: f64, overlay: &[T], ) -> MouseCursor; } diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index a99080f4..904e3c65 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -73,12 +73,13 @@ impl Renderer { encoder: &mut wgpu::CommandEncoder, target: Target<'_>, (primitive, mouse_cursor): &(Primitive, MouseCursor), + scale_factor: f64, overlay: &[T], ) -> MouseCursor { log::debug!("Drawing"); let (width, height) = target.viewport.dimensions(); - let scale_factor = target.viewport.scale_factor(); + let scale_factor = scale_factor as f32; let transformation = target.viewport.transformation(); let mut layers = Vec::new(); diff --git a/wgpu/src/viewport.rs b/wgpu/src/viewport.rs index a4bcb704..66242468 100644 --- a/wgpu/src/viewport.rs +++ b/wgpu/src/viewport.rs @@ -1,31 +1,28 @@ use crate::Transformation; +/// A viewing region for displaying computer graphics. #[derive(Debug)] pub struct Viewport { width: u32, height: u32, - scale_factor: f32, transformation: Transformation, } impl Viewport { - pub fn new(width: u32, height: u32, scale_factor: f64) -> Viewport { + /// Creates a new [`Viewport`] with the given dimensions. + pub fn new(width: u32, height: u32) -> Viewport { Viewport { width, height, - scale_factor: scale_factor as f32, transformation: Transformation::orthographic(width, height), } } + /// Returns the dimensions of the [`Viewport`]. pub fn dimensions(&self) -> (u32, u32) { (self.width, self.height) } - pub fn scale_factor(&self) -> f32 { - self.scale_factor - } - pub(crate) fn transformation(&self) -> Transformation { self.transformation } diff --git a/wgpu/src/window/backend.rs b/wgpu/src/window/backend.rs index fda34a0a..0e4f02c9 100644 --- a/wgpu/src/window/backend.rs +++ b/wgpu/src/window/backend.rs @@ -47,9 +47,8 @@ impl iced_native::window::Backend for Backend { surface: &Self::Surface, width: u32, height: u32, - scale_factor: f64, ) -> SwapChain { - SwapChain::new(&self.device, surface, width, height, scale_factor) + SwapChain::new(&self.device, surface, width, height) } fn draw<T: AsRef<str>>( @@ -57,6 +56,7 @@ impl iced_native::window::Backend for Backend { renderer: &mut Self::Renderer, swap_chain: &mut SwapChain, output: &<Self::Renderer as iced_native::Renderer>::Output, + scale_factor: f64, overlay: &[T], ) -> MouseCursor { let (frame, viewport) = swap_chain.next_frame(); @@ -89,6 +89,7 @@ impl iced_native::window::Backend for Backend { viewport, }, output, + scale_factor, overlay, ); diff --git a/wgpu/src/window/swap_chain.rs b/wgpu/src/window/swap_chain.rs index 46aaa869..3760e8a2 100644 --- a/wgpu/src/window/swap_chain.rs +++ b/wgpu/src/window/swap_chain.rs @@ -17,11 +17,10 @@ impl SwapChain { surface: &wgpu::Surface, width: u32, height: u32, - scale_factor: f64, ) -> SwapChain { SwapChain { raw: new_swap_chain(surface, width, height, device), - viewport: Viewport::new(width, height, scale_factor), + viewport: Viewport::new(width, height), } } diff --git a/winit/src/application.rs b/winit/src/application.rs index 0d90525a..22d1afab 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -175,7 +175,6 @@ pub trait Application: Sized { &surface, physical_size.width, physical_size.height, - size.scale_factor(), ) }; @@ -313,7 +312,6 @@ pub trait Application: Sized { &surface, physical_size.width, physical_size.height, - size.scale_factor(), ); resized = false; @@ -323,6 +321,7 @@ pub trait Application: Sized { &mut renderer, &mut swap_chain, &primitive, + size.scale_factor(), &debug.overlay(), ); |