From 52ba033ea742366440eb79ec7c8db47d652c5750 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 11 Feb 2018 08:59:56 -0800 Subject: [PATCH] Avoid flickery erase in render_line This also improves perf. The issue was that the erase of the whole line of the background may be observed by the X server when SHM is enabled because we don't wait for the exposure/copy to the window pixmap before updating the same row fractionally later. Avoiding the unconditional erase and just painting the full cell contents over means that there's no opportunity for a visible flash. In addition, since we render the cells background individually, that erase was not needed. This should save us some work and take some load off the cpu. --- src/xwin.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/xwin.rs b/src/xwin.rs index 120b286b7..92a3cb372 100644 --- a/src/xwin.rs +++ b/src/xwin.rs @@ -652,15 +652,6 @@ impl<'a> TerminalWindow<'a> { &term::color::ColorAttribute::Background, ); - // Clear this dirty row - self.buffer_image.borrow_mut().clear_rect( - 0, - y, - self.width as usize, - self.cell_height, - background_color.into(), - ); - // Break the line into clusters of cells with the same attributes let cell_clusters = line.cluster(); for cluster in cell_clusters { @@ -791,6 +782,15 @@ impl<'a> TerminalWindow<'a> { } } + // Clear anything remaining to the right of the line + self.buffer_image.borrow_mut().clear_rect( + x, + y, + self.width as usize - x as usize, + self.cell_height, + background_color.into(), + ); + // If we have SHM available, we can send up just this changed line match &*self.buffer_image.borrow() { &BufferImage::Shared(ref shm) => {