KiCad PCB EDA Suite
Loading...
Searching...
No Matches
vertex_container.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright 2013-2017 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
27
28#ifndef VERTEX_CONTAINER_H_
29#define VERTEX_CONTAINER_H_
30
32
33namespace KIGFX
34{
35class VERTEX_ITEM;
36class SHADER;
37
39{
40public:
44 static VERTEX_CONTAINER* MakeContainer( bool aCached );
45
46 virtual ~VERTEX_CONTAINER();
47
52 virtual bool IsCached() const = 0;
53
61 virtual void Abandon() {}
62
66 virtual void Map() {}
67
71 virtual void Unmap() {}
72
78 virtual void SetItem( VERTEX_ITEM* aItem ) = 0;
79
83 virtual void FinishItem() {};
84
95 virtual VERTEX* Allocate( unsigned int aSize ) = 0;
96
102 virtual void Delete( VERTEX_ITEM* aItem ) = 0;
103
107 virtual void Clear() = 0;
108
113 {
114 return m_vertices;
115 }
116
122 virtual VERTEX* GetVertices( unsigned int aOffset ) const
123 {
124 return &m_vertices[aOffset];
125 }
126
130 virtual unsigned int GetSize() const
131 {
132 return m_currentSize;
133 }
134
140 bool IsDirty() const
141 {
142 return m_dirty;
143 }
144
149 void SetDirty()
150 {
151 m_dirty = true;
152 }
153
158 {
159 m_dirty = false;
160 }
161
162protected:
163 VERTEX_CONTAINER( unsigned int aSize = DEFAULT_SIZE );
164
170 unsigned int usedSpace() const
171 {
172 return m_currentSize - m_freeSpace;
173 }
174
176 unsigned int m_freeSpace;
177
179 unsigned int m_currentSize;
180
182 unsigned int m_initialSize;
183
186
187 // Status flags
190
192 static constexpr unsigned int DEFAULT_SIZE = 1048576;
193};
194} // namespace KIGFX
195
196#endif /* VERTEX_CONTAINER_H_ */
Provide the access to the OpenGL shaders.
Definition shader.h:73
unsigned int m_initialSize
Store the initial size, so it can be resized to this on Clear()
VERTEX * m_vertices
Actual storage memory.
static constexpr unsigned int DEFAULT_SIZE
Default initial size of a container (expressed in vertices)
virtual VERTEX * Allocate(unsigned int aSize)=0
Return allocated space for the requested number of vertices associated with the current item (set wit...
unsigned int m_currentSize
Current container size, expressed in vertices.
unsigned int m_freeSpace
Free space left in the container, expressed in vertices.
unsigned int usedSpace() const
Return size of the used memory space.
VERTEX_CONTAINER(unsigned int aSize=DEFAULT_SIZE)
void SetDirty()
Set the dirty flag, so vertices in the container are going to be reuploaded to the GPU on the next fr...
virtual void SetItem(VERTEX_ITEM *aItem)=0
Set the item for the further actions.
virtual VERTEX * GetVertices(unsigned int aOffset) const
Return vertices stored at the specific offset.
virtual unsigned int GetSize() const
Return amount of vertices currently stored in the container.
virtual void FinishItem()
Clean up after adding an item.
virtual void Clear()=0
Remove all data stored in the container and restores its original state.
VERTEX * GetAllVertices() const
Return pointer to the vertices stored in the container.
virtual void Delete(VERTEX_ITEM *aItem)=0
Erase the data related to an item.
virtual void Unmap()
Finish the vertices updates stage.
virtual bool IsCached() const =0
Return true if the container caches vertex data in RAM or video memory.
virtual void Abandon()
Give up ownership of any GL objects without deleting them.
static VERTEX_CONTAINER * MakeContainer(bool aCached)
Return a pointer to a new container of an appropriate type.
void ClearDirty()
Clear the dirty flag to prevent reuploading vertices to the GPU memory.
bool IsDirty() const
Return information about the container cache state.
virtual void Map()
Prepare the container for vertices updates.
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
Common defines and consts used in vertex related classes.