Debian Codegraph @

libs/image/tiles3/swap/kis_swapped_data_store.h

raw symbols SCIP
1 /*
2 * SPDX-FileCopyrightText: 2010 Dmitry Kazakov <[email protected]>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef __KIS_SWAPPED_DATA_STORE_H
8 #define __KIS_SWAPPED_DATA_STORE_H
9
10 #include "kritaimage_export.h"
11
12 #include <QMutex>
13 #include <QByteArray>
14
15
16 class QMutex;
17 class KisTileData;
18 class KisAbstractTileCompressor;
19 class KisChunkAllocator;
20 class KisMemoryWindow;
21
22 class KRITAIMAGE_EXPORT KisSwappedDataStore
23 {
24 public:
25 KisSwappedDataStore();
26 ~KisSwappedDataStore();
27
28 /**
29 * Returns number of swapped out tile data objects
30 */
31 quint64 numTiles() const;
32
33 /**
34 * Swap out the data stored in the \a td to the swap file
35 * and free memory occupied by td->data().
36 * LOCKING: the lock on the tile data should be taken
37 * by the caller before making a call.
38 */
39 bool trySwapOutTileData(KisTileData *td);
40
41 /**
42 * Restore the data of a \a td basing on information
43 * stored in the swap file.
44 * LOCKING: the lock on the tile data should be taken
45 * by the caller before making a call.
46 */
47 void swapInTileData(KisTileData *td);
48
49 /**
50 * Forget all the information linked with the tile data.
51 * This should be done before deleting of the tile data,
52 * whose actual data is swapped-out
53 */
54 void forgetTileData(KisTileData *td);
55
56 /**
57 * Returns the metric of the total memory stored in the swap
58 * in *uncompressed* form!
59 */
60 qint64 totalSwapMemoryUsed() const;
61
62 /**
63 * Some debugging output
64 */
65 void debugStatistics();
66
67 private:
68 QByteArray m_buffer;
69 KisAbstractTileCompressor *m_compressor;
70
71 KisChunkAllocator *m_allocator;
72 KisMemoryWindow *m_swapSpace;
73
74 QMutex m_lock;
75
76 qint64 m_totalSwapMemoryUsed;
77 };
78
79 #endif /* __KIS_SWAPPED_DATA_STORE_H */
80