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 (C) 2020-2021 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, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
32#ifndef VERTEX_CONTAINER_H_
33#define VERTEX_CONTAINER_H_
34
36
37namespace KIGFX
38{
39class VERTEX_ITEM;
40class SHADER;
41
43{
44public:
48 static VERTEX_CONTAINER* MakeContainer( bool aCached );
49
50 virtual ~VERTEX_CONTAINER();
51
56 virtual bool IsCached() const = 0;
57
61 virtual void Map() {}
62
66 virtual void Unmap() {}
67
73 virtual void SetItem( VERTEX_ITEM* aItem ) = 0;
74
78 virtual void FinishItem() {};
79
90 virtual VERTEX* Allocate( unsigned int aSize ) = 0;
91
97 virtual void Delete( VERTEX_ITEM* aItem ) = 0;
98
102 virtual void Clear() = 0;
103
108 {
109 return m_vertices;
110 }
111
117 virtual VERTEX* GetVertices( unsigned int aOffset ) const
118 {
119 return &m_vertices[aOffset];
120 }
121
125 virtual unsigned int GetSize() const
126 {
127 return m_currentSize;
128 }
129
135 bool IsDirty() const
136 {
137 return m_dirty;
138 }
139
144 void SetDirty()
145 {
146 m_dirty = true;
147 }
148
153 {
154 m_dirty = false;
155 }
156
157protected:
158 VERTEX_CONTAINER( unsigned int aSize = DEFAULT_SIZE );
159
165 unsigned int usedSpace() const
166 {
167 return m_currentSize - m_freeSpace;
168 }
169
171 unsigned int m_freeSpace;
172
174 unsigned int m_currentSize;
175
177 unsigned int m_initialSize;
178
181
182 // Status flags
185
187 static constexpr unsigned int DEFAULT_SIZE = 1048576;
188};
189} // namespace KIGFX
190
191#endif /* VERTEX_CONTAINER_H_ */
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.
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: color4d.cpp:247
Common defines and consts used in vertex related classes.