Struct evdi::buffer::Buffer

source ·
pub struct Buffer {
    pub version: Option<u32>,
    pub id: BufferId,
    pub width: usize,
    pub height: usize,
    pub stride: usize,
    pub pixel_format: Result<DrmFourcc, UnrecognizedFourcc>,
    /* private fields */
}
Expand description

A buffer used to store the virtual screen pixels.

Fields§

§version: Option<u32>

None if the buffer never been written to, otherwise Some(n) where n increases by some amount every time the buffer is written to.

let timeout = Duration::from_secs(1);
let buf_id = handle.new_buffer(&mode);

assert!(handle.get_buffer(buf_id).expect("Buffer exists").version.is_none());

handle.request_update(buf_id, timeout).await?;
let after_first = handle
    .get_buffer(buf_id).expect("buffer exists")
    .version.expect("Buffer must have been updated");

handle.request_update(buf_id, timeout).await?;
let after_second = handle
    .get_buffer(buf_id).expect("buffer exists")
    .version.expect("Buffer must have been updated");

assert!(after_second > after_first);
§id: BufferId§width: usize§height: usize§stride: usize§pixel_format: Result<DrmFourcc, UnrecognizedFourcc>

Implementations§

source§

impl Buffer

Owned and created by Handles. The general flow is

let buffer_id: BufferId = handle.new_buffer(&mode);
let buffer_data: &Buffer = handle.get_buffer(buffer_id).expect("Buffer exists");

handle.unregister_buffer(buffer_id);
assert!(handle.get_buffer(buffer_id).is_none());
source

pub fn bytes(&self) -> &[u8]

Get a reference to the underlying bytes of this buffer.

Use Buffer::width, Buffer::height, Buffer::stride, and Buffer::pixel_format to interpret this.

source

pub fn rects(&self) -> &[evdi_rect]

source

pub fn debug_write_to_ppm(&self, f: &mut File) -> Result<()>

Write the pixels to a file in the unoptimized image format PPM.

This is useful when debugging, as you can open the file in an image viewer and see if the buffer is processed correctly.

Panics: If the pixel format isn’t Xbgr8888, to simplify the implementation. This function should therefore only be used as a debug helper where you can guarantee that your kernel won’t output in a different format.

Trait Implementations§

source§

impl Debug for Buffer

source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more