pub struct CanvasBuffer {
pub addr: *mut u8,
pub width: usize,
pub height: usize,
pub pitch: usize,
pub bpp: u16,
pub back_buffer: Option<Vec<u32>>,
pub draw_to_back: bool,
pub dirty: DirtyRectSet,
pub track_dirty: bool,
pub present_pending: bool,
pub last_present_tick: u64,
pub ops: FramebufferOps,
}Expand description
A raw framebuffer canvas with optional double buffering.
Encapsulates the HW framebuffer pointer, optional back-buffer (always
32bpp), dirty-region tracking, SIMD-accelerated pixel ops, and a
present() that flushes dirty regions to the real hardware.
Used by both the VGA text-mode writer (VgaWriter) and the raw
hardware video driver (hardware::video::Framebuffer), eliminating
the duplicated present() / dirty-tracking logic between them.
Fields§
§addr: *mut u8Pointer to the start of the HW framebuffer (HHDM-mapped virtual).
width: usizeWidth in pixels.
height: usizeHeight in pixels.
pitch: usizeBytes per row (stride / pitch).
bpp: u16Bits per pixel (24 or 32).
back_buffer: Option<Vec<u32>>Optional back-buffer (always 32bpp / u32 per pixel).
draw_to_back: boolIf true, draw operations write to back_buffer instead of HW.
dirty: DirtyRectSetSet of dirty rectangles pending a present().
track_dirty: boolIf true, dirty rectangles are tracked.
present_pending: boolWhether a present() has been requested.
last_present_tick: u64Tick of the last present() (for rate-limiting).
ops: FramebufferOpsSIMD-accelerated pixel ops (fill, blit, blend, convert).
Implementations§
Source§impl CanvasBuffer
impl CanvasBuffer
Sourcepub fn enable_back_buffer(&mut self) -> bool
pub fn enable_back_buffer(&mut self) -> bool
Enable double-buffering by allocating and syncing a back-buffer.
Sourcepub fn disable_back_buffer(&mut self, do_present: bool)
pub fn disable_back_buffer(&mut self, do_present: bool)
Disable double-buffering, optionally presenting first.
Sourcepub fn pixel_offset(&self, x: usize, y: usize) -> Option<usize>
pub fn pixel_offset(&self, x: usize, y: usize) -> Option<usize>
Byte offset in HW memory for pixel (x, y).
Sourcepub fn read_hw_pixel(&self, x: usize, y: usize) -> u32
pub fn read_hw_pixel(&self, x: usize, y: usize) -> u32
Read a packed pixel directly from HW memory.
Sourcepub fn write_hw_pixel(&mut self, x: usize, y: usize, color: u32)
pub fn write_hw_pixel(&mut self, x: usize, y: usize, color: u32)
Write a packed pixel to HW memory.
Sourcepub fn read_pixel(&self, x: usize, y: usize) -> u32
pub fn read_pixel(&self, x: usize, y: usize) -> u32
Read pixel (x, y) : from back-buffer if available, else HW.
Sourcepub fn write_pixel(&mut self, x: usize, y: usize, color: u32)
pub fn write_pixel(&mut self, x: usize, y: usize, color: u32)
Write pixel (x, y) : to back-buffer if available, else HW.
Sourcepub fn fill_rect(&mut self, x: usize, y: usize, w: usize, h: usize, color: u32)
pub fn fill_rect(&mut self, x: usize, y: usize, w: usize, h: usize, color: u32)
Fill a rectangle with a packed colour.
Sourcepub fn present(&mut self)
pub fn present(&mut self)
Flush dirty back-buffer regions to the hardware framebuffer.
Uses SIMD-accelerated ops.blit when the back-buffer’s row stride
matches the frame-buffer’s stride, falling back to row-by-row copies.
Sourcepub fn request_present(&mut self)
pub fn request_present(&mut self)
Request a present (throttled).
Sourcepub fn present_if_due(&mut self, force: bool, now: u64)
pub fn present_if_due(&mut self, force: bool, now: u64)
Present if a request is pending and the throttle delay has elapsed.
Trait Implementations§
impl Send for CanvasBuffer
Auto Trait Implementations§
impl !Sync for CanvasBuffer
impl Freeze for CanvasBuffer
impl RefUnwindSafe for CanvasBuffer
impl Unpin for CanvasBuffer
impl UnsafeUnpin for CanvasBuffer
impl UnwindSafe for CanvasBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more