render: require more rendering primitives to have Sync and/or Send

This commit is contained in:
Victoria Fischer 2024-12-01 21:24:59 +01:00
parent 15308ecd76
commit 06a527a552
2 changed files with 6 additions and 7 deletions

View File

@ -73,7 +73,7 @@ impl<P: Pixbuf<Pixel=T::Color>, T: FastWrite> Output for StrideOutput<P, T> {
}
}
pub trait FastWrite {
pub trait FastWrite: Send {
type Target: SmartLedsWrite;
type Color: HardwarePixel;
type Error;

View File

@ -23,18 +23,17 @@ pub trait Sample {
fn sample(&mut self, rect: &Rectangle<Virtual>) -> impl PixelView<Pixel = Self::Pixel>;
}
pub trait Shader: Send + Debug {
pub trait Shader: Send + Sync {
fn draw(&self, surface_coords: &VirtualCoordinates, frame: usize) -> Rgb<u8>;
}
pub trait Surfaces: Debug {
pub trait Surfaces: Send + Sync {
type Surface: Surface;
fn new_surface(&mut self, area: &Rectangle<Virtual>) -> Result<Self::Surface, io::Error>;
fn render_to<S: Sample>(&self, output: &mut S, frame: usize);
}
pub trait Surface: Default + Clone + Debug {
pub trait Surface: Send + Sync {
fn with_shader<F: FnMut(&dyn Shader)>(&self, f: F);
fn set_shader(&mut self, shader: Box<dyn Shader>);
fn clear_shader(&mut self);
@ -45,7 +44,7 @@ pub trait Surface: Default + Clone + Debug {
fn set_opacity(&mut self, opacity: u8);
}
pub trait Output: Sample {
pub trait Output: Sample + Send {
fn blank(&mut self);
fn commit(&mut self);
}
@ -71,7 +70,7 @@ impl<T: Output, S: Surfaces> Renderer<T, S> {
}
}
impl<T: Output + Debug, S: Surfaces> Task for Renderer<T, S> {
impl<T: Output, S: Surfaces> Task for Renderer<T, S> {
fn name(&self) -> &'static str { "Renderer" }
fn tick(&mut self) {