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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user