[][src]Struct sunrise_vi::vbe::Framebuffer

pub struct Framebuffer<'a> {
    buf: &'a mut [VBEColor],
    width: usize,
    height: usize,
    bpp: usize,
}

A wrapper around a linear framebuffer. The framebuffer is usually acquired through the map_framebuffer syscall.

Fields

buf: &'a mut [VBEColor]width: usizeheight: usizebpp: usize

Bits-per-pixel. Usually 8.

Implementations

impl<'a> Framebuffer<'a>[src]

pub fn new() -> Result<Framebuffer<'static>, Error>[src]

Creates an instance of the linear framebuffer.

Safety

This function should only be called once, to ensure there is only a single mutable reference to the underlying framebuffer.

pub fn new_buffer(
    buf: &'a mut [VBEColor],
    width: usize,
    height: usize,
    bpp: usize
) -> Framebuffer<'a>
[src]

Creates a backbuffer backed by an in-memory array.

This is useful to avoid flickering and other display artifact. Compositing should happen in such a backbuffer, and the final result should then be copied into the actual framebuffer.

pub fn width(&self) -> usize[src]

framebuffer width in pixels. Does not account for bpp

pub fn height(&self) -> usize[src]

framebuffer height in pixels. Does not account for bpp

pub fn bpp(&self) -> usize[src]

The number of bits that forms a pixel. Used to compute offsets in framebuffer memory to corresponding pixel px_offset = px_nbr * bpp

pub fn get_px_offset(&self, x: usize, y: usize) -> usize[src]

Gets the offset in memory of a pixel based on an x and y.

Panics

Panics if y >= self.height() or x >= self.width()

pub fn write_px(&mut self, offset: usize, color: VBEColor)[src]

Writes a pixel in the framebuffer respecting the bgr pattern

Panics

Panics if offset is invalid

pub fn write_px_at(&mut self, x: usize, y: usize, color: VBEColor)[src]

Writes a pixel in the framebuffer respecting the bgr pattern Computes the offset in the framebuffer from x and y

Panics

Panics if coords are invalid

pub fn get_fb(&mut self) -> &mut [VBEColor][src]

Gets the underlying framebuffer

pub fn clear(&mut self)[src]

Clears the whole screen

pub fn clear_at(&mut self, x: usize, y: usize, width: usize, height: usize)[src]

Clears a segment of the screen.

Panics

Panics if x + width or y + height falls outside the framebuffer.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Framebuffer<'a>

impl<'a> Send for Framebuffer<'a>

impl<'a> Sync for Framebuffer<'a>

impl<'a> Unpin for Framebuffer<'a>

impl<'a> !UnwindSafe for Framebuffer<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SizedIPCBuffer for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.