move ShapeBuffer to FontSystem
This commit is contained in:
parent
0935f549ee
commit
9dc024616b
5 changed files with 69 additions and 186 deletions
|
|
@ -6,7 +6,7 @@ use alloc::vec::Vec;
|
|||
use fontdb::Family;
|
||||
use unicode_script::Script;
|
||||
|
||||
use crate::{Font, FontMatchKey, FontSystem, ShapePlanCache};
|
||||
use crate::{Font, FontMatchKey, FontSystem, ShapeBuffer, ShapePlanCache};
|
||||
|
||||
use self::platform::*;
|
||||
|
||||
|
|
@ -119,8 +119,11 @@ impl<'a> FontFallbackIter<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn shape_plan_cache(&mut self) -> &mut ShapePlanCache {
|
||||
self.font_system.shape_plan_cache()
|
||||
pub fn shape_caches(&mut self) -> (&mut ShapeBuffer, &mut ShapePlanCache) {
|
||||
(
|
||||
&mut self.font_system.shape_buffer,
|
||||
&mut self.font_system.shape_plan_cache,
|
||||
)
|
||||
}
|
||||
|
||||
fn face_contains_family(&self, id: fontdb::ID, family_name: &str) -> bool {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{Attrs, Font, FontMatchAttrs, HashMap, ShapePlanCache};
|
||||
use crate::{Attrs, Font, FontMatchAttrs, HashMap, ShapeBuffer, ShapePlanCache};
|
||||
use alloc::string::String;
|
||||
use alloc::sync::Arc;
|
||||
use alloc::vec::Vec;
|
||||
|
|
@ -101,7 +101,10 @@ pub struct FontSystem {
|
|||
font_matches_cache: HashMap<FontMatchAttrs, Arc<Vec<FontMatchKey>>>,
|
||||
|
||||
/// Cache for rustybuzz shape plans.
|
||||
shape_plan_cache: ShapePlanCache,
|
||||
pub(crate) shape_plan_cache: ShapePlanCache,
|
||||
|
||||
/// Scratch buffer for shaping and laying out.
|
||||
pub(crate) shape_buffer: ShapeBuffer,
|
||||
|
||||
/// Cache for shaped runs
|
||||
#[cfg(feature = "shape-run-cache")]
|
||||
|
|
@ -171,6 +174,7 @@ impl FontSystem {
|
|||
shape_plan_cache: ShapePlanCache::default(),
|
||||
#[cfg(feature = "shape-run-cache")]
|
||||
shape_run_cache: crate::ShapeRunCache::default(),
|
||||
shape_buffer: ShapeBuffer::default(),
|
||||
};
|
||||
ret.cache_fonts(cloned_monospace_font_ids.clone());
|
||||
cloned_monospace_font_ids.into_iter().for_each(|id| {
|
||||
|
|
@ -196,11 +200,6 @@ impl FontSystem {
|
|||
&self.db
|
||||
}
|
||||
|
||||
/// Get the shape plan cache.
|
||||
pub(crate) fn shape_plan_cache(&mut self) -> &mut ShapePlanCache {
|
||||
&mut self.shape_plan_cache
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the database.
|
||||
pub fn db_mut(&mut self) -> &mut fontdb::Database {
|
||||
self.font_matches_cache.clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue