aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src
diff options
context:
space:
mode:
authorlbonn <lbonn@users.noreply.github.com>2020-05-12 15:23:35 +0200
committerGitHub <noreply@github.com>2020-05-12 16:23:35 +0300
commit77f2d6e853f1ad54e6dc844a811b78daeb463e76 (patch)
tree2bdda495a8825f1dbb3ff3743f76c9dafd40dbe1 /alacritty/src
parent2c2104a51776ac826dde35f54423657f2d5150fb (diff)
downloadr-alacritty-77f2d6e853f1ad54e6dc844a811b78daeb463e76.tar.gz
r-alacritty-77f2d6e853f1ad54e6dc844a811b78daeb463e76.tar.bz2
r-alacritty-77f2d6e853f1ad54e6dc844a811b78daeb463e76.zip
Fix emojis being blended with background
Fixes #1864.
Diffstat (limited to 'alacritty/src')
-rw-r--r--alacritty/src/renderer/mod.rs30
1 files changed, 19 insertions, 11 deletions
diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs
index 2be68892..296e4169 100644
--- a/alacritty/src/renderer/mod.rs
+++ b/alacritty/src/renderer/mod.rs
@@ -418,6 +418,8 @@ struct InstanceData {
bg_g: f32,
bg_b: f32,
bg_a: f32,
+ // Flag indicating that glyph uses multiple colors, like an Emoji.
+ multicolor: u8,
}
#[derive(Debug)]
@@ -465,19 +467,11 @@ impl Batch {
Self { tex: 0, instances: Vec::with_capacity(BATCH_MAX) }
}
- pub fn add_item(&mut self, mut cell: RenderableCell, glyph: &Glyph) {
+ pub fn add_item(&mut self, cell: RenderableCell, glyph: &Glyph) {
if self.is_empty() {
self.tex = glyph.tex_id;
}
- if glyph.colored {
- // XXX Temporary workaround to prevent emojis being rendered with a wrong colors on, at
- // least, dark backgrounds. For more info see #1864.
- cell.fg.r = 255;
- cell.fg.g = 255;
- cell.fg.b = 255;
- }
-
self.instances.push(InstanceData {
col: cell.column.0 as f32,
row: cell.line.0 as f32,
@@ -500,6 +494,7 @@ impl Batch {
bg_g: f32::from(cell.bg.g),
bg_b: f32::from(cell.bg.b),
bg_a: cell.bg_alpha,
+ multicolor: glyph.colored as u8,
});
}
@@ -643,6 +638,17 @@ impl QuadRenderer {
);
gl::EnableVertexAttribArray(4);
gl::VertexAttribDivisor(4, 1);
+ // Multicolor flag.
+ gl::VertexAttribPointer(
+ 5,
+ 1,
+ gl::BYTE,
+ gl::FALSE,
+ size_of::<InstanceData>() as i32,
+ (17 * size_of::<f32>()) as *const _,
+ );
+ gl::EnableVertexAttribArray(5);
+ gl::VertexAttribDivisor(5, 1);
// Rectangle setup.
gl::GenVertexArrays(1, &mut rect_vao);
@@ -1513,14 +1519,16 @@ impl Atlas {
gl::PixelStorei(gl::UNPACK_ALIGNMENT, 1);
gl::GenTextures(1, &mut id);
gl::BindTexture(gl::TEXTURE_2D, id);
+ // Use RGBA texture for both normal and emoji glyphs, since it has no performance
+ // impact.
gl::TexImage2D(
gl::TEXTURE_2D,
0,
- gl::RGB as i32,
+ gl::RGBA as i32,
size,
size,
0,
- gl::RGB,
+ gl::RGBA,
gl::UNSIGNED_BYTE,
ptr::null(),
);