mirror of
https://github.com/wez/wezterm.git
synced 2024-09-20 19:27:22 +03:00
gui: remove adjust
from vertex
This comes from a time where our quads were always locked to grid positions. We don't need it any more: we can simply add the adjustments to the quad positions that we set. Removing it makes the vertex a bit smaller and reduces the amount of GPU accessible memory we need to use.
This commit is contained in:
parent
8c66d02364
commit
7e8e215dc7
@ -5,7 +5,6 @@
|
||||
precision highp float;
|
||||
|
||||
in vec2 position;
|
||||
in vec2 adjust;
|
||||
in vec2 tex;
|
||||
in vec4 fg_color;
|
||||
in float has_color;
|
||||
@ -29,5 +28,5 @@ void main() {
|
||||
pass_through_vertex();
|
||||
|
||||
// Use the adjusted cell position to render the quad
|
||||
gl_Position = projection * vec4(position + adjust, 0.0, 1.0);
|
||||
gl_Position = projection * vec4(position, 0.0, 1.0);
|
||||
}
|
||||
|
@ -17,8 +17,6 @@ pub const V_BOT_RIGHT: usize = 3;
|
||||
pub struct Vertex {
|
||||
// Physical position of the corner of the character cell
|
||||
pub position: (f32, f32),
|
||||
// bearing offset within the cell
|
||||
pub adjust: (f32, f32),
|
||||
// glyph texture
|
||||
pub tex: (f32, f32),
|
||||
pub fg_color: (f32, f32, f32, f32),
|
||||
@ -37,7 +35,7 @@ pub struct Vertex {
|
||||
// image, we use the solid bg color
|
||||
pub has_color: f32,
|
||||
}
|
||||
::window::glium::implement_vertex!(Vertex, position, adjust, tex, fg_color, hsv, has_color);
|
||||
::window::glium::implement_vertex!(Vertex, position, tex, fg_color, hsv, has_color);
|
||||
|
||||
/// A helper for updating the 4 vertices that compose a glyph cell
|
||||
pub struct Quad<'a> {
|
||||
@ -53,14 +51,6 @@ impl<'a> Quad<'a> {
|
||||
self.vert[V_BOT_RIGHT].tex = (coords.max_x(), coords.max_y());
|
||||
}
|
||||
|
||||
/// Apply bearing adjustment for the glyph texture.
|
||||
pub fn set_texture_adjust(&mut self, left: f32, top: f32, right: f32, bottom: f32) {
|
||||
self.vert[V_TOP_LEFT].adjust = (left, top);
|
||||
self.vert[V_TOP_RIGHT].adjust = (right, top);
|
||||
self.vert[V_BOT_LEFT].adjust = (left, bottom);
|
||||
self.vert[V_BOT_RIGHT].adjust = (right, bottom);
|
||||
}
|
||||
|
||||
/// Set the color glyph "flag"
|
||||
pub fn set_has_color(&mut self, has_color: bool) {
|
||||
let has_color = if has_color { 1. } else { 0. };
|
||||
|
@ -38,7 +38,6 @@ impl<'a> MappedQuads<'a> {
|
||||
vert: &mut self.mapping[idx..idx + VERTICES_PER_CELL],
|
||||
};
|
||||
|
||||
quad.set_texture_adjust(0., 0., 0., 0.);
|
||||
quad.set_has_color(false);
|
||||
|
||||
Ok(quad)
|
||||
|
@ -398,7 +398,6 @@ impl super::TermWindow {
|
||||
rect.max_x() as f32 - left_offset,
|
||||
rect.max_y() as f32 - top_offset,
|
||||
);
|
||||
quad.set_texture_adjust(0., 0., 0., 0.);
|
||||
quad.set_texture(gl_state.util_sprites.filled_box.texture_coords());
|
||||
quad.set_is_background();
|
||||
quad.set_fg_color(color);
|
||||
@ -439,7 +438,6 @@ impl super::TermWindow {
|
||||
(point.x + cell_size.width as f32) - left_offset,
|
||||
(point.y + cell_size.height as f32) - top_offset,
|
||||
);
|
||||
quad.set_texture_adjust(0., 0., 0., 0.);
|
||||
quad.set_texture(sprite);
|
||||
quad.set_fg_color(color);
|
||||
quad.set_hsv(None);
|
||||
@ -1044,7 +1042,6 @@ impl super::TermWindow {
|
||||
self.dimensions.pixel_width as f32 / 2.,
|
||||
self.dimensions.pixel_height as f32 / 2.,
|
||||
);
|
||||
quad.set_texture_adjust(0., 0., 0., 0.);
|
||||
quad.set_texture(sprite.texture_coords());
|
||||
quad.set_is_background_image();
|
||||
quad.set_hsv(config.window_background_image_hsb);
|
||||
@ -1965,7 +1962,6 @@ impl super::TermWindow {
|
||||
},
|
||||
pos_y + cell_height,
|
||||
);
|
||||
quad.set_texture_adjust(0., 0., 0., 0.);
|
||||
quad.set_hsv(hsv);
|
||||
quad.set_has_color(false);
|
||||
|
||||
@ -2012,7 +2008,6 @@ impl super::TermWindow {
|
||||
},
|
||||
pos_y + cell_height,
|
||||
);
|
||||
quad.set_texture_adjust(0., 0., 0., 0.);
|
||||
quad.set_hsv(hsv);
|
||||
quad.set_has_color(false);
|
||||
|
||||
@ -2061,7 +2056,6 @@ impl super::TermWindow {
|
||||
);
|
||||
quad.set_fg_color(glyph_color);
|
||||
quad.set_texture(texture.texture_coords());
|
||||
quad.set_texture_adjust(0., 0., 0., 0.);
|
||||
quad.set_hsv(if glyph.brightness_adjust != 1.0 {
|
||||
let hsv =
|
||||
hsv.unwrap_or_else(|| HsbTransform::default());
|
||||
@ -2106,14 +2100,13 @@ impl super::TermWindow {
|
||||
|
||||
let mut quad = layers[1].allocate()?;
|
||||
quad.set_position(
|
||||
pos_x,
|
||||
pos_y,
|
||||
pos_x + cell_width,
|
||||
pos_y + cell_height,
|
||||
pos_x + left,
|
||||
pos_y + top,
|
||||
pos_x + cell_width + right,
|
||||
pos_y + cell_height + bottom,
|
||||
);
|
||||
quad.set_fg_color(glyph_color);
|
||||
quad.set_texture(texture_rect);
|
||||
quad.set_texture_adjust(left, top, right, bottom);
|
||||
quad.set_hsv(if glyph.brightness_adjust != 1.0 {
|
||||
let hsv = hsv.unwrap_or_else(|| HsbTransform::default());
|
||||
Some(HsbTransform {
|
||||
@ -2232,7 +2225,6 @@ impl super::TermWindow {
|
||||
let mut quad = layers[2].allocate()?;
|
||||
quad.set_position(pos_x, pos_y, pos_x + cell_width, pos_y + cell_height);
|
||||
|
||||
quad.set_texture_adjust(0., 0., 0., 0.);
|
||||
quad.set_has_color(false);
|
||||
quad.set_hsv(hsv);
|
||||
|
||||
@ -2286,7 +2278,6 @@ impl super::TermWindow {
|
||||
quad.set_hsv(hsv);
|
||||
quad.set_fg_color(glyph_color);
|
||||
quad.set_texture(sprite);
|
||||
quad.set_texture_adjust(0., 0., 0., 0.);
|
||||
quad.set_has_color(false);
|
||||
Ok(())
|
||||
}
|
||||
@ -2358,12 +2349,11 @@ impl super::TermWindow {
|
||||
|
||||
let (padding_left, padding_top, padding_right, padding_bottom) = image.padding();
|
||||
|
||||
quad.set_position(pos_x, pos_y, pos_x + cell_width, pos_y + cell_height);
|
||||
quad.set_texture_adjust(
|
||||
padding_left as f32,
|
||||
padding_top as f32,
|
||||
padding_left as f32 - padding_right as f32,
|
||||
padding_top as f32 - padding_bottom as f32,
|
||||
quad.set_position(
|
||||
pos_x + padding_left as f32,
|
||||
pos_y + padding_top as f32,
|
||||
pos_x + cell_width + padding_left as f32 - padding_right as f32,
|
||||
pos_y + cell_height + padding_top as f32 - padding_bottom as f32,
|
||||
);
|
||||
quad.set_hsv(hsv);
|
||||
quad.set_fg_color(glyph_color);
|
||||
|
Loading…
Reference in New Issue
Block a user