Skip to content
Permalink
Browse files

Use non-IPC webrender API over explicit IPC channels.

  • Loading branch information
jdm committed Nov 25, 2019
1 parent a922c49 commit 564c16d75499ae45b3945f487e49587c6fd662c7
Showing with 494 additions and 360 deletions.
  1. +10 −10 Cargo.lock
  2. +2 −1 components/canvas/Cargo.toml
  3. +53 −34 components/canvas/canvas_paint_thread.rs
  4. +14 −0 components/canvas/lib.rs
  5. +2 −2 components/canvas/webgl_mode/inprocess.rs
  6. +1 −1 components/canvas_traits/Cargo.toml
  7. +0 −7 components/canvas_traits/canvas.rs
  8. +1 −1 components/compositing/Cargo.toml
  9. +1 −1 components/constellation/Cargo.toml
  10. +142 −13 components/constellation/constellation.rs
  11. +8 −3 components/constellation/pipeline.rs
  12. +1 −1 components/embedder_traits/Cargo.toml
  13. +1 −1 components/gfx/Cargo.toml
  14. +1 −1 components/layout/Cargo.toml
  15. +1 −1 components/layout_2020/Cargo.toml
  16. +1 −1 components/layout_thread/Cargo.toml
  17. +13 −30 components/layout_thread/lib.rs
  18. +1 −1 components/layout_thread_2020/Cargo.toml
  19. +14 −31 components/layout_thread_2020/lib.rs
  20. +1 −1 components/layout_traits/Cargo.toml
  21. +4 −2 components/layout_traits/lib.rs
  22. +1 −1 components/malloc_size_of/Cargo.toml
  23. +1 −1 components/media/Cargo.toml
  24. +1 −1 components/msg/Cargo.toml
  25. +1 −1 components/net/Cargo.toml
  26. +7 −5 components/net/image_cache.rs
  27. +1 −1 components/net_traits/Cargo.toml
  28. +2 −1 components/net_traits/image_cache.rs
  29. +30 −0 components/net_traits/lib.rs
  30. +1 −1 components/script/Cargo.toml
  31. +3 −3 components/script/dom/bindings/trace.rs
  32. +5 −5 components/script/dom/htmlmediaelement.rs
  33. +6 −6 components/script/dom/window.rs
  34. +3 −3 components/script/script_thread.rs
  35. +1 −1 components/script_layout_interface/Cargo.toml
  36. +2 −1 components/script_traits/Cargo.toml
  37. +137 −4 components/script_traits/lib.rs
  38. +1 −1 components/servo/Cargo.toml
  39. +1 −2 components/webrender_traits/Cargo.toml
  40. +4 −4 components/webrender_traits/lib.rs
  41. +1 −1 tests/wpt/metadata/FileAPI/url/url-in-tags-revoke.window.js.ini
  42. +0 −2 tests/wpt/metadata/css/CSS2/floats/floats-in-table-caption-001.html.ini
  43. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-009.xht.ini
  44. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-010.xht.ini
  45. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-011.xht.ini
  46. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-012.xht.ini
  47. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-017.xht.ini
  48. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-018.xht.ini
  49. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-019.xht.ini
  50. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-020.xht.ini
  51. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-115.xht.ini
  52. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-116.xht.ini
  53. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-121.xht.ini
  54. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-122.xht.ini
  55. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-173.xht.ini
  56. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-174.xht.ini
  57. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-175.xht.ini
  58. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-176.xht.ini
  59. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-197.xht.ini
  60. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-198.xht.ini
  61. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-199.xht.ini
  62. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-200.xht.ini
  63. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-201.xht.ini
  64. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-202.xht.ini
  65. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-203.xht.ini
  66. +0 −5 tests/wpt/metadata/css/CSS2/tables/table-anonymous-objects-204.xht.ini
  67. +0 −4 tests/wpt/metadata/css/compositing/mix-blend-mode/mix-blend-mode-parent-with-text.html.ini
  68. +0 −2 tests/wpt/metadata/css/css-text/line-break/line-break-normal-018.xht.ini
  69. +0 −2 tests/wpt/metadata/css/css-text/line-break/line-break-strict-018.xht.ini
  70. +0 −2 tests/wpt/metadata/css/css-text/white-space/trailing-ideographic-space-004.html.ini
  71. +2 −1 tests/wpt/metadata/css/css-transforms/transform-input-007.html.ini
  72. +2 −1 tests/wpt/metadata/css/css-transforms/transform-input-009.html.ini
  73. +2 −1 tests/wpt/metadata/css/css-transforms/transform-input-010.html.ini
  74. +1 −2 tests/wpt/metadata/css/css-transforms/transform-input-012.html.ini
  75. +3 −0 ...ing/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-transform-translatez.html.ini
  76. +0 −37 tests/wpt/metadata/wasm/jsapi/idlharness.any.js.ini
  77. +3 −0 tests/wpt/mozilla/meta/css/inline_block_baseline_a.html.ini

Some generated files are not rendered by default. Learn more.

@@ -21,6 +21,7 @@ azure = {git = "https://github.com/servo/rust-azure", optional = true}
bitflags = "1.0"
byteorder = "1"
canvas_traits = {path = "../canvas_traits"}
crossbeam-channel = "0.3"
cssparser = "0.27.1"
embedder_traits = {path = "../embedder_traits"}
euclid = "0.20"
@@ -35,7 +36,7 @@ pixels = {path = "../pixels"}
servo_config = {path = "../config"}
sparkle = "0.1.12"
webrender = {git = "https://github.com/servo/webrender"}
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webrender_api = {git = "https://github.com/servo/webrender"}
webrender_traits = {path = "../webrender_traits"}
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}
# NOTE: the sm-angle feature only enables angle on windows, not other platforms!
@@ -3,9 +3,12 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

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

/// Creates a new `CanvasPaintThread` and returns an `IpcSender` to
/// communicate with it.
pub fn start() -> IpcSender<CanvasMsg> {
let (sender, receiver) = ipc::channel::<CanvasMsg>().unwrap();
pub fn start() -> (Sender<ConstellationCanvasMsg>, IpcSender<CanvasMsg>) {
let (ipc_sender, ipc_receiver) = ipc::channel::<CanvasMsg>().unwrap();
let msg_receiver = ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(ipc_receiver);
let (create_sender, create_receiver) = unbounded();
thread::Builder::new()
.name("CanvasThread".to_owned())
.spawn(move || {
let mut canvas_paint_thread = CanvasPaintThread::new();
loop {
match receiver.recv() {
Ok(msg) => match msg {
CanvasMsg::Canvas2d(message, canvas_id) => {
canvas_paint_thread.process_canvas_2d_message(message, canvas_id);
},
CanvasMsg::Close(canvas_id) => {
canvas_paint_thread.canvases.remove(&canvas_id);
},
CanvasMsg::Create(creator, size, webrenderer_api_sender, antialias) => {
let canvas_id = canvas_paint_thread.create_canvas(
select! {
recv(msg_receiver) -> msg => {
match msg {
Ok(CanvasMsg::Canvas2d(message, canvas_id)) => {
canvas_paint_thread.process_canvas_2d_message(message, canvas_id);
},
Ok(CanvasMsg::Close(canvas_id)) => {
canvas_paint_thread.canvases.remove(&canvas_id);
},
Ok(CanvasMsg::Recreate(size, canvas_id)) => {
canvas_paint_thread.canvas(canvas_id).recreate(size);
},
Ok(CanvasMsg::FromScript(message, canvas_id)) => match message {
FromScriptMsg::SendPixels(chan) => {
canvas_paint_thread.canvas(canvas_id).send_pixels(chan);
},
},
Ok(CanvasMsg::FromLayout(message, canvas_id)) => match message {
FromLayoutMsg::SendData(chan) => {
canvas_paint_thread.canvas(canvas_id).send_data(chan);
},
},
Err(e) => {
warn!("Error on CanvasPaintThread receive ({})", e);
},
}
}
recv(create_receiver) -> msg => {
match msg {
Ok(ConstellationCanvasMsg::Create {
id_sender: creator,
size,
webrenderer_api_sender,
antialias,
);
creator.send(canvas_id).unwrap();
},
CanvasMsg::Recreate(size, canvas_id) => {
canvas_paint_thread.canvas(canvas_id).recreate(size);
},
CanvasMsg::FromScript(message, canvas_id) => match message {
FromScriptMsg::SendPixels(chan) => {
canvas_paint_thread.canvas(canvas_id).send_pixels(chan);
webrender_sender: webrenderer_api_sender,
antialias
}) => {
let canvas_id = canvas_paint_thread.create_canvas(
size,
webrenderer_api_sender,
antialias,
);
creator.send(canvas_id).unwrap();
},
},
CanvasMsg::FromLayout(message, canvas_id) => match message {
FromLayoutMsg::SendData(chan) => {
canvas_paint_thread.canvas(canvas_id).send_data(chan);
Ok(ConstellationCanvasMsg::Exit) => break,
Err(e) => {
warn!("Error on CanvasPaintThread receive ({})", e);
},
},
CanvasMsg::Exit => break,
},
Err(e) => {
warn!("Error on CanvasPaintThread receive ({})", e);
},
}
}
}
}
})
.expect("Thread spawning failed");

sender
(create_sender, ipc_sender)
}

pub fn create_canvas(
@@ -4,6 +4,10 @@

#![deny(unsafe_code)]

use canvas_traits::canvas::CanvasId;
use crossbeam_channel::Sender;
use euclid::default::Size2D;

#[macro_use]
extern crate bitflags;
#[macro_use]
@@ -22,3 +26,13 @@ pub mod canvas_paint_thread;
mod webgl_limits;
mod webgl_mode;
pub mod webgl_thread;

pub enum ConstellationCanvasMsg {
Create {
id_sender: Sender<CanvasId>,
size: Size2D<u64>,
webrender_sender: webrender_api::RenderApiSender,
antialias: bool,
},
Exit,
}
@@ -28,7 +28,7 @@ pub struct WebGLComm {
pub webgl_threads: WebGLThreads,
pub webxr_swap_chains: SwapChains<WebXRSwapChainId>,
pub image_handler: Box<dyn WebrenderExternalImageApi>,
pub output_handler: Option<Box<dyn webrender::OutputImageHandler>>,
pub output_handler: Option<Box<dyn webrender_api::OutputImageHandler>>,
}

impl WebGLComm {
@@ -168,7 +168,7 @@ impl OutputHandler {
}

/// Bridge between the WR frame outputs and WebGL to implement DOMToTexture synchronization.
impl webrender::OutputImageHandler for OutputHandler {
impl webrender_api::OutputImageHandler for OutputHandler {
fn lock(
&mut self,
id: webrender_api::PipelineId,
@@ -25,6 +25,6 @@ serde = "1.0"
serde_bytes = "0.11"
servo_config = {path = "../config"}
sparkle = "0.1"
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webrender_api = {git = "https://github.com/servo/webrender"}
webvr_traits = {path = "../webvr_traits"}
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}
@@ -21,17 +21,10 @@ pub struct CanvasId(pub u64);
#[derive(Deserialize, Serialize)]
pub enum CanvasMsg {
Canvas2d(Canvas2dMsg, CanvasId),
Create(
IpcSender<CanvasId>,
Size2D<u64>,
webrender_api::RenderApiSender,
bool,
),
FromLayout(FromLayoutMsg, CanvasId),
FromScript(FromScriptMsg, CanvasId),
Recreate(Size2D<u64>, CanvasId),
Close(CanvasId),
Exit,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -38,7 +38,7 @@ servo_url = {path = "../url"}
style_traits = {path = "../style_traits"}
time = "0.1.17"
webrender = {git = "https://github.com/servo/webrender", features = ["capture"]}
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webrender_api = {git = "https://github.com/servo/webrender"}
webvr_traits = {path = "../webvr_traits"}
webvr = {path = "../webvr"}
webxr = {git = "https://github.com/servo/webxr"}
@@ -49,7 +49,7 @@ servo_remutex = {path = "../remutex"}
servo_url = {path = "../url"}
webgpu = {path = "../webgpu"}
webvr_traits = {path = "../webvr_traits"}
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webrender_api = {git = "https://github.com/servo/webrender"}
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}

[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 comments on commit 564c16d

Please sign in to comment.
You can’t perform that action at this time.