mirror of
https://github.com/wez/wezterm.git
synced 2024-11-30 14:49:26 +03:00
background: avoid allocating empty layers
Only increment the layer index if we allocated any quads into it
This commit is contained in:
parent
1ae72bccae
commit
749db1435d
@ -374,8 +374,11 @@ impl crate::TermWindow {
|
|||||||
top: StableRowIndex,
|
top: StableRowIndex,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let gl_state = self.render_state.as_ref().unwrap();
|
let gl_state = self.render_state.as_ref().unwrap();
|
||||||
for (idx, layer) in self.window_background.iter().enumerate() {
|
let mut layer_idx = -127;
|
||||||
self.render_background(gl_state, bg_color, layer, idx, top)?;
|
for layer in self.window_background.iter() {
|
||||||
|
if self.render_background(gl_state, bg_color, layer, layer_idx, top)? {
|
||||||
|
layer_idx = layer_idx.saturating_add(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -385,10 +388,10 @@ impl crate::TermWindow {
|
|||||||
gl_state: &RenderState,
|
gl_state: &RenderState,
|
||||||
bg_color: LinearRgba,
|
bg_color: LinearRgba,
|
||||||
layer: &LoadedBackgroundLayer,
|
layer: &LoadedBackgroundLayer,
|
||||||
layer_index: usize,
|
layer_index: i8,
|
||||||
top: StableRowIndex,
|
top: StableRowIndex,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<bool> {
|
||||||
let render_layer = gl_state.layer_for_zindex(-127 + layer_index as i8)?;
|
let render_layer = gl_state.layer_for_zindex(layer_index)?;
|
||||||
let vbs = render_layer.vb.borrow();
|
let vbs = render_layer.vb.borrow();
|
||||||
let mut vb_mut0 = vbs[0].current_vb_mut();
|
let mut vb_mut0 = vbs[0].current_vb_mut();
|
||||||
let mut layer0 = vbs[0].map(&mut vb_mut0);
|
let mut layer0 = vbs[0].map(&mut vb_mut0);
|
||||||
@ -529,6 +532,8 @@ impl crate::TermWindow {
|
|||||||
|
|
||||||
let limit_y = top_pixel + pixel_height;
|
let limit_y = top_pixel + pixel_height;
|
||||||
|
|
||||||
|
let mut emitted = false;
|
||||||
|
|
||||||
for y_step in start_tile.. {
|
for y_step in start_tile.. {
|
||||||
let offset_y = (y_step - start_tile) as f32 * repeat_y;
|
let offset_y = (y_step - start_tile) as f32 * repeat_y;
|
||||||
let origin_y = origin_y + offset_y;
|
let origin_y = origin_y + offset_y;
|
||||||
@ -547,6 +552,7 @@ impl crate::TermWindow {
|
|||||||
}
|
}
|
||||||
let origin_x = origin_x + offset_x;
|
let origin_x = origin_x + offset_x;
|
||||||
let mut quad = layer0.allocate()?;
|
let mut quad = layer0.allocate()?;
|
||||||
|
emitted = true;
|
||||||
// log::info!("quad {origin_x},{origin_y} {width}x{height}");
|
// log::info!("quad {origin_x},{origin_y} {width}x{height}");
|
||||||
quad.set_position(origin_x, origin_y, origin_x + width, origin_y + height);
|
quad.set_position(origin_x, origin_y, origin_x + width, origin_y + height);
|
||||||
|
|
||||||
@ -569,6 +575,6 @@ impl crate::TermWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(emitted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user