aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickpixmapcache.cpp
diff options
context:
space:
mode:
authorLouis du Verdier <louis.du.verdier@free.fr>2014-06-05 08:44:16 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-05 14:09:31 +0200
commit468a65c89eebeeb8c02cb83fe8ffd37c3e8937d2 (patch)
tree5fb2ece74d4323b17a6500b74fe8573980f69b7e /src/quick/util/qquickpixmapcache.cpp
parent8a71e2bd031230777dcfbb482af40a03b8d91507 (diff)
Optimize the way AnimatedImage display its content
Since QtQuick2, the AnimatedImage component is less efficient than it was with QtQuick1, using more CPU and RAM. This commit makes it upload when required each animation frame as a cached texture (using QQuickPixmapCache) to speed up the component. Task-number: QTBUG-38921 Change-Id: I7ab0b5f47ecec6cb3cdded0dd219d6acc1bc4148 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/quick/util/qquickpixmapcache.cpp')
-rw-r--r--src/quick/util/qquickpixmapcache.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 0a5b26281a..95b3ac5b21 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -1182,6 +1182,17 @@ void QQuickPixmap::setImage(const QImage &p)
d = new QQuickPixmapData(this, textureFactoryForImage(p));
}
+void QQuickPixmap::setPixmap(const QQuickPixmap &other)
+{
+ clear();
+
+ if (other.d) {
+ d = other.d;
+ d->addref();
+ d->declarativePixmaps.insert(this);
+ }
+}
+
int QQuickPixmap::width() const
{
if (d && d->textureFactory)
@@ -1305,6 +1316,14 @@ void QQuickPixmap::clear(QObject *obj)
}
}
+bool QQuickPixmap::isCached(const QUrl &url, const QSize &requestSize)
+{
+ QQuickPixmapKey key = { &url, &requestSize };
+ QQuickPixmapStore *store = pixmapStore();
+
+ return store->m_cache.contains(key);
+}
+
bool QQuickPixmap::connectFinished(QObject *object, const char *method)
{
if (!d || !d->reply) {