breakwater_parser/framebuffer/
mod.rspub mod simple;
pub trait FrameBuffer {
fn get_width(&self) -> usize;
fn get_height(&self) -> usize;
fn get_size(&self) -> usize {
self.get_width() * self.get_height()
}
#[inline(always)]
fn get(&self, x: usize, y: usize) -> Option<u32> {
if x < self.get_width() && y < self.get_height() {
Some(unsafe { self.get_unchecked(x, y) })
} else {
None
}
}
unsafe fn get_unchecked(&self, x: usize, y: usize) -> u32;
fn set(&self, x: usize, y: usize, rgba: u32);
#[inline(always)]
fn set_multi(&self, start_x: usize, start_y: usize, pixels: &[u8]) -> (usize, usize) {
let starting_index = start_x + start_y * self.get_width();
let pixels_copied = self.set_multi_from_start_index(starting_index, pixels);
let new_x = (start_x + pixels_copied) % self.get_width();
let new_y = start_y + (pixels_copied / self.get_width());
(new_x, new_y)
}
fn set_multi_from_start_index(&self, starting_index: usize, pixels: &[u8]) -> usize;
fn as_bytes(&self) -> &[u8];
fn as_pixels(&self) -> &[u32];
}