diff options
author | Matt Keeler <mjkeeler7@gmail.com> | 2018-08-04 15:13:02 -0400 |
---|---|---|
committer | Matt Keeler <mjkeeler7@gmail.com> | 2018-08-07 07:39:44 -0400 |
commit | f3e5f2e1d5eca41a1d8e4e806e652381db8f083c (patch) | |
tree | be8e8bddf3e8fc7b2274849812a749bcca23411a | |
parent | b8d3a7772c27268adba195a559b5fdd590169ddd (diff) | |
download | alacritty-f3e5f2e1d5eca41a1d8e4e806e652381db8f083c.tar.gz alacritty-f3e5f2e1d5eca41a1d8e4e806e652381db8f083c.zip |
Get rid of some flooring in calculations
The Rust book says casting floats to ints will round towards 0 so for positive floats the behavior is the same as floor anyways.
-rw-r--r-- | src/display.rs | 4 | ||||
-rw-r--r-- | src/renderer/mod.rs | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/display.rs b/src/display.rs index f93ed844..ca7da357 100644 --- a/src/display.rs +++ b/src/display.rs @@ -163,8 +163,8 @@ impl Display { let height = cell_height as u32 * dimensions.lines_u32(); let new_viewport_size = PhysicalSize::new( - (width + 2 * u32::from(config.padding().x) * dpr.floor() as u32) as f64, - (height + 2 * u32::from(config.padding().y) * dpr.floor() as u32) as f64); + (width + 2 * (config.padding().x as f64 * dpr) as u32) as f64, + (height + 2 * (config.padding().y as f64 * dpr) as u32) as f64); window.set_inner_size(new_viewport_size.to_logical(dpr)); renderer.resize(new_viewport_size, dpr); diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index c260f64d..ff7bded5 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -721,8 +721,8 @@ impl QuadRenderer { pub fn resize(&mut self, size: PhysicalSize, dpr: f64) { let (width, height) : (u32, u32) = size.into(); - let padding_x = (self.program.padding_x as f64 * dpr).floor() as i32; - let padding_y = (self.program.padding_y as f64 * dpr).floor() as i32; + let padding_x = (self.program.padding_x as f64 * dpr) as i32; + let padding_y = (self.program.padding_y as f64 * dpr) as i32; // viewport unsafe { @@ -1033,8 +1033,8 @@ impl ShaderProgram { fn update_projection(&self, width: f32, height: f32, dpr: f32) { // Bounds check - if (width as u32) < (2 * (self.padding_x as f32 * dpr).floor() as u32) || - (height as u32) < (2 * (self.padding_y as f32 * dpr).floor() as u32) + if (width as u32) < (2 * (self.padding_x as f32 * dpr) as u32) || + (height as u32) < (2 * (self.padding_y as f32 * dpr) as u32) { return; } |