Revert "fix(text): don't reload cache every redraw"

This reverts commit 590e093086.
This commit is contained in:
Ashley Wulber 2026-05-29 16:43:44 -04:00
parent 590e093086
commit ebb3b125bf
2 changed files with 4 additions and 12 deletions

View file

@ -15,7 +15,6 @@ use std::collections::hash_map;
pub struct Pipeline { pub struct Pipeline {
glyph_cache: GlyphCache, glyph_cache: GlyphCache,
cache: RefCell<Cache>, cache: RefCell<Cache>,
swash_cache: cosmic_text::SwashCache,
} }
impl Pipeline { impl Pipeline {
@ -23,7 +22,6 @@ impl Pipeline {
Pipeline { Pipeline {
glyph_cache: GlyphCache::new(), glyph_cache: GlyphCache::new(),
cache: RefCell::new(Cache::new()), cache: RefCell::new(Cache::new()),
swash_cache: cosmic_text::SwashCache::new(),
} }
} }
@ -56,7 +54,6 @@ impl Pipeline {
draw( draw(
font_system.raw(), font_system.raw(),
&mut self.glyph_cache, &mut self.glyph_cache,
&mut self.swash_cache,
paragraph.buffer(), paragraph.buffer(),
position, position,
color, color,
@ -84,7 +81,6 @@ impl Pipeline {
draw( draw(
font_system.raw(), font_system.raw(),
&mut self.glyph_cache, &mut self.glyph_cache,
&mut self.swash_cache,
editor.buffer(), editor.buffer(),
position, position,
color, color,
@ -146,7 +142,6 @@ impl Pipeline {
draw( draw(
font_system, font_system,
&mut self.glyph_cache, &mut self.glyph_cache,
&mut self.swash_cache,
&entry.buffer, &entry.buffer,
Point::new(x, y), Point::new(x, y),
color, color,
@ -170,7 +165,6 @@ impl Pipeline {
draw( draw(
font_system.raw(), font_system.raw(),
&mut self.glyph_cache, &mut self.glyph_cache,
&mut self.swash_cache,
buffer, buffer,
position, position,
color, color,
@ -189,7 +183,6 @@ impl Pipeline {
fn draw( fn draw(
font_system: &mut cosmic_text::FontSystem, font_system: &mut cosmic_text::FontSystem,
glyph_cache: &mut GlyphCache, glyph_cache: &mut GlyphCache,
swash_cache: &mut cosmic_text::SwashCache,
buffer: &cosmic_text::Buffer, buffer: &cosmic_text::Buffer,
position: Point, position: Point,
color: Color, color: Color,
@ -199,6 +192,8 @@ fn draw(
) { ) {
let position = position * transformation; let position = position * transformation;
let mut swash = cosmic_text::SwashCache::new();
for run in buffer.layout_runs() { for run in buffer.layout_runs() {
for glyph in run.glyphs { for glyph in run.glyphs {
let physical_glyph = glyph.physical( let physical_glyph = glyph.physical(
@ -210,7 +205,7 @@ fn draw(
physical_glyph.cache_key, physical_glyph.cache_key,
glyph.color_opt.map(from_color).unwrap_or(color), glyph.color_opt.map(from_color).unwrap_or(color),
font_system, font_system,
swash_cache, &mut swash,
) { ) {
let pixmap = tiny_skia::PixmapRef::from_bytes( let pixmap = tiny_skia::PixmapRef::from_bytes(
buffer, buffer,

View file

@ -308,7 +308,6 @@ pub struct State {
prepare_layer: usize, prepare_layer: usize,
cache: BufferCache, cache: BufferCache,
storage: Storage, storage: Storage,
swash_cache: cryoglyph::SwashCache,
} }
impl State { impl State {
@ -353,7 +352,6 @@ impl State {
renderer, renderer,
&mut atlas, &mut atlas,
&mut self.cache, &mut self.cache,
&mut self.swash_cache,
text, text,
layer_bounds * layer_transformation, layer_bounds * layer_transformation,
layer_transformation * *transformation, layer_transformation * *transformation,
@ -450,7 +448,6 @@ fn prepare(
renderer: &mut cryoglyph::TextRenderer, renderer: &mut cryoglyph::TextRenderer,
atlas: &mut cryoglyph::TextAtlas, atlas: &mut cryoglyph::TextAtlas,
buffer_cache: &mut BufferCache, buffer_cache: &mut BufferCache,
swash_cache: &mut cryoglyph::SwashCache,
sections: &[Text], sections: &[Text],
layer_bounds: Rectangle, layer_bounds: Rectangle,
layer_transformation: Transformation, layer_transformation: Transformation,
@ -646,6 +643,6 @@ fn prepare(
atlas, atlas,
viewport, viewport,
text_areas, text_areas,
swash_cache, &mut cryoglyph::SwashCache::new(),
) )
} }