summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src
diff options
context:
space:
mode:
authorKirill Chibisov <wchibisovkirill@gmail.com>2019-10-26 22:45:47 +0300
committerChristian Duerr <contact@christianduerr.com>2019-10-26 21:45:47 +0200
commit9ff2838844df45b6a1f20621ced870e9e1855ec8 (patch)
tree67bae587a48bf2aa7cfa5c733acf1ff901793301 /alacritty_terminal/src
parent77127fbb41748eae264b1a7578a3bd7d0f94d5c5 (diff)
downloadalacritty-9ff2838844df45b6a1f20621ced870e9e1855ec8.tar.gz
alacritty-9ff2838844df45b6a1f20621ced870e9e1855ec8.zip
Fix visual bell rendering mode
Fixes #2911.
Diffstat (limited to 'alacritty_terminal/src')
-rw-r--r--alacritty_terminal/src/renderer/mod.rs26
-rw-r--r--alacritty_terminal/src/renderer/rects.rs7
2 files changed, 12 insertions, 21 deletions
diff --git a/alacritty_terminal/src/renderer/mod.rs b/alacritty_terminal/src/renderer/mod.rs
index 51c0d0f0..76daac91 100644
--- a/alacritty_terminal/src/renderer/mod.rs
+++ b/alacritty_terminal/src/renderer/mod.rs
@@ -713,13 +713,7 @@ impl QuadRenderer {
}
// Draw all rectangles simultaneously to prevent excessive program swaps
- pub fn draw_rects(
- &mut self,
- props: &term::SizeInfo,
- visual_bell_color: Rgb,
- visual_bell_intensity: f64,
- cell_line_rects: Vec<RenderRect>,
- ) {
+ pub fn draw_rects(&mut self, props: &term::SizeInfo, rects: Vec<RenderRect>) {
// Swap to rectangle rendering program
unsafe {
// Swap program
@@ -729,7 +723,7 @@ impl QuadRenderer {
gl::Viewport(0, 0, props.width as i32, props.height as i32);
// Change blending strategy
- gl::BlendFunc(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
+ gl::BlendFuncSeparate(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA, gl::SRC_ALPHA, gl::ONE);
// Setup data and buffers
gl::BindVertexArray(self.rect_vao);
@@ -747,13 +741,9 @@ impl QuadRenderer {
gl::EnableVertexAttribArray(0);
}
- // Draw visual bell
- let rect = RenderRect::new(0., 0., props.width, props.height, visual_bell_color);
- self.render_rect(&rect, visual_bell_intensity as f32, props);
-
- // Draw underlines and strikeouts
- for cell_line_rect in cell_line_rects {
- self.render_rect(&cell_line_rect, 255., props);
+ // Draw all the rects
+ for rect in rects {
+ self.render_rect(&rect, props);
}
// Deactivate rectangle program again
@@ -881,9 +871,9 @@ impl QuadRenderer {
// Render a rectangle
//
// This requires the rectangle program to be activated
- fn render_rect(&mut self, rect: &RenderRect, alpha: f32, size: &term::SizeInfo) {
+ fn render_rect(&mut self, rect: &RenderRect, size: &term::SizeInfo) {
// Do nothing when alpha is fully transparent
- if alpha == 0. {
+ if rect.alpha == 0. {
return;
}
@@ -908,7 +898,7 @@ impl QuadRenderer {
);
// Color
- self.rect_program.set_color(rect.color, alpha);
+ self.rect_program.set_color(rect.color, rect.alpha);
// Draw the rectangle
gl::DrawElements(gl::TRIANGLES, 6, gl::UNSIGNED_INT, ptr::null());
diff --git a/alacritty_terminal/src/renderer/rects.rs b/alacritty_terminal/src/renderer/rects.rs
index dd72f673..c105c2e7 100644
--- a/alacritty_terminal/src/renderer/rects.rs
+++ b/alacritty_terminal/src/renderer/rects.rs
@@ -27,11 +27,12 @@ pub struct RenderRect {
pub width: f32,
pub height: f32,
pub color: Rgb,
+ pub alpha: f32,
}
impl RenderRect {
- pub fn new(x: f32, y: f32, width: f32, height: f32, color: Rgb) -> Self {
- RenderRect { x, y, width, height, color }
+ pub fn new(x: f32, y: f32, width: f32, height: f32, color: Rgb, alpha: f32) -> Self {
+ RenderRect { x, y, width, height, color, alpha }
}
}
@@ -65,7 +66,7 @@ impl RenderLine {
y = max_y;
}
- RenderRect::new(start_x + size.padding_x, y + size.padding_y, width, height, self.color)
+ RenderRect::new(start_x + size.padding_x, y + size.padding_y, width, height, self.color, 1.)
}
}