diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-07 15:38:51 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-16 09:59:15 +0200 |
commit | 3768ec496cb8be1b8bedafd08c19732a405dfeea (patch) | |
tree | c35780a359ebf600e489c8d4369929d00b308644 | |
parent | bc1b6e73bb31c7eb9b9f6b4920d2e99ac441bc08 (diff) |
Add argument to QSGTexture::removedFromAtlas()
...as requested by the Qt 6 TODO. To preserve binary (and source)
compatibility in 5.14, the argument was changed into a variable in
QSGTexturePrivate, with a public setter. This can now go away and the
signature of removedFromAtlas() can get updated.
Task-number: QTBUG-82997
Change-Id: I930c0014712c78e140b778b6e9a4d8b92c5bdc8c
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
10 files changed, 18 insertions, 34 deletions
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp index 45d7a65555..ed37305374 100644 --- a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp +++ b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp @@ -154,7 +154,7 @@ bool Texture::hasAlphaChannel() const return !QSGCompressedTexture::formatIsOpaque(static_cast<Atlas*>(m_atlas)->format()); } -QSGTexture *Texture::removedFromAtlas() const +QSGTexture *Texture::removedFromAtlas(QRhiResourceUpdateBatch *) const { if (m_nonatlas_texture) { m_nonatlas_texture->setMipmapFiltering(mipmapFiltering()); diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h index aec7dbf976..a2d6d96dfe 100644 --- a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h +++ b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h @@ -97,7 +97,7 @@ public: QRectF normalizedTextureSubRect() const override { return m_texture_coords_rect; } - QSGTexture *removedFromAtlas() const override; + QSGTexture *removedFromAtlas(QRhiResourceUpdateBatch *) const override; const QByteArray &data() const { return m_data; } int sizeInBytes() const { return m_dataLength; } diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp index 1dde0a31f2..277b422d7c 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture.cpp +++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp @@ -453,11 +453,19 @@ QSGTexture::~QSGTexture() Implementations of this function are recommended to return the same instance for multiple calls to limit memory usage. + \a resourceUpdates is an optional resource update batch, on which texture + operations, if any, are enqueued. Materials can retrieve an instance from + QSGMaterialRhiShader::RenderState. When null, the removedFromAtlas() + implementation creates its own batch and submit it right away. However, + when a valid instance is specified, this function will not submit the + update batch. + \warning This function can only be called from the rendering thread. */ -QSGTexture *QSGTexture::removedFromAtlas() const +QSGTexture *QSGTexture::removedFromAtlas(QRhiResourceUpdateBatch *resourceUpdates) const { + Q_UNUSED(resourceUpdates); Q_ASSERT_X(!isAtlasTexture(), "QSGTexture::removedFromAtlas()", "Called on a non-atlas texture"); return nullptr; } @@ -767,15 +775,6 @@ QSGTexture::NativeTexture QSGTexture::nativeTexture() const return {}; } -/*! - \internal - */ -void QSGTexture::setWorkResourceUpdateBatch(QRhiResourceUpdateBatch *resourceUpdates) -{ - Q_D(QSGTexture); - d->workResourceUpdateBatch = resourceUpdates; -} - bool QSGTexturePrivate::hasDirtySamplerOptions() const { return wrapChanged || filteringChanged || anisotropyChanged; diff --git a/src/quick/scenegraph/coreapi/qsgtexture.h b/src/quick/scenegraph/coreapi/qsgtexture.h index f394e1977b..0973f9b283 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture.h +++ b/src/quick/scenegraph/coreapi/qsgtexture.h @@ -96,7 +96,7 @@ public: virtual bool isAtlasTexture() const; - virtual QSGTexture *removedFromAtlas() const; + virtual QSGTexture *removedFromAtlas(QRhiResourceUpdateBatch *resourceUpdates = nullptr) const; virtual void bind() = 0; // ### Qt 6: remove void updateBindOptions(bool force = false); // ### Qt 6: remove @@ -120,9 +120,6 @@ public: void updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates); - // ### Qt 6: make this an argument for removedFromAtlas() - void setWorkResourceUpdateBatch(QRhiResourceUpdateBatch *resourceUpdates); - protected: QSGTexture(QSGTexturePrivate &dd); }; diff --git a/src/quick/scenegraph/coreapi/qsgtexture_p.h b/src/quick/scenegraph/coreapi/qsgtexture_p.h index b98642b206..cd6eced3d7 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture_p.h +++ b/src/quick/scenegraph/coreapi/qsgtexture_p.h @@ -88,8 +88,6 @@ public: // ### Qt 6: should be virtual in the public class instead virtual void updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates); - QRhiResourceUpdateBatch *workResourceUpdateBatch = nullptr; // ### Qt 6: remove - uint wrapChanged : 1; uint filteringChanged : 1; uint anisotropyChanged : 1; diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp index e86dae7c09..e804dc96b7 100644 --- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp +++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp @@ -402,9 +402,7 @@ void QSGRhiShaderEffectMaterialShader::updateSampledImage(RenderState &state, in // committed operations to state.resourceUpdateBatch()... The // only safe way then is to use the same batch the atlas' // updateRhiTexture() used. - t->setWorkResourceUpdateBatch(state.resourceUpdateBatch()); - QSGTexture *newTexture = t->removedFromAtlas(); - t->setWorkResourceUpdateBatch(nullptr); + QSGTexture *newTexture = t->removedFromAtlas(state.resourceUpdateBatch()); if (newTexture) t = newTexture; } diff --git a/src/quick/scenegraph/util/qsgopenglatlastexture.cpp b/src/quick/scenegraph/util/qsgopenglatlastexture.cpp index a3f9286cfb..0f29cb3b38 100644 --- a/src/quick/scenegraph/util/qsgopenglatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgopenglatlastexture.cpp @@ -555,7 +555,7 @@ Texture::~Texture() delete m_nonatlas_texture; } -QSGTexture *Texture::removedFromAtlas() const +QSGTexture *Texture::removedFromAtlas(QRhiResourceUpdateBatch *) const { if (m_nonatlas_texture) { m_nonatlas_texture->setMipmapFiltering(mipmapFiltering()); diff --git a/src/quick/scenegraph/util/qsgopenglatlastexture_p.h b/src/quick/scenegraph/util/qsgopenglatlastexture_p.h index 8860872ae1..a81c62ad63 100644 --- a/src/quick/scenegraph/util/qsgopenglatlastexture_p.h +++ b/src/quick/scenegraph/util/qsgopenglatlastexture_p.h @@ -189,7 +189,7 @@ public: QRect atlasSubRect() const { return m_allocated_rect; } QRect atlasSubRectWithoutPadding() const { return m_allocated_rect.adjusted(1, 1, -1, -1); } - QSGTexture *removedFromAtlas() const override; + QSGTexture *removedFromAtlas(QRhiResourceUpdateBatch *) const override; void releaseImage() { m_image = QImage(); } const QImage &image() const { return m_image; } diff --git a/src/quick/scenegraph/util/qsgrhiatlastexture.cpp b/src/quick/scenegraph/util/qsgrhiatlastexture.cpp index ec92666f0d..75577a9bd8 100644 --- a/src/quick/scenegraph/util/qsgrhiatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgrhiatlastexture.cpp @@ -392,12 +392,6 @@ TextureBase::~TextureBase() m_atlas->remove(this); } -QRhiResourceUpdateBatch *TextureBase::workResourceUpdateBatch() const -{ - Q_D(const TextureBase); - return d->workResourceUpdateBatch; -} - int TextureBase::comparisonKey() const { // We need special care here: a typical comparisonKey() implementation @@ -447,7 +441,7 @@ Texture::~Texture() delete m_nonatlas_texture; } -QSGTexture *Texture::removedFromAtlas() const +QSGTexture *Texture::removedFromAtlas(QRhiResourceUpdateBatch *resourceUpdates) const { if (!m_nonatlas_texture) { m_nonatlas_texture = new QSGPlainTexture; @@ -463,7 +457,7 @@ QSGTexture *Texture::removedFromAtlas() const QRhiTexture *extractTex = rhi->newTexture(m_atlas->texture()->format(), r.size()); if (extractTex->build()) { bool ownResUpd = false; - QRhiResourceUpdateBatch *resUpd = workResourceUpdateBatch(); // ### Qt 6: should be an arg to this function + QRhiResourceUpdateBatch *resUpd = resourceUpdates; if (!resUpd) { ownResUpd = true; resUpd = rhi->nextResourceUpdateBatch(); diff --git a/src/quick/scenegraph/util/qsgrhiatlastexture_p.h b/src/quick/scenegraph/util/qsgrhiatlastexture_p.h index 85d07ae24b..fb8d5257d1 100644 --- a/src/quick/scenegraph/util/qsgrhiatlastexture_p.h +++ b/src/quick/scenegraph/util/qsgrhiatlastexture_p.h @@ -166,8 +166,6 @@ public: bool isAtlasTexture() const override { return true; } QRect atlasSubRect() const { return m_allocated_rect; } - QRhiResourceUpdateBatch *workResourceUpdateBatch() const; - protected: QRect m_allocated_rect; AtlasBase *m_atlas; @@ -198,7 +196,7 @@ public: QRect atlasSubRect() const { return m_allocated_rect; } QRect atlasSubRectWithoutPadding() const { return m_allocated_rect.adjusted(1, 1, -1, -1); } - QSGTexture *removedFromAtlas() const override; + QSGTexture *removedFromAtlas(QRhiResourceUpdateBatch *resourceUpdates) const override; void releaseImage() { m_image = QImage(); } const QImage &image() const { return m_image; } |