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
impl Buffer
Owned and created by Handle
s. 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());
sourcepub fn bytes(&self) -> &[u8] ⓘ
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.
pub fn rects(&self) -> &[evdi_rect]
sourcepub fn debug_write_to_ppm(&self, f: &mut File) -> Result<()>
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.