KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGFX::VERTEX_CONTAINER Class Referenceabstract

#include <vertex_container.h>

Inheritance diagram for KIGFX::VERTEX_CONTAINER:
KIGFX::CACHED_CONTAINER KIGFX::NONCACHED_CONTAINER KIGFX::CACHED_CONTAINER_GPU KIGFX::CACHED_CONTAINER_RAM

Public Member Functions

virtual ~VERTEX_CONTAINER ()
 
virtual bool IsCached () const =0
 Return true if the container caches vertex data in RAM or video memory. More...
 
virtual void Map ()
 Prepare the container for vertices updates. More...
 
virtual void Unmap ()
 Finish the vertices updates stage. More...
 
virtual void SetItem (VERTEX_ITEM *aItem)=0
 Set the item for the further actions. More...
 
virtual void FinishItem ()
 Clean up after adding an item. More...
 
virtual VERTEXAllocate (unsigned int aSize)=0
 Return allocated space for the requested number of vertices associated with the current item (set with SetItem()). More...
 
virtual void Delete (VERTEX_ITEM *aItem)=0
 Erase the data related to an item. More...
 
virtual void Clear ()=0
 Remove all data stored in the container and restores its original state. More...
 
VERTEXGetAllVertices () const
 Return pointer to the vertices stored in the container. More...
 
virtual VERTEXGetVertices (unsigned int aOffset) const
 Return vertices stored at the specific offset. More...
 
virtual unsigned int GetSize () const
 Return amount of vertices currently stored in the container. More...
 
bool IsDirty () const
 Return information about the container cache state. More...
 
void SetDirty ()
 Set the dirty flag, so vertices in the container are going to be reuploaded to the GPU on the next frame. More...
 
void ClearDirty ()
 Clear the dirty flag to prevent reuploading vertices to the GPU memory. More...
 

Static Public Member Functions

static VERTEX_CONTAINERMakeContainer (bool aCached)
 Return a pointer to a new container of an appropriate type. More...
 

Protected Member Functions

 VERTEX_CONTAINER (unsigned int aSize=DEFAULT_SIZE)
 
unsigned int usedSpace () const
 Return size of the used memory space. More...
 

Protected Attributes

unsigned int m_freeSpace
 Current container size, expressed in vertices. More...
 
unsigned int m_currentSize
 Store the initial size, so it can be resized to this on Clear() More...
 
unsigned int m_initialSize
 Actual storage memory. More...
 
VERTEXm_vertices
 
bool m_failed
 
bool m_dirty
 Default initial size of a container (expressed in vertices) More...
 

Static Protected Attributes

static constexpr unsigned int DEFAULT_SIZE = 1048576
 

Detailed Description

Definition at line 42 of file vertex_container.h.

Constructor & Destructor Documentation

◆ ~VERTEX_CONTAINER()

VERTEX_CONTAINER::~VERTEX_CONTAINER ( )
virtual

Definition at line 71 of file vertex_container.cpp.

◆ VERTEX_CONTAINER()

VERTEX_CONTAINER::VERTEX_CONTAINER ( unsigned int  aSize = DEFAULT_SIZE)
protected

Definition at line 60 of file vertex_container.cpp.

Member Function Documentation

◆ Allocate()

virtual VERTEX * KIGFX::VERTEX_CONTAINER::Allocate ( unsigned int  aSize)
pure virtual

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.

Implemented in KIGFX::CACHED_CONTAINER, and KIGFX::NONCACHED_CONTAINER.

◆ Clear()

virtual void KIGFX::VERTEX_CONTAINER::Clear ( )
pure virtual

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

Implemented in KIGFX::CACHED_CONTAINER, and KIGFX::NONCACHED_CONTAINER.

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

◆ ClearDirty()

void KIGFX::VERTEX_CONTAINER::ClearDirty ( )
inline

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

Definition at line 152 of file vertex_container.h.

References m_dirty.

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

◆ Delete()

virtual void KIGFX::VERTEX_CONTAINER::Delete ( VERTEX_ITEM aItem)
pure virtual

Erase the data related to an item.

Parameters
aItemis the item to be erased.

Implemented in KIGFX::CACHED_CONTAINER, and KIGFX::NONCACHED_CONTAINER.

◆ FinishItem()

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

Clean up after adding an item.

Reimplemented in KIGFX::CACHED_CONTAINER.

Definition at line 78 of file vertex_container.h.

◆ GetAllVertices()

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

Return pointer to the vertices stored in the container.

Definition at line 107 of file vertex_container.h.

References m_vertices.

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

◆ GetSize()

virtual unsigned int KIGFX::VERTEX_CONTAINER::GetSize ( ) const
inlinevirtual

Return amount of vertices currently stored in the container.

Reimplemented in KIGFX::NONCACHED_CONTAINER.

Definition at line 125 of file vertex_container.h.

References m_currentSize.

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

◆ GetVertices()

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

Return vertices stored at the specific offset.

Parameters
aOffsetis the offset.

Definition at line 117 of file vertex_container.h.

References m_vertices.

◆ IsCached()

virtual bool KIGFX::VERTEX_CONTAINER::IsCached ( ) const
pure virtual

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

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

Implemented in KIGFX::CACHED_CONTAINER, and KIGFX::NONCACHED_CONTAINER.

Referenced by KIGFX::GPU_MANAGER::MakeManager().

◆ IsDirty()

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

Return information about the container cache state.

Returns
True in case the vertices have to be reuploaded.

Definition at line 135 of file vertex_container.h.

References m_dirty.

◆ MakeContainer()

VERTEX_CONTAINER * VERTEX_CONTAINER::MakeContainer ( bool  aCached)
static

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

Definition at line 42 of file vertex_container.cpp.

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

◆ Map()

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

Prepare the container for vertices updates.

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

Definition at line 61 of file vertex_container.h.

◆ SetDirty()

void KIGFX::VERTEX_CONTAINER::SetDirty ( )
inline

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

Definition at line 144 of file vertex_container.h.

References m_dirty.

◆ SetItem()

virtual void KIGFX::VERTEX_CONTAINER::SetItem ( VERTEX_ITEM aItem)
pure virtual

Set the item for the further actions.

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

Implemented in KIGFX::CACHED_CONTAINER, and KIGFX::NONCACHED_CONTAINER.

◆ Unmap()

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

Finish the vertices updates stage.

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

Definition at line 66 of file vertex_container.h.

◆ usedSpace()

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

Return size of the used memory space.

Returns
Size of the used memory space (expressed as a number of vertices). Free space left in the container, expressed in vertices

Definition at line 165 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(), and KIGFX::CACHED_CONTAINER_GPU::defragmentResizeMemcpy().

Member Data Documentation

◆ DEFAULT_SIZE

constexpr unsigned int KIGFX::VERTEX_CONTAINER::DEFAULT_SIZE = 1048576
staticconstexprprotected

Definition at line 187 of file vertex_container.h.

◆ m_currentSize

◆ m_dirty

bool KIGFX::VERTEX_CONTAINER::m_dirty
protected

Default initial size of a container (expressed in vertices)

Definition at line 184 of file vertex_container.h.

Referenced by KIGFX::CACHED_CONTAINER::Allocate(), ClearDirty(), KIGFX::CACHED_CONTAINER_RAM::defragmentResize(), IsDirty(), SetDirty(), and KIGFX::CACHED_CONTAINER_RAM::Unmap().

◆ m_failed

bool KIGFX::VERTEX_CONTAINER::m_failed
protected

◆ m_freeSpace

◆ m_initialSize

unsigned int KIGFX::VERTEX_CONTAINER::m_initialSize
protected

Actual storage memory.

Definition at line 177 of file vertex_container.h.

Referenced by KIGFX::CACHED_CONTAINER::Delete().

◆ m_vertices


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