fonts: Use IpcSharedMemory to send font data (#33530)

This changes modifes the way that font data is sent over IPC channels.
Instead of serializing the data or sending it via IPC byte senders, font
data is copied into shared memory and a copy of the handle is sent over
the channel.

There is also the idea of sending the file handle of the on disk data of
system fonts. This could be implemented as a further followup once there
is an abstraction in `ipc-channel` over file handles.

To accomplish this, a `FontData` abstraction is added, which also allows
caching an in-memory shared `Arc<Vec<u8>>` version of the data (neeeded
by some APIs). This could also be a place for caching font tables in the
future.

Finally, the `FontCacheThread` is renamed to the `SystemFontService`
while the proxy for this is now named `SystemFontServiceProxy`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2024-09-25 09:31:55 +02:00 committed by GitHub
parent 2c6d9a190f
commit ade902207f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 601 additions and 544 deletions

View file

@ -21,7 +21,7 @@ use canvas_traits::webgl::WebGLPipeline;
use compositing_traits::{CompositionPipeline, CompositorMsg, CompositorProxy};
use crossbeam_channel::{unbounded, Sender};
use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
use fonts::FontCacheThread;
use fonts::{SystemFontServiceProxy, SystemFontServiceProxySender};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
use ipc_channel::Error;
@ -153,8 +153,8 @@ pub struct InitialPipelineState {
/// A channel to the service worker manager thread
pub swmanager_thread: IpcSender<SWManagerMsg>,
/// A channel to the font cache thread.
pub font_cache_thread: FontCacheThread,
/// A proxy to the system font service, responsible for managing the list of system fonts.
pub system_font_service: Arc<SystemFontServiceProxy>,
/// Channels to the resource-related threads.
pub resource_threads: ResourceThreads,
@ -281,7 +281,7 @@ impl Pipeline {
devtools_ipc_sender: script_to_devtools_ipc_sender,
bluetooth_thread: state.bluetooth_thread,
swmanager_thread: state.swmanager_thread,
font_cache_thread: state.font_cache_thread,
system_font_service: state.system_font_service.to_sender(),
resource_threads: state.resource_threads,
time_profiler_chan: state.time_profiler_chan,
mem_profiler_chan: state.mem_profiler_chan,
@ -487,7 +487,7 @@ pub struct UnprivilegedPipelineContent {
devtools_ipc_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
bluetooth_thread: IpcSender<BluetoothRequest>,
swmanager_thread: IpcSender<SWManagerMsg>,
font_cache_thread: FontCacheThread,
system_font_service: SystemFontServiceProxySender,
resource_threads: ResourceThreads,
time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: profile_mem::ProfilerChan,
@ -550,7 +550,7 @@ impl UnprivilegedPipelineContent {
inherited_secure_context: self.load_data.inherited_secure_context,
},
layout_factory,
self.font_cache_thread.clone(),
Arc::new(self.system_font_service.to_proxy()),
self.load_data.clone(),
self.user_agent,
);