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
RDumbBuffer Class Referencefinal

A DRM dumb buffer for software (CPU) rendering. More...

#include <RDumbBuffer.h>

+ Inheritance diagram for RDumbBuffer:

Public Member Functions

 ~RDumbBuffer () noexcept
 Unmaps and destroys the underlying dumb buffer.
 
std::shared_ptr< RCorecore () const noexcept
 Returns the internal shared reference to the core instance.
 
std::shared_ptr< RDRMFramebufferfb () const noexcept
 Returns the DRM framebuffer wrapping this dumb buffer, for KMS scanout.
 
SkISize size () const noexcept
 Returns the width and height of the buffer in pixels.
 
const RFormatInfoformatInfo () const noexcept
 Returns detailed information about the buffer's DRM format.
 
RDeviceallocator () const noexcept
 Returns the DRM device that allocated this buffer.
 
UInt32 handle () const noexcept
 Returns the GEM handle of the dumb buffer, valid on the allocator device.
 
UInt32 stride () const noexcept
 Returns the buffer stride (bytes per row).
 
UInt8 * pixels () const noexcept
 Returns a pointer to the mapped, CPU-accessible pixel data.
 
- Public Member Functions inherited from RObject
 RObject ()=default
 Constructs a default RObject.
 

Static Public Member Functions

static std::shared_ptr< RDumbBufferMake (SkISize size, const RDRMFormat &format, RDevice *allocator=nullptr) noexcept
 Creates and maps a DRM dumb buffer.
 

Detailed Description

A DRM dumb buffer for software (CPU) rendering.

Wraps a DRM dumb buffer (drmModeCreateDumbBuffer), a simple CPU-accessible buffer suitable for software rendering and scanout on devices without GPU acceleration. The buffer is mapped into the process address space (via mmap) so its pixels can be read and written directly, and it is also wrapped in an RDRMFramebuffer so it can be presented via KMS.

Dumb buffers only support the DRM_FORMAT_MOD_INVALID or DRM_FORMAT_MOD_LINEAR modifier, and only single-block (1x1 pixel-per-block) formats. The allocating device must advertise the DumbBuffer capability.

Use Make() to create an instance.

Constructor & Destructor Documentation

◆ ~RDumbBuffer()

~RDumbBuffer ( )
noexcept

Unmaps and destroys the underlying dumb buffer.

Member Function Documentation

◆ Make()

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

Creates and maps a DRM dumb buffer.

Parameters
sizeThe width and height of the buffer in pixels; must be non-empty.
formatThe DRM format and modifiers. The modifier set must contain DRM_FORMAT_MOD_INVALID or DRM_FORMAT_MOD_LINEAR, and the format must be a supported single-block (1x1) format.
allocatorThe DRM device to allocate on. If nullptr, RCore::mainDevice() is used. Must support the DumbBuffer capability.
Returns
A shared pointer to a valid RDumbBuffer on success, nullptr on failure.

◆ 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.

◆ fb()

std::shared_ptr< RDRMFramebuffer > fb ( ) const
noexcept

Returns the DRM framebuffer wrapping this dumb buffer, for KMS scanout.

◆ size()

SkISize size ( ) const
inlinenoexcept

Returns the width and height of the buffer in pixels.

◆ formatInfo()

const RFormatInfo & formatInfo ( ) const
inlinenoexcept

Returns detailed information about the buffer's DRM format.

◆ allocator()

RDevice * allocator ( ) const
inlinenoexcept

Returns the DRM device that allocated this buffer.

◆ handle()

UInt32 handle ( ) const
inlinenoexcept

Returns the GEM handle of the dumb buffer, valid on the allocator device.

◆ stride()

UInt32 stride ( ) const
inlinenoexcept

Returns the buffer stride (bytes per row).

◆ pixels()

UInt8 * pixels ( ) const
inlinenoexcept

Returns a pointer to the mapped, CPU-accessible pixel data.

The mapping is read/write and remains valid for the lifetime of this object.