mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
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.
This commit is contained in:
parent
e9591ce62f
commit
efa0d45757
16 changed files with 152 additions and 247 deletions
|
@ -27,7 +27,6 @@ use crate::font::{
|
|||
};
|
||||
use crate::font_cache_thread::FontIdentifier;
|
||||
use crate::platform::font_template::FontTemplateData;
|
||||
use crate::platform::macos::font_context::FontContextHandle;
|
||||
use crate::text::glyph::GlyphId;
|
||||
|
||||
const KERN_PAIR_LEN: usize = 6;
|
||||
|
@ -158,7 +157,6 @@ impl fmt::Debug for CachedKernTable {
|
|||
|
||||
impl FontHandleMethods for FontHandle {
|
||||
fn new_from_template(
|
||||
_fctx: &FontContextHandle,
|
||||
template: Arc<FontTemplateData>,
|
||||
pt_size: Option<Au>,
|
||||
) -> Result<FontHandle, &'static str> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue