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 QT3DEXTRAS_AREAALLOCATOR_P_H
5#define QT3DEXTRAS_AREAALLOCATOR_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//
19// This file is copied from qtdeclarative/src/quick/scenegraph/util/qsgareaallocator_p.h
20//
21
22#include <QtCore/qsize.h>
23#include <private/qglobal_p.h>
24
25QT_BEGIN_NAMESPACE
26
27class QRect;
28class QPoint;
29
30namespace Qt3DExtras {
31
32struct AreaAllocatorNode;
33
34class AreaAllocator
35{
36public:
37 AreaAllocator(const QSize &size);
38 ~AreaAllocator();
39
40 QRect allocate(const QSize &size);
41 bool deallocate(const QRect &rect);
42 bool isEmpty() const { return m_root == 0; }
43 QSize size() const { return m_size; }
44private:
45 bool allocateInNode(const QSize &size, QPoint &result, const QRect &currentRect, AreaAllocatorNode *node);
46 bool deallocateInNode(const QPoint &pos, AreaAllocatorNode *node);
47 void mergeNodeWithNeighbors(AreaAllocatorNode *node);
48
49 AreaAllocatorNode *m_root;
50 QSize m_size;
51};
52
53} // namespace Qt3DExtras
54
55QT_END_NAMESPACE
56
57#endif // QT3DEXTRAS_AREAALLOCATOR_P_H
58

source code of qt3d/src/extras/text/areaallocator_p.h