Move non-gfx things out of gfx_traits and create a base crate (#32296)

For a long time, `gfx_traits` has held a lot of things unrelated to graphics
and also unrelated to the `gfx` crate (which is mostly about fonts).
This is a cleanup which does a few things:

1. Move non `gfx` crate things out of `gfx_traits`. This is important in
   order to prevent dependency cycles with a different integration between
   layout, script, and fonts.
2. Rename the `msg` crate to `base`. It didn't really contain anything
   to do with messages and instead mostly holds ids, which are used
   across many different crates in Servo. This new crate will hold the
   *rare* data types that are widely used.

Details:

 - All BackgroundHangMonitor-related things from base to a new
   `background_hang_monitor_api` crate.
 - Moved `TraversalDirection` to `script_traits`
 - Moved `Epoch`-related things from `gfx_traits` to `base`.
 - Moved `PrintTree` to base. This should be widely useful in Servo.
 - Moved `WebrenderApi` from `base` to `webrender_traits` and renamed it
   to `WebRenderFontApi`.
This commit is contained in:
Martin Robinson 2024-05-17 14:28:58 +02:00 committed by GitHub
parent 1017533297
commit 3398fc017b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
163 changed files with 709 additions and 632 deletions

View file

@ -34,6 +34,7 @@ xr-profile = ["canvas/xr-profile", "canvas_traits/xr-profile", "script/xr-profil
[dependencies]
background_hang_monitor = { path = "../background_hang_monitor" }
base = { workspace = true }
bluetooth = { path = "../bluetooth" }
bluetooth_traits = { workspace = true }
canvas = { path = "../canvas", default-features = false }
@ -58,7 +59,6 @@ layout_thread_2020 = { path = "../layout_thread_2020" }
log = { workspace = true }
media = { path = "../media" }
mozangle = { workspace = true }
msg = { workspace = true }
net = { path = "../net" }
net_traits = { workspace = true }
profile = { path = "../profile" }

View file

@ -25,6 +25,8 @@ use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::vec::Drain;
pub use base::id::TopLevelBrowsingContextId;
use base::id::{PipelineNamespace, PipelineNamespaceId};
use bluetooth::BluetoothThreadFactory;
use bluetooth_traits::BluetoothRequest;
use canvas::canvas_paint_thread::{self, CanvasPaintThread};
@ -70,8 +72,6 @@ pub use gleam::gl;
use ipc_channel::ipc::{self, IpcSender};
use log::{error, trace, warn, Log, Metadata, Record};
use media::{GLPlayerThreads, GlApi, NativeDisplay, WindowGLContext};
pub use msg::constellation_msg::TopLevelBrowsingContextId;
use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId};
use net::resource_thread::new_resource_threads;
use net_traits::IpcSend;
use profile::{mem as profile_mem, time as profile_time};
@ -96,12 +96,13 @@ use webrender_api::{
NativeFontHandle,
};
use webrender_traits::{
WebrenderExternalImageHandlers, WebrenderExternalImageRegistry, WebrenderImageHandlerType,
WebRenderFontApi, WebrenderExternalImageHandlers, WebrenderExternalImageRegistry,
WebrenderImageHandlerType,
};
pub use {
background_hang_monitor, bluetooth, bluetooth_traits, canvas, canvas_traits, compositing,
background_hang_monitor, base, bluetooth, bluetooth_traits, canvas, canvas_traits, compositing,
constellation, devtools, devtools_traits, embedder_traits, euclid, gfx, ipc_channel,
keyboard_types, layout_thread_2013, layout_thread_2020, media, msg, net, net_traits, profile,
keyboard_types, layout_thread_2013, layout_thread_2020, media, net, net_traits, profile,
profile_traits, script, script_layout_interface, script_traits, servo_config as config,
servo_config, servo_geometry, servo_url as url, servo_url, style, style_traits, webgpu,
webrender_api, webrender_traits,
@ -1051,7 +1052,7 @@ fn create_constellation(
struct FontCacheWR(CompositorProxy);
impl gfx_traits::WebrenderApi for FontCacheWR {
impl WebRenderFontApi for FontCacheWR {
fn add_font_instance(
&self,
font_key: FontKey,