mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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
|
@ -82,6 +82,13 @@ pub struct PlatformFont {
|
|||
scaled_du_to_px: f32,
|
||||
}
|
||||
|
||||
// Based on information from the Skia codebase, it seems that DirectWrite APIs from
|
||||
// Windows 10 and beyond are thread safe. If problems arise from this, we can protect the
|
||||
// platform font with a Mutex.
|
||||
// See https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/src/ports/SkScalerContext_win_dw.cpp;l=56;bpv=0;bpt=1.
|
||||
unsafe impl Sync for PlatformFont {}
|
||||
unsafe impl Send for PlatformFont {}
|
||||
|
||||
struct Nondebug<T>(T);
|
||||
|
||||
impl<T> fmt::Debug for Nondebug<T> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue