Revert "compositor: Create a single cross-process compositor API (#33619)" (#33645)

This reverts commit f2f5614ad6.

This is causing intermittent crashes: https://github.com/servo/servo/actions/runs/11167043809/job/31044255019

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-10-04 11:08:19 +02:00 committed by GitHub
parent 826e31eaa5
commit 48f8ff6236
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 799 additions and 545 deletions

View file

@ -30,7 +30,7 @@ use style::values::computed::font::{FamilyName, FontFamilyNameSyntax, SingleFont
use style::Atom;
use url::Url;
use webrender_api::{FontInstanceFlags, FontInstanceKey, FontKey};
use webrender_traits::CrossProcessCompositorApi;
use webrender_traits::{ScriptToCompositorMsg, WebRenderScriptApi};
use crate::font::{
Font, FontDescriptor, FontFamilyDescriptor, FontGroup, FontRef, FontSearchScope,
@ -52,7 +52,7 @@ pub struct FontContext {
resource_threads: ReentrantMutex<CoreResourceThread>,
/// A sender that can send messages and receive replies from the compositor.
compositor_api: ReentrantMutex<CrossProcessCompositorApi>,
webrender_api: ReentrantMutex<WebRenderScriptApi>,
/// The actual instances of fonts ie a [`FontTemplate`] combined with a size and
/// other font properties, along with the font data and a platform font instance.
@ -100,14 +100,14 @@ impl MallocSizeOf for FontContext {
impl FontContext {
pub fn new(
system_font_service_proxy: Arc<SystemFontServiceProxy>,
compositor_api: CrossProcessCompositorApi,
webrender_api: WebRenderScriptApi,
resource_threads: ResourceThreads,
) -> Self {
#[allow(clippy::default_constructed_unit_structs)]
Self {
system_font_service_proxy,
resource_threads: ReentrantMutex::new(resource_threads.core_thread),
compositor_api: ReentrantMutex::new(compositor_api),
webrender_api: ReentrantMutex::new(webrender_api),
fonts: Default::default(),
resolved_font_groups: Default::default(),
web_fonts: Arc::new(RwLock::default()),
@ -323,11 +323,15 @@ impl FontContext {
.entry(identifier.clone())
.or_insert_with(|| {
let font_key = self.system_font_service_proxy.generate_font_key();
self.compositor_api.lock().add_font(
font_key,
font_data.as_ipc_shared_memory(),
identifier.index(),
);
let _ = self
.webrender_api
.lock()
.sender()
.send(ScriptToCompositorMsg::AddFont(
font_key,
font_data.as_ipc_shared_memory(),
identifier.index(),
));
font_key
});
@ -337,11 +341,13 @@ impl FontContext {
.entry((font_key, pt_size))
.or_insert_with(|| {
let font_instance_key = self.system_font_service_proxy.generate_font_instance_key();
self.compositor_api.lock().add_font_instance(
font_instance_key,
font_key,
pt_size.to_f32_px(),
flags,
let _ = self.webrender_api.lock().sender().send(
ScriptToCompositorMsg::AddFontInstance(
font_instance_key,
font_key,
pt_size.to_f32_px(),
flags,
),
);
font_instance_key
});