27#ifndef CACHED_CONTAINER_H_
28#define CACHED_CONTAINER_H_
79 virtual void Clear()
override;
92 virtual void Map()
override = 0;
95 virtual void Unmap()
override = 0;
101 typedef std::pair<unsigned int, unsigned int>
CHUNK;
105 typedef std::set<VERTEX_ITEM*>
ITEMS;
159 return aChunk.second;
165 void addFreeChunk(
unsigned int aOffset,
unsigned int aSize );
Class to store VERTEX instances with caching.
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.
void mergeFreeChunks()
Look for consecutive free memory chunks and merges them, decreasing fragmentation of memory.
void showFreeChunks()
Debug & test functions.
VERTEX_ITEM * m_item
Properties of currently modified chunk & item.
FREE_CHUNK_MAP m_freeChunks
Stored VERTEX_ITEMs.
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.
virtual bool IsMapped() const =0
Return true if vertex buffer is currently mapped.
virtual ~CACHED_CONTAINER()
ITEMS m_items
Currently modified item.
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.
std::set< VERTEX_ITEM * > ITEMS
List of all the stored items.
static constexpr unsigned int DEFAULT_SIZE
The Cairo implementation of the graphics abstraction layer.
Class to store vertices and handle transfers between system memory and GPU memory.