aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorChristiaan Janssen <christiaan.janssen@digia.com>2012-10-24 16:09:29 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-30 13:07:16 +0200
commit107444f7c479ed6a1a3d2c42b026ebc9c1fe4b29 (patch)
tree1b2d5de24ac315fc1e57beeb38d0fed141fafab6 /src/quick
parent3b0a9b27fec09cdab4cde7bfc41578c8c17a8832 (diff)
QmlProfiler: Pixmap Cache
Change-Id: Ibc237bb162c24030438b89d54fa8802ee66b080a Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/util/qquickpixmapcache.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index c5968c2bc1..9cf8c5812d 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -71,6 +71,8 @@
#include <QQmlFile>
#include <QMetaMethod>
+#include <private/qqmlprofilerservice_p.h>
+
#define IMAGEREQUEST_MAX_REQUEST_COUNT 8
#define IMAGEREQUEST_MAX_REDIRECT_RECURSION 16
#define CACHE_EXPIRE_TIME 30
@@ -890,11 +892,15 @@ bool QQuickPixmapReply::event(QEvent *event)
if (data) {
Event *de = static_cast<Event *>(event);
data->pixmapStatus = (de->error == NoError) ? QQuickPixmap::Ready : QQuickPixmap::Error;
-
+ QQmlPixmapProfiler pixmapProfiler;
if (data->pixmapStatus == QQuickPixmap::Ready) {
+ pixmapProfiler.finishLoading(data->url);
data->textureFactory = de->textureFactory;
data->implicitSize = de->implicitSize;
+ if (data->implicitSize.width() > 0)
+ pixmapProfiler.setSize(url, data->implicitSize.width(), data->implicitSize.height());
} else {
+ pixmapProfiler.errorLoading(data->url);
data->errorString = de->errorString;
data->removeFromCache(); // We don't continue to cache error'd pixmaps
}
@@ -920,6 +926,7 @@ int QQuickPixmapData::cost() const
void QQuickPixmapData::addref()
{
++refCount;
+ QQmlPixmapProfiler().referenceCountChanged(url, refCount);
if (prevUnreferencedPtr)
pixmapStore()->referencePixmap(this);
}
@@ -928,6 +935,7 @@ void QQuickPixmapData::release()
{
Q_ASSERT(refCount > 0);
--refCount;
+ QQmlPixmapProfiler().referenceCountChanged(url, refCount);
if (refCount == 0) {
if (reply) {
QQuickPixmapReply *cancelReply = reply;
@@ -958,6 +966,10 @@ void QQuickPixmapData::addToCache()
QQuickPixmapKey key = { &url, &requestSize };
pixmapStore()->m_cache.insert(key, this);
inCache = true;
+ QQmlPixmapProfiler pixmapProfiler;
+ pixmapProfiler.cacheCountChanged(url, pixmapStore()->m_cache.count());
+ if (implicitSize.width() > 0)
+ pixmapProfiler.setSize(url, implicitSize.width(), implicitSize.height());
}
}
@@ -965,6 +977,7 @@ void QQuickPixmapData::removeFromCache()
{
if (inCache) {
QQuickPixmapKey key = { &url, &requestSize };
+ QQmlPixmapProfiler().cacheCountChanged(url, pixmapStore()->m_cache.count());
pixmapStore()->m_cache.remove(key);
inCache = false;
}
@@ -1238,14 +1251,21 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
if (!(options & QQuickPixmap::Asynchronous)) {
bool ok = false;
+ QQmlPixmapProfiler pixmapProfiler;
+ pixmapProfiler.startLoading(url);
d = createPixmapDataSync(this, engine, url, requestSize, &ok);
if (ok) {
+ pixmapProfiler.finishLoading(url);
+ if (d->implicitSize.width() > 0)
+ QQmlPixmapProfiler().setSize(url, d->implicitSize.width(), d->implicitSize.height());
if (options & QQuickPixmap::Cache)
d->addToCache();
return;
}
- if (d) // loadable, but encountered error while loading
+ if (d) { // loadable, but encountered error while loading
+ pixmapProfiler.errorLoading(url);
return;
+ }
}
if (!engine)