diff options
Diffstat (limited to 'components/shared/webrender/lib.rs')
-rw-r--r-- | components/shared/webrender/lib.rs | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/components/shared/webrender/lib.rs b/components/shared/webrender/lib.rs index e5a794fccf0..718d53e44a1 100644 --- a/components/shared/webrender/lib.rs +++ b/components/shared/webrender/lib.rs @@ -191,16 +191,18 @@ pub trait WebRenderFontApi { flags: FontInstanceFlags, ) -> FontInstanceKey; fn add_font(&self, data: Arc<Vec<u8>>, index: u32) -> FontKey; - /// Forward an already prepared `AddFont` message, sending it on to the compositor. This is used - /// to get WebRender [`FontKey`]s for web fonts in the per-layout `FontContext`. + fn add_system_font(&self, handle: NativeFontHandle) -> FontKey; + + /// Forward a `AddFont` message, sending it on to the compositor. This is used to get WebRender + /// [`FontKey`]s for web fonts in the per-layout `FontContext`. fn forward_add_font_message( &self, bytes_receiver: IpcBytesReceiver, font_index: u32, result_sender: IpcSender<FontKey>, ); - /// Forward an already prepared `AddFontInstance` message, sending it on to the compositor. This - /// is used to get WebRender [`FontInstanceKey`]s for web fonts in the per-layout `FontContext`. + /// Forward a `AddFontInstance` message, sending it on to the compositor. This is used to get + /// WebRender [`FontInstanceKey`]s for web fonts in the per-layout `FontContext`. fn forward_add_font_instance_message( &self, font_key: FontKey, @@ -208,7 +210,6 @@ pub trait WebRenderFontApi { flags: FontInstanceFlags, result_receiver: IpcSender<FontInstanceKey>, ); - fn add_system_font(&self, handle: NativeFontHandle) -> FontKey; } pub enum CanvasToCompositorMsg { @@ -257,6 +258,8 @@ pub enum ScriptToCompositorMsg { GenerateImageKey(IpcSender<ImageKey>), /// Perform a resource update operation. UpdateImages(Vec<SerializedImageUpdate>), + /// Remove the given font resources from our WebRender instance. + RemoveFonts(Vec<FontKey>, Vec<FontInstanceKey>), } /// A mechanism to send messages from networking to the WebRender instance. @@ -420,6 +423,19 @@ impl WebRenderScriptApi { } }); } + + pub fn remove_unused_font_resources( + &self, + keys: Vec<FontKey>, + instance_keys: Vec<FontInstanceKey>, + ) { + if keys.is_empty() && instance_keys.is_empty() { + return; + } + let _ = self + .0 + .send(ScriptToCompositorMsg::RemoveFonts(keys, instance_keys)); + } } #[derive(Deserialize, Serialize)] |