Castor3D 0.16.0
Multiplatform 3D engine
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
castor::PxBufferBase Class Reference

#include <PixelBufferBase.hpp>

Inheritance diagram for castor::PxBufferBase:
Inheritance graph
[legend]
Collaboration diagram for castor::PxBufferBase:
Collaboration graph
[legend]

Public Types

using PxArray = Vector< uint8_t >
 
using PixelData = PxArray::iterator
 
using ConstPixelData = PxArray::const_iterator
 

Public Member Functions

CU_API PxBufferBase (PxBufferConvertOptions const *options, std::atomic_bool const *interrupt, Size const &size, PixelFormat pixelFormat, uint32_t layers=1u, uint32_t levels=1u, uint8_t const *buffer=nullptr, PixelFormat bufferFormat=PixelFormat::eR8G8B8A8_UNORM, uint32_t bufferAlign=0u)
 Creates a buffer from a source buffer, uninitialised data if no source is given.
 
CU_API PxBufferBase (Size const &size, PixelFormat pixelFormat, uint32_t layers=1u, uint32_t levels=1u, uint8_t const *buffer=nullptr, PixelFormat bufferFormat=PixelFormat::eR8G8B8A8_UNORM, uint32_t bufferAlign=0u)
 Creates a buffer from a source buffer, uninitialised data if no source is given.
 
CU_API PxBufferBase (PxBufferBase const &pixelBuffer)
 Copy Constructor.
 
CU_API PxBufferBase (PxBufferBase &&pixelBuffer) noexcept
 Move Constructor.
 
CU_API ~PxBufferBase () noexcept=default
 Destructor.
 
CU_API PxBufferBaseoperator= (PxBufferBase const &pixelBuffer)
 Copy assignment operator.
 
CU_API PxBufferBaseoperator= (PxBufferBase &&pixelBuffer) noexcept
 Move assignment operator.
 
CU_API void clear ()
 Deletes the data buffer.
 
CU_API void initialise (PxBufferConvertOptions const *options, std::atomic_bool const *interrupt, uint8_t const *buffer, PixelFormat bufferFormat, uint32_t bufferAlign=0u)
 Initialises the data buffer to the given one.
 
void initialise (uint8_t const *buffer, PixelFormat bufferFormat, uint32_t bufferAlign=0u)
 Initialises the data buffer to the given one.
 
CU_API void initialise (Size const &size)
 Initialises the data buffer at the given size.
 
CU_API void flip ()
 Makes a vertical swap of pixels.
 
CU_API void swap (PxBufferBase &pixelBuffer) noexcept
 Swaps this buffer's data with the given one's.
 
CU_API void update (uint32_t layers, uint32_t levels)
 Updates the buffer container, with given layers and miplevels counts.
 
CU_API void generateMips ()
 Generate mipmaps.
 
CU_API uint32_t convertToTiles (uint32_t maxSize)
 Convert to tiles map (no effect if m_layers <= 1).
 
PxBufferBaseUPtr clone () const
 
CU_API PixelData getAt (uint32_t x, uint32_t y, uint32_t index=0u, uint32_t level=0u)
 
CU_API ConstPixelData getAt (uint32_t x, uint32_t y, uint32_t index=0u, uint32_t level=0u) const
 
uint64_t getSize () const noexcept
 
uint8_t const * begin () const noexcept
 
uint8_t const * end () const noexcept
 
uint8_t const * cbegin () const noexcept
 
uint8_t const * cend () const noexcept
 
uint8_t const * getConstPtr () const noexcept
 
uint8_t * getPtr () noexcept
 
bool isFlipped () const noexcept
 
PixelFormat getFormat () const noexcept
 
uint32_t getWidth () const noexcept
 
uint32_t getHeight () const noexcept
 
Point3ui getTiles () const noexcept
 
Size getTileSize () const noexcept
 
uint32_t getTileWidth () const noexcept
 
uint32_t getTileHeight () const noexcept
 
uint32_t getLayers () const noexcept
 
uint32_t getLevels () const noexcept
 
uint32_t getAlign () const noexcept
 
Size const & getDimensions () const noexcept
 
uint32_t getCount () const noexcept
 
PixelData getAt (Position const &position)
 
ConstPixelData getAt (Position const &position) const
 

Static Public Member Functions

static CU_API PxBufferBaseUPtr create (PxBufferConvertOptions const *options, std::atomic_bool const *interrupt, Size const &size, uint32_t layers, uint32_t levels, PixelFormat wantedFormat, uint8_t const *buffer=nullptr, PixelFormat bufferFormat=PixelFormat::eR8G8B8A8_UNORM, uint32_t bufferAlign=0u)
 Creates a buffer with the given data.
 
static CU_API PxBufferBaseUPtr create (PxBufferConvertOptions const *options, Size const &size, uint32_t layers, uint32_t levels, PixelFormat wantedFormat, uint8_t const *buffer=nullptr, PixelFormat bufferFormat=PixelFormat::eR8G8B8A8_UNORM, uint32_t bufferAlign=0u)
 Creates a buffer with the given data.
 
static CU_API PxBufferBaseUPtr create (Size const &size, uint32_t layers, uint32_t levels, PixelFormat wantedFormat, uint8_t const *buffer=nullptr, PixelFormat bufferFormat=PixelFormat::eR8G8B8A8_UNORM, uint32_t bufferAlign=0u)
 Creates a buffer with the given data.
 
static CU_API PxBufferBaseUPtr create (PxBufferConvertOptions const *options, std::atomic_bool const *interrupt, Size const &size, PixelFormat wantedFormat, uint8_t const *buffer=nullptr, PixelFormat bufferFormat=PixelFormat::eR8G8B8A8_UNORM, uint32_t bufferAlign=0u)
 Creates a buffer with the given data.
 
static CU_API PxBufferBaseUPtr create (PxBufferConvertOptions const *options, Size const &size, PixelFormat wantedFormat, uint8_t const *buffer=nullptr, PixelFormat bufferFormat=PixelFormat::eR8G8B8A8_UNORM, uint32_t bufferAlign=0u)
 Creates a buffer with the given data.
 
static CU_API PxBufferBaseUPtr create (Size const &size, PixelFormat wantedFormat, uint8_t const *buffer=nullptr, PixelFormat bufferFormat=PixelFormat::eR8G8B8A8_UNORM, uint32_t bufferAlign=0u)
 Creates a buffer with the given data.
 

Protected Member Functions

uint32_t doConvert (uint32_t x, uint32_t y) const
 

Protected Attributes

Size m_size
 
uint32_t m_layers
 
uint32_t m_levels
 
uint32_t m_align
 
Point3ui m_tiles { 1u, 1u, 1u }
 
PxArray m_buffer
 

Member Typedef Documentation

◆ ConstPixelData

using castor::PxBufferBase::ConstPixelData = PxArray::const_iterator

◆ PixelData

using castor::PxBufferBase::PixelData = PxArray::iterator

◆ PxArray

Constructor & Destructor Documentation

◆ PxBufferBase() [1/4]

CU_API castor::PxBufferBase::PxBufferBase ( PxBufferConvertOptions const * options,
std::atomic_bool const * interrupt,
Size const & size,
PixelFormat pixelFormat,
uint32_t layers = 1u,
uint32_t levels = 1u,
uint8_t const * buffer = nullptr,
PixelFormat bufferFormat = PixelFormat::eR8G8B8A8_UNORM,
uint32_t bufferAlign = 0u )

Creates a buffer from a source buffer, uninitialised data if no source is given.

Parameters
[in]optionsThe convertion options.
[in]interruptTells if the convertion is to be interrupted.
[in]sizeBuffer dimensions.
[in]pixelFormatPixels format.
[in]layersThe number of layers stored in the buffer.
[in]levelsThe number of miplevels stored in the buffer.
[in]bufferThe source buffer.
[in]bufferFormatThe pixels format of the source buffer.
[in]bufferAlignThe alignment of the source buffer.

◆ PxBufferBase() [2/4]

CU_API castor::PxBufferBase::PxBufferBase ( Size const & size,
PixelFormat pixelFormat,
uint32_t layers = 1u,
uint32_t levels = 1u,
uint8_t const * buffer = nullptr,
PixelFormat bufferFormat = PixelFormat::eR8G8B8A8_UNORM,
uint32_t bufferAlign = 0u )

Creates a buffer from a source buffer, uninitialised data if no source is given.

Parameters
[in]sizeBuffer dimensions.
[in]pixelFormatPixels format.
[in]layersThe number of layers stored in the buffer.
[in]levelsThe number of miplevels stored in the buffer.
[in]bufferThe source buffer.
[in]bufferFormatThe pixels format of the source buffer.
[in]bufferAlignThe alignment of the source buffer.

◆ PxBufferBase() [3/4]

CU_API castor::PxBufferBase::PxBufferBase ( PxBufferBase const & pixelBuffer)

Copy Constructor.

Parameters
[in]pixelBufferThe PxBufferBase object to copy

◆ PxBufferBase() [4/4]

CU_API castor::PxBufferBase::PxBufferBase ( PxBufferBase && pixelBuffer)
noexcept

Move Constructor.

Parameters
[in]pixelBufferThe PxBufferBase object to move

◆ ~PxBufferBase()

CU_API castor::PxBufferBase::~PxBufferBase ( )
defaultnoexcept

Destructor.

Member Function Documentation

◆ begin()

uint8_t const * castor::PxBufferBase::begin ( ) const
inlinenoexcept

References m_buffer.

Referenced by end().

Here is the caller graph for this function:

◆ cbegin()

uint8_t const * castor::PxBufferBase::cbegin ( ) const
inlinenoexcept

References m_buffer.

Referenced by cend().

Here is the caller graph for this function:

◆ cend()

uint8_t const * castor::PxBufferBase::cend ( ) const
inlinenoexcept

References cbegin(), and getSize().

Here is the call graph for this function:

◆ clear()

CU_API void castor::PxBufferBase::clear ( )

Deletes the data buffer.

◆ clone()

PxBufferBaseUPtr castor::PxBufferBase::clone ( ) const
inline
Returns
A clone of this buffer.

◆ convertToTiles()

CU_API uint32_t castor::PxBufferBase::convertToTiles ( uint32_t maxSize)

Convert to tiles map (no effect if m_layers <= 1).

◆ create() [1/6]

static CU_API PxBufferBaseUPtr castor::PxBufferBase::create ( PxBufferConvertOptions const * options,
Size const & size,
PixelFormat wantedFormat,
uint8_t const * buffer = nullptr,
PixelFormat bufferFormat = PixelFormat::eR8G8B8A8_UNORM,
uint32_t bufferAlign = 0u )
inlinestatic

Creates a buffer with the given data.

Parameters
[in]optionsThe convertion options.
[in]sizeBuffer dimensions.
[in]wantedFormatPixels format.
[in]bufferData buffer.
[in]bufferFormatData buffer's pixels format.
[in]bufferAlignThe alignment of the source buffer.
Returns
The created buffer.

References create().

Here is the call graph for this function:

◆ create() [2/6]

static CU_API PxBufferBaseUPtr castor::PxBufferBase::create ( PxBufferConvertOptions const * options,
Size const & size,
uint32_t layers,
uint32_t levels,
PixelFormat wantedFormat,
uint8_t const * buffer = nullptr,
PixelFormat bufferFormat = PixelFormat::eR8G8B8A8_UNORM,
uint32_t bufferAlign = 0u )
inlinestatic

Creates a buffer with the given data.

Parameters
[in]optionsThe convertion options.
[in]sizeBuffer dimensions.
[in]layersBuffer layers (or slices).
[in]levelsBuffer mip levels.
[in]wantedFormatPixels format.
[in]bufferData buffer.
[in]bufferFormatData buffer's pixels format.
[in]bufferAlignThe alignment of the source buffer.
Returns
The created buffer.

References create().

Here is the call graph for this function:

◆ create() [3/6]

static CU_API PxBufferBaseUPtr castor::PxBufferBase::create ( PxBufferConvertOptions const * options,
std::atomic_bool const * interrupt,
Size const & size,
PixelFormat wantedFormat,
uint8_t const * buffer = nullptr,
PixelFormat bufferFormat = PixelFormat::eR8G8B8A8_UNORM,
uint32_t bufferAlign = 0u )
inlinestatic

Creates a buffer with the given data.

Parameters
[in]optionsThe convertion options.
[in]interruptTells if the convertion is to be interrupted.
[in]sizeBuffer dimensions.
[in]wantedFormatPixels format.
[in]bufferData buffer.
[in]bufferFormatData buffer's pixels format.
[in]bufferAlignThe alignment of the source buffer.
Returns
The created buffer.

References create().

Here is the call graph for this function:

◆ create() [4/6]

static CU_API PxBufferBaseUPtr castor::PxBufferBase::create ( PxBufferConvertOptions const * options,
std::atomic_bool const * interrupt,
Size const & size,
uint32_t layers,
uint32_t levels,
PixelFormat wantedFormat,
uint8_t const * buffer = nullptr,
PixelFormat bufferFormat = PixelFormat::eR8G8B8A8_UNORM,
uint32_t bufferAlign = 0u )
static

Creates a buffer with the given data.

Remarks
Interruptible version.
Parameters
[in]optionsThe convertion options.
[in]interruptTells if the convertion is to be interrupted.
[in]sizeBuffer dimensions.
[in]layersBuffer layers (or slices).
[in]levelsBuffer mip levels.
[in]wantedFormatPixels format.
[in]bufferData buffer.
[in]bufferFormatData buffer's pixels format.
[in]bufferAlignThe alignment of the source buffer.
Returns
The created buffer.

Referenced by create(), create(), create(), create(), create(), and castor::WhiteNoise::generate().

Here is the caller graph for this function:

◆ create() [5/6]

static CU_API PxBufferBaseUPtr castor::PxBufferBase::create ( Size const & size,
PixelFormat wantedFormat,
uint8_t const * buffer = nullptr,
PixelFormat bufferFormat = PixelFormat::eR8G8B8A8_UNORM,
uint32_t bufferAlign = 0u )
inlinestatic

Creates a buffer with the given data.

Parameters
[in]sizeBuffer dimensions.
[in]wantedFormatPixels format.
[in]bufferData buffer.
[in]bufferFormatData buffer's pixels format.
[in]bufferAlignThe alignment of the source buffer.
Returns
The created buffer.

References create().

Here is the call graph for this function:

◆ create() [6/6]

static CU_API PxBufferBaseUPtr castor::PxBufferBase::create ( Size const & size,
uint32_t layers,
uint32_t levels,
PixelFormat wantedFormat,
uint8_t const * buffer = nullptr,
PixelFormat bufferFormat = PixelFormat::eR8G8B8A8_UNORM,
uint32_t bufferAlign = 0u )
inlinestatic

Creates a buffer with the given data.

Parameters
[in]sizeBuffer dimensions.
[in]layersBuffer layers (or slices).
[in]levelsBuffer mip levels.
[in]wantedFormatPixels format.
[in]bufferData buffer.
[in]bufferFormatData buffer's pixels format.
[in]bufferAlignThe alignment of the source buffer.
Returns
The created buffer.

References create().

Here is the call graph for this function:

◆ doConvert()

uint32_t castor::PxBufferBase::doConvert ( uint32_t x,
uint32_t y ) const
inlineprotected

References getWidth().

Here is the call graph for this function:

◆ end()

uint8_t const * castor::PxBufferBase::end ( ) const
inlinenoexcept

References begin(), and getSize().

Here is the call graph for this function:

◆ flip()

CU_API void castor::PxBufferBase::flip ( )

Makes a vertical swap of pixels.

◆ generateMips()

CU_API void castor::PxBufferBase::generateMips ( )

Generate mipmaps.

◆ getAlign()

uint32_t castor::PxBufferBase::getAlign ( ) const
inlinenoexcept

References m_align.

◆ getAt() [1/4]

PixelData castor::PxBufferBase::getAt ( Position const & position)
inline

References getAt(), castor::Position::x(), and castor::Position::y().

Here is the call graph for this function:

◆ getAt() [2/4]

ConstPixelData castor::PxBufferBase::getAt ( Position const & position) const
inline

References getAt(), castor::Position::x(), and castor::Position::y().

Here is the call graph for this function:

◆ getAt() [3/4]

CU_API PixelData castor::PxBufferBase::getAt ( uint32_t x,
uint32_t y,
uint32_t index = 0u,
uint32_t level = 0u )

name Getters.

Referenced by getAt(), and getAt().

Here is the caller graph for this function:

◆ getAt() [4/4]

CU_API ConstPixelData castor::PxBufferBase::getAt ( uint32_t x,
uint32_t y,
uint32_t index = 0u,
uint32_t level = 0u ) const

◆ getConstPtr()

uint8_t const * castor::PxBufferBase::getConstPtr ( ) const
inlinenoexcept

References m_buffer.

◆ getCount()

uint32_t castor::PxBufferBase::getCount ( ) const
inlinenoexcept

References getHeight(), and getWidth().

Here is the call graph for this function:

◆ getDimensions()

Size const & castor::PxBufferBase::getDimensions ( ) const
inlinenoexcept

References m_size.

◆ getFormat()

PixelFormat castor::PxBufferBase::getFormat ( ) const
inlinenoexcept

◆ getHeight()

uint32_t castor::PxBufferBase::getHeight ( ) const
inlinenoexcept

References castor::Size::getHeight(), and m_size.

Referenced by getCount().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLayers()

uint32_t castor::PxBufferBase::getLayers ( ) const
inlinenoexcept

References m_layers.

◆ getLevels()

uint32_t castor::PxBufferBase::getLevels ( ) const
inlinenoexcept

References m_levels.

◆ getPtr()

uint8_t * castor::PxBufferBase::getPtr ( )
inlinenoexcept

References m_buffer.

◆ getSize()

uint64_t castor::PxBufferBase::getSize ( ) const
inlinenoexcept
Returns
count() * (size of a pixel)

References m_buffer.

Referenced by cend(), and end().

Here is the caller graph for this function:

◆ getTileHeight()

uint32_t castor::PxBufferBase::getTileHeight ( ) const
inlinenoexcept

References castor::Size::getHeight(), m_size, and m_tiles.

Referenced by getTileSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTiles()

Point3ui castor::PxBufferBase::getTiles ( ) const
inlinenoexcept

References m_tiles.

◆ getTileSize()

Size castor::PxBufferBase::getTileSize ( ) const
inlinenoexcept

References getTileHeight(), and getTileWidth().

Here is the call graph for this function:

◆ getTileWidth()

uint32_t castor::PxBufferBase::getTileWidth ( ) const
inlinenoexcept

References castor::Size::getWidth(), m_size, and m_tiles.

Referenced by getTileSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getWidth()

uint32_t castor::PxBufferBase::getWidth ( ) const
inlinenoexcept

References castor::Size::getWidth(), and m_size.

Referenced by doConvert(), and getCount().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialise() [1/3]

CU_API void castor::PxBufferBase::initialise ( PxBufferConvertOptions const * options,
std::atomic_bool const * interrupt,
uint8_t const * buffer,
PixelFormat bufferFormat,
uint32_t bufferAlign = 0u )

Initialises the data buffer to the given one.

Remarks
Conversions are made if needed.
Parameters
[in]optionsThe convertion options.
[in]interruptTells if the convertion is to be interrupted.
[in]bufferData buffer.
[in]bufferFormatData buffer's pixels format.
[in]bufferAlignBuffer data's alignment.

Referenced by initialise().

Here is the caller graph for this function:

◆ initialise() [2/3]

CU_API void castor::PxBufferBase::initialise ( Size const & size)

Initialises the data buffer at the given size.

Remarks
Conversions are made if needed
Parameters
[in]sizeBuffer dimensions

◆ initialise() [3/3]

void castor::PxBufferBase::initialise ( uint8_t const * buffer,
PixelFormat bufferFormat,
uint32_t bufferAlign = 0u )
inline

Initialises the data buffer to the given one.

Remarks
Conversions are made if needed
Parameters
[in]bufferData buffer.
[in]bufferFormatData buffer's pixels format.
[in]bufferAlignBuffer data's alignment.

References initialise().

Here is the call graph for this function:

◆ isFlipped()

bool castor::PxBufferBase::isFlipped ( ) const
inlinenoexcept

◆ operator=() [1/2]

CU_API PxBufferBase & castor::PxBufferBase::operator= ( PxBufferBase && pixelBuffer)
noexcept

Move assignment operator.

Parameters
[in]pixelBufferThe PxBufferBase object to move
Returns
A reference to this PxBufferBase object

◆ operator=() [2/2]

CU_API PxBufferBase & castor::PxBufferBase::operator= ( PxBufferBase const & pixelBuffer)

Copy assignment operator.

Parameters
[in]pixelBufferThe PxBufferBase object to copy
Returns
A reference to this PxBufferBase object

◆ swap()

CU_API void castor::PxBufferBase::swap ( PxBufferBase & pixelBuffer)
noexcept

Swaps this buffer's data with the given one's.

Parameters
[in]pixelBufferThe buffer to swap

◆ update()

CU_API void castor::PxBufferBase::update ( uint32_t layers,
uint32_t levels )

Updates the buffer container, with given layers and miplevels counts.

Parameters
[in]layersThe number of layers stored in the buffer.
[in]levelsThe number of miplevels stored in the buffer.

Member Data Documentation

◆ m_align

uint32_t castor::PxBufferBase::m_align
protected

Referenced by getAlign().

◆ m_buffer

PxArray castor::PxBufferBase::m_buffer
mutableprotected

◆ m_layers

uint32_t castor::PxBufferBase::m_layers
protected

Referenced by getLayers().

◆ m_levels

uint32_t castor::PxBufferBase::m_levels
protected

Referenced by getLevels().

◆ m_size

Size castor::PxBufferBase::m_size
protected

◆ m_tiles

Point3ui castor::PxBufferBase::m_tiles { 1u, 1u, 1u }
protected

The documentation for this class was generated from the following file: