1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QSGAREAALLOCATOR_P_H |
5 | #define QSGAREAALLOCATOR_P_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 <private/qtquickglobal_p.h> |
19 | #include <QtCore/qsize.h> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class QRect; |
24 | class QPoint; |
25 | struct QSGAreaAllocatorNode; |
26 | class Q_QUICK_PRIVATE_EXPORT QSGAreaAllocator |
27 | { |
28 | public: |
29 | QSGAreaAllocator(const QSize &size); |
30 | ~QSGAreaAllocator(); |
31 | |
32 | QRect allocate(const QSize &size); |
33 | bool deallocate(const QRect &rect); |
34 | bool isEmpty() const { return m_root == nullptr; } |
35 | QSize size() const { return m_size; } |
36 | |
37 | QByteArray serialize(); |
38 | const char *deserialize(const char *data, int size); |
39 | |
40 | private: |
41 | bool allocateInNode(const QSize &size, QPoint &result, const QRect ¤tRect, QSGAreaAllocatorNode *node); |
42 | bool deallocateInNode(const QPoint &pos, QSGAreaAllocatorNode *node); |
43 | void mergeNodeWithNeighbors(QSGAreaAllocatorNode *node); |
44 | |
45 | QSGAreaAllocatorNode *m_root; |
46 | QSize m_size; |
47 | }; |
48 | |
49 | QT_END_NAMESPACE |
50 | |
51 | #endif |
52 | |