diff options
author | Louis du Verdier <louis.du.verdier@free.fr> | 2014-06-05 08:44:16 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-05 14:09:31 +0200 |
commit | 468a65c89eebeeb8c02cb83fe8ffd37c3e8937d2 (patch) | |
tree | 5fb2ece74d4323b17a6500b74fe8573980f69b7e /src/quick/util | |
parent | 8a71e2bd031230777dcfbb482af40a03b8d91507 (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')
-rw-r--r-- | src/quick/util/qquickpixmapcache.cpp | 19 | ||||
-rw-r--r-- | src/quick/util/qquickpixmapcache_p.h | 2 |
2 files changed, 21 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) { diff --git a/src/quick/util/qquickpixmapcache_p.h b/src/quick/util/qquickpixmapcache_p.h index 6ab1ff6482..76bbf6d341 100644 --- a/src/quick/util/qquickpixmapcache_p.h +++ b/src/quick/util/qquickpixmapcache_p.h @@ -101,6 +101,7 @@ public: const QSize &requestSize() const; QImage image() const; void setImage(const QImage &); + void setPixmap(const QQuickPixmap &other); QQuickTextureFactory *textureFactory() const; @@ -122,6 +123,7 @@ public: bool connectDownloadProgress(QObject *, int); static void purgeCache(); + static bool isCached(const QUrl &url, const QSize &requestSize); private: Q_DISABLE_COPY(QQuickPixmap) |