KiCad PCB EDA Suite
cached_container_gpu.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 <maciej.suminski@cern.ch>
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 
27 #ifndef CACHED_CONTAINER_GPU_H_
28 #define CACHED_CONTAINER_GPU_H_
29 
31 
32 namespace KIGFX
33 {
34 
39 {
40 public:
41  CACHED_CONTAINER_GPU( unsigned int aSize = DEFAULT_SIZE );
43 
44  unsigned int GetBufferHandle() const override
45  {
46  return m_glBufferHandle;
47  }
48 
49  bool IsMapped() const override
50  {
51  return m_isMapped;
52  }
53 
55  void Map() override;
56 
58  void Unmap() override;
59 
60 protected:
70  bool defragmentResize( unsigned int aNewSize ) override;
71  bool defragmentResizeMemcpy( unsigned int aNewSize );
72 
74  bool m_isMapped;
75 
77  unsigned int m_glBufferHandle;
78 
81 };
82 } // namespace KIGFX
83 
84 #endif /* CACHED_CONTAINER_GPU_H_ */
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:191
unsigned int GetBufferHandle() const override
Return handle to the vertex buffer.
unsigned int m_glBufferHandle
Flag saying whether it is safe to use glCopyBufferSubData.
CACHED_CONTAINER_GPU(unsigned int aSize=DEFAULT_SIZE)
bool m_isMapped
Vertex buffer handle.
bool IsMapped() const override
Prepare the container for vertices updates.
void Unmap() override
Finish the vertices updates stage.
Class to store VERTEX instances with caching.
static constexpr unsigned int DEFAULT_SIZE
void Map() override
Finish the vertices updates stage.
Specialization of CACHED_CONTAINER that stores data in video memory via memory mapping.
bool defragmentResizeMemcpy(unsigned int aNewSize)
Flag saying if vertex buffer is currently mapped.
bool defragmentResize(unsigned int aNewSize) override
Remove empty spaces between chunks and optionally resizes the container.