aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/display/damage.rs
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2022-11-03 19:37:54 +0300
committerGitHub <noreply@github.com>2022-11-03 19:37:54 +0300
commit0e418bc2f761617455cc58aaabc375055dfe4284 (patch)
treefc15d2260404914e21297d392f7f9c32a5f2bffc /alacritty/src/display/damage.rs
parent578e08486dfcdee0b2cd0e7a66752ff50edc46b8 (diff)
downloadr-alacritty-0e418bc2f761617455cc58aaabc375055dfe4284.tar.gz
r-alacritty-0e418bc2f761617455cc58aaabc375055dfe4284.tar.bz2
r-alacritty-0e418bc2f761617455cc58aaabc375055dfe4284.zip
Update glutin to 0.30.0
The glutin 0.30.0 update decouples glutin from winit which provides us with basis for a multithreaded renderer. This also improves robustness of our configuration picking, context creation, and surface handling. As an example we're now able to start on systems without a vsync, we don't try to build lots of contexts to check if some config works, and so on. That also brings us possibility to handle context losses, but that's a future work. Fixes #1268.
Diffstat (limited to 'alacritty/src/display/damage.rs')
-rw-r--r--alacritty/src/display/damage.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/alacritty/src/display/damage.rs b/alacritty/src/display/damage.rs
index d9b271c5..380a2f63 100644
--- a/alacritty/src/display/damage.rs
+++ b/alacritty/src/display/damage.rs
@@ -1,7 +1,7 @@
use std::cmp;
use std::iter::Peekable;
-use glutin::Rect;
+use glutin::surface::Rect;
use alacritty_terminal::term::{LineDamageBounds, TermDamageIterator};
@@ -25,17 +25,23 @@ impl<'a> RenderDamageIterator<'a> {
let x = size_info.padding_x() + line_damage.left as u32 * size_info.cell_width();
let y = y_top - (line_damage.line + 1) as u32 * size_info.cell_height();
let width = (line_damage.right - line_damage.left + 1) as u32 * size_info.cell_width();
- Rect { x, y, height: size_info.cell_height(), width }
+ Rect::new(x as i32, y as i32, width as i32, size_info.cell_height() as i32)
}
// Make sure to damage near cells to include wide chars.
#[inline]
fn overdamage(&self, mut rect: Rect) -> Rect {
let size_info = &self.size_info;
- rect.x = rect.x.saturating_sub(size_info.cell_width());
- rect.width = cmp::min(size_info.width() - rect.x, rect.width + 2 * size_info.cell_width());
- rect.y = rect.y.saturating_sub(size_info.cell_height() / 2);
- rect.height = cmp::min(size_info.height() - rect.y, rect.height + size_info.cell_height());
+ rect.x = rect.x.saturating_sub(size_info.cell_width() as i32);
+ rect.width = cmp::min(
+ size_info.width() as i32 - rect.x,
+ rect.width + 2 * size_info.cell_width() as i32,
+ );
+ rect.y = rect.y.saturating_sub(size_info.cell_height() as i32 / 2);
+ rect.height = cmp::min(
+ size_info.height() as i32 - rect.y,
+ rect.height + size_info.cell_height() as i32,
+ );
rect
}
@@ -63,7 +69,7 @@ impl<'a> Iterator for RenderDamageIterator<'a> {
}
}
-/// Check if two given [`glutin::Rect`] overlap.
+/// Check if two given [`glutin::surface::Rect`] overlap.
fn rects_overlap(lhs: Rect, rhs: Rect) -> bool {
!(
// `lhs` is left of `rhs`.
@@ -77,12 +83,12 @@ fn rects_overlap(lhs: Rect, rhs: Rect) -> bool {
)
}
-/// Merge two [`glutin::Rect`] by producing the smallest rectangle that contains both.
+/// Merge two [`glutin::surface::Rect`] by producing the smallest rectangle that contains both.
#[inline]
fn merge_rects(lhs: Rect, rhs: Rect) -> Rect {
let left_x = cmp::min(lhs.x, rhs.x);
let right_x = cmp::max(lhs.x + lhs.width, rhs.x + rhs.width);
let y_top = cmp::max(lhs.y + lhs.height, rhs.y + rhs.height);
let y_bottom = cmp::min(lhs.y, rhs.y);
- Rect { x: left_x, y: y_bottom, width: right_x - left_x, height: y_top - y_bottom }
+ Rect::new(left_x, y_bottom, right_x - left_x, y_top - y_bottom)
}