mappings: split coord mapping from pixel mapping

This commit is contained in:
2024-11-29 10:57:33 +01:00
parent d28c2a1a4c
commit 9289a829be
3 changed files with 77 additions and 81 deletions

View File

@@ -2,12 +2,30 @@ use std::io;
use rgb::Rgb;
use crate::geometry::*;
use crate::lib8::Rgb8Blend;
use crate::lib8::interpolate::Fract8Ops;
use crate::power::AsMilliwatts;
use crate::task::Task;
use crate::time::Periodically;
use running_average::RealTimeRunningAverage;
use std::marker::PhantomData;
use std::fmt::Debug;
pub trait HardwarePixel: Send + Sync + Rgb8Blend + Copy + AsMilliwatts + Default + From<Rgb<u8>> + Fract8Ops {}
impl<T> HardwarePixel for T where T: Send + Sync + Rgb8Blend + Copy + AsMilliwatts + Default + From<Rgb<u8>> + Fract8Ops {}
pub trait PixelView {
type Pixel: HardwarePixel;
fn next(&mut self) -> Option<(Coordinates<Virtual>, &mut Self::Pixel)>;
}
pub trait Sample {
type Pixel: HardwarePixel;
fn sample(&mut self, rect: &Rectangle<Virtual>) -> impl PixelView<Pixel = Self::Pixel>;
}
pub trait Shader: Send + Debug {
fn draw(&self, surface_coords: &VirtualCoordinates, frame: usize) -> Rgb<u8>;
}