aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-09-25 09:31:55 +0200
committerGitHub <noreply@github.com>2024-09-25 07:31:55 +0000
commitade902207fc1f941fc77fa47bff1db0375ed7220 (patch)
treed94e171f40e2c6ad56b7e1a07cb1a78173509644 /components/shared
parent2c6d9a190f947ca6fe58a06d2549c4924e678d3a (diff)
downloadservo-ade902207fc1f941fc77fa47bff1db0375ed7220.tar.gz
servo-ade902207fc1f941fc77fa47bff1db0375ed7220.zip
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>
Diffstat (limited to 'components/shared')
-rw-r--r--components/shared/script_layout/lib.rs6
-rw-r--r--components/shared/webrender/lib.rs8
2 files changed, 7 insertions, 7 deletions
diff --git a/components/shared/script_layout/lib.rs b/components/shared/script_layout/lib.rs
index 1faff34b767..1ad180411d3 100644
--- a/components/shared/script_layout/lib.rs
+++ b/components/shared/script_layout/lib.rs
@@ -24,7 +24,7 @@ use canvas_traits::canvas::{CanvasId, CanvasMsg};
use crossbeam_channel::Sender;
use euclid::default::{Point2D, Rect};
use euclid::Size2D;
-use fonts::FontCacheThread;
+use fonts::SystemFontServiceProxy;
use ipc_channel::ipc::IpcSender;
use libc::c_void;
use malloc_size_of_derive::MallocSizeOf;
@@ -175,7 +175,7 @@ pub struct LayoutConfig {
pub script_chan: IpcSender<ConstellationControlMsg>,
pub image_cache: Arc<dyn ImageCache>,
pub resource_threads: ResourceThreads,
- pub font_cache_thread: FontCacheThread,
+ pub system_font_service: Arc<SystemFontServiceProxy>,
pub time_profiler_chan: time::ProfilerChan,
pub webrender_api_sender: WebRenderScriptApi,
pub paint_time_metrics: PaintTimeMetrics,
@@ -281,7 +281,7 @@ pub trait ScriptThreadFactory {
fn create(
state: InitialScriptState,
layout_factory: Arc<dyn LayoutFactory>,
- font_cache_thread: FontCacheThread,
+ system_font_service: Arc<SystemFontServiceProxy>,
load_data: LoadData,
user_agent: Cow<'static, str>,
);
diff --git a/components/shared/webrender/lib.rs b/components/shared/webrender/lib.rs
index 718d53e44a1..14f3d3d338a 100644
--- a/components/shared/webrender/lib.rs
+++ b/components/shared/webrender/lib.rs
@@ -15,7 +15,7 @@ use crossbeam_channel::Sender;
use display_list::{CompositorDisplayListInfo, ScrollTreeNodeId};
use embedder_traits::Cursor;
use euclid::default::Size2D;
-use ipc_channel::ipc::{self, IpcBytesReceiver, IpcSender};
+use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
use libc::c_void;
use log::warn;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@@ -190,14 +190,14 @@ pub trait WebRenderFontApi {
size: f32,
flags: FontInstanceFlags,
) -> FontInstanceKey;
- fn add_font(&self, data: Arc<Vec<u8>>, index: u32) -> FontKey;
+ fn add_font(&self, data: Arc<IpcSharedMemory>, index: u32) -> FontKey;
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,
+ data: Arc<IpcSharedMemory>,
font_index: u32,
result_sender: IpcSender<FontKey>,
);
@@ -219,7 +219,7 @@ pub enum CanvasToCompositorMsg {
pub enum FontToCompositorMsg {
AddFontInstance(FontKey, f32, FontInstanceFlags, Sender<FontInstanceKey>),
- AddFont(Sender<FontKey>, u32, IpcBytesReceiver),
+ AddFont(Sender<FontKey>, u32, Arc<IpcSharedMemory>),
AddSystemFont(Sender<FontKey>, NativeFontHandle),
}