mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Integrate swapchain surface provider changes into webgl and webxr implementations.
This commit is contained in:
parent
b062f51495
commit
fbcf2bbc3e
17 changed files with 223 additions and 117 deletions
|
@ -14,6 +14,7 @@ use std::num::{NonZeroU32, NonZeroU64};
|
|||
use std::ops::Deref;
|
||||
use webrender_api::{DocumentId, ImageKey, PipelineId};
|
||||
use webvr_traits::WebVRPoseInformation;
|
||||
use webxr_api::SessionId;
|
||||
use webxr_api::SwapChainId as WebXRSwapChainId;
|
||||
|
||||
/// Helper function that creates a WebGL channel (WebGLSender, WebGLReceiver) to be used in WebGLCommands.
|
||||
|
@ -80,6 +81,7 @@ pub enum WebGLMsg {
|
|||
WebGLContextId,
|
||||
Size2D<i32>,
|
||||
WebGLSender<Option<WebXRSwapChainId>>,
|
||||
SessionId,
|
||||
),
|
||||
/// Performs a buffer swap.
|
||||
///
|
||||
|
@ -188,9 +190,14 @@ impl WebGLMsgSender {
|
|||
&self,
|
||||
size: Size2D<i32>,
|
||||
sender: WebGLSender<Option<WebXRSwapChainId>>,
|
||||
id: SessionId,
|
||||
) -> WebGLSendResult {
|
||||
self.sender
|
||||
.send(WebGLMsg::CreateWebXRSwapChain(self.ctx_id, size, sender))
|
||||
self.sender.send(WebGLMsg::CreateWebXRSwapChain(
|
||||
self.ctx_id,
|
||||
size,
|
||||
sender,
|
||||
id,
|
||||
))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -9,6 +9,7 @@ mod mpsc;
|
|||
|
||||
use crate::webgl::WebGLMsg;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use servo_config::opts;
|
||||
use std::fmt;
|
||||
|
@ -78,6 +79,18 @@ where
|
|||
WebGLReceiver::Mpsc(ref receiver) => receiver.try_recv().map_err(|_| ()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> crossbeam_channel::Receiver<T>
|
||||
where
|
||||
T: Send + 'static,
|
||||
{
|
||||
match self {
|
||||
WebGLReceiver::Ipc(receiver) => {
|
||||
ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(receiver)
|
||||
},
|
||||
WebGLReceiver::Mpsc(receiver) => receiver.into_inner(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn webgl_channel<T>() -> Result<(WebGLSender<T>, WebGLReceiver<T>), ()>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserializer, Serializer};
|
||||
use std::sync::mpsc;
|
||||
|
||||
#[macro_use]
|
||||
macro_rules! unreachable_serializable {
|
||||
|
@ -26,8 +25,8 @@ macro_rules! unreachable_serializable {
|
|||
};
|
||||
}
|
||||
|
||||
pub struct WebGLSender<T>(mpsc::Sender<T>);
|
||||
pub struct WebGLReceiver<T>(mpsc::Receiver<T>);
|
||||
pub struct WebGLSender<T>(crossbeam_channel::Sender<T>);
|
||||
pub struct WebGLReceiver<T>(crossbeam_channel::Receiver<T>);
|
||||
|
||||
impl<T> Clone for WebGLSender<T> {
|
||||
fn clone(&self) -> Self {
|
||||
|
@ -37,24 +36,27 @@ impl<T> Clone for WebGLSender<T> {
|
|||
|
||||
impl<T> WebGLSender<T> {
|
||||
#[inline]
|
||||
pub fn send(&self, data: T) -> Result<(), mpsc::SendError<T>> {
|
||||
pub fn send(&self, data: T) -> Result<(), crossbeam_channel::SendError<T>> {
|
||||
self.0.send(data)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> WebGLReceiver<T> {
|
||||
#[inline]
|
||||
pub fn recv(&self) -> Result<T, mpsc::RecvError> {
|
||||
pub fn recv(&self) -> Result<T, crossbeam_channel::RecvError> {
|
||||
self.0.recv()
|
||||
}
|
||||
#[inline]
|
||||
pub fn try_recv(&self) -> Result<T, mpsc::TryRecvError> {
|
||||
pub fn try_recv(&self) -> Result<T, crossbeam_channel::TryRecvError> {
|
||||
self.0.try_recv()
|
||||
}
|
||||
pub fn into_inner(self) -> crossbeam_channel::Receiver<T> {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
pub fn webgl_channel<T>() -> Result<(WebGLSender<T>, WebGLReceiver<T>), ()> {
|
||||
let (sender, receiver) = mpsc::channel();
|
||||
let (sender, receiver) = crossbeam_channel::unbounded();
|
||||
Ok((WebGLSender(sender), WebGLReceiver(receiver)))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue