mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
These two traits both exposed different parts of the compositing API, but now that the compositor doesn't depend directly on `script` any longer and the `script_traits` crate has been split into the `constellation_traits` crate, this can be finally be cleaned up without causing circular dependencies. In addition, some unit tests for the `IOPCompositor`'s scroll node tree are also moved into `compositing_traits` as well. Testing: This just combines two crates, so no new tests are necessary. Fixes: #35984. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
77 lines
2.2 KiB
Rust
77 lines
2.2 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 log::warn;
|
|
use swapchain::WGPUImageMap;
|
|
pub use swapchain::{ContextData, WGPUExternalImages};
|
|
use webgpu_traits::{WebGPU, WebGPUMsg};
|
|
use webrender::RenderApiSender;
|
|
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 std::sync::{Arc, Mutex};
|
|
|
|
use compositing_traits::WebrenderExternalImageRegistry;
|
|
use ipc_channel::ipc::{self, IpcReceiver};
|
|
use servo_config::pref;
|
|
use webrender_api::DocumentId;
|
|
|
|
pub mod swapchain;
|
|
|
|
pub fn start_webgpu_thread(
|
|
webrender_api_sender: RenderApiSender,
|
|
webrender_document: DocumentId,
|
|
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
|
|
wgpu_image_map: WGPUImageMap,
|
|
) -> 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,
|
|
webrender_api_sender,
|
|
webrender_document,
|
|
external_images,
|
|
wgpu_image_map,
|
|
)
|
|
.run();
|
|
})
|
|
{
|
|
warn!("Failed to spawn WGPU thread ({})", e);
|
|
return None;
|
|
}
|
|
Some((WebGPU(sender), script_recv))
|
|
}
|