aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/qmlprofilerextension/pixmapcachemodel.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/qmlprofilerextension/pixmapcachemodel.h')
-rw-r--r--plugins/qmlprofilerextension/pixmapcachemodel.h57
1 files changed, 48 insertions, 9 deletions
diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.h b/plugins/qmlprofilerextension/pixmapcachemodel.h
index 73e7aef8a1..78ce3cfd42 100644
--- a/plugins/qmlprofilerextension/pixmapcachemodel.h
+++ b/plugins/qmlprofilerextension/pixmapcachemodel.h
@@ -24,6 +24,7 @@
#include <QStringList>
#include <QColor>
+#include <QSize>
namespace QmlProfilerExtension {
namespace Internal {
@@ -32,13 +33,36 @@ class PixmapCacheModel : public QmlProfiler::AbstractTimelineModel
{
Q_OBJECT
public:
+ enum CacheState {
+ Uncached, // After loading started (or some other proof of existence) or after uncaching
+ ToBeCached, // After determining the pixmap is to be cached but before knowing its size
+ Cached, // After caching a pixmap or determining the size of a ToBeCached pixmap
+ Uncacheable, // If loading failed without ToBeCached or after a corrupt pixmap has been uncached
+ Corrupt // If after ToBeCached we learn that loading failed
+ };
- struct PixmapCacheEvent {
- int pixmapEventType;
- int urlIndex;
- int sizeIndex;
- int rowNumberCollapsed;
- qint64 cacheSize;
+ enum LoadState {
+ Initial,
+ Loading,
+ Finished,
+ Error
+ };
+
+ struct PixmapState {
+ PixmapState(int width, int height, CacheState cache = Uncached) :
+ size(width, height), started(-1), loadState(Initial), cacheState(cache) {}
+ PixmapState(CacheState cache = Uncached) : started(-1), loadState(Initial), cacheState(cache) {}
+ QSize size;
+ int started;
+ LoadState loadState;
+ CacheState cacheState;
+ };
+
+ struct Pixmap {
+ Pixmap() {}
+ Pixmap(const QString &url) : url(url), sizes(1) {}
+ QString url;
+ QVector<PixmapState> sizes;
};
enum PixmapEventType {
@@ -52,6 +76,14 @@ public:
MaximumPixmapEventType
};
+ struct PixmapCacheEvent {
+ PixmapEventType pixmapEventType;
+ int urlIndex;
+ int sizeIndex;
+ int rowNumberCollapsed;
+ qint64 cacheSize;
+ };
+
PixmapCacheModel(QObject *parent = 0);
quint64 features() const;
@@ -71,10 +103,17 @@ protected:
void clear();
private:
- static const int PixmapCacheCountHue = 240;
+ void computeMaxCacheSize();
+ void resizeUnfinishedLoads();
+ void flattenLoads();
+ int updateCacheCount(int lastCacheSizeEvent, qint64 startTime, qint64 pixSize,
+ PixmapCacheEvent &newEvent, int typeId);
+
+ QVector<PixmapCacheEvent> m_data;
+ QVector<Pixmap> m_pixmaps;
+ qint64 m_maxCacheSize;
- class PixmapCacheModelPrivate;
- Q_DECLARE_PRIVATE(PixmapCacheModel)
+ static const int s_pixmapCacheCountHue = 240;
};
} // namespace Internal