2013-06-19 15:12:32 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2013-06-20 12:34:02 +02:00
|
|
|
** Copyright (C) 2013 Digia Plc
|
|
|
|
|
** All rights reserved.
|
|
|
|
|
** For any questions to Digia, please use contact form at http://qt.digia.com <http://qt.digia.com/>
|
2013-06-19 15:12:32 +02:00
|
|
|
**
|
2013-06-20 12:34:02 +02:00
|
|
|
** This file is part of the Qt Enterprise Qt Quick Profiler Add-on.
|
2013-06-19 15:12:32 +02:00
|
|
|
**
|
2013-06-20 12:34:02 +02:00
|
|
|
** Licensees holding valid Qt Enterprise licenses may use this file in
|
|
|
|
|
** accordance with the Qt Enterprise License Agreement provided with the
|
2013-06-19 15:12:32 +02:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2013-06-20 12:34:02 +02:00
|
|
|
** a written agreement between you and Digia.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please use
|
|
|
|
|
** contact form at http://qt.digia.com <http://qt.digia.com/>
|
2013-06-19 15:12:32 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef PIXMAPCACHEMODEL_H
|
|
|
|
|
#define PIXMAPCACHEMODEL_H
|
|
|
|
|
|
2014-06-12 16:03:40 +02:00
|
|
|
#include "qmlprofiler/abstracttimelinemodel.h"
|
2014-02-18 18:34:43 +01:00
|
|
|
#include "qmlprofiler/qmlprofilerdatamodel.h"
|
2013-06-19 15:12:32 +02:00
|
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
#include <QColor>
|
2014-10-27 19:54:23 +01:00
|
|
|
#include <QSize>
|
2013-06-19 15:12:32 +02:00
|
|
|
|
2013-06-24 14:17:43 +02:00
|
|
|
namespace QmlProfilerExtension {
|
2013-06-19 15:12:32 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-06-12 16:03:40 +02:00
|
|
|
class PixmapCacheModel : public QmlProfiler::AbstractTimelineModel
|
2013-06-19 15:12:32 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2014-10-27 19:54:23 +01:00
|
|
|
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
|
|
|
|
|
};
|
2013-06-19 15:12:32 +02:00
|
|
|
|
2014-10-27 19:54:23 +01:00
|
|
|
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;
|
2013-06-19 15:12:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum PixmapEventType {
|
|
|
|
|
PixmapSizeKnown,
|
|
|
|
|
PixmapReferenceCountChanged,
|
|
|
|
|
PixmapCacheCountChanged,
|
|
|
|
|
PixmapLoadingStarted,
|
|
|
|
|
PixmapLoadingFinished,
|
|
|
|
|
PixmapLoadingError,
|
|
|
|
|
|
|
|
|
|
MaximumPixmapEventType
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-27 19:54:23 +01:00
|
|
|
struct PixmapCacheEvent {
|
2014-10-28 14:30:04 +01:00
|
|
|
int typeId;
|
2014-10-27 19:54:23 +01:00
|
|
|
PixmapEventType pixmapEventType;
|
|
|
|
|
int urlIndex;
|
|
|
|
|
int sizeIndex;
|
|
|
|
|
int rowNumberCollapsed;
|
|
|
|
|
qint64 cacheSize;
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-28 17:39:23 +01:00
|
|
|
PixmapCacheModel(QmlProfiler::QmlProfilerModelManager *manager, QObject *parent = 0);
|
2013-06-19 15:12:32 +02:00
|
|
|
|
2014-06-24 11:53:19 +02:00
|
|
|
int rowMaxValue(int rowNumber) const;
|
2013-06-19 15:12:32 +02:00
|
|
|
|
2014-07-08 14:53:47 +02:00
|
|
|
int row(int index) const;
|
2014-10-28 14:30:04 +01:00
|
|
|
int typeId(int index) const;
|
2014-07-08 14:53:47 +02:00
|
|
|
QColor color(int index) const;
|
2014-09-02 12:30:40 +02:00
|
|
|
float relativeHeight(int index) const;
|
2013-06-19 15:12:32 +02:00
|
|
|
|
2014-07-08 14:53:47 +02:00
|
|
|
QVariantList labels() const;
|
2013-06-19 15:12:32 +02:00
|
|
|
|
2014-07-07 14:41:44 +02:00
|
|
|
QVariantMap details(int index) const;
|
2013-07-10 16:47:16 +02:00
|
|
|
|
2014-09-11 11:15:48 +02:00
|
|
|
protected:
|
2013-06-19 15:12:32 +02:00
|
|
|
void loadData();
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
|
|
private:
|
2014-10-27 19:54:23 +01:00
|
|
|
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;
|
2014-02-26 17:44:58 +01:00
|
|
|
|
2014-10-27 19:54:23 +01:00
|
|
|
static const int s_pixmapCacheCountHue = 240;
|
2013-06-19 15:12:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2013-06-24 14:17:43 +02:00
|
|
|
} // namespace QmlProfilerExtension
|
2013-06-19 15:12:32 +02:00
|
|
|
|
|
|
|
|
#endif // PIXMAPCACHEMODEL_H
|