#![deny(missing_docs)]
use std::num::NonZeroU32;
use winit::dpi::PhysicalPosition;
use winit::window::Window;
pub use winit;
pub trait Backend: Sized {
fn new(window: &Window, resolution: (u32, u32), scale: u32) -> Option<Self>;
fn resize(&mut self, width: NonZeroU32, height: NonZeroU32) -> Option<()>;
fn draw_image<'a, P: 'a, I>(
&mut self,
image: &'a dyn BackendImage<'a, P, Iterator = I>,
converter: &dyn Converter<Palette = P>,
window: &Window,
background: u32,
) -> Option<()>
where
I: Iterator<Item = &'a P>;
fn window_pos_to_inner(
&self,
position: PhysicalPosition<f64>,
window: &Window,
resolution: (u32, u32),
) -> Result<(i32, i32), (i32, i32)>;
}
pub trait Converter {
type Palette;
fn convert(&self, color: &Self::Palette) -> u32;
}
pub trait BackendImage<'a, P: 'a> {
type Iterator: Iterator<Item = &'a P>;
unsafe fn pixel_unsafe(&self, x: u32, y: u32) -> &P;
fn width(&self) -> u32;
fn height(&self) -> u32;
fn pixels(&'a self) -> Self::Iterator;
}