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:
Martin Robinson 2024-05-02 12:34:10 +02:00 committed by GitHub
parent 8ec5344f70
commit 556bfb7dff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 437 additions and 500 deletions

View file

@ -1239,7 +1239,7 @@ impl InlineFlow {
/// `style` is the style of the block.
pub fn minimum_line_metrics(
&self,
font_context: &mut LayoutFontContext,
font_context: &LayoutFontContext,
style: &ComputedValues,
) -> LineMetrics {
InlineFlow::minimum_line_metrics_for_fragments(
@ -1255,7 +1255,7 @@ impl InlineFlow {
/// `style` is the style of the block that these fragments belong to.
pub fn minimum_line_metrics_for_fragments(
fragments: &[Fragment],
font_context: &mut LayoutFontContext,
font_context: &LayoutFontContext,
style: &ComputedValues,
) -> LineMetrics {
// As a special case, if this flow contains only hypothetical fragments, then the entire