diff options
author | Mike Krus <mike.krus@kdab.com> | 2019-10-30 11:40:09 +0000 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2019-10-30 12:55:48 +0000 |
commit | 94895f0270ccb3a2423857e82b78b23581b1c2d8 (patch) | |
tree | 20297cc9dee9f6c8948020654c26b5af8929a199 /src/render | |
parent | fbda2a3ba97907f04210fe8a6dac0f3056c6384d (diff) |
Fix status change on QTextureLoader
Now setting to Loading when the functor change is synced to the backend.
Avoid creating a new functor when downloads have completed, just use
the same one and mark the node as dirty.
Avoid recreating the functor when the format change comes from the
backend (which caused the image to be loaded again).
Change-Id: Ifcbbf54db56b57a58b0b5d1ce5f1475b6587f697
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/renderers/opengl/textures/gltexture.cpp | 1 | ||||
-rw-r--r-- | src/render/texture/qtexture.cpp | 18 | ||||
-rw-r--r-- | src/render/texture/texture.cpp | 2 |
3 files changed, 10 insertions, 11 deletions
diff --git a/src/render/renderers/opengl/textures/gltexture.cpp b/src/render/renderers/opengl/textures/gltexture.cpp index e0a379138..20e6007a0 100644 --- a/src/render/renderers/opengl/textures/gltexture.cpp +++ b/src/render/renderers/opengl/textures/gltexture.cpp @@ -232,7 +232,6 @@ void GLTexture::loadTextureDataFromImages() GLTexture::TextureUpdateInfo GLTexture::createOrUpdateGLTexture() { TextureUpdateInfo textureInfo; - m_properties.status = QAbstractTexture::Error; m_wasTextureRecreated = false; const bool hasSharedTextureId = m_sharedTextureId > 0; diff --git a/src/render/texture/qtexture.cpp b/src/render/texture/qtexture.cpp index bca66e630..84a228428 100644 --- a/src/render/texture/qtexture.cpp +++ b/src/render/texture/qtexture.cpp @@ -1125,7 +1125,7 @@ TextureDownloadRequest::TextureDownloadRequest(const QTextureFromSourceGenerator } -// Executed in aspect thread +// Executed in main thread void TextureDownloadRequest::onCompleted() { if (cancelled() || !succeeded()) @@ -1142,16 +1142,11 @@ void TextureDownloadRequest::onCompleted() QTextureFromSourceGeneratorPtr oldGenerator = qSharedPointerCast<QTextureFromSourceGenerator>(texture->dataGenerator()); - // We create a new functor - // Which is a copy of the old one + the downloaded sourceData - auto newGenerator = QTextureFromSourceGeneratorPtr::create(*oldGenerator); - // Set raw data on functor so that it can really load something - newGenerator->m_sourceData = m_data; + oldGenerator->m_sourceData = m_data; - // Set new generator on texture - // it implictely marks the texture as dirty so that the functor runs again with the downloaded data - texture->setDataGenerator(newGenerator); + // Mark the texture as dirty so that the functor runs again with the downloaded data + texture->addDirtyFlag(Render::Texture::DirtyDataGenerator); } /*! @@ -1520,7 +1515,10 @@ QTextureLoader::QTextureLoader(QNode *parent) // Regenerate the texture functor when properties we support overriding // from QAbstractTexture get changed. Q_D(QTextureLoader); - auto regenerate = [=] () { d->updateGenerator(); }; + auto regenerate = [=] () { + if (!notificationsBlocked()) // check the change doesn't come from the backend + d->updateGenerator(); + }; connect(this, &QAbstractTexture::formatChanged, regenerate); } diff --git a/src/render/texture/texture.cpp b/src/render/texture/texture.cpp index 5ebde56b0..1414cd337 100644 --- a/src/render/texture/texture.cpp +++ b/src/render/texture/texture.cpp @@ -149,6 +149,8 @@ void Texture::syncFromFrontEnd(const QNode *frontEnd, bool firstTime) auto newGenerator = node->dataGenerator(); if (newGenerator != m_dataFunctor) { setDataGenerator(newGenerator); + QAbstractTexturePrivate *dTexture = static_cast<QAbstractTexturePrivate *>(QNodePrivate::get(const_cast<QNode *>(frontEnd))); + dTexture->setStatus(QAbstractTexture::Loading); } QAbstractTexturePrivate *dnode = dynamic_cast<QAbstractTexturePrivate *>(QAbstractTexturePrivate::get(const_cast<QAbstractTexture *>(node))); |