Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
glslmemorypool_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSSG_GLSLMEMORYPOOL_H
5#define QSSG_GLSLMEMORYPOOL_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick3DGlslParser/private/glsl_p.h>
19
20#include <cstddef>
21#include <new>
22
24
25namespace GLSL {
26
27class MemoryPool;
28
29class Q_QUICK3DGLSLPARSER_EXPORT MemoryPool
30{
32 void operator =(const MemoryPool &other);
33
34public:
35 MemoryPool();
37
38 void reset();
39
40 inline void *allocate(size_t size)
41 {
42 size = (size + 7) & ~7;
43 if (_ptr && (_ptr + size < _end)) {
44 void *addr = _ptr;
45 _ptr += size;
46 return addr;
47 }
48 return allocate_helper(size);
49 }
50
51private:
52 void *allocate_helper(size_t size);
53
54private:
55 char **_blocks;
56 int _allocatedBlocks;
57 int _blockCount;
58 char *_ptr;
59 char *_end;
60
61 enum
62 {
63 BLOCK_SIZE = 8 * 1024,
64 DEFAULT_BLOCK_COUNT = 8
65 };
66};
67
68class Q_QUICK3DGLSLPARSER_EXPORT Managed
69{
70 Managed(const Managed &other);
71 void operator = (const Managed &other);
72
73public:
74 Managed();
75 virtual ~Managed();
76
77 void *operator new(size_t size, MemoryPool *pool);
78 void operator delete(void *);
79 void operator delete(void *, MemoryPool *);
80};
81
82} // namespace GLSL
83
85
86#endif // QSSG_GLSLMEMORYPOOL_H
void * allocate(size_t size)
Definition glsl_p.h:22
Combined button and popup list for selecting options.
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean reset
GLenum const void * addr
QSharedPointer< T > other(t)
[5]