mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-11 13:51:01 -05:00
parent
2c2104a517
commit
77f2d6e853
6 changed files with 53 additions and 21 deletions
|
@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Resize lag on launch under some X11 wms
|
- Resize lag on launch under some X11 wms
|
||||||
- Increased input latency due to vsync behavior on X11
|
- Increased input latency due to vsync behavior on X11
|
||||||
- Freeze when application is invisible on Wayland
|
- Freeze when application is invisible on Wayland
|
||||||
|
- Emoji colors blending with terminal background
|
||||||
|
|
||||||
## 0.4.2
|
## 0.4.2
|
||||||
|
|
||||||
|
|
|
@ -418,6 +418,8 @@ struct InstanceData {
|
||||||
bg_g: f32,
|
bg_g: f32,
|
||||||
bg_b: f32,
|
bg_b: f32,
|
||||||
bg_a: f32,
|
bg_a: f32,
|
||||||
|
// Flag indicating that glyph uses multiple colors, like an Emoji.
|
||||||
|
multicolor: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -465,19 +467,11 @@ impl Batch {
|
||||||
Self { tex: 0, instances: Vec::with_capacity(BATCH_MAX) }
|
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() {
|
if self.is_empty() {
|
||||||
self.tex = glyph.tex_id;
|
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 {
|
self.instances.push(InstanceData {
|
||||||
col: cell.column.0 as f32,
|
col: cell.column.0 as f32,
|
||||||
row: cell.line.0 as f32,
|
row: cell.line.0 as f32,
|
||||||
|
@ -500,6 +494,7 @@ impl Batch {
|
||||||
bg_g: f32::from(cell.bg.g),
|
bg_g: f32::from(cell.bg.g),
|
||||||
bg_b: f32::from(cell.bg.b),
|
bg_b: f32::from(cell.bg.b),
|
||||||
bg_a: cell.bg_alpha,
|
bg_a: cell.bg_alpha,
|
||||||
|
multicolor: glyph.colored as u8,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,6 +638,17 @@ impl QuadRenderer {
|
||||||
);
|
);
|
||||||
gl::EnableVertexAttribArray(4);
|
gl::EnableVertexAttribArray(4);
|
||||||
gl::VertexAttribDivisor(4, 1);
|
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.
|
// Rectangle setup.
|
||||||
gl::GenVertexArrays(1, &mut rect_vao);
|
gl::GenVertexArrays(1, &mut rect_vao);
|
||||||
|
@ -1513,14 +1519,16 @@ impl Atlas {
|
||||||
gl::PixelStorei(gl::UNPACK_ALIGNMENT, 1);
|
gl::PixelStorei(gl::UNPACK_ALIGNMENT, 1);
|
||||||
gl::GenTextures(1, &mut id);
|
gl::GenTextures(1, &mut id);
|
||||||
gl::BindTexture(gl::TEXTURE_2D, 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::TexImage2D(
|
||||||
gl::TEXTURE_2D,
|
gl::TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
gl::RGB as i32,
|
gl::RGBA as i32,
|
||||||
size,
|
size,
|
||||||
size,
|
size,
|
||||||
0,
|
0,
|
||||||
gl::RGB,
|
gl::RGBA,
|
||||||
gl::UNSIGNED_BYTE,
|
gl::UNSIGNED_BYTE,
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -488,8 +488,8 @@ impl Font {
|
||||||
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
|
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Give the context an opaque, black background.
|
// Set background color for graphics context.
|
||||||
cg_context.set_rgb_fill_color(0.0, 0.0, 0.0, 1.0);
|
cg_context.set_rgb_fill_color(0.0, 0.0, 0.0, 0.0);
|
||||||
let context_rect = CGRect::new(
|
let context_rect = CGRect::new(
|
||||||
&CGPoint::new(0.0, 0.0),
|
&CGPoint::new(0.0, 0.0),
|
||||||
&CGSize::new(f64::from(rasterized_width), f64::from(rasterized_height)),
|
&CGSize::new(f64::from(rasterized_width), f64::from(rasterized_height)),
|
||||||
|
|
|
@ -173,7 +173,10 @@ pub struct RasterizedGlyph {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum BitmapBuffer {
|
pub enum BitmapBuffer {
|
||||||
|
/// RGB alphamask.
|
||||||
RGB(Vec<u8>),
|
RGB(Vec<u8>),
|
||||||
|
|
||||||
|
/// RGBA pixels with premultiplied alpha.
|
||||||
RGBA(Vec<u8>),
|
RGBA(Vec<u8>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
in vec2 TexCoords;
|
in vec2 TexCoords;
|
||||||
flat in vec3 fg;
|
flat in vec3 fg;
|
||||||
flat in vec4 bg;
|
flat in vec4 bg;
|
||||||
|
flat in int colored;
|
||||||
uniform int backgroundPass;
|
uniform int backgroundPass;
|
||||||
|
|
||||||
layout(location = 0, index = 0) out vec4 color;
|
layout(location = 0, index = 0) out vec4 color;
|
||||||
|
@ -31,8 +32,22 @@ void main()
|
||||||
alphaMask = vec4(1.0);
|
alphaMask = vec4(1.0);
|
||||||
color = vec4(bg.rgb, 1.0);
|
color = vec4(bg.rgb, 1.0);
|
||||||
} else {
|
} else {
|
||||||
|
if (colored != 0) {
|
||||||
|
// Color glyphs, like emojis.
|
||||||
|
vec4 glyphColor = texture(mask, TexCoords);
|
||||||
|
alphaMask = vec4(glyphColor.a);
|
||||||
|
|
||||||
|
// Revert alpha premultiplication.
|
||||||
|
if (glyphColor.a != 0) {
|
||||||
|
glyphColor.rgb = vec3(glyphColor.rgb / glyphColor.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
color = vec4(glyphColor.rgb, 1.0);
|
||||||
|
} else {
|
||||||
|
// Regular text glyphs.
|
||||||
vec3 textColor = texture(mask, TexCoords).rgb;
|
vec3 textColor = texture(mask, TexCoords).rgb;
|
||||||
alphaMask = vec4(textColor, textColor.r);
|
alphaMask = vec4(textColor, textColor.r);
|
||||||
color = vec4(fg, 1.0);
|
color = vec4(fg, 1.0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,24 +12,28 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#version 330 core
|
#version 330 core
|
||||||
// Cell properties
|
// Cell properties.
|
||||||
layout (location = 0) in vec2 gridCoords;
|
layout (location = 0) in vec2 gridCoords;
|
||||||
|
|
||||||
// glyph properties
|
// Glyph properties.
|
||||||
layout (location = 1) in vec4 glyph;
|
layout (location = 1) in vec4 glyph;
|
||||||
|
|
||||||
// uv mapping
|
// uv mapping.
|
||||||
layout (location = 2) in vec4 uv;
|
layout (location = 2) in vec4 uv;
|
||||||
|
|
||||||
// text fg color
|
// Text fg color.
|
||||||
layout (location = 3) in vec3 textColor;
|
layout (location = 3) in vec3 textColor;
|
||||||
|
|
||||||
// Background color
|
// Background color.
|
||||||
layout (location = 4) in vec4 backgroundColor;
|
layout (location = 4) in vec4 backgroundColor;
|
||||||
|
|
||||||
|
// Set to 1 if the glyph colors should be kept.
|
||||||
|
layout (location = 5) in int coloredGlyph;
|
||||||
|
|
||||||
out vec2 TexCoords;
|
out vec2 TexCoords;
|
||||||
flat out vec3 fg;
|
flat out vec3 fg;
|
||||||
flat out vec4 bg;
|
flat out vec4 bg;
|
||||||
|
flat out int colored;
|
||||||
|
|
||||||
// Terminal properties
|
// Terminal properties
|
||||||
uniform vec2 cellDim;
|
uniform vec2 cellDim;
|
||||||
|
@ -71,4 +75,5 @@ void main()
|
||||||
|
|
||||||
bg = vec4(backgroundColor.rgb / 255.0, backgroundColor.a);
|
bg = vec4(backgroundColor.rgb / 255.0, backgroundColor.a);
|
||||||
fg = textColor / vec3(255.0, 255.0, 255.0);
|
fg = textColor / vec3(255.0, 255.0, 255.0);
|
||||||
|
colored = coloredGlyph;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue