mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Instead of exposing many different kinds of messages to the compositor that are routed through the constellation, expose a single message type which can be sent across IPC channels. In addition, this IPC channel and the route to the crossbeam channel with the compositor is created along with the `CompositorProxy`, simplifying what needs to be passed around during pipeline initialization. Previously, some image updates (from video) were sent over IPC with a special serialization routine and some were sent via crossbeam channels (canvas). Now all updates go over the IPC channel `IpcSharedMemory` is used to avoid serialization penalties. This should improve performance and reduce copies for video, but add a memory copy overhead for canvas. This will improve in the future when canvas renders directly into a texture. All-in-all this is a simplification which opens the path toward having a standard compositor API and reduces the number of duplicate messages and proxying that had to happen in libservo. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
30cbf01280
commit
9195344b75
28 changed files with 547 additions and 800 deletions
|
@ -27,7 +27,7 @@ use style::values::specified::FontStretch as SpecifiedFontStretch;
|
|||
use style::Atom;
|
||||
use tracing::{instrument, span, Level};
|
||||
use webrender_api::{FontInstanceFlags, FontInstanceKey, FontKey};
|
||||
use webrender_traits::WebRenderFontApi;
|
||||
use webrender_traits::CrossProcessCompositorApi;
|
||||
|
||||
use crate::font::FontDescriptor;
|
||||
use crate::font_store::FontStore;
|
||||
|
@ -97,7 +97,7 @@ struct ResolvedGenericFontFamilies {
|
|||
pub struct SystemFontService {
|
||||
port: IpcReceiver<SystemFontServiceMessage>,
|
||||
local_families: FontStore,
|
||||
webrender_api: Box<dyn WebRenderFontApi>,
|
||||
compositor_api: CrossProcessCompositorApi,
|
||||
webrender_fonts: HashMap<FontIdentifier, FontKey>,
|
||||
font_instances: HashMap<(FontKey, Au), FontInstanceKey>,
|
||||
generic_fonts: ResolvedGenericFontFamilies,
|
||||
|
@ -129,7 +129,7 @@ impl SystemFontServiceProxySender {
|
|||
}
|
||||
|
||||
impl SystemFontService {
|
||||
pub fn spawn(webrender_api: Box<dyn WebRenderFontApi + Send>) -> SystemFontServiceProxySender {
|
||||
pub fn spawn(compositor_api: CrossProcessCompositorApi) -> SystemFontServiceProxySender {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
thread::Builder::new()
|
||||
|
@ -139,7 +139,7 @@ impl SystemFontService {
|
|||
let mut cache = SystemFontService {
|
||||
port: receiver,
|
||||
local_families: Default::default(),
|
||||
webrender_api,
|
||||
compositor_api,
|
||||
webrender_fonts: HashMap::new(),
|
||||
font_instances: HashMap::new(),
|
||||
generic_fonts: Default::default(),
|
||||
|
@ -204,7 +204,7 @@ impl SystemFontService {
|
|||
|
||||
const FREE_FONT_KEYS_BATCH_SIZE: usize = 40;
|
||||
const FREE_FONT_INSTANCE_KEYS_BATCH_SIZE: usize = 40;
|
||||
let (mut new_font_keys, mut new_font_instance_keys) = self.webrender_api.fetch_font_keys(
|
||||
let (mut new_font_keys, mut new_font_instance_keys) = self.compositor_api.fetch_font_keys(
|
||||
FREE_FONT_KEYS_BATCH_SIZE - self.free_font_keys.len(),
|
||||
FREE_FONT_INSTANCE_KEYS_BATCH_SIZE - self.free_font_instance_keys.len(),
|
||||
);
|
||||
|
@ -290,7 +290,7 @@ impl SystemFontService {
|
|||
) -> FontInstanceKey {
|
||||
self.fetch_new_keys();
|
||||
|
||||
let webrender_font_api = &self.webrender_api;
|
||||
let compositor_api = &self.compositor_api;
|
||||
let webrender_fonts = &mut self.webrender_fonts;
|
||||
let font_data = self.local_families.get_or_initialize_font_data(&identifier);
|
||||
|
||||
|
@ -305,12 +305,12 @@ impl SystemFontService {
|
|||
// this for those platforms.
|
||||
#[cfg(target_os = "macos")]
|
||||
if let FontIdentifier::Local(local_font_identifier) = identifier {
|
||||
webrender_font_api
|
||||
compositor_api
|
||||
.add_system_font(font_key, local_font_identifier.native_font_handle());
|
||||
return font_key;
|
||||
}
|
||||
|
||||
webrender_font_api.add_font(
|
||||
compositor_api.add_font(
|
||||
font_key,
|
||||
font_data.as_ipc_shared_memory(),
|
||||
identifier.index(),
|
||||
|
@ -323,7 +323,7 @@ impl SystemFontService {
|
|||
.entry((font_key, pt_size))
|
||||
.or_insert_with(|| {
|
||||
let font_instance_key = self.free_font_instance_keys.pop().unwrap();
|
||||
webrender_font_api.add_font_instance(
|
||||
compositor_api.add_font_instance(
|
||||
font_instance_key,
|
||||
font_key,
|
||||
pt_size.to_f32_px(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue