Provide webrender_api::RenderApiSender to ScriptThread and DOM Window

This will allow the HTMLMediaElement later to get a handle to the
RenderApi for rendering video frames.

At a later time, all media handling should be moved to its own
thread/process that is communicated with via IPC. At that point this
can be removed again.

Original-patch-by: Sebastian Dröge <sebastian@centricular.com>
This commit is contained in:
Víctor Manuel Jáquez Leal 2018-08-22 18:13:13 +02:00 committed by Fernando Jiménez Moreno
parent 77c7eda0bf
commit 781b3b712b
4 changed files with 32 additions and 3 deletions

View file

@ -132,7 +132,9 @@ use time;
use timers::{IsInterval, TimerCallback};
use url::Position;
use webdriver_handlers::jsval_to_webdriver;
use webrender_api::{ExternalScrollId, DeviceIntPoint, DeviceUintSize, DocumentId};
use webrender_api::{
DeviceIntPoint, DeviceUintSize, DocumentId, ExternalScrollId, RenderApiSender,
};
use webvr_traits::WebVRMsg;
/// Current state of the window object
@ -308,6 +310,17 @@ pub struct Window {
/// Flag to identify whether mutation observers are present(true)/absent(false)
exists_mut_observer: Cell<bool>,
/// Webrender API Sender
#[ignore_malloc_size_of = "defined in webrender_api"]
webrender_api_sender: RenderApiSender,
}
// FIXME(victor): this doesn't belong here
#[allow(unsafe_code)]
unsafe impl ::dom::bindings::trace::JSTraceable for RenderApiSender {
unsafe fn trace(&self, _trc: *mut ::js::jsapi::JSTracer) {
// Do nothing
}
}
impl Window {
@ -483,6 +496,10 @@ impl Window {
}
self.add_pending_reflow();
}
pub fn get_webrender_api_sender(&self) -> RenderApiSender {
self.webrender_api_sender.clone()
}
}
// https://html.spec.whatwg.org/multipage/#atob
@ -2083,6 +2100,7 @@ impl Window {
webvr_chan: Option<IpcSender<WebVRMsg>>,
microtask_queue: Rc<MicrotaskQueue>,
webrender_document: DocumentId,
webrender_api_sender: RenderApiSender,
) -> DomRoot<Self> {
let layout_rpc: Box<LayoutRPC + Send> = {
let (rpc_send, rpc_recv) = channel();
@ -2161,6 +2179,7 @@ impl Window {
paint_worklet: Default::default(),
webrender_document,
exists_mut_observer: Cell::new(false),
webrender_api_sender,
});
unsafe { WindowBinding::Wrap(runtime.cx(), win) }