Skip to content

Commit

Permalink
Skip unnescessary peaks
Browse files Browse the repository at this point in the history
  • Loading branch information
taj-p committed Nov 26, 2024
1 parent eaeeb42 commit 8372d0a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
10 changes: 0 additions & 10 deletions src/text_atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,6 @@ impl InnerAtlas {
self.kind.num_channels()
}

pub(crate) fn promote(&mut self, glyph: GlyphonCacheKey) {
self.glyph_cache.promote(&glyph);
self.glyphs_in_use.insert(glyph);
}

pub(crate) fn put(&mut self, glyph: GlyphonCacheKey, details: GlyphDetails) {
self.glyph_cache.put(glyph, details);
self.glyphs_in_use.insert(glyph);
}

pub(crate) fn grow(
&mut self,
device: &wgpu::Device,
Expand Down
18 changes: 10 additions & 8 deletions src/text_render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,12 @@ fn prepare_glyph<R>(
where
R: FnMut(RasterizeCustomGlyphRequest) -> Option<RasterizedCustomGlyph>,
{
if atlas.mask_atlas.glyph_cache.contains(&cache_key) {
atlas.mask_atlas.promote(cache_key);
} else if atlas.color_atlas.glyph_cache.contains(&cache_key) {
atlas.color_atlas.promote(cache_key);
let details = if let Some(details) = atlas.mask_atlas.glyph_cache.get(&cache_key) {
atlas.mask_atlas.glyphs_in_use.insert(cache_key);
details
} else if let Some(details) = atlas.color_atlas.glyph_cache.get(&cache_key) {
atlas.color_atlas.glyphs_in_use.insert(cache_key);
details
} else {
let Some(image) = (get_glyph_image)(cache, font_system, &mut rasterize_custom_glyph) else {
return Ok(None);
Expand Down Expand Up @@ -503,7 +505,7 @@ where
(GpuCacheStatus::SkipRasterization, None, inner)
};

inner.put(
inner.glyph_cache.put(
cache_key,
GlyphDetails {
width: image.width,
Expand All @@ -514,9 +516,9 @@ where
left: image.left,
},
);
}

let details = atlas.glyph(&cache_key).unwrap();
inner.glyphs_in_use.insert(cache_key);
inner.glyph_cache.get(&cache_key).unwrap()
};

let mut x = x + details.left as i32;
let mut y = (line_y * scale_factor).round() as i32 + y - details.top as i32;
Expand Down

0 comments on commit 8372d0a

Please sign in to comment.