From 01fdc11552b7da19d074fad224e138976f689156 Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Sat, 14 Dec 2024 15:32:07 +0100 Subject: [PATCH] buffers: cleanup now dead sharedsurface impl --- src/buffers.rs | 79 -------------------------------------------------- 1 file changed, 79 deletions(-) diff --git a/src/buffers.rs b/src/buffers.rs index c2690f7..b49db4f 100644 --- a/src/buffers.rs +++ b/src/buffers.rs @@ -6,7 +6,6 @@ use crate::render::{PixelView, Sample, Shader, Surface, Surfaces, HardwarePixel} use crate::task::Task; use std::fmt::Debug; -use std::io; use std::ops::IndexMut; use std::sync::atomic::AtomicBool; @@ -243,84 +242,6 @@ impl Task for BufferedSurfacePool { } } -#[derive(Clone)] -pub struct SharedSurface { - binding: Arc> -} - - -impl Default for SharedSurface { - fn default() -> Self { - Self { - binding: Arc::new(Mutex::new(ShaderBinding { - shader: None, - rect: Rectangle::everything(), - opacity: 255 - })), - } - } -} - -impl Surface for SharedSurface { - fn set_shader(&mut self, shader: Box) { - self.binding.lock().unwrap().shader = Some(shader); - } - - fn clear_shader(&mut self) { - self.binding.lock().unwrap().shader = None; - } - - fn set_rect(&mut self, rect: Rectangle) { - self.binding.lock().unwrap().rect = rect; - } - - fn set_opacity(&mut self, opacity: u8) { - self.binding.lock().unwrap().opacity = opacity - } -} - - -#[derive(Clone)] -pub struct SurfacePool { - surfaces: Vec -} - -impl SurfacePool { - pub const fn new() -> Self { - Self { - surfaces: Vec::new() - } - } -} - -impl Surfaces for SurfacePool { - type Surface = SharedSurface; - type Error = io::Error; - fn new_surface(&mut self, area: Rectangle) -> Result { - let mut surface = SharedSurface::default(); - surface.set_rect(area); - self.surfaces.push(surface.clone()); - return Ok(surface); - } - - fn render_to(&self, output: &mut Sampler, frame: usize) { - for surface in self.surfaces.iter() { - let binding = surface.binding.lock().unwrap(); - let opacity = binding.opacity; - if opacity > 0 { - let rect = binding.rect; - let mut sample = output.sample(&rect); - - if let Some(ref shader) = binding.shader { - while let Some((virt_coords, pixel)) = sample.next() { - *pixel = pixel.blend8(shader.draw(&virt_coords, frame).into(), opacity); - } - } - } - } - } -} - pub trait Pixbuf: AsMilliwatts + IndexMut + Send { type Pixel: HardwarePixel; fn new() -> Self;