drm/control/
framebuffer.rsuse crate::buffer;
use crate::control;
use drm_ffi as ffi;
use drm_fourcc::{DrmFourcc, DrmModifier};
#[repr(transparent)]
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct Handle(control::RawResourceHandle);
unsafe impl bytemuck::ZeroableInOption for Handle {}
unsafe impl bytemuck::PodInOption for Handle {}
impl From<Handle> for control::RawResourceHandle {
fn from(handle: Handle) -> Self {
handle.0
}
}
impl From<Handle> for u32 {
fn from(handle: Handle) -> Self {
handle.0.into()
}
}
impl From<control::RawResourceHandle> for Handle {
fn from(handle: control::RawResourceHandle) -> Self {
Handle(handle)
}
}
impl control::ResourceHandle for Handle {
const FFI_TYPE: u32 = ffi::DRM_MODE_OBJECT_FB;
}
impl std::fmt::Debug for Handle {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_tuple("framebuffer::Handle").field(&self.0).finish()
}
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Info {
pub(crate) handle: Handle,
pub(crate) size: (u32, u32),
pub(crate) pitch: u32,
pub(crate) bpp: u32,
pub(crate) depth: u32,
pub(crate) buffer: Option<buffer::Handle>,
}
impl Info {
pub fn handle(&self) -> Handle {
self.handle
}
pub fn size(&self) -> (u32, u32) {
self.size
}
pub fn pitch(&self) -> u32 {
self.pitch
}
pub fn bpp(&self) -> u32 {
self.bpp
}
pub fn depth(&self) -> u32 {
self.depth
}
pub fn buffer(&self) -> Option<buffer::Handle> {
self.buffer
}
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct PlanarInfo {
pub(crate) handle: Handle,
pub(crate) size: (u32, u32),
pub(crate) pixel_format: DrmFourcc,
pub(crate) flags: control::FbCmd2Flags,
pub(crate) buffers: [Option<buffer::Handle>; 4],
pub(crate) pitches: [u32; 4],
pub(crate) offsets: [u32; 4],
pub(crate) modifier: Option<DrmModifier>,
}
impl PlanarInfo {
pub fn handle(&self) -> Handle {
self.handle
}
pub fn size(&self) -> (u32, u32) {
self.size
}
pub fn pixel_format(&self) -> DrmFourcc {
self.pixel_format
}
pub fn flags(&self) -> control::FbCmd2Flags {
self.flags
}
pub fn buffers(&self) -> [Option<buffer::Handle>; 4] {
self.buffers
}
pub fn pitches(&self) -> [u32; 4] {
self.pitches
}
pub fn offsets(&self) -> [u32; 4] {
self.offsets
}
pub fn modifier(&self) -> Option<DrmModifier> {
self.modifier
}
}