mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
fonts: Make FontContext
thread-safe and share it per-Layout (#32205)
This allows sharing font templates, fonts, and platform fonts across layout threads. It's the first step toward storing web fonts in the layout versus the shared `FontCacheThread`. Now fonts and font groups have some locking (especially on FreeType), which will probably affect performance. On the other hand, we measured memory usage and this saves roughly 40 megabytes of memory when loading servo.org based on data from the memory profiler. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
parent
8ec5344f70
commit
556bfb7dff
27 changed files with 437 additions and 500 deletions
|
@ -63,6 +63,17 @@ pub struct PlatformFont {
|
|||
can_do_fast_shaping: bool,
|
||||
}
|
||||
|
||||
// From https://developer.apple.com/documentation/coretext:
|
||||
// > All individual functions in Core Text are thread-safe. Font objects (CTFont,
|
||||
// > CTFontDescriptor, and associated objects) can be used simultaneously by multiple
|
||||
// > operations, work queues, or threads. However, the layout objects (CTTypesetter,
|
||||
// > CTFramesetter, CTRun, CTLine, CTFrame, and associated objects) should be used in a
|
||||
// > single operation, work queue, or thread.
|
||||
//
|
||||
// The other element is a read-only CachedKernTable which is stored in a CFData.
|
||||
unsafe impl Sync for PlatformFont {}
|
||||
unsafe impl Send for PlatformFont {}
|
||||
|
||||
impl PlatformFont {
|
||||
/// Cache all the data needed for basic horizontal kerning. This is used only as a fallback or
|
||||
/// fast path (when the GPOS table is missing or unnecessary) so it needn't handle every case.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue