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

Describes the memory layout properties of a DRM pixel format. More...

#include <RDRMFormat.h>

Public Member Functions

constexpr UInt32 pixelsPerBlock () const noexcept
 Returns the total number of pixels covered by a single block.
 
constexpr UInt32 blocksPerRow (UInt32 width) const noexcept
 Computes the number of blocks required to cover a given image width.
 
constexpr UInt32 minStride (UInt32 width) const noexcept
 Calculates the minimum required stride (in bytes) for a given image width.
 
constexpr bool validateStride (UInt32 width, UInt32 stride) const noexcept
 Validates whether the provided stride matches the alignment and is sufficient for the image width.
 

Public Attributes

RFormat format
 The DRM format.
 
UInt32 bytesPerBlock
 Number of bytes required to store one block of pixels.
 
UInt32 blockWidth
 Width of one block of pixels.
 
UInt32 blockHeight
 Height of one block of pixels.
 
UInt32 bpp
 Bits per pixel.
 
UInt32 depth
 Number of bits that are actually used to represent color information — often excluding alpha or padding bits.
 
UInt32 planes
 Number of separate memory planes used to store pixel data.
 
bool alpha
 true if the format includes an alpha channel.
 

Detailed Description

Describes the memory layout properties of a DRM pixel format.

Provides block dimensions, byte sizes and plane counts, along with helpers to compute strides and validate buffer layouts for a given image width.

Member Function Documentation

◆ pixelsPerBlock()

constexpr UInt32 pixelsPerBlock ( ) const
inlineconstexprnoexcept

Returns the total number of pixels covered by a single block.

This is calculated as blockWidth × blockHeight.

◆ blocksPerRow()

constexpr UInt32 blocksPerRow ( UInt32  width) const
inlineconstexprnoexcept

Computes the number of blocks required to cover a given image width.

This uses ceiling division to ensure partial blocks are counted. Important for compressed formats where data is grouped in blocks of multiple pixels.

Parameters
widthImage width in pixels.
Returns
Number of horizontal blocks needed to cover the width.

◆ minStride()

constexpr UInt32 minStride ( UInt32  width) const
inlineconstexprnoexcept

Calculates the minimum required stride (in bytes) for a given image width.

The stride must be at least this value to ensure a full row of image data can be represented in memory. This value is based on the number of blocks per row and the number of bytes per block.

Parameters
widthImage width in pixels.
Returns
Minimum stride in bytes needed to accommodate the image width.

◆ validateStride()

constexpr bool validateStride ( UInt32  width,
UInt32  stride 
) const
inlineconstexprnoexcept

Validates whether the provided stride matches the alignment and is sufficient for the image width.

Parameters
widthImage width in pixels.
strideStride in bytes.
Returns
true if stride is valid, false otherwise.

Member Data Documentation

◆ format

RFormat format

The DRM format.

◆ bytesPerBlock

UInt32 bytesPerBlock

Number of bytes required to store one block of pixels.

For uncompressed formats with 1x1 blocks, this typically equals the number of bytes per pixel.

◆ blockWidth

UInt32 blockWidth

Width of one block of pixels.

The number of pixels wide in a single block for this image format (1 for uncompressed formats). For example, in a format with a blockWidth of 4, each block covers 4 pixels horizontally. This is important for formats that compress or group pixels in blocks rather than individually.

◆ blockHeight

UInt32 blockHeight

Height of one block of pixels.

The number of pixels tall in a single block for this image format (1 for uncompressed formats). For example, if blockHeight is 2, each block covers 2 pixels vertically. This matters for formats that group or compress pixels in blocks instead of individually.

◆ bpp

UInt32 bpp

Bits per pixel.

◆ depth

UInt32 depth

Number of bits that are actually used to represent color information — often excluding alpha or padding bits.

◆ planes

UInt32 planes

Number of separate memory planes used to store pixel data.

Typically 1 for packed RGB formats, 2–3 for planar YUV formats.

◆ alpha

bool alpha

true if the format includes an alpha channel.