KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGFX::NONCACHED_CONTAINER Class Reference

#include <noncached_container.h>

Inheritance diagram for KIGFX::NONCACHED_CONTAINER:
KIGFX::VERTEX_CONTAINER

Public Member Functions

 NONCACHED_CONTAINER (unsigned int aSize=DEFAULT_SIZE)
 Construct a non-cached container object.
 
virtual ~NONCACHED_CONTAINER ()
 
bool IsCached () const override
 Return true if the container caches vertex data in RAM or video memory.
 
virtual void SetItem (VERTEX_ITEM *aItem) override
 Set the item for the further actions.
 
virtual VERTEX * Allocate (unsigned int aSize) override
 Return allocated space for the requested number of vertices associated with the current item (set with SetItem()).
 
void Delete (VERTEX_ITEM *aItem) override
 Erase the data related to an item.
 
virtual void Clear () override
 Remove all data stored in the container and restores its original state.
 
virtual unsigned int GetSize () const override
 Return amount of vertices currently stored in the container.
 
virtual void Abandon ()
 Give up ownership of any GL objects without deleting them.
 
virtual void Map ()
 Prepare the container for vertices updates.
 
virtual void Unmap ()
 Finish the vertices updates stage.
 
virtual void FinishItem ()
 Clean up after adding an item.
 
VERTEX * GetAllVertices () const
 Return pointer to the vertices stored in the container.
 
virtual VERTEX * GetVertices (unsigned int aOffset) const
 Return vertices stored at the specific offset.
 
bool IsDirty () const
 Return information about the container cache state.
 
void SetDirty ()
 Set the dirty flag, so vertices in the container are going to be reuploaded to the GPU on the next frame.
 
void ClearDirty ()
 Clear the dirty flag to prevent reuploading vertices to the GPU memory.
 

Static Public Member Functions

static VERTEX_CONTAINER * MakeContainer (bool aCached)
 Return a pointer to a new container of an appropriate type.
 

Protected Member Functions

unsigned int usedSpace () const
 Return size of the used memory space.
 

Protected Attributes

unsigned int m_freePtr
 Index of the free first space where a vertex can be stored.
 
unsigned int m_freeSpace
 Free space left in the container, expressed in vertices.
 
unsigned int m_currentSize
 Current container size, expressed in vertices.
 
unsigned int m_initialSize
 Store the initial size, so it can be resized to this on Clear()
 
VERTEX * m_vertices
 Actual storage memory.
 
bool m_failed
 
bool m_dirty
 

Static Protected Attributes

static constexpr unsigned int DEFAULT_SIZE = 1048576
 Default initial size of a container (expressed in vertices)
 

Detailed Description

Definition at line 38 of file noncached_container.h.

Constructor & Destructor Documentation

◆ NONCACHED_CONTAINER()

NONCACHED_CONTAINER::NONCACHED_CONTAINER ( unsigned int aSize = DEFAULT_SIZE)

Construct a non-cached container object.

Parameters
aSizeis the size of the cache.
Exceptions
bad_allocexception if memory allocation fails.

Definition at line 35 of file noncached_container.cpp.

References m_freePtr, KIGFX::VERTEX_CONTAINER::m_vertices, and KIGFX::VERTEX_CONTAINER::VERTEX_CONTAINER().

◆ ~NONCACHED_CONTAINER()

NONCACHED_CONTAINER::~NONCACHED_CONTAINER ( )
virtual

Definition at line 51 of file noncached_container.cpp.

References KIGFX::VERTEX_CONTAINER::m_vertices.

Member Function Documentation

◆ Abandon()

virtual void KIGFX::VERTEX_CONTAINER::Abandon ( )
inlinevirtualinherited

Give up ownership of any GL objects without deleting them.

Used when the owning context can no longer be made current, so a delete would be executed against whichever context is, possibly one from another share group. The names are released when the owning context is destroyed.

Reimplemented in KIGFX::CACHED_CONTAINER_GPU.

Definition at line 61 of file vertex_container.h.

◆ Allocate()

VERTEX * NONCACHED_CONTAINER::Allocate ( unsigned int aSize)
overridevirtual

Return allocated space for the requested number of vertices associated with the current item (set with SetItem()).

The allocated space is added at the end of the chunk used by the current item and may serve to store new vertices.

Parameters
aSizeis the number of vertices to be allocated.
Returns
Pointer to the allocated space or NULL in case of failure.

Implements KIGFX::VERTEX_CONTAINER.

Definition at line 64 of file noncached_container.cpp.

References KIGFX::VERTEX_CONTAINER::m_currentSize, m_freePtr, KIGFX::VERTEX_CONTAINER::m_freeSpace, and KIGFX::VERTEX_CONTAINER::m_vertices.

◆ Clear()

void NONCACHED_CONTAINER::Clear ( )
overridevirtual

Remove all data stored in the container and restores its original state.

Implements KIGFX::VERTEX_CONTAINER.

Definition at line 94 of file noncached_container.cpp.

References KIGFX::VERTEX_CONTAINER::m_currentSize, m_freePtr, and KIGFX::VERTEX_CONTAINER::m_freeSpace.

◆ ClearDirty()

void KIGFX::VERTEX_CONTAINER::ClearDirty ( )
inlineinherited

Clear the dirty flag to prevent reuploading vertices to the GPU memory.

Definition at line 157 of file vertex_container.h.

References m_dirty.

Referenced by KIGFX::GPU_CACHED_MANAGER::EndDrawing().

◆ Delete()

void KIGFX::NONCACHED_CONTAINER::Delete ( VERTEX_ITEM * aItem)
inlineoverridevirtual

Erase the data related to an item.

Parameters
aItemis the item to be erased.

Implements KIGFX::VERTEX_CONTAINER.

Definition at line 62 of file noncached_container.h.

◆ FinishItem()

virtual void KIGFX::VERTEX_CONTAINER::FinishItem ( )
inlinevirtualinherited

Clean up after adding an item.

Reimplemented in KIGFX::CACHED_CONTAINER.

Definition at line 83 of file vertex_container.h.

◆ GetAllVertices()

VERTEX * KIGFX::VERTEX_CONTAINER::GetAllVertices ( ) const
inlineinherited

Return pointer to the vertices stored in the container.

Definition at line 112 of file vertex_container.h.

References m_vertices.

◆ GetSize()

virtual unsigned int KIGFX::NONCACHED_CONTAINER::GetSize ( ) const
inlineoverridevirtual

Return amount of vertices currently stored in the container.

Reimplemented from KIGFX::VERTEX_CONTAINER.

Definition at line 68 of file noncached_container.h.

References m_freePtr.

◆ GetVertices()

virtual VERTEX * KIGFX::VERTEX_CONTAINER::GetVertices ( unsigned int aOffset) const
inlinevirtualinherited

Return vertices stored at the specific offset.

Parameters
aOffsetis the offset.

Definition at line 122 of file vertex_container.h.

References m_vertices.

◆ IsCached()

bool KIGFX::NONCACHED_CONTAINER::IsCached ( ) const
inlineoverridevirtual

Return true if the container caches vertex data in RAM or video memory.

Otherwise it is a single batch draw which is later discarded.

Implements KIGFX::VERTEX_CONTAINER.

Definition at line 50 of file noncached_container.h.

◆ IsDirty()

bool KIGFX::VERTEX_CONTAINER::IsDirty ( ) const
inlineinherited

Return information about the container cache state.

Returns
True in case the vertices have to be reuploaded.

Definition at line 140 of file vertex_container.h.

References m_dirty.

◆ MakeContainer()

VERTEX_CONTAINER * VERTEX_CONTAINER::MakeContainer ( bool aCached)
staticinherited

Return a pointer to a new container of an appropriate type.

Definition at line 38 of file vertex_container.cpp.

References VERTEX_CONTAINER().

Referenced by KIGFX::VERTEX_MANAGER::VERTEX_MANAGER().

◆ Map()

virtual void KIGFX::VERTEX_CONTAINER::Map ( )
inlinevirtualinherited

Prepare the container for vertices updates.

Reimplemented in KIGFX::CACHED_CONTAINER, KIGFX::CACHED_CONTAINER_GPU, and KIGFX::CACHED_CONTAINER_RAM.

Definition at line 66 of file vertex_container.h.

◆ SetDirty()

void KIGFX::VERTEX_CONTAINER::SetDirty ( )
inlineinherited

Set the dirty flag, so vertices in the container are going to be reuploaded to the GPU on the next frame.

Definition at line 149 of file vertex_container.h.

References m_dirty.

◆ SetItem()

void NONCACHED_CONTAINER::SetItem ( VERTEX_ITEM * aItem)
overridevirtual

Set the item for the further actions.

Parameters
aItemis the item or NULL in case of finishing the item.

Implements KIGFX::VERTEX_CONTAINER.

Definition at line 57 of file noncached_container.cpp.

◆ Unmap()

virtual void KIGFX::VERTEX_CONTAINER::Unmap ( )
inlinevirtualinherited

Finish the vertices updates stage.

Reimplemented in KIGFX::CACHED_CONTAINER, KIGFX::CACHED_CONTAINER_GPU, and KIGFX::CACHED_CONTAINER_RAM.

Definition at line 71 of file vertex_container.h.

◆ usedSpace()

unsigned int KIGFX::VERTEX_CONTAINER::usedSpace ( ) const
inlineprotectedinherited

Return size of the used memory space.

Returns
Size of the used memory space (expressed as a number of vertices).

Definition at line 170 of file vertex_container.h.

References m_currentSize, and m_freeSpace.

Referenced by KIGFX::CACHED_CONTAINER::defragment(), KIGFX::CACHED_CONTAINER_GPU::defragmentResize(), KIGFX::CACHED_CONTAINER_RAM::defragmentResize(), KIGFX::CACHED_CONTAINER_GPU::defragmentResizeMemcpy(), and KIGFX::CACHED_CONTAINER_GPU::defragmentResizeStaged().

Member Data Documentation

◆ DEFAULT_SIZE

unsigned int KIGFX::VERTEX_CONTAINER::DEFAULT_SIZE = 1048576
staticconstexprprotectedinherited

Default initial size of a container (expressed in vertices)

Definition at line 192 of file vertex_container.h.

◆ m_currentSize

◆ m_dirty

◆ m_failed

bool KIGFX::VERTEX_CONTAINER::m_failed
protectedinherited

◆ m_freePtr

unsigned int KIGFX::NONCACHED_CONTAINER::m_freePtr
protected

Index of the free first space where a vertex can be stored.

Definition at line 77 of file noncached_container.h.

Referenced by Allocate(), Clear(), GetSize(), and NONCACHED_CONTAINER().

◆ m_freeSpace

◆ m_initialSize

unsigned int KIGFX::VERTEX_CONTAINER::m_initialSize
protectedinherited

Store the initial size, so it can be resized to this on Clear()

Definition at line 182 of file vertex_container.h.

Referenced by KIGFX::CACHED_CONTAINER::Delete(), and VERTEX_CONTAINER().

◆ m_vertices


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