RgaBuffer

Struct RgaBuffer 

Source
pub struct RgaBuffer { /* private fields */ }
Expand description

一个描述 RGA 内存缓冲对象的类型。

Implementations§

Source§

impl RgaBuffer

Source

pub fn new( rga: Arc<Rga>, width: i32, height: i32, bpp: i32, ) -> Result<Self, Error>

创建一个新的 RGA 内存缓冲对象。

§Examples
use rkrga::{Rga, RgaBuffer};
use std::sync::Arc;

let rga = Arc::new(Rga::new().unwrap());
let mut bo = RgaBuffer::new(Arc::clone(&rga), 1920, 1080, 32); // 1920x1080 RGBA8888
bo.map().unwrap();
assert_eq!(bo.len(), 1920 * 1080 * 4);
assert_eq!(bo.as_ptr(), std::ptr::null());
bo.unmap();
Source

pub fn new_mapped( rga: Arc<Rga>, width: i32, height: i32, bpp: i32, ) -> Result<Self, Error>

创建一个新的且已映射到用户空间的 RGA 内存缓冲对象。

Source

pub fn with_rect(rga: Arc<Rga>, rect: &RgaRect) -> Result<Self, Error>

为指定的 RGA 图像区域创建一个 RGA 内存缓冲对象。

Source

pub fn with_rect_mapped(rga: Arc<Rga>, rect: &RgaRect) -> Result<Self, Error>

为指定的 RGA 图像区域创建一个 RGA 内存缓冲对象。

Source

pub fn fd(&self) -> i32

返回文件描述符。

§Note

此文件描述符并不能用于 DMA 操作,用于 DMA 操作的请使用 dma_fd 返回值。

Source

pub fn handle(&self) -> u32

返回资源句柄。

Source

pub fn offset(&self) -> usize

返回有效数据的偏移位置。

Source

pub fn pitch(&self) -> usize

返回一行数据的字节跨度。

Source

pub unsafe fn ptr(&self) -> *mut u8

返回映射到用户空间的地址。

§Note

当用户未进行映射操作时,会返回 NULL。

§Safety

请小心使用此指针。

Source

pub fn size(&self) -> usize

返回已分配的内存块字节数。

Source

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

返回字节数组。

Source

pub fn as_ptr<T>(&self) -> *const T

返回指定类型的映射到用户空间的只读地址。

Source

pub fn as_mut_ptr<T>(&mut self) -> *mut T

返回指定类型的映射到用户空间的可读写地址。

Source

pub fn as_slice<T>(&self) -> &[T]

返回指定类型的映射到用户空间的只读数组切片。

Source

pub fn as_mut_slice<T>(&mut self) -> &mut [T]

返回指定类型的映射到用户空间的可读写数组切片。

Source

pub fn is_empty(&self) -> bool

当未分配到内存时返回 false。

Source

pub fn len(&self) -> usize

返回有效的字节长度。

Source

pub fn dma_fd(&self) -> Result<i32, Error>

返回用于 DMA 操作的文件描述符。

Source

pub fn map(&mut self) -> Result<(), Error>

映射对象到用户空间。

Source

pub fn unmap(&mut self) -> Result<(), Error>

解除对象到用户空间的映射。

Trait Implementations§

Source§

impl Debug for RgaBuffer

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for RgaBuffer

Source§

fn default() -> RgaBuffer

Returns the “default value” for a type. Read more
Source§

impl Drop for RgaBuffer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.