diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-04-12 12:39:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-12 10:39:32 +0000 |
commit | efa0d457574f02dfbe2403f501a4626acdcb64db (patch) | |
tree | f114f9a1233a111863170b6eea10f02d11d57b37 /components/gfx/font.rs | |
parent | e9591ce62f210d374463bdf1a6d956e19cca81f0 (diff) | |
download | servo-efa0d457574f02dfbe2403f501a4626acdcb64db.tar.gz servo-efa0d457574f02dfbe2403f501a4626acdcb64db.zip |
Remove `FontContextHandle` (#32038)
The `FontContextHandle` was really only used on FreeType platforms to
store the `FT_Library` handle to use for creating faces. Each
`FontContext` and `FontCacheThread` would create its own
`FontContextHandle`. This change removes this data structure in favor of
a mutex-protected shared `FontContextHandle` for an entire Servo
process. The handle is initialized using a `OnceLock` to ensure that it
only happens once and also that it stays alive for the entire process
lifetime.
In addition to greatly simplifying the code, this will make it possible
for different threads to share platform-specific `FontHandle`s, avoiding
multiple allocations for a single font.
The only downside to all of this is that memory usage of FreeType fonts
isn't measured (though the mechanism is still there). This is because
the `FontCacheThread` currently doesn't do any memory measurement.
Eventually this *will* happen though, during the font system redesign.
In exchange, this should reduce the memory usage since there is only a
single FreeType library loaded into memory now.
This is part of #32033.
Diffstat (limited to 'components/gfx/font.rs')
-rw-r--r-- | components/gfx/font.rs | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 6916b2e5261..f01f916d4ba 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -28,7 +28,6 @@ use crate::font_cache_thread::FontIdentifier; use crate::font_context::{FontContext, FontSource}; use crate::font_template::FontTemplateDescriptor; use crate::platform::font::{FontHandle, FontTable}; -use crate::platform::font_context::FontContextHandle; pub use crate::platform::font_list::fallback_font_families; use crate::platform::font_template::FontTemplateData; use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore}; @@ -56,7 +55,6 @@ static TEXT_SHAPING_PERFORMANCE_COUNTER: AtomicUsize = AtomicUsize::new(0); pub trait FontHandleMethods: Sized { fn new_from_template( - fctx: &FontContextHandle, template: Arc<FontTemplateData>, pt_size: Option<Au>, ) -> Result<Self, &'static str>; |