Commit 836a6d03 authored by Matt Keeler's avatar Matt Keeler Committed by Peter van der meulen

Update padding calculations

The goal is to calculate the physical padding size as floor(padding * dpr). Sometimes we can rely on casting to an integer for flooring the result. Other times we need an explicit call to floor the float.
parent b4ed3a2e
......@@ -178,8 +178,8 @@ impl Display {
height: viewport_size.height as f32,
cell_width: cell_width as f32,
cell_height: cell_height as f32,
padding_x: f32::from(config.padding().x) * dpr as f32,
padding_y: f32::from(config.padding().y) * dpr as f32,
padding_x: (config.padding().x as f64 * dpr).floor() as f32,
padding_y: (config.padding().y as f64 * dpr).floor() as f32,
};
// Channel for resize events
......@@ -296,8 +296,8 @@ impl Display {
if terminal.font_size != self.font_size || dpr != self.size_info.dpr {
self.font_size = terminal.font_size;
self.size_info.dpr = dpr;
self.size_info.padding_x = f32::from(config.padding().x) * dpr as f32;
self.size_info.padding_y = f32::from(config.padding().y) * dpr as f32;
self.size_info.padding_x = (config.padding().x as f64 * dpr).floor() as f32;
self.size_info.padding_y = (config.padding().y as f64 * dpr).floor() as f32;
self.update_glyph_cache(config);
if new_size == None {
......
......@@ -1038,9 +1038,12 @@ impl ShaderProgram {
}
fn update_projection(&self, width: f32, height: f32, dpr: f32) {
let padding_x = (self.padding_x as f32 * dpr).floor();
let padding_y = (self.padding_y as f32 * dpr).floor();
// Bounds check
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)
if (width as u32) < (2 * padding_x as u32) ||
(height as u32) < (2 * padding_y as u32)
{
return;
}
......@@ -1052,8 +1055,8 @@ impl ShaderProgram {
// correctly.
let ortho = cgmath::ortho(
0.,
width - (2. * f32::from(self.padding_x) * dpr),
2. * f32::from(self.padding_y) * dpr,
width - (2. * padding_x),
2. * padding_x,
height,
-1.,
1.,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment