From 94895f0270ccb3a2423857e82b78b23581b1c2d8 Mon Sep 17 00:00:00 2001 From: Mike Krus Date: Wed, 30 Oct 2019 11:40:09 +0000 Subject: 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 --- src/render/renderers/opengl/textures/gltexture.cpp | 1 - src/render/texture/qtexture.cpp | 18 ++++++++---------- src/render/texture/texture.cpp | 2 ++ 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src/render') 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(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(QNodePrivate::get(const_cast(frontEnd))); + dTexture->setStatus(QAbstractTexture::Loading); } QAbstractTexturePrivate *dnode = dynamic_cast(QAbstractTexturePrivate::get(const_cast(node))); -- cgit v1.2.3