diff --git a/wezterm-gui/src/glyphcache.rs b/wezterm-gui/src/glyphcache.rs index e2b7b3de9..17317f044 100644 --- a/wezterm-gui/src/glyphcache.rs +++ b/wezterm-gui/src/glyphcache.rs @@ -218,19 +218,19 @@ impl BlockKey { } #[derive(Debug)] -struct ImageFrame { +pub struct ImageFrame { duration: Duration, image: ::window::bitmaps::Image, } #[derive(Debug)] -enum CachedImage { +pub enum CachedImage { Animation(DecodedImage), SingleFrame, } #[derive(Debug)] -struct DecodedImage { +pub struct DecodedImage { frame_start: Instant, current_frame: usize, frames: Vec, @@ -318,7 +318,7 @@ pub struct GlyphCache { glyph_cache: HashMap>>, pub atlas: Atlas, fonts: Rc, - image_cache: LruCache, + pub image_cache: LruCache, frame_cache: HashMap<(usize, usize), Sprite>, line_glyphs: HashMap>, block_glyphs: HashMap>, diff --git a/wezterm-gui/src/renderstate.rs b/wezterm-gui/src/renderstate.rs index ee0c955b7..97caf6dee 100644 --- a/wezterm-gui/src/renderstate.rs +++ b/wezterm-gui/src/renderstate.rs @@ -348,9 +348,19 @@ impl RenderState { size: Option, ) -> anyhow::Result<()> { let size = size.unwrap_or_else(|| self.glyph_cache.borrow().atlas.size()); - let mut glyph_cache = GlyphCache::new_gl(&self.context, fonts, size, metrics)?; - self.util_sprites = UtilSprites::new(&mut glyph_cache, metrics)?; - *self.glyph_cache.borrow_mut() = glyph_cache; + let mut new_glyph_cache = GlyphCache::new_gl(&self.context, fonts, size, metrics)?; + self.util_sprites = UtilSprites::new(&mut new_glyph_cache, metrics)?; + + let mut glyph_cache = self.glyph_cache.borrow_mut(); + + // Steal the decoded image cache; without this, any animating gifs + // would reset back to frame 0 each time we filled the texture + std::mem::swap( + &mut glyph_cache.image_cache, + &mut new_glyph_cache.image_cache, + ); + + *glyph_cache = new_glyph_cache; Ok(()) } }