mirror of
https://github.com/wez/wezterm.git
synced 2024-09-20 19:27:22 +03:00
Improve UX when we run out of texture space
Rather than leaving the frame un-rendered, this commit arranges to make one last pass but with all image quad assignments skipped. This should at least make a reasonable effort at displaying text on the screen. refs: https://github.com/wez/wezterm/issues/879
This commit is contained in:
parent
94d409d340
commit
887152a13d
@ -223,6 +223,9 @@ pub struct TermWindow {
|
|||||||
|
|
||||||
event_states: HashMap<String, EventState>,
|
event_states: HashMap<String, EventState>,
|
||||||
has_animation: RefCell<Option<Instant>>,
|
has_animation: RefCell<Option<Instant>>,
|
||||||
|
/// We use this to attempt to do something reasonable
|
||||||
|
/// if we run out of texture space
|
||||||
|
allow_images: bool,
|
||||||
scheduled_animation: RefCell<Option<Instant>>,
|
scheduled_animation: RefCell<Option<Instant>>,
|
||||||
|
|
||||||
gl: Option<Rc<glium::backend::Context>>,
|
gl: Option<Rc<glium::backend::Context>>,
|
||||||
@ -483,6 +486,7 @@ impl TermWindow {
|
|||||||
event_states: HashMap::new(),
|
event_states: HashMap::new(),
|
||||||
has_animation: RefCell::new(None),
|
has_animation: RefCell::new(None),
|
||||||
scheduled_animation: RefCell::new(None),
|
scheduled_animation: RefCell::new(None),
|
||||||
|
allow_images: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let tw = Rc::new(RefCell::new(myself));
|
let tw = Rc::new(RefCell::new(myself));
|
||||||
|
@ -86,6 +86,8 @@ impl super::TermWindow {
|
|||||||
// If nothing on screen needs animating, then we can avoid
|
// If nothing on screen needs animating, then we can avoid
|
||||||
// invalidating as frequently
|
// invalidating as frequently
|
||||||
*self.has_animation.borrow_mut() = None;
|
*self.has_animation.borrow_mut() = None;
|
||||||
|
// Start with the assumption that we should allow images to render
|
||||||
|
self.allow_images = true;
|
||||||
|
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
||||||
@ -138,6 +140,14 @@ impl super::TermWindow {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
|
if self.allow_images {
|
||||||
|
self.allow_images = false;
|
||||||
|
log::info!(
|
||||||
|
"Not enough texture space ({:#}); \
|
||||||
|
will retry render with images disabled",
|
||||||
|
err
|
||||||
|
);
|
||||||
|
} else {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Failed to {} texture: {}",
|
"Failed to {} texture: {}",
|
||||||
if pass == 0 { "clear" } else { "resize" },
|
if pass == 0 { "clear" } else { "resize" },
|
||||||
@ -145,6 +155,7 @@ impl super::TermWindow {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if err.root_cause().downcast_ref::<ClearShapeCache>().is_some() {
|
} else if err.root_cause().downcast_ref::<ClearShapeCache>().is_some() {
|
||||||
self.shape_cache.borrow_mut().clear();
|
self.shape_cache.borrow_mut().clear();
|
||||||
} else {
|
} else {
|
||||||
@ -260,7 +271,7 @@ impl super::TermWindow {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if pos.index == 0 {
|
if pos.index == 0 && self.allow_images {
|
||||||
// Render the window background image
|
// Render the window background image
|
||||||
if let Some(im) = self.window_background.as_ref() {
|
if let Some(im) = self.window_background.as_ref() {
|
||||||
let mut quad = quads.allocate()?;
|
let mut quad = quads.allocate()?;
|
||||||
@ -1214,6 +1225,10 @@ impl super::TermWindow {
|
|||||||
hsv: Option<config::HsbTransform>,
|
hsv: Option<config::HsbTransform>,
|
||||||
glyph_color: LinearRgba,
|
glyph_color: LinearRgba,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
|
if !self.allow_images {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let padding = self
|
let padding = self
|
||||||
.render_metrics
|
.render_metrics
|
||||||
.cell_size
|
.cell_size
|
||||||
|
Loading…
Reference in New Issue
Block a user