mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +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
|
@ -3,14 +3,13 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::ops::{Deref, RangeInclusive};
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{f32, fmt, mem, thread};
|
||||
|
||||
use app_units::Au;
|
||||
use atomic_refcell::AtomicRefCell;
|
||||
use gfx_traits::WebrenderApi;
|
||||
use ipc_channel::ipc::{self, IpcBytesSender, IpcReceiver, IpcSender};
|
||||
use log::{debug, trace};
|
||||
|
@ -125,7 +124,8 @@ impl FontTemplates {
|
|||
return;
|
||||
}
|
||||
}
|
||||
self.templates.push(Rc::new(RefCell::new(new_template)));
|
||||
self.templates
|
||||
.push(Arc::new(AtomicRefCell::new(new_template)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -730,7 +730,7 @@ impl FontSource for FontCacheThread {
|
|||
.into_iter()
|
||||
.map(|serialized_font_template| {
|
||||
let font_data = serialized_font_template.bytes_receiver.recv().ok();
|
||||
Rc::new(RefCell::new(FontTemplate {
|
||||
Arc::new(AtomicRefCell::new(FontTemplate {
|
||||
identifier: serialized_font_template.identifier,
|
||||
descriptor: serialized_font_template.descriptor.clone(),
|
||||
data: font_data.map(Arc::new),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue