KiCad PCB EDA Suite
KIGFX::VERTEX_CONTAINER Class Referenceabstract

#include <vertex_container.h>

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

Public Member Functions

virtual ~VERTEX_CONTAINER ()
 
virtual void Map ()
 Function Map() prepares the container for vertices updates. More...
 
virtual void Unmap ()
 Function Unmap() finishes the vertices updates stage. More...
 
virtual void SetItem (VERTEX_ITEM *aItem)=0
 Function SetItem() sets the item in order to modify or finishes its current modifications. More...
 
virtual void FinishItem ()
 Function FinishItem() does the cleaning after adding an item. More...
 
virtual VERTEXAllocate (unsigned int aSize)=0
 Function Allocate() returns allocated space (possibly resizing the used memory chunk or allocating a new chunk if it was not stored before) for the given number of vertices associated with the current item (set by SetItem()). More...
 
virtual void Delete (VERTEX_ITEM *aItem)=0
 Function Delete() erases the selected item. More...
 
virtual void Clear ()=0
 Function Clear() removes all the data stored in the container and restores its original state. More...
 
virtual VERTEXGetAllVertices () const
 Function GetAllVertices() returns all the vertices stored in the container. More...
 
virtual VERTEXGetVertices (unsigned int aOffset) const
 Function GetVertices() returns vertices stored at the specific offset. More...
 
virtual unsigned int GetSize () const
 Function GetSize() returns amount of vertices currently stored in the container. More...
 
bool IsDirty ()
 Function IsDirty() returns information about container cache state. More...
 
void SetDirty ()
 Function SetDirty() sets the dirty flag, so vertices in the container are going to be reuploaded to the GPU on the next frame. More...
 

Static Public Member Functions

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

Protected Member Functions

 VERTEX_CONTAINER (unsigned int aSize=defaultInitSize)
 How many vertices we can store in the container. More...
 
unsigned int usedSpace () const
 Function usedSpace() returns size of the used memory space. More...
 

Protected Attributes

unsigned int m_freeSpace
 How big is the current container, 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 (should be handled using malloc/realloc/free to speed up resizing) More...
 
VERTEXm_vertices
 State flags. More...
 
bool m_failed
 
bool m_dirty
 

Static Protected Attributes

static const unsigned int defaultInitSize = 1048576
 

Detailed Description

Definition at line 40 of file vertex_container.h.

Constructor & Destructor Documentation

VERTEX_CONTAINER::~VERTEX_CONTAINER ( )
virtual

Definition at line 53 of file vertex_container.cpp.

54 {
55 }
VERTEX_CONTAINER::VERTEX_CONTAINER ( unsigned int  aSize = defaultInitSize)
protected

How many vertices we can store in the container.

Definition at line 46 of file vertex_container.cpp.

46  :
47  m_freeSpace( aSize ), m_currentSize( aSize ), m_initialSize( aSize ),
48  m_vertices( NULL ), m_failed( false ), m_dirty( true )
49 {
50 }
unsigned int m_initialSize
Actual storage memory (should be handled using malloc/realloc/free to speed up resizing) ...
unsigned int m_currentSize
Store the initial size, so it can be resized to this on Clear()
VERTEX * m_vertices
State flags.
unsigned int m_freeSpace
How big is the current container, expressed in vertices.

Member Function Documentation

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

Function Allocate() returns allocated space (possibly resizing the used memory chunk or allocating a new chunk if it was not stored before) for the given number of vertices associated with the current item (set by SetItem()).

The newly 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.

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

Function Clear() removes all the data stored in the container and restores its original state.

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

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

Function Delete() erases the selected item.

Parameters
aItemis the item to be erased.

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

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

Function FinishItem() does the cleaning after adding an item.

Reimplemented in KIGFX::CACHED_CONTAINER.

Definition at line 75 of file vertex_container.h.

75 {};
virtual VERTEX* KIGFX::VERTEX_CONTAINER::GetAllVertices ( ) const
inlinevirtual

Function GetAllVertices() returns all the vertices stored in the container.

It is especially useful for transferring data to the GPU memory.

Definition at line 107 of file vertex_container.h.

References m_vertices.

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

108  {
109  return m_vertices;
110  }
VERTEX * m_vertices
State flags.
virtual unsigned int KIGFX::VERTEX_CONTAINER::GetSize ( ) const
inlinevirtual

Function GetSize() returns amount of vertices currently stored in the container.

Reimplemented in KIGFX::NONCACHED_CONTAINER.

Definition at line 126 of file vertex_container.h.

References m_currentSize.

Referenced by KIGFX::GPU_CACHED_MANAGER::BeginDrawing(), KIGFX::GPU_CACHED_MANAGER::DrawAll(), KIGFX::GPU_NONCACHED_MANAGER::EndDrawing(), and KIGFX::GPU_CACHED_MANAGER::GPU_CACHED_MANAGER().

127  {
128  return m_currentSize;
129  }
unsigned int m_currentSize
Store the initial size, so it can be resized to this on Clear()
virtual VERTEX* KIGFX::VERTEX_CONTAINER::GetVertices ( unsigned int  aOffset) const
inlinevirtual

Function GetVertices() returns vertices stored at the specific offset.

Parameters
aOffsetis the offset.

Definition at line 117 of file vertex_container.h.

References m_vertices.

118  {
119  return &m_vertices[aOffset];
120  }
VERTEX * m_vertices
State flags.
bool KIGFX::VERTEX_CONTAINER::IsDirty ( )
inline

Function IsDirty() returns information about container cache state.

Clears the flag after calling the function.

Returns
true in case the vertices have to be reuploaded.

Definition at line 136 of file vertex_container.h.

References m_dirty.

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

137  {
138  bool state = m_dirty;
139 
140  m_dirty = false;
141 
142  return state;
143  }
VERTEX_CONTAINER * VERTEX_CONTAINER::MakeContainer ( bool  aCached)
static

Function MakeContainer() Returns a pointer to a new container of an appropriate type.

Definition at line 37 of file vertex_container.cpp.

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

38 {
39  if( aCached )
40  return new CACHED_CONTAINER;
41  else
42  return new NONCACHED_CONTAINER;
43 }
virtual void KIGFX::VERTEX_CONTAINER::Map ( )
inlinevirtual

Function Map() prepares the container for vertices updates.

Reimplemented in KIGFX::CACHED_CONTAINER.

Definition at line 55 of file vertex_container.h.

55 {}
void KIGFX::VERTEX_CONTAINER::SetDirty ( )
inline

Function SetDirty() sets the dirty flag, so vertices in the container are going to be reuploaded to the GPU on the next frame.

Definition at line 150 of file vertex_container.h.

References m_dirty.

151  {
152  m_dirty = true;
153  }
virtual void KIGFX::VERTEX_CONTAINER::SetItem ( VERTEX_ITEM aItem)
pure virtual

Function SetItem() sets the item in order to modify or finishes its current modifications.

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

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

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

Function Unmap() finishes the vertices updates stage.

Reimplemented in KIGFX::CACHED_CONTAINER.

Definition at line 61 of file vertex_container.h.

62  {}
unsigned int KIGFX::VERTEX_CONTAINER::usedSpace ( ) const
inlineprotected

Function usedSpace() returns size of the used memory space.

Returns
Size of the used memory space (expressed as a number of vertices).Default initial size of a container (expressed in vertices)

Definition at line 179 of file vertex_container.h.

References m_freeSpace.

Referenced by KIGFX::CACHED_CONTAINER::defragmentResize(), KIGFX::CACHED_CONTAINER::defragmentResizeMemcpy(), and KIGFX::CACHED_CONTAINER::test().

Member Data Documentation

const unsigned int KIGFX::VERTEX_CONTAINER::defaultInitSize = 1048576
staticprotected

Definition at line 185 of file vertex_container.h.

bool KIGFX::VERTEX_CONTAINER::m_dirty
protected

Definition at line 172 of file vertex_container.h.

Referenced by KIGFX::CACHED_CONTAINER::Allocate(), IsDirty(), and SetDirty().

bool KIGFX::VERTEX_CONTAINER::m_failed
protected
unsigned int KIGFX::VERTEX_CONTAINER::m_initialSize
protected

Actual storage memory (should be handled using malloc/realloc/free to speed up resizing)

Definition at line 165 of file vertex_container.h.

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


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