Ream v0.1.0-1
C++ graphics library for Linux
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
RGBMBo Class Reference

Wrapper around a native GBM buffer object (gbm_bo). More...

#include <RGBMBo.h>

+ Inheritance diagram for RGBMBo:

Public Member Functions

 ~RGBMBo () noexcept
 Destroys the underlying gbm_bo if this object owns it.
 
RDeviceallocator () const noexcept
 Returns the allocator device used to create this buffer.
 
bool hasModifier () const noexcept
 Checks whether the buffer was created with an explicit modifier.
 
RModifier modifier () const noexcept
 Returns the DRM format modifier of the buffer.
 
RFormat format () const noexcept
 Returns the DRM pixel format of the buffer.
 
SkISize size () const noexcept
 Returns the width and height of the buffer in pixels.
 
int planeCount () const noexcept
 Returns the number of planes in the buffer.
 
union gbm_bo_handle planeHandle (int planeIndex) const noexcept
 Returns the GEM flink handle for a specific plane.
 
UInt32 planeStride (int planeIndex) const noexcept
 Returns the stride (bytes per row) for a specific plane.
 
UInt32 planeOffset (int planeIndex) const noexcept
 Returns the byte offset of a specific plane within the buffer.
 
CZSpFd planeFd (int planeIndex) const noexcept
 Exports a DMA-BUF file descriptor for a specific plane.
 
bool supportsMapRead () const noexcept
 Checks whether the buffer supports memory mapping for read access.
 
bool supportsMapWrite () const noexcept
 Checks whether the buffer supports memory mapping for write access.
 
gbm_bo * bo () const noexcept
 Returns the raw gbm_bo handle.
 
std::shared_ptr< RCorecore () const noexcept
 Returns the internal shared reference to the core instance.
 
- Public Member Functions inherited from RObject
 RObject ()=default
 Constructs a default RObject.
 

Static Public Member Functions

static std::shared_ptr< RGBMBoMake (SkISize size, const RDRMFormat &format, RDevice *allocator=nullptr) noexcept
 Creates a GBM buffer object.
 

Detailed Description

Wrapper around a native GBM buffer object (gbm_bo).

This class encapsulates a GBM buffer object, providing safe access to its properties and DMA-BUF export information. It manages the lifetime of the gbm_bo handle and related resources.

Use Make() to create an instance. The buffer object is created either with or without modifiers, depending on platform support and requested format.

Constructor & Destructor Documentation

◆ ~RGBMBo()

~RGBMBo ( )
noexcept

Destroys the underlying gbm_bo if this object owns it.

Member Function Documentation

◆ Make()

static std::shared_ptr< RGBMBo > Make ( SkISize  size,
const RDRMFormat format,
RDevice allocator = nullptr 
)
staticnoexcept

Creates a GBM buffer object.

Allocates a new gbm_bo with the specified size and format.

If no allocator is provided, the default device from RCore::mainDevice() is used.

Parameters
sizeThe width and height of the buffer.
formatThe DRM pixel format and modifiers.
allocatorThe device to use for allocation (optional).
Returns
A shared pointer to a valid RGBMBo on success, nullptr on failure.

◆ allocator()

RDevice * allocator ( ) const
inlinenoexcept

Returns the allocator device used to create this buffer.

◆ hasModifier()

bool hasModifier ( ) const
inlinenoexcept

Checks whether the buffer was created with an explicit modifier.

If true, the buffer was created using gbm_bo_create_with_modifiers and has a valid modifier. If false, it was created using gbm_bo_create, and the modifier may be DRM_FORMAT_MOD_INVALID or DRM_FORMAT_MOD_LINEAR.

Returns
True if the buffer has an explicit modifier, false otherwise.

◆ modifier()

RModifier modifier ( ) const
noexcept

Returns the DRM format modifier of the buffer.

See also
hasModifier()

◆ format()

RFormat format ( ) const
noexcept

Returns the DRM pixel format of the buffer.

◆ size()

SkISize size ( ) const
noexcept

Returns the width and height of the buffer in pixels.

◆ planeCount()

int planeCount ( ) const
noexcept

Returns the number of planes in the buffer.

Returns
Number of planes (usually 1 for RGB, may be more for YUV).

◆ planeHandle()

union gbm_bo_handle planeHandle ( int  planeIndex) const
noexcept

Returns the GEM flink handle for a specific plane.

Note
Handles must not be manually closed or used by other device than the allocator. For cross-device sharing, use dmaInfo().
Parameters
planeIndexIndex of the plane (0-based).
Returns
The GEM flink handle (DRM buffer object handle) for the specified plane.

◆ planeStride()

UInt32 planeStride ( int  planeIndex) const
noexcept

Returns the stride (bytes per row) for a specific plane.

Parameters
planeIndexIndex of the plane (0-based).
Returns
The stride in bytes for the specified plane.

◆ planeOffset()

UInt32 planeOffset ( int  planeIndex) const
noexcept

Returns the byte offset of a specific plane within the buffer.

Parameters
planeIndexIndex of the plane (0-based).
Returns
The offset in bytes for the specified plane.

◆ planeFd()

CZSpFd planeFd ( int  planeIndex) const
noexcept

Exports a DMA-BUF file descriptor for a specific plane.

Note
The returned file descriptor is owned by the caller (wrapped in a CZSpFd) and must be closed when no longer needed. For a full export of all planes, use dmaExport().
Parameters
planeIndexIndex of the plane (0-based).
Returns
A CZSpFd wrapping the plane's DMA-BUF file descriptor.

◆ supportsMapRead()

bool supportsMapRead ( ) const
noexcept

Checks whether the buffer supports memory mapping for read access.

Note
The mapping present a linear view of the buffer, independently of the modifier.
Returns
True if gbm_bo_map can be used for reading, false otherwise.

◆ supportsMapWrite()

bool supportsMapWrite ( ) const
noexcept

Checks whether the buffer supports memory mapping for write access.

Note
The mapping present a linear view of the buffer, independently of the modifier.
Returns
True if gbm_bo_map can be used for writing, false otherwise.

◆ bo()

gbm_bo * bo ( ) const
inlinenoexcept

Returns the raw gbm_bo handle.

Note
This handle is owned by the object. Do not manually destroy it.
Returns
Pointer to the underlying gbm_bo.

◆ core()

std::shared_ptr< RCore > core ( ) const
inlinenoexcept

Returns the internal shared reference to the core instance.

This ensures the current RCore instance stays alive while the buffer exists.