summaryrefslogtreecommitdiffstats
path: root/src/renderer/mod.rs
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2019-04-25 20:01:23 +0000
committerGitHub <noreply@github.com>2019-04-25 20:01:23 +0000
commit494348abe80f591dfdd68fd4987bafc59fcb32c1 (patch)
tree6045c1e4f1e846962d0fe4d2c925c14c4805a98d /src/renderer/mod.rs
parente964af8a5ea390d96667e80873060d33079134fd (diff)
Fix cursor disappearing
The cfc20d4f34dca535654cc32df18e785296af4cc5 commit introduced a regression which would cause the cursor to disappear after the glyph cache has been filled. Since the cursor was not cached on the glyph cache, the cursor would quickly fill up the OpenGL texture with lots of cursor textures and then things would break after the atlas was filled completely. This adds a separate cursor cache which is keyed by the cursor style that will persist the texture without flooding the atlas. This fixes #2355.
Diffstat (limited to 'src/renderer/mod.rs')
-rw-r--r--src/renderer/mod.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs
index fd10c861..c0e3081d 100644
--- a/src/renderer/mod.rs
+++ b/src/renderer/mod.rs
@@ -26,6 +26,7 @@ use font::{self, FontDesc, FontKey, GlyphKey, Rasterize, RasterizedGlyph, Raster
use glutin::dpi::PhysicalSize;
use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
+use crate::ansi::CursorStyle;
use crate::config::{self, Config, Delta};
use crate::gl;
use crate::gl::types::*;
@@ -154,6 +155,9 @@ pub struct GlyphCache {
/// Cache of buffered glyphs
cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>,
+ /// Cache of buffered cursor glyphs
+ cursor_cache: HashMap<CursorStyle, Glyph, BuildHasherDefault<FnvHasher>>,
+
/// Rasterizer for loading new glyphs
rasterizer: Rasterizer,
@@ -195,6 +199,7 @@ impl GlyphCache {
let mut cache = GlyphCache {
cache: HashMap::default(),
+ cursor_cache: HashMap::default(),
rasterizer,
font_size: font.size(),
font_key: regular,
@@ -302,6 +307,7 @@ impl GlyphCache {
// Clear currently cached data in both GL and the registry
loader.clear();
self.cache = HashMap::default();
+ self.cursor_cache = HashMap::default();
// Update dpi scaling
self.rasterizer.update_dpr(dpr as f32);
@@ -984,9 +990,12 @@ impl<'a> RenderApi<'a> {
pub fn render_cell(&mut self, cell: RenderableCell, glyph_cache: &mut GlyphCache) {
let chars = match cell.inner {
- RenderableCellContent::Raw(ref raw) => {
+ RenderableCellContent::Cursor((cursor_style, ref raw)) => {
// Raw cell pixel buffers like cursors don't need to go through font lookup
- let glyph = self.load_glyph(raw);
+ let glyph = glyph_cache
+ .cursor_cache
+ .entry(cursor_style)
+ .or_insert_with(|| self.load_glyph(raw));
self.add_render_item(&cell, &glyph);
return;
},