1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 06:10:06 -04:00

Optimize: get glyph uv rects during layouts instead of in tesselation

This allows them to be cached, saving around 20% total CPU.

It also makes the code more nicely structured
This commit is contained in:
Emil Ernerfeldt
2021-03-30 21:07:19 +02:00
parent 22cd1a8e10
commit 0802a9d9c0
4 changed files with 71 additions and 46 deletions

View File

@@ -247,6 +247,7 @@ impl Fonts {
}
}
#[inline(always)]
pub fn pixels_per_point(&self) -> f32 {
self.pixels_per_point
}
@@ -255,6 +256,11 @@ impl Fonts {
&self.definitions
}
#[inline(always)]
pub fn round_to_pixel(&self, point: f32) -> f32 {
(point * self.pixels_per_point).round() / self.pixels_per_point
}
/// Call each frame to get the latest available font texture data.
pub fn texture(&self) -> Arc<Texture> {
let atlas = self.atlas.lock();