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
57 virtual void Map() {}
58
62 virtual void Unmap() {}
63
69 virtual void SetItem( VERTEX_ITEM* aItem ) = 0;
70
74 virtual void FinishItem() {};
75
86 virtual VERTEX* Allocate( unsigned int aSize ) = 0;
87
93 virtual void Delete( VERTEX_ITEM* aItem ) = 0;
94
98 virtual void Clear() = 0;
99
104 {
105 return m_vertices;
106 }
107
113 virtual VERTEX* GetVertices( unsigned int aOffset ) const
114 {
115 return &m_vertices[aOffset];
116 }
117
121 virtual unsigned int GetSize() const
122 {
123 return m_currentSize;
124 }
125
131 bool IsDirty() const
132 {
133 return m_dirty;
134 }
135
140 void SetDirty()
141 {
142 m_dirty = true;
143 }
144
149 {
150 m_dirty = false;
151 }
152
153protected:
154 VERTEX_CONTAINER( unsigned int aSize = DEFAULT_SIZE );
155
161 unsigned int usedSpace() const
162 {
163 return m_currentSize - m_freeSpace;
164 }
165
167 unsigned int m_freeSpace;
168
170 unsigned int m_currentSize;
171
173 unsigned int m_initialSize;
174
177
178 // Status flags
181
183 static constexpr unsigned int DEFAULT_SIZE = 1048576;
184};
185} // namespace KIGFX
186
187#endif /* VERTEX_CONTAINER_H_ */
Provide the access to the OpenGL shaders.
Definition shader.h:73
unsigned int m_initialSize
Actual storage memory.
static constexpr unsigned int DEFAULT_SIZE
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
Store the initial size, so it can be resized to this on Clear()
unsigned int m_freeSpace
Current container size, 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...
bool m_dirty
Default initial size of a container (expressed in vertices)
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.
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:29
Common defines and consts used in vertex related classes.