mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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
|
@ -3,13 +3,11 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
pub use crate::platform::freetype::{font, font_context};
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
pub use crate::platform::freetype::{font_list, font_template};
|
||||
pub use crate::platform::freetype::{font, font_list, font_template, library_handle};
|
||||
#[cfg(target_os = "macos")]
|
||||
pub use crate::platform::macos::{font, font_context, font_list, font_template};
|
||||
pub use crate::platform::macos::{font, font_list, font_template};
|
||||
#[cfg(target_os = "windows")]
|
||||
pub use crate::platform::windows::{font, font_context, font_list, font_template};
|
||||
pub use crate::platform::windows::{font, font_list, font_template};
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
mod freetype {
|
||||
|
@ -27,7 +25,6 @@ mod freetype {
|
|||
}
|
||||
|
||||
pub mod font;
|
||||
pub mod font_context;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod font_list;
|
||||
|
@ -39,14 +36,13 @@ mod freetype {
|
|||
#[cfg(target_os = "android")]
|
||||
pub use self::android::font_list;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
pub mod font_template;
|
||||
pub mod library_handle;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
mod macos {
|
||||
pub mod font;
|
||||
pub mod font_context;
|
||||
pub mod font_list;
|
||||
pub mod font_template;
|
||||
}
|
||||
|
@ -54,7 +50,6 @@ mod macos {
|
|||
#[cfg(target_os = "windows")]
|
||||
mod windows {
|
||||
pub mod font;
|
||||
pub mod font_context;
|
||||
pub mod font_list;
|
||||
pub mod font_template;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue