1
0
Fork 0
forked from wry/wry

dmabuf: add PlaneVec

This commit is contained in:
Julian Orth 2023-10-23 20:41:33 +02:00
parent 3e4bed66b0
commit d022d96fbf
9 changed files with 42 additions and 23 deletions

View file

@ -1,4 +1,9 @@
use {crate::format::Format, std::rc::Rc, uapi::OwnedFd};
use {
crate::{format::Format, video::Modifier},
arrayvec::ArrayVec,
std::rc::Rc,
uapi::OwnedFd,
};
#[derive(Clone)]
pub struct DmaBufPlane {
@ -12,6 +17,10 @@ pub struct DmaBuf {
pub width: i32,
pub height: i32,
pub format: &'static Format,
pub modifier: u64,
pub planes: Vec<DmaBufPlane>,
pub modifier: Modifier,
pub planes: PlaneVec<DmaBufPlane>,
}
pub const MAX_PLANES: usize = 4;
pub type PlaneVec<T> = ArrayVec<T, MAX_PLANES>;

View file

@ -5,7 +5,7 @@ use {
format::formats,
utils::oserror::OsError,
video::{
dmabuf::{DmaBuf, DmaBufPlane},
dmabuf::{DmaBuf, DmaBufPlane, PlaneVec},
drm::{Drm, DrmError},
ModifiedFormat, INVALID_MODIFIER,
},
@ -161,7 +161,7 @@ unsafe fn export_bo(bo: *mut Bo) -> Result<DmaBuf, GbmError> {
}
},
planes: {
let mut planes = vec![];
let mut planes = PlaneVec::new();
for plane in 0..gbm_bo_get_plane_count(bo) {
let offset = gbm_bo_get_offset(bo, plane);
let stride = gbm_bo_get_stride_for_plane(bo, plane);