Reuse line layouts when reusing view

This commit is contained in:
Antonio Scandurra 2024-01-11 16:57:06 +01:00
parent 18eaefd0ed
commit cbbba41748
3 changed files with 80 additions and 27 deletions

View file

@ -9,11 +9,11 @@ pub use line_layout::*;
pub use line_wrapper::*;
use crate::{
px, Bounds, DevicePixels, Hsla, Pixels, PlatformTextSystem, Point, Result, SharedString, Size,
UnderlineStyle,
px, Bounds, DevicePixels, EntityId, Hsla, Pixels, PlatformTextSystem, Point, Result,
SharedString, Size, UnderlineStyle,
};
use anyhow::anyhow;
use collections::FxHashMap;
use collections::{FxHashMap, FxHashSet};
use core::fmt;
use itertools::Itertools;
use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
@ -186,6 +186,10 @@ impl TextSystem {
}
}
pub fn with_view<R>(&self, view_id: EntityId, f: impl FnOnce() -> R) -> R {
self.line_layout_cache.with_view(view_id, f)
}
pub fn layout_line(
&self,
text: &str,
@ -361,7 +365,11 @@ impl TextSystem {
}
pub fn start_frame(&self) {
self.line_layout_cache.start_frame()
self.line_layout_cache.start_frame();
}
pub fn end_frame(&self, reused_views: &FxHashSet<EntityId>) {
self.line_layout_cache.end_frame(reused_views)
}
pub fn line_wrapper(