KiCad PCB EDA Suite
noncached_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 (C) 2013 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
31 #ifndef NONCACHED_CONTAINER_H_
32 #define NONCACHED_CONTAINER_H_
33 
35 
36 namespace KIGFX
37 {
38 class VERTEX_ITEM;
39 class SHADER;
40 
42 {
43 public:
44  NONCACHED_CONTAINER( unsigned int aSize = DEFAULT_SIZE );
45  virtual ~NONCACHED_CONTAINER();
46 
47  bool IsCached() const override
48  {
49  return false;
50  }
51 
53  virtual void SetItem( VERTEX_ITEM* aItem ) override;
54 
56  virtual VERTEX* Allocate( unsigned int aSize ) override;
57 
59  void Delete( VERTEX_ITEM* aItem ) override {}
60 
62  virtual void Clear() override;
63 
65  virtual unsigned int GetSize() const override
66  {
67  // As the m_freePtr points to the first free space, we can safely assume
68  // that this is the number of vertices stored inside
69  return m_freePtr;
70  }
71 
72 protected:
74  unsigned int m_freePtr;
75 };
76 } // namespace KIGFX
77 
78 #endif /* NONCACHED_CONTAINER_H_ */
virtual VERTEX * Allocate(unsigned int aSize) override
Returns allocated space for the requested number of vertices associated with the current item (set wi...
virtual void SetItem(VERTEX_ITEM *aItem) override
Sets the item for the further actions.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
Data structure for vertices {X,Y,Z,R,G,B,A,shader¶m}
Definition: vertex_common.h:50
unsigned int m_freePtr
< Index of the free first space where a vertex can be stored
virtual unsigned int GetSize() const override
Function GetSize() returns amount of vertices currently stored in the container.
static constexpr unsigned int DEFAULT_SIZE
virtual void Clear() override
Removes all data stored in the container and restores its original state.
Class to store vertices and handle transfers between system memory and GPU memory.
void Delete(VERTEX_ITEM *aItem) override
Erases the data related to an item.
bool IsCached() const override
Returns true if the container caches vertex data in RAM or video memory.
NONCACHED_CONTAINER(unsigned int aSize=DEFAULT_SIZE)