mirror of
https://github.com/wez/wezterm.git
synced 2024-12-29 16:42:13 +03:00
fix "random" thick cursor outlines
These visual artifacts seemed to affect everything other than Wayland and were a bit annoying. The manifestation was that the cursor outline box might have an extra line of another color on one or more of the borders; whether it did or not seemed dependent on a combination of the position of the cursor and the pixel width/height of the overall window. This commit sets the texture sampler to prefer not to interpolate/merge the value if it is between pixels and instead take the nearest texel.
This commit is contained in:
parent
746f42be17
commit
6656097794
@ -39,18 +39,21 @@ void main() {
|
||||
// Sample the underline glyph texture for this location.
|
||||
// Note that the texture is whitespace in the case where this is
|
||||
// no underline or strikethrough.
|
||||
// We tint the underline glyph with the foreground color
|
||||
vec4 under_color = multiply(o_fg_color, texture(glyph_tex, o_underline));
|
||||
vec4 under_color = texture(glyph_tex, o_underline);
|
||||
if (under_color.a != 0.0) {
|
||||
// if the line glyph isn't transparent in this position then
|
||||
// we take this pixel color, otherwise we'll leave the color
|
||||
// if the underline glyph isn't transparent in this position then
|
||||
// we take the text fg color, otherwise we'll leave the color
|
||||
// at the background color.
|
||||
color = under_color;
|
||||
color.rgb = o_fg_color.rgb;
|
||||
}
|
||||
|
||||
vec4 cursor_outline = multiply(o_cursor_color, texture(glyph_tex, o_cursor));
|
||||
// Similar to the above: if the cursor texture isn't transparent
|
||||
// in this location, we'll use the cursor color instead of the background.
|
||||
// The cursor color overrides any underline color we might have picked
|
||||
// in the section above.
|
||||
vec4 cursor_outline = texture(glyph_tex, o_cursor);
|
||||
if (cursor_outline.a != 0.0) {
|
||||
color = cursor_outline;
|
||||
color.rgb = o_cursor_color.rgb;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -18,6 +18,9 @@ use ::term::input::MouseButton as TMB;
|
||||
use ::term::input::MouseEventKind as TMEK;
|
||||
use ::window::bitmaps::atlas::{OutOfTextureSpace, SpriteSlice};
|
||||
use ::window::bitmaps::Texture2d;
|
||||
use ::window::glium::uniforms::{
|
||||
MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerWrapFunction,
|
||||
};
|
||||
use ::window::glium::{uniform, BlendingFunction, LinearBlendingFactor, Surface};
|
||||
use ::window::MouseButtons as WMB;
|
||||
use ::window::MouseEventKind as WMEK;
|
||||
@ -1616,6 +1619,14 @@ impl TermWindow {
|
||||
|
||||
drop(quads);
|
||||
|
||||
// Clamp and use the nearest texel rather than interpolate.
|
||||
// This prevents things like the box cursor outlines from
|
||||
// being randomly doubled in width or height
|
||||
let glyph_tex = Sampler::new(&*tex)
|
||||
.wrap_function(SamplerWrapFunction::Clamp)
|
||||
.magnify_filter(MagnifySamplerFilter::Nearest)
|
||||
.minify_filter(MinifySamplerFilter::Nearest);
|
||||
|
||||
// Pass 1: Draw backgrounds, strikethrough and underline
|
||||
frame.draw(
|
||||
&*vb,
|
||||
@ -1623,7 +1634,7 @@ impl TermWindow {
|
||||
&gl_state.program,
|
||||
&uniform! {
|
||||
projection: projection,
|
||||
glyph_tex: &*tex,
|
||||
glyph_tex: glyph_tex,
|
||||
bg_and_line_layer: true,
|
||||
},
|
||||
&draw_params,
|
||||
@ -1658,7 +1669,7 @@ impl TermWindow {
|
||||
&gl_state.program,
|
||||
&uniform! {
|
||||
projection: projection,
|
||||
glyph_tex: &*tex,
|
||||
glyph_tex: glyph_tex,
|
||||
bg_and_line_layer: false,
|
||||
},
|
||||
&draw_params,
|
||||
|
Loading…
Reference in New Issue
Block a user