mirror of
https://github.com/servo/servo.git
synced 2025-07-25 16:20:36 +01:00
fonts: fix broken caching of font template matches (#34325)
After a cache miss, `find_matching_font_template` never updates the cache entry with the response from the `SystemFontService` leading to several unnecessary IPC calls during layout. Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
c05612fc9a
commit
a731b25f0c
2 changed files with 19 additions and 2 deletions
|
@ -533,11 +533,15 @@ impl SystemFontServiceProxy {
|
||||||
);
|
);
|
||||||
panic!("SystemFontService has already exited.");
|
panic!("SystemFontService has already exited.");
|
||||||
};
|
};
|
||||||
templates
|
|
||||||
|
let templates: Vec<_> = templates
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(AtomicRefCell::new)
|
.map(AtomicRefCell::new)
|
||||||
.map(Arc::new)
|
.map(Arc::new)
|
||||||
.collect()
|
.collect();
|
||||||
|
self.templates.write().insert(cache_key, templates.clone());
|
||||||
|
|
||||||
|
templates
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn generate_font_key(&self) -> FontKey {
|
pub(crate) fn generate_font_key(&self) -> FontKey {
|
||||||
|
|
|
@ -370,6 +370,19 @@ mod font_context {
|
||||||
.matching_templates(&font_descriptor, &family_descriptor)[0]
|
.matching_templates(&font_descriptor, &family_descriptor)[0]
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
|
let _ = context
|
||||||
|
.context
|
||||||
|
.matching_templates(&font_descriptor, &family_descriptor);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
context
|
||||||
|
.system_font_service
|
||||||
|
.find_font_count
|
||||||
|
.fetch_add(0, Ordering::Relaxed),
|
||||||
|
1,
|
||||||
|
"we should only have requested matching templates from the font service once"
|
||||||
|
);
|
||||||
|
|
||||||
let font1 = context
|
let font1 = context
|
||||||
.context
|
.context
|
||||||
.font(font_template.clone(), &font_descriptor)
|
.font(font_template.clone(), &font_descriptor)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue