diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-12-02 07:59:44 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-02 09:05:05 +0100 |
commit | e32eb8ee5d413ab6a908c2e3274645a489cb9df2 (patch) | |
tree | a6e0491905ad6af212f40e41ee2e2ed5bb0b90ef /src/imports | |
parent | 310618d504aed92ac532c69471ef196829b3f07c (diff) |
Remove QSGContext and QSGTexture from QDeclarativePixmapData
In order to cleanly support multiple windows we need to not
have the QSGContext reference in QDeclarativeEngine and we
need to be able to have one copy of the texture for each
QSGContext that is not sharing when we have multiple windows.
This also makes it easier to the release graphical resources from
a running application, which is another feature that we want
to eventually implement.
This patch does remove an adaptation feature which is the
decodeToTexture, which seemed like a good idea at the time
but in hindsight has not been used for anything.
Edit: resolved conflict in qquickimage.cpp
Edit: updated QDeclarativePixmap testcase
Edit: updated QQuickImage testcase
Edit: Rebased on top of QDeclarativePixmapCacheChanges
Change-Id: Ifc61dd8158d3f841437d029b6031a91196145517
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/etcprovider/qetcprovider.cpp | 35 | ||||
-rw-r--r-- | src/imports/etcprovider/qetcprovider.h | 2 |
2 files changed, 32 insertions, 5 deletions
diff --git a/src/imports/etcprovider/qetcprovider.cpp b/src/imports/etcprovider/qetcprovider.cpp index 053258a794..5ea7ea9b6b 100644 --- a/src/imports/etcprovider/qetcprovider.cpp +++ b/src/imports/etcprovider/qetcprovider.cpp @@ -143,10 +143,37 @@ QSize EtcTexture::textureSize() const return m_size; } -QSGTexture *QEtcProvider::requestTexture(const QString &id, QSize *size, const QSize &requestedSize) + +class QEtcTextureFactory : public QDeclarativeTextureFactory +{ +public: + QByteArray m_data; + QSize m_size; + QSize m_paddedSize; + + QSize textureSize() const { + return m_size; + } + + int textureByteCount() const { + return m_data.size(); + } + + QSGTexture *createTexture() const { + EtcTexture *texture = new EtcTexture; + texture->m_data = m_data; + texture->m_size = m_size; + texture->m_paddedSize = m_paddedSize; + return texture; + } + +}; + + +QDeclarativeTextureFactory *QEtcProvider::requestTexture(const QString &id, QSize *size, const QSize &requestedSize) { Q_UNUSED(requestedSize); - EtcTexture *ret = 0; + QEtcTextureFactory *ret = 0; size->setHeight(0); size->setWidth(0); @@ -156,7 +183,7 @@ QSGTexture *QEtcProvider::requestTexture(const QString &id, QSize *size, const Q qDebug() << "requestTexture opening file: " << id; #endif if (file.open(QIODevice::ReadOnly)) { - ret = new EtcTexture(); + ret = new QEtcTextureFactory; ret->m_data = file.readAll(); if (!ret->m_data.isEmpty()) { ETCHeader *pETCHeader = NULL; @@ -168,7 +195,7 @@ QSGTexture *QEtcProvider::requestTexture(const QString &id, QSize *size, const Q ret->m_paddedSize.setWidth(getPaddedWidth(pETCHeader)); } else { - free (ret); + delete ret; ret = 0; } } diff --git a/src/imports/etcprovider/qetcprovider.h b/src/imports/etcprovider/qetcprovider.h index 46ec421162..cac37584d4 100644 --- a/src/imports/etcprovider/qetcprovider.h +++ b/src/imports/etcprovider/qetcprovider.h @@ -90,7 +90,7 @@ public: qDebug () << "Creating QEtcProvider."; #endif } - QSGTexture *requestTexture(const QString &id, QSize *size, const QSize &requestedSize); + QDeclarativeTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize); }; QT_END_NAMESPACE |