fonts: Clean up WebRender web fonts when they are no longer used (#32545)

This is the first part of cleaning up unused WebRender resources.
Currently this only cleans up web font resources, but a more
full-featured implementation in the future could also clean up unused
system fonts.

Fixes #32345.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2024-06-18 16:02:27 +02:00 committed by GitHub
parent bd15a4fbd8
commit fef1337da0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 181 additions and 7 deletions

View file

@ -845,6 +845,23 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
.send_transaction(self.webrender_document, txn);
},
ForwardedToCompositorMsg::Layout(ScriptToCompositorMsg::RemoveFonts(
keys,
instance_keys,
)) => {
let mut transaction = Transaction::new();
for instance in instance_keys.into_iter() {
transaction.delete_font_instance(instance);
}
for key in keys.into_iter() {
transaction.delete_font(key);
}
self.webrender_api
.send_transaction(self.webrender_document, transaction);
},
ForwardedToCompositorMsg::Net(NetToCompositorMsg::AddImage(key, desc, data)) => {
let mut txn = Transaction::new();
txn.add_image(key, desc, data, None);