Imaging Control 4 C++ Library 1.0.0
Loading...
Searching...
No Matches
BufferAllocator Struct Referenceabstract

Interface for custom image buffer allocators More...

Public Member Functions

virtual bool allocate_buffer (size_t buffer_size, size_t alignment, void *&buffer_ptr, void *&user_data)=0
 Requests the allocator to allocate a memory buffer.
 
virtual void free_buffer (void *buffer_ptr, void *user_data)=0
 Requests the allocator to free a previously-allocated memory buffer.
 

Detailed Description

Interface for custom image buffer allocators

Custom image buffer allocators can be used to use specific application-defined memory regions as image buffers. For example, it could be used to let the library write image data directly into a texture.

BufferAllocator instances can be passed to QueueSink::create(), SnapSink::create() or BufferPool::create() to override the default buffer allocation mechanisms of the sinks or buffer pool.

Member Function Documentation

◆ allocate_buffer()

virtual bool allocate_buffer ( size_t  buffer_size,
size_t  alignment,
void *&  buffer_ptr,
void *&  user_data 
)
pure virtual

Requests the allocator to allocate a memory buffer.

Parameters
[in]buffer_sizeThe size of the requested memory buffer
[in]alignmentRequests memory to be allocated on a specific alignment boundary.
This value is always a power of 2.
[out]buffer_ptrA reference to a pointer that receives the address of the newly-allocated buffer
[out]user_dataUser data to attach to the buffer. The user data is passed to free_buffer when the allocated memory is freed again.
Returns
true on success. If the allocation could not be performed, return false.

◆ free_buffer()

virtual void free_buffer ( void *  buffer_ptr,
void *  user_data 
)
pure virtual

Requests the allocator to free a previously-allocated memory buffer.

Parameters
[in]buffer_ptrPointer to the memory buffer to be freed
[in]user_dataThe user data that was returned from allocate_buffer when the memory buffer was allocated