Skip to content

Commit bb74a75

Browse files
committed
Use non-IPC webrender API over explicit IPC channels.
1 parent 8e0aa68 commit bb74a75

File tree

40 files changed

+458
-151
lines changed

40 files changed

+458
-151
lines changed

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ mio = { git = "https://github.com/servo/mio.git", branch = "servo" }
3232
winapi = { git = "https://github.com/servo/winapi-rs", branch = "patch-1" }
3333
spirv_cross = { git = "https://github.com/kvark/spirv_cross", branch = "wgpu" }
3434
wgpu-native = { git = "https://github.com/zakorgy/wgpu", branch = "v0.4" }
35+
36+
[patch."https://github.com/servo/webrender"]
37+
webrender_api = { git = "https://github.com/jdm/webrender", branch = "no-ipc" }
38+
webrender = { git = "https://github.com/jdm/webrender", branch = "no-ipc" }
39+
#webrender_api = { path = "../webrender/webrender_api" }
40+
#webrender = { path = "../webrender/webrender" }

components/canvas/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ azure = {git = "https://github.com/servo/rust-azure", optional = true}
2121
bitflags = "1.0"
2222
byteorder = "1"
2323
canvas_traits = {path = "../canvas_traits"}
24+
crossbeam-channel = "0.3"
2425
cssparser = "0.27.1"
2526
embedder_traits = {path = "../embedder_traits"}
2627
euclid = "0.20"
@@ -35,7 +36,7 @@ pixels = {path = "../pixels"}
3536
servo_config = {path = "../config"}
3637
sparkle = "0.1.12"
3738
webrender = {git = "https://github.com/servo/webrender"}
38-
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
39+
webrender_api = {git = "https://github.com/servo/webrender"}
3940
webrender_traits = {path = "../webrender_traits"}
4041
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}
4142
# NOTE: the sm-angle feature only enables angle on windows, not other platforms!

components/canvas/canvas_paint_thread.rs

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
44

55
use crate::canvas_data::*;
6+
use crate::ConstellationCanvasMsg;
67
use canvas_traits::canvas::*;
8+
use crossbeam_channel::{select, unbounded, Sender};
79
use euclid::default::Size2D;
810
use ipc_channel::ipc::{self, IpcSender};
11+
use ipc_channel::router::ROUTER;
912
use std::borrow::ToOwned;
1013
use std::collections::HashMap;
1114
use std::thread;
@@ -30,53 +33,69 @@ impl<'a> CanvasPaintThread<'a> {
3033

3134
/// Creates a new `CanvasPaintThread` and returns an `IpcSender` to
3235
/// communicate with it.
33-
pub fn start() -> IpcSender<CanvasMsg> {
34-
let (sender, receiver) = ipc::channel::<CanvasMsg>().unwrap();
36+
pub fn start() -> (Sender<ConstellationCanvasMsg>, IpcSender<CanvasMsg>) {
37+
let (ipc_sender, ipc_receiver) = ipc::channel::<CanvasMsg>().unwrap();
38+
let msg_receiver = ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(ipc_receiver);
39+
let (create_sender, create_receiver) = unbounded();
3540
thread::Builder::new()
3641
.name("CanvasThread".to_owned())
3742
.spawn(move || {
3843
let mut canvas_paint_thread = CanvasPaintThread::new();
3944
loop {
40-
match receiver.recv() {
41-
Ok(msg) => match msg {
42-
CanvasMsg::Canvas2d(message, canvas_id) => {
43-
canvas_paint_thread.process_canvas_2d_message(message, canvas_id);
44-
},
45-
CanvasMsg::Close(canvas_id) => {
46-
canvas_paint_thread.canvases.remove(&canvas_id);
47-
},
48-
CanvasMsg::Create(creator, size, webrenderer_api_sender, antialias) => {
49-
let canvas_id = canvas_paint_thread.create_canvas(
45+
select! {
46+
recv(msg_receiver) -> msg => {
47+
match msg {
48+
Ok(CanvasMsg::Canvas2d(message, canvas_id)) => {
49+
canvas_paint_thread.process_canvas_2d_message(message, canvas_id);
50+
},
51+
Ok(CanvasMsg::Close(canvas_id)) => {
52+
canvas_paint_thread.canvases.remove(&canvas_id);
53+
},
54+
Ok(CanvasMsg::Recreate(size, canvas_id)) => {
55+
canvas_paint_thread.canvas(canvas_id).recreate(size);
56+
},
57+
Ok(CanvasMsg::FromScript(message, canvas_id)) => match message {
58+
FromScriptMsg::SendPixels(chan) => {
59+
canvas_paint_thread.canvas(canvas_id).send_pixels(chan);
60+
},
61+
},
62+
Ok(CanvasMsg::FromLayout(message, canvas_id)) => match message {
63+
FromLayoutMsg::SendData(chan) => {
64+
canvas_paint_thread.canvas(canvas_id).send_data(chan);
65+
},
66+
},
67+
Err(e) => {
68+
warn!("Error on CanvasPaintThread receive ({})", e);
69+
},
70+
}
71+
}
72+
recv(create_receiver) -> msg => {
73+
match msg {
74+
Ok(ConstellationCanvasMsg::Create {
75+
id_sender: creator,
5076
size,
51-
webrenderer_api_sender,
52-
antialias,
53-
);
54-
creator.send(canvas_id).unwrap();
55-
},
56-
CanvasMsg::Recreate(size, canvas_id) => {
57-
canvas_paint_thread.canvas(canvas_id).recreate(size);
58-
},
59-
CanvasMsg::FromScript(message, canvas_id) => match message {
60-
FromScriptMsg::SendPixels(chan) => {
61-
canvas_paint_thread.canvas(canvas_id).send_pixels(chan);
77+
webrender_sender: webrenderer_api_sender,
78+
antialias
79+
}) => {
80+
let canvas_id = canvas_paint_thread.create_canvas(
81+
size,
82+
webrenderer_api_sender,
83+
antialias,
84+
);
85+
creator.send(canvas_id).unwrap();
6286
},
63-
},
64-
CanvasMsg::FromLayout(message, canvas_id) => match message {
65-
FromLayoutMsg::SendData(chan) => {
66-
canvas_paint_thread.canvas(canvas_id).send_data(chan);
87+
Ok(ConstellationCanvasMsg::Exit) => break,
88+
Err(e) => {
89+
warn!("Error on CanvasPaintThread receive ({})", e);
6790
},
68-
},
69-
CanvasMsg::Exit => break,
70-
},
71-
Err(e) => {
72-
warn!("Error on CanvasPaintThread receive ({})", e);
73-
},
91+
}
92+
}
7493
}
7594
}
7695
})
7796
.expect("Thread spawning failed");
7897

79-
sender
98+
(create_sender, ipc_sender)
8099
}
81100

82101
pub fn create_canvas(

components/canvas/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
#![deny(unsafe_code)]
66

7+
use canvas_traits::canvas::CanvasId;
8+
use euclid::default::Size2D;
9+
use ipc_channel::ipc::IpcSender;
10+
711
#[macro_use]
812
extern crate bitflags;
913
#[macro_use]
@@ -22,3 +26,13 @@ pub mod canvas_paint_thread;
2226
mod webgl_limits;
2327
mod webgl_mode;
2428
pub mod webgl_thread;
29+
30+
pub enum ConstellationCanvasMsg {
31+
Create {
32+
id_sender: IpcSender<CanvasId>,
33+
size: Size2D<u64>,
34+
webrender_sender: webrender_api::RenderApiSender,
35+
antialias: bool,
36+
},
37+
Exit,
38+
}

components/canvas/webgl_mode/inprocess.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct WebGLComm {
2828
pub webgl_threads: WebGLThreads,
2929
pub webxr_swap_chains: SwapChains<WebXRSwapChainId>,
3030
pub image_handler: Box<dyn WebrenderExternalImageApi>,
31-
pub output_handler: Option<Box<dyn webrender::OutputImageHandler>>,
31+
pub output_handler: Option<Box<dyn webrender_api::OutputImageHandler>>,
3232
}
3333

3434
impl WebGLComm {
@@ -168,7 +168,7 @@ impl OutputHandler {
168168
}
169169

170170
/// Bridge between the WR frame outputs and WebGL to implement DOMToTexture synchronization.
171-
impl webrender::OutputImageHandler for OutputHandler {
171+
impl webrender_api::OutputImageHandler for OutputHandler {
172172
fn lock(
173173
&mut self,
174174
id: webrender_api::PipelineId,

components/canvas_traits/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ serde = "1.0"
2525
serde_bytes = "0.11"
2626
servo_config = {path = "../config"}
2727
sparkle = "0.1"
28-
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
28+
webrender_api = {git = "https://github.com/servo/webrender"}
2929
webvr_traits = {path = "../webvr_traits"}
3030
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}

components/canvas_traits/canvas.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,10 @@ pub struct CanvasId(pub u64);
2121
#[derive(Deserialize, Serialize)]
2222
pub enum CanvasMsg {
2323
Canvas2d(Canvas2dMsg, CanvasId),
24-
Create(
25-
IpcSender<CanvasId>,
26-
Size2D<u64>,
27-
webrender_api::RenderApiSender,
28-
bool,
29-
),
3024
FromLayout(FromLayoutMsg, CanvasId),
3125
FromScript(FromScriptMsg, CanvasId),
3226
Recreate(Size2D<u64>, CanvasId),
3327
Close(CanvasId),
34-
Exit,
3528
}
3629

3730
#[derive(Clone, Debug, Deserialize, Serialize)]

components/compositing/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ servo_url = {path = "../url"}
3838
style_traits = {path = "../style_traits"}
3939
time = "0.1.17"
4040
webrender = {git = "https://github.com/servo/webrender", features = ["capture"]}
41-
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
41+
webrender_api = {git = "https://github.com/servo/webrender"}
4242
webvr_traits = {path = "../webvr_traits"}
4343
webvr = {path = "../webvr"}
4444
webxr = {git = "https://github.com/servo/webxr"}

components/constellation/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ servo_remutex = {path = "../remutex"}
4949
servo_url = {path = "../url"}
5050
webgpu = {path = "../webgpu"}
5151
webvr_traits = {path = "../webvr_traits"}
52-
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
52+
webrender_api = {git = "https://github.com/servo/webrender"}
5353
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}
5454

5555
[target.'cfg(all(not(target_os = "windows"), not(target_os = "ios"), not(target_os="android"), not(target_arch="arm"), not(target_arch="aarch64")))'.dependencies]

0 commit comments

Comments
 (0)