23#ifndef CACHED_CONTAINER_H_
24#define CACHED_CONTAINER_H_
75 virtual void Clear()
override;
88 virtual void Map()
override = 0;
91 virtual void Unmap()
override = 0;
97 typedef std::pair<unsigned int, unsigned int>
CHUNK;
152 return aChunk.second;
158 void addFreeChunk(
unsigned int aOffset,
unsigned int aSize );
unsigned int m_chunkOffset
Maximal vertex index number stored in the container.
void addFreeChunk(unsigned int aOffset, unsigned int aSize)
Add a chunk marked as a free space.
int getChunkSize(const CHUNK &aChunk) const
Return the size of a chunk.
std::set< VERTEX_ITEM * > m_items
Stored VERTEX_ITEMs.
void mergeFreeChunks()
Look for consecutive free memory chunks and merges them, decreasing fragmentation of memory.
void showFreeChunks()
Debug & test functions.
VERTEX_ITEM * m_item
Currently modified item.
FREE_CHUNK_MAP m_freeChunks
Store size & offset of free chunks.
std::multimap< unsigned int, unsigned int > FREE_CHUNK_MAP
void defragment(VERTEX *aTarget)
Transfer all stored data to a new buffer, removing empty spaces between the data chunks in the contai...
virtual unsigned int GetBufferHandle() const =0
Return handle to the vertex buffer.
virtual void FinishItem() override
Clean up after adding an item.
std::pair< unsigned int, unsigned int > CHUNK
< Maps size of free memory chunks to their offsets
virtual void Delete(VERTEX_ITEM *aItem) override
Remove all data stored in the container and restores its original state.
unsigned int getChunkOffset(const CHUNK &aChunk) const
Return the offset of a chunk.
virtual VERTEX * Allocate(unsigned int aSize) override
Return allocated space for the requested number of vertices associated with the current item (set wit...
virtual unsigned int AllItemsSize() const
virtual void Clear() override
Remove all data stored in the container and restores its original state.
virtual bool defragmentResize(unsigned int aNewSize)=0
Remove empty spaces between chunks and optionally resizes the container.
virtual void SetItem(VERTEX_ITEM *aItem) override
Clean up after adding an item.
bool IsCached() const override
Return true if the container caches vertex data in RAM or video memory.
CACHED_CONTAINER(unsigned int aSize=DEFAULT_SIZE)
virtual bool IsMapped() const =0
Return true if vertex buffer is currently mapped.
virtual ~CACHED_CONTAINER()
virtual void Unmap() override=0
Finish the vertices updates stage.
virtual void Map() override=0
Finish the vertices updates stage.
bool reallocate(unsigned int aSize)
Resize the chunk that stores the current item to the given size.
Provide the access to the OpenGL shaders.
static constexpr unsigned int DEFAULT_SIZE
VERTEX_CONTAINER(unsigned int aSize=DEFAULT_SIZE)
The Cairo implementation of the graphics abstraction layer.
Class to store vertices and handle transfers between system memory and GPU memory.