mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
For a long time, the "Compositor" hasn't done any compositing. This is handled by WebRender. In addition the "Compositor" does many other tasks. This change renames `IOCompositor` to `Paint`. `Paint` is Servo's paint subsystem and contains multiple `Painter`s. This change does not rename the crate; that will be done in a followup change. Testing: This just renames types and updates comments, so no new tests are necessary. --------- Signed-off-by: Martin Robinson <mrobinson@igalia.com>
73 lines
2.1 KiB
Rust
73 lines
2.1 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
use canvas_context::WebGpuExternalImageMap;
|
|
pub use canvas_context::{ContextData, WebGpuExternalImages};
|
|
use log::warn;
|
|
use webgpu_traits::{WebGPU, WebGPUMsg};
|
|
use wgpu_thread::WGPU;
|
|
pub use {wgpu_core as wgc, wgpu_types as wgt};
|
|
|
|
mod poll_thread;
|
|
mod wgpu_thread;
|
|
|
|
use std::borrow::Cow;
|
|
|
|
use compositing_traits::{CrossProcessPaintApi, WebRenderExternalImageIdManager};
|
|
use ipc_channel::ipc::{self, IpcReceiver};
|
|
use servo_config::pref;
|
|
|
|
pub mod canvas_context;
|
|
|
|
pub fn start_webgpu_thread(
|
|
paint_api: CrossProcessPaintApi,
|
|
webrender_external_image_id_manager: WebRenderExternalImageIdManager,
|
|
wgpu_image_map: WebGpuExternalImageMap,
|
|
) -> Option<(WebGPU, IpcReceiver<WebGPUMsg>)> {
|
|
if !pref!(dom_webgpu_enabled) {
|
|
return None;
|
|
}
|
|
let (sender, receiver) = match ipc::channel() {
|
|
Ok(sender_and_receiver) => sender_and_receiver,
|
|
Err(e) => {
|
|
warn!(
|
|
"Failed to create sender and receiver for WGPU thread ({})",
|
|
e
|
|
);
|
|
return None;
|
|
},
|
|
};
|
|
let sender_clone = sender.clone();
|
|
|
|
let (script_sender, script_recv) = match ipc::channel() {
|
|
Ok(sender_and_receiver) => sender_and_receiver,
|
|
Err(e) => {
|
|
warn!(
|
|
"Failed to create receiver and sender for WGPU thread ({})",
|
|
e
|
|
);
|
|
return None;
|
|
},
|
|
};
|
|
|
|
if let Err(e) = std::thread::Builder::new()
|
|
.name("WGPU".to_owned())
|
|
.spawn(move || {
|
|
WGPU::new(
|
|
receiver,
|
|
sender_clone,
|
|
script_sender,
|
|
paint_api,
|
|
webrender_external_image_id_manager,
|
|
wgpu_image_map,
|
|
)
|
|
.run();
|
|
})
|
|
{
|
|
warn!("Failed to spawn WGPU thread ({})", e);
|
|
return None;
|
|
}
|
|
Some((WebGPU(sender), script_recv))
|
|
}
|