Krita Source Code Documentation
Loading...
Searching...
No Matches
KisTiledExtentManager.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com>
3 * SPDX-FileCopyrightText: 2018 Andrey Kamakin <a.kamakin@icloud.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#ifndef KISTILEDEXTENTMANAGER_H
9#define KISTILEDEXTENTMANAGER_H
10
11#include <QReadWriteLock>
12#include <QMap>
13#include <QRect>
14#include "kritaimage_export.h"
15
16
17class KRITAIMAGE_EXPORT KisTiledExtentManager
18{
19 static const qint32 InitialBufferSize = 256;
20
21 class KRITAIMAGE_EXPORT Data
22 {
23 public:
24 Data();
25 ~Data();
26
27 bool add(qint32 index);
28 bool remove(qint32 index);
29 void replace(const QVector<qint32> &indexes);
30 void clear();
31 bool isEmpty();
32 qint32 min();
33 qint32 max();
34
35 public:
36 QReadWriteLock m_extentLock;
37
38 private:
39 inline void unsafeAdd(qint32 index);
40 inline void unsafeMigrate(qint32 index);
41 inline void migrate(qint32 index);
42 inline void updateMin();
43 inline void updateMax();
44
45 private:
46 qint32 m_min;
47 qint32 m_max;
48 qint32 m_offset;
49 qint32 m_capacity;
50 qint32 m_count;
51 QAtomicInt *m_buffer;
52 QReadWriteLock m_migrationLock;
53 };
54
55public:
57
58 void notifyTileAdded(qint32 col, qint32 row);
59 void notifyTileRemoved(qint32 col, qint32 row);
60 void replaceTileStats(const QVector<QPoint> &indexes);
61 void clear();
62 QRect extent() const;
63
64private:
65 void updateExtent();
66 friend class KisTiledDataManagerTest;
67
68private:
69 mutable QReadWriteLock m_extentLock;
73};
74
75#endif // KISTILEDEXTENTMANAGER_H