mirror of
https://github.com/servo/servo.git
synced 2025-06-08 00:23:30 +00:00
Signed-off-by: Lucas Fabián Montenegro <40044087+lucasMontenegro@users.noreply.github.com>
This commit is contained in:
parent
8bbcf0abaf
commit
256ab5353b
3 changed files with 39 additions and 40 deletions
|
@ -2043,15 +2043,13 @@ where
|
||||||
return warn!("Browsing context group not found");
|
return warn!("Browsing context group not found");
|
||||||
};
|
};
|
||||||
let webgpu_chan = match browsing_context_group.webgpus.entry(host) {
|
let webgpu_chan = match browsing_context_group.webgpus.entry(host) {
|
||||||
Entry::Vacant(v) => v
|
Entry::Vacant(v) => WebGPU::new(
|
||||||
.insert(
|
|
||||||
match WebGPU::new(
|
|
||||||
self.webrender_wgpu.webrender_api.create_sender(),
|
self.webrender_wgpu.webrender_api.create_sender(),
|
||||||
self.webrender_document,
|
self.webrender_document,
|
||||||
self.webrender_wgpu.webrender_external_images.clone(),
|
self.webrender_wgpu.webrender_external_images.clone(),
|
||||||
self.webrender_wgpu.wgpu_image_map.clone(),
|
self.webrender_wgpu.wgpu_image_map.clone(),
|
||||||
) {
|
)
|
||||||
Some(webgpu) => {
|
.map(|webgpu| {
|
||||||
let msg = ConstellationControlMsg::SetWebGPUPort(webgpu.1);
|
let msg = ConstellationControlMsg::SetWebGPUPort(webgpu.1);
|
||||||
if let Err(e) = source_pipeline.event_loop.send(msg) {
|
if let Err(e) = source_pipeline.event_loop.send(msg) {
|
||||||
warn!(
|
warn!(
|
||||||
|
@ -2059,27 +2057,24 @@ where
|
||||||
source_pipeline_id, e
|
source_pipeline_id, e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
webgpu.0
|
v.insert(webgpu.0).clone()
|
||||||
},
|
}),
|
||||||
None => {
|
Entry::Occupied(o) => Some(o.get().clone()),
|
||||||
return warn!("Failed to create new WebGPU thread");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.clone(),
|
|
||||||
Entry::Occupied(o) => o.get().clone(),
|
|
||||||
};
|
};
|
||||||
match request {
|
match request {
|
||||||
FromScriptMsg::RequestAdapter(response_sender, options, ids) => {
|
FromScriptMsg::RequestAdapter(response_sender, options, ids) => match webgpu_chan {
|
||||||
|
None => warn!("Failed to send request adapter message, missing WebGPU channel"),
|
||||||
|
Some(webgpu_chan) => {
|
||||||
let adapter_request = WebGPURequest::RequestAdapter {
|
let adapter_request = WebGPURequest::RequestAdapter {
|
||||||
sender: response_sender,
|
sender: response_sender,
|
||||||
options,
|
options,
|
||||||
ids,
|
ids,
|
||||||
};
|
};
|
||||||
if webgpu_chan.0.send((None, adapter_request)).is_err() {
|
if webgpu_chan.0.send((None, adapter_request)).is_err() {
|
||||||
return warn!("Failed to send request adapter message on WebGPU channel");
|
warn!("Failed to send request adapter message on WebGPU channel");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
FromScriptMsg::GetWebGPUChan(response_sender) => {
|
FromScriptMsg::GetWebGPUChan(response_sender) => {
|
||||||
if response_sender.send(webgpu_chan).is_err() {
|
if response_sender.send(webgpu_chan).is_err() {
|
||||||
return warn!(
|
return warn!(
|
||||||
|
|
|
@ -269,11 +269,15 @@ impl HTMLCanvasElement {
|
||||||
.global()
|
.global()
|
||||||
.script_to_constellation_chan()
|
.script_to_constellation_chan()
|
||||||
.send(ScriptMsg::GetWebGPUChan(sender));
|
.send(ScriptMsg::GetWebGPUChan(sender));
|
||||||
|
receiver
|
||||||
|
.recv()
|
||||||
|
.expect("Failed to get WebGPU channel")
|
||||||
|
.map(|channel| {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let channel = receiver.recv().expect("Failed to get WebGPU channel");
|
|
||||||
let context = GPUCanvasContext::new(window.upcast::<GlobalScope>(), self, channel);
|
let context = GPUCanvasContext::new(window.upcast::<GlobalScope>(), self, channel);
|
||||||
*self.context.borrow_mut() = Some(CanvasContext::WebGPU(Dom::from_ref(&*context)));
|
*self.context.borrow_mut() = Some(CanvasContext::WebGPU(Dom::from_ref(&*context)));
|
||||||
Some(context)
|
context
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the base WebGLRenderingContext for WebGL or WebGL 2, if exists.
|
/// Gets the base WebGLRenderingContext for WebGL or WebGL 2, if exists.
|
||||||
|
|
|
@ -263,7 +263,7 @@ pub enum ScriptMsg {
|
||||||
SmallVec<[wgpu::id::AdapterId; 4]>,
|
SmallVec<[wgpu::id::AdapterId; 4]>,
|
||||||
),
|
),
|
||||||
/// Get WebGPU channel
|
/// Get WebGPU channel
|
||||||
GetWebGPUChan(IpcSender<WebGPU>),
|
GetWebGPUChan(IpcSender<Option<WebGPU>>),
|
||||||
/// Notify the constellation of a pipeline's document's title.
|
/// Notify the constellation of a pipeline's document's title.
|
||||||
TitleChanged(PipelineId, String),
|
TitleChanged(PipelineId, String),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue