File indexing completed on 2024-05-12 15:58:28

0001 /*
0002  *  SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef __KIS_MEMORY_STATISTICS_SERVER_H
0008 #define __KIS_MEMORY_STATISTICS_SERVER_H
0009 
0010 #include <QtGlobal>
0011 #include <QObject>
0012 #include <QScopedPointer>
0013 
0014 #include "kritaimage_export.h"
0015 #include "kis_types.h"
0016 
0017 
0018 class KRITAIMAGE_EXPORT KisMemoryStatisticsServer : public QObject
0019 {
0020     Q_OBJECT
0021 public:
0022     struct Statistics
0023     {
0024         Statistics()
0025             : imageSize(0),
0026               layersSize(0),
0027               projectionsSize(0),
0028               lodSize(0),
0029 
0030               totalMemorySize(0),
0031               realMemorySize(0),
0032               historicalMemorySize(0),
0033               poolSize(0),
0034 
0035               swapSize(0),
0036 
0037               totalMemoryLimit(0),
0038               tilesHardLimit(0),
0039               tilesSoftLimit(0),
0040               tilesPoolLimit(0)
0041         {
0042         }
0043 
0044         qint64 imageSize;
0045         qint64 layersSize;
0046         qint64 projectionsSize;
0047         qint64 lodSize;
0048 
0049         qint64 totalMemorySize;
0050         qint64 realMemorySize;
0051         qint64 historicalMemorySize;
0052         qint64 poolSize;
0053 
0054         qint64 swapSize;
0055 
0056         qint64 totalMemoryLimit;
0057         qint64 tilesHardLimit;
0058         qint64 tilesSoftLimit;
0059         qint64 tilesPoolLimit;
0060     };
0061 
0062 
0063 
0064 public:
0065     KisMemoryStatisticsServer();
0066     ~KisMemoryStatisticsServer() override;
0067     static KisMemoryStatisticsServer* instance();
0068 
0069     Statistics fetchMemoryStatistics(KisImageSP image) const;
0070 
0071 public Q_SLOTS:
0072     void notifyImageChanged();
0073     void tryForceUpdateMemoryStatisticsWhileIdle();
0074 
0075 Q_SIGNALS:
0076     void sigUpdateMemoryStatistics();
0077 
0078 
0079 private:
0080     struct Private;
0081     const QScopedPointer<Private> m_d;
0082 };
0083 
0084 #endif /* __KIS_MEMORY_STATISTICS_SERVER_H */