mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Revert "Auto merge of #18114 - emilio:revert-webgl-refactor, r=nox"
This reverts commit4d10d39e8f
, reversing changes made toee94e2b7c0
.
This commit is contained in:
parent
4d10d39e8f
commit
676f2c8acf
54 changed files with 3154 additions and 1426 deletions
51
components/canvas_traits/webgl_channel/mpsc.rs
Normal file
51
components/canvas_traits/webgl_channel/mpsc.rs
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserializer, Serializer};
|
||||
use std::sync::mpsc;
|
||||
|
||||
#[macro_use]
|
||||
macro_rules! unreachable_serializable {
|
||||
($name:ident) => {
|
||||
impl<T> Serialize for $name<T> {
|
||||
fn serialize<S: Serializer>(&self, _: S) -> Result<S::Ok, S::Error> {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> Deserialize<'a> for $name<T> {
|
||||
fn deserialize<D>(_: D) -> Result<$name<T>, D::Error>
|
||||
where D: Deserializer<'a> {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct WebGLSender<T>(mpsc::Sender<T>);
|
||||
pub struct WebGLReceiver<T>(mpsc::Receiver<T>);
|
||||
|
||||
impl<T> WebGLSender<T> {
|
||||
#[inline]
|
||||
pub fn send(&self, data: T) -> Result<(), mpsc::SendError<T>> {
|
||||
self.0.send(data)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> WebGLReceiver<T> {
|
||||
#[inline]
|
||||
pub fn recv(&self) -> Result<T, mpsc::RecvError> {
|
||||
self.0.recv()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn webgl_channel<T>() -> Result<(WebGLSender<T>, WebGLReceiver<T>), ()> {
|
||||
let (sender, receiver) = mpsc::channel();
|
||||
Ok((WebGLSender(sender), WebGLReceiver(receiver)))
|
||||
}
|
||||
|
||||
unreachable_serializable!(WebGLReceiver);
|
||||
unreachable_serializable!(WebGLSender);
|
Loading…
Add table
Add a link
Reference in a new issue