aboutsummaryrefslogtreecommitdiff
path: root/src/display.rs
diff options
context:
space:
mode:
authortrimental <timmins.s.lucas@gmail.com>2018-09-24 00:21:47 +0800
committerChristian Duerr <chrisduerr@users.noreply.github.com>2018-09-23 16:21:47 +0000
commit9b694fcc547f664ed0fecdd5c84c067d7d3e7f14 (patch)
treedd27cbd90aabdabff648b8196db5221a99182d12 /src/display.rs
parentcee35b309de129f16d4c9df80172e43f5320c82a (diff)
downloadalacritty-9b694fcc547f664ed0fecdd5c84c067d7d3e7f14.tar.gz
alacritty-9b694fcc547f664ed0fecdd5c84c067d7d3e7f14.zip
Fix mesa rendering outside window borders on wayland
The mesa workaround has lead to some issues with rendering on Wayland. To resolve this problem, the mesa workaround has been restructured in a way which still allows clearing the screen before rendering without killing performance with the mesa driver. The performance is identical to the master brach and there have been no recorded regressions.
Diffstat (limited to 'src/display.rs')
-rw-r--r--src/display.rs52
1 files changed, 24 insertions, 28 deletions
diff --git a/src/display.rs b/src/display.rs
index 4c3ffed1..928434d8 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -25,6 +25,7 @@ use font::{self, Rasterize};
use meter::Meter;
use renderer::{self, GlyphCache, QuadRenderer};
use term::{Term, SizeInfo};
+use sync::FairMutex;
use window::{self, Size, Pixels, Window, SetInnerSize};
@@ -97,7 +98,6 @@ pub struct Display {
meter: Meter,
font_size: font::Size,
size_info: SizeInfo,
- last_background_color: Rgb,
}
/// Can wakeup the render loop from other threads
@@ -210,7 +210,6 @@ impl Display {
meter: Meter::new(),
font_size: font::Size::new(0.),
size_info,
- last_background_color: background_color,
})
}
@@ -325,7 +324,29 @@ impl Display {
/// A reference to Term whose state is being drawn must be provided.
///
/// This call may block if vsync is enabled
- pub fn draw(&mut self, mut terminal: MutexGuard<Term>, config: &Config) {
+ pub fn draw(&mut self, terminal: &FairMutex<Term>, config: &Config) {
+ let terminal_locked = terminal.lock();
+ let size_info = *terminal_locked.size_info();
+ let visual_bell_intensity = terminal_locked.visual_bell.intensity();
+ let background_color = terminal_locked.background_color();
+
+ // Clear when terminal mutex isn't held. Mesa for
+ // some reason takes a long time to call glClear(). The driver descends
+ // into xcb_connect_to_fd() which ends up calling __poll_nocancel()
+ // which blocks for a while.
+ //
+ // By keeping this outside of the critical region, the Mesa bug is
+ // worked around to some extent. Since this doesn't actually address the
+ // issue of glClear being slow, less time is available for input
+ // handling and rendering.
+ drop(terminal_locked);
+
+ self.renderer.with_api(config, &size_info, visual_bell_intensity, |api| {
+ api.clear(background_color);
+ });
+
+ let mut terminal = terminal.lock();
+
// Clear dirty flag
terminal.dirty = !terminal.visual_bell.completed();
@@ -345,13 +366,6 @@ impl Display {
}
}
- let size_info = *terminal.size_info();
- let visual_bell_intensity = terminal.visual_bell.intensity();
-
- let background_color = terminal.background_color();
- let background_color_changed = background_color != self.last_background_color;
- self.last_background_color = background_color;
-
{
let glyph_cache = &mut self.glyph_cache;
@@ -366,11 +380,6 @@ impl Display {
// mutable borrow
let window_focused = self.window.is_focused;
self.renderer.with_api(config, &size_info, visual_bell_intensity, |mut api| {
- // Clear screen to update whole background with new color
- if background_color_changed {
- api.clear(background_color);
- }
-
// Draw the grid
api.render_cells(
terminal.renderable_cells(config, window_focused),
@@ -394,19 +403,6 @@ impl Display {
self.window
.swap_buffers()
.expect("swap buffers");
-
- // Clear after swap_buffers when terminal mutex isn't held. Mesa for
- // some reason takes a long time to call glClear(). The driver descends
- // into xcb_connect_to_fd() which ends up calling __poll_nocancel()
- // which blocks for a while.
- //
- // By keeping this outside of the critical region, the Mesa bug is
- // worked around to some extent. Since this doesn't actually address the
- // issue of glClear being slow, less time is available for input
- // handling and rendering.
- self.renderer.with_api(config, &size_info, visual_bell_intensity, |api| {
- api.clear(background_color);
- });
}
pub fn get_window_id(&self) -> Option<usize> {