use crate::render::{BufferMetrics, BufferMisc, BufferPointers};
#[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))]
#[derive(PartialEq, Debug, Eq, Clone, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "c_compatible", repr(C))]
pub struct Buffer {
pub data: Vec<u32>,
pub width: usize,
pub height: usize,
pub total_size: usize,
}
unsafe impl core::marker::Send for Buffer {}
unsafe impl core::marker::Sync for Buffer {}
mod collision_support;
mod draw;
mod get_converted;
mod get_pixel;
mod manipulate;
mod misc;
mod new;
mod set_color;
mod set_pixel;
mod trim;
impl core::ops::Deref for Buffer {
type Target = [u32];
fn deref(&self) -> &Self::Target {
&self.data
}
}
impl Buffer {
#[must_use]
pub const fn pointer(&self) -> *const u32 {
self.data.as_ptr()
}
#[must_use]
pub const fn mut_pointer(&mut self) -> *mut u32 {
self.data.as_mut_ptr()
}
pub const fn update_total_size(&mut self) {
self.total_size = self.width * self.height;
}
}
impl BufferMisc for Buffer {
fn data(&mut self) -> &mut [u32] {
&mut self.data
}
}
impl const BufferMetrics for Buffer {
fn width(&self) -> usize {
self.width
}
fn height(&self) -> usize {
self.height
}
}
impl const BufferPointers for Buffer {
fn pointer(&self) -> *const u32 {
self.pointer()
}
fn mut_pointer(&mut self) -> *mut u32 {
self.mut_pointer()
}
}