aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-04-07 16:02:10 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-04-28 11:46:27 +0200
commitd59e12a329e6a2127fd43e438cbfe9f750c646fc (patch)
tree58b3ea6c94cfcc26f6e473145b7dabccdcec3bea /src
parentc2de5643cd4f1b8d8b10e2bb62fdf95f12fdd9e3 (diff)
Move updateRhiTexture and co. to QSGTexture
Use a more descriptive name, commitTextureOperations() in order to avoid confusion with QSGDynamicTexture::updateTexture() which has nothing to do with this. With this the QSGTexture interface has all 5.14 pending changes done (changes that were plumbed via ugly hacks due to having had to deal with binary compatibility). The awful enforcing of subclassing QSGTexturePrivate for each and every QSGTexture subclass is now eliminated. Purging the direct OpenGL code path will involve removing QSGTexture functions like textureId(), bind(), updateBindOptions(). With this patch we now we have all the equivalents (or, in some cases, spiritual successors) in place. Task-number: QTBUG-82997 Change-Id: I7a831f982070c52abc7a36604130a1110d14ff9c Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/particles/qquickimageparticle.cpp14
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp40
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h13
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture.cpp60
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture.h5
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture_p.h5
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp4
-rw-r--r--src/quick/scenegraph/qsgdefaultspritenode.cpp2
-rw-r--r--src/quick/scenegraph/qsgrhilayer.cpp9
-rw-r--r--src/quick/scenegraph/qsgrhilayer_p.h13
-rw-r--r--src/quick/scenegraph/qsgrhishadereffectnode.cpp4
-rw-r--r--src/quick/scenegraph/util/qsgdefaultpainternode.cpp13
-rw-r--r--src/quick/scenegraph/util/qsgdefaultpainternode_p.h10
-rw-r--r--src/quick/scenegraph/util/qsgplaintexture.cpp99
-rw-r--r--src/quick/scenegraph/util/qsgplaintexture_p.h6
-rw-r--r--src/quick/scenegraph/util/qsgrhiatlastexture.cpp16
-rw-r--r--src/quick/scenegraph/util/qsgrhiatlastexture_p.h14
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.cpp2
-rw-r--r--src/quickshapes/qquickshapegenericrenderer.cpp6
20 files changed, 140 insertions, 197 deletions
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
index ce7e99a3a0..f2e3715061 100644
--- a/src/particles/qquickimageparticle.cpp
+++ b/src/particles/qquickimageparticle.cpp
@@ -221,10 +221,10 @@ public:
{
ImageMaterialData *state = static_cast<ImageMaterial *>(newMaterial)->state();
if (binding == 2) {
- state->colorTable->updateRhiTexture(renderState.rhi(), renderState.resourceUpdateBatch());
+ state->colorTable->commitTextureOperations(renderState.rhi(), renderState.resourceUpdateBatch());
*texture = state->colorTable;
} else if (binding == 1) {
- state->texture->updateRhiTexture(renderState.rhi(), renderState.resourceUpdateBatch());
+ state->texture->commitTextureOperations(renderState.rhi(), renderState.resourceUpdateBatch());
*texture = state->texture;
}
}
@@ -362,7 +362,7 @@ public:
{
ImageMaterialData *state = static_cast<ImageMaterial *>(newMaterial)->state();
if (binding == 1) {
- state->texture->updateRhiTexture(renderState.rhi(), renderState.resourceUpdateBatch());
+ state->texture->commitTextureOperations(renderState.rhi(), renderState.resourceUpdateBatch());
*texture = state->texture;
}
}
@@ -529,10 +529,10 @@ public:
{
ImageMaterialData *state = static_cast<ImageMaterial *>(newMaterial)->state();
if (binding == 2) {
- state->colorTable->updateRhiTexture(renderState.rhi(), renderState.resourceUpdateBatch());
+ state->colorTable->commitTextureOperations(renderState.rhi(), renderState.resourceUpdateBatch());
*texture = state->colorTable;
} else if (binding == 1) {
- state->texture->updateRhiTexture(renderState.rhi(), renderState.resourceUpdateBatch());
+ state->texture->commitTextureOperations(renderState.rhi(), renderState.resourceUpdateBatch());
*texture = state->texture;
}
}
@@ -682,7 +682,7 @@ public:
{
ImageMaterialData *state = static_cast<ImageMaterial *>(newMaterial)->state();
if (binding == 1) {
- state->texture->updateRhiTexture(renderState.rhi(), renderState.resourceUpdateBatch());
+ state->texture->commitTextureOperations(renderState.rhi(), renderState.resourceUpdateBatch());
*texture = state->texture;
}
}
@@ -830,7 +830,7 @@ public:
{
ImageMaterialData *state = static_cast<ImageMaterial *>(newMaterial)->state();
if (binding == 1) {
- state->texture->updateRhiTexture(renderState.rhi(), renderState.resourceUpdateBatch());
+ state->texture->commitTextureOperations(renderState.rhi(), renderState.resourceUpdateBatch());
*texture = state->texture;
}
}
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp
index 44ddb805d0..59cc967167 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(QSG_LOG_TEXTUREIO, "qt.scenegraph.textureio");
QSGCompressedTexture::QSGCompressedTexture(const QTextureFileData &texData)
- : QSGTexture(*(new QSGCompressedTexturePrivate)),
+ : QSGTexture(*(new QSGTexturePrivate)),
m_textureData(texData)
{
m_size = m_textureData.size();
@@ -271,28 +271,26 @@ static QPair<QRhiTexture::Format, bool> toRhiCompressedFormat(uint glinternalfor
}
}
-QRhiTexture *QSGCompressedTexturePrivate::rhiTexture() const
+QRhiTexture *QSGCompressedTexture::rhiTexture() const
{
- Q_Q(const QSGCompressedTexture);
- return q->m_texture;
+ return m_texture;
}
-void QSGCompressedTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
+void QSGCompressedTexture::commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
{
- Q_Q(QSGCompressedTexture);
- if (q->m_uploaded)
+ if (m_uploaded)
return;
- q->m_uploaded = true; // even if fails, no point in trying again
+ m_uploaded = true; // even if fails, no point in trying again
- if (!q->m_textureData.isValid()) {
- qCDebug(QSG_LOG_TEXTUREIO, "Invalid texture data for %s", q->m_textureData.logName().constData());
+ if (!m_textureData.isValid()) {
+ qCDebug(QSG_LOG_TEXTUREIO, "Invalid texture data for %s", m_textureData.logName().constData());
return;
}
- const QPair<QRhiTexture::Format, bool> fmt = toRhiCompressedFormat(q->m_textureData.glInternalFormat());
+ const QPair<QRhiTexture::Format, bool> fmt = toRhiCompressedFormat(m_textureData.glInternalFormat());
if (fmt.first == QRhiTexture::UnknownFormat) {
- qWarning("Unknown compressed format 0x%x", q->m_textureData.glInternalFormat());
+ qWarning("Unknown compressed format 0x%x", m_textureData.glInternalFormat());
return;
}
@@ -301,25 +299,25 @@ void QSGCompressedTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdate
texFlags |= QRhiTexture::sRGB;
if (!rhi->isTextureFormatSupported(fmt.first, texFlags)) {
- qWarning("Unsupported compressed format 0x%x", q->m_textureData.glInternalFormat());
+ qWarning("Unsupported compressed format 0x%x", m_textureData.glInternalFormat());
return;
}
- if (!q->m_texture) {
- q->m_texture = rhi->newTexture(fmt.first, q->m_size, 1, texFlags);
- if (!q->m_texture->build()) {
+ if (!m_texture) {
+ m_texture = rhi->newTexture(fmt.first, m_size, 1, texFlags);
+ if (!m_texture->build()) {
qWarning("Failed to create QRhiTexture for compressed data");
- delete q->m_texture;
- q->m_texture = nullptr;
+ delete m_texture;
+ m_texture = nullptr;
return;
}
}
// only upload mip level 0 since we never do mipmapping for compressed textures (for now?)
- resourceUpdates->uploadTexture(q->m_texture, QRhiTextureUploadEntry(0, 0,
- { q->m_textureData.data().constData() + q->m_textureData.dataOffset(), q->m_textureData.dataLength() }));
+ resourceUpdates->uploadTexture(m_texture, QRhiTextureUploadEntry(0, 0,
+ { m_textureData.data().constData() + m_textureData.dataOffset(), m_textureData.dataLength() }));
- q->m_textureData = QTextureFileData(); // Release this memory, not needed anymore
+ m_textureData = QTextureFileData(); // Release this memory, not needed anymore
}
QTextureFileData QSGCompressedTexture::textureData() const
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h
index 084205c5b5..d584f0e2d4 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h
@@ -59,11 +59,8 @@
QT_BEGIN_NAMESPACE
-class QSGCompressedTexturePrivate;
-
class Q_QUICK_PRIVATE_EXPORT QSGCompressedTexture : public QSGTexture
{
- Q_DECLARE_PRIVATE(QSGCompressedTexture)
Q_OBJECT
public:
QSGCompressedTexture(const QTextureFileData& texData);
@@ -76,6 +73,8 @@ public:
int comparisonKey() const override;
int textureId() const override;
void bind() override;
+ QRhiTexture *rhiTexture() const override;
+ void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
QTextureFileData textureData() const;
@@ -94,14 +93,6 @@ namespace QSGOpenGLAtlasTexture {
class Manager;
}
-class QSGCompressedTexturePrivate : public QSGTexturePrivate
-{
- Q_DECLARE_PUBLIC(QSGCompressedTexture)
-public:
- QRhiTexture *rhiTexture() const override;
- void updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
-};
-
class Q_QUICK_PRIVATE_EXPORT QSGCompressedTextureFactory : public QQuickTextureFactory
{
public:
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index 81b9d96560..e5f8f81f21 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -3499,7 +3499,7 @@ void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms,
}
if (pd->textureBindingTable[binding] && pd->samplerBindingTable[binding]) {
- QRhiTexture *texture = QSGTexturePrivate::get(pd->textureBindingTable[binding])->rhiTexture();
+ QRhiTexture *texture = pd->textureBindingTable[binding]->rhiTexture();
// texture may be null if the update above failed for any reason,
// or if the QSGTexture chose to return null intentionally. This is
// valid and we still need to provide something to the shader.
diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp
index 00ba58d868..f7f49f3278 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture.cpp
+++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp
@@ -732,6 +732,24 @@ void QSGTexture::updateBindOptions(bool force) // legacy (GL-only)
}
/*!
+ \return the QRhiTexture for this QSGTexture or null if there is none (either
+ because a valid texture has not been created internally yet, or because the
+ concept is not applicable to the scenegraph backend in use).
+
+ This function is not expected to create a new QRhiTexture in case there is
+ none. Just return null in that case. The expectation towards the renderer
+ is that a null texture leads to using a transparent, dummy texture instead.
+
+ \warning This function can only be called from the rendering thread.
+
+ \since 6.0
+ */
+QRhiTexture *QSGTexture::rhiTexture() const
+{
+ return nullptr;
+}
+
+/*!
Call this function to enqueue image upload operations to \a
resourceUpdates, in case there are any pending ones. When there is no new
data (for example, because there was no setImage() since the last call to
@@ -740,17 +758,14 @@ void QSGTexture::updateBindOptions(bool force) // legacy (GL-only)
Materials involving \a rhi textures are expected to call this function from
their updateSampledImage() implementation, typically without any conditions.
- \note This function is only used when running the graphics API independent
- rendering path of the scene graph.
-
\warning This function can only be called from the rendering thread.
- \since 5.14
+ \since 6.0
*/
-void QSGTexture::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
+void QSGTexture::commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
{
- Q_D(QSGTexture);
- d->updateRhiTexture(rhi, resourceUpdates);
+ Q_UNUSED(rhi);
+ Q_UNUSED(resourceUpdates);
}
/*!
@@ -767,8 +782,7 @@ void QSGTexture::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUp
*/
QSGTexture::NativeTexture QSGTexture::nativeTexture() const
{
- Q_D(const QSGTexture);
- if (auto *tex = d->rhiTexture()) {
+ if (auto *tex = rhiTexture()) {
auto nativeTexture = tex->nativeTexture();
return {nativeTexture.object, nativeTexture.layout};
}
@@ -786,34 +800,6 @@ void QSGTexturePrivate::resetDirtySamplerOptions()
}
/*!
- \internal
-
- \return the QRhiTexture for this QSGTexture or null if there is none.
-
- Unlike textureId(), this function is not expected to create a new
- QRhiTexture in case there is none. Just return null in that case. The
- expectation towards the renderer is that a null texture leads to using a
- transparent, dummy texture instead.
-
- \note This function is only used when running the graphics API independent
- rendering path of the scene graph.
-
- \warning This function can only be called from the rendering thread.
-
- \since 5.14
- */
-QRhiTexture *QSGTexturePrivate::rhiTexture() const
-{
- return nullptr;
-}
-
-void QSGTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
-{
- Q_UNUSED(rhi);
- Q_UNUSED(resourceUpdates);
-}
-
-/*!
\class QSGDynamicTexture
\brief The QSGDynamicTexture class serves as a baseclass for dynamically changing textures,
such as content that is rendered to FBO's.
diff --git a/src/quick/scenegraph/coreapi/qsgtexture.h b/src/quick/scenegraph/coreapi/qsgtexture.h
index 0973f9b283..b0f01b1933 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture.h
+++ b/src/quick/scenegraph/coreapi/qsgtexture.h
@@ -87,6 +87,7 @@ public:
virtual int comparisonKey() const = 0;
virtual int textureId() const = 0; // ### Qt 6: remove
+ virtual QRhiTexture *rhiTexture() const;
NativeTexture nativeTexture() const;
virtual QSize textureSize() const = 0;
virtual bool hasAlphaChannel() const = 0;
@@ -101,6 +102,8 @@ public:
virtual void bind() = 0; // ### Qt 6: remove
void updateBindOptions(bool force = false); // ### Qt 6: remove
+ virtual void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates);
+
void setMipmapFiltering(Filtering filter);
QSGTexture::Filtering mipmapFiltering() const;
@@ -118,8 +121,6 @@ public:
inline QRectF convertToNormalizedSourceRect(const QRectF &rect) const;
- void updateRhiTexture(QRhi *rhi, 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 091cf43d8f..4a7af7ae4e 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture_p.h
+++ b/src/quick/scenegraph/coreapi/qsgtexture_p.h
@@ -83,11 +83,6 @@ public:
void resetDirtySamplerOptions();
bool hasDirtySamplerOptions() const;
- virtual QRhiTexture *rhiTexture() const;
-
- // ### Qt 6: should be virtual in the public class instead
- virtual void updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates);
-
uint wrapChanged : 1;
uint filteringChanged : 1;
uint anisotropyChanged : 1;
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index be6ef25feb..cfa645bfd0 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -451,8 +451,8 @@ bool QSGTextMaskRhiShader::updateUniformData(RenderState &state,
changed = true;
}
- QRhiTexture *oldRtex = oldMat ? QSGTexturePrivate::get(oldMat->texture())->rhiTexture() : nullptr;
- QRhiTexture *newRtex = QSGTexturePrivate::get(mat->texture())->rhiTexture();
+ QRhiTexture *oldRtex = oldMat ? oldMat->texture()->rhiTexture() : nullptr;
+ QRhiTexture *newRtex = mat->texture()->rhiTexture();
if (updated || !oldMat || oldRtex != newRtex) {
const QVector2D textureScale = QVector2D(1.0f / mat->rhiGlyphCache()->width(),
1.0f / mat->rhiGlyphCache()->height());
diff --git a/src/quick/scenegraph/qsgdefaultspritenode.cpp b/src/quick/scenegraph/qsgdefaultspritenode.cpp
index b2af09cc62..b179838576 100644
--- a/src/quick/scenegraph/qsgdefaultspritenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultspritenode.cpp
@@ -199,7 +199,7 @@ void SpriteMaterialRhiShader::updateSampledImage(RenderState &state, int binding
QQuickSpriteMaterial *mat = static_cast<QQuickSpriteMaterial *>(newMaterial);
QSGTexture *t = mat->texture;
- t->updateRhiTexture(state.rhi(), state.resourceUpdateBatch());
+ t->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
*texture = t;
}
diff --git a/src/quick/scenegraph/qsgrhilayer.cpp b/src/quick/scenegraph/qsgrhilayer.cpp
index 924c807989..5772ff3a3d 100644
--- a/src/quick/scenegraph/qsgrhilayer.cpp
+++ b/src/quick/scenegraph/qsgrhilayer.cpp
@@ -44,7 +44,7 @@
#include <private/qsgdefaultrendercontext_p.h>
QSGRhiLayer::QSGRhiLayer(QSGRenderContext *context)
- : QSGLayer(*(new QSGRhiLayerPrivate))
+ : QSGLayer(*(new QSGTexturePrivate))
, m_mipmap(false)
, m_live(true)
, m_recursive(false)
@@ -98,13 +98,12 @@ void QSGRhiLayer::bind()
Q_ASSERT_X(false, "QSGRhiLayer::bind()", "Not implemented for RHI");
}
-QRhiTexture *QSGRhiLayerPrivate::rhiTexture() const
+QRhiTexture *QSGRhiLayer::rhiTexture() const
{
- Q_Q(const QSGRhiLayer);
- return q->m_texture;
+ return m_texture;
}
-void QSGRhiLayerPrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
+void QSGRhiLayer::commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
{
Q_UNUSED(rhi);
Q_UNUSED(resourceUpdates);
diff --git a/src/quick/scenegraph/qsgrhilayer_p.h b/src/quick/scenegraph/qsgrhilayer_p.h
index f3a9ec5e9d..ba0567c737 100644
--- a/src/quick/scenegraph/qsgrhilayer_p.h
+++ b/src/quick/scenegraph/qsgrhilayer_p.h
@@ -58,12 +58,11 @@
QT_BEGIN_NAMESPACE
class QSGDefaultRenderContext;
-class QSGRhiLayerPrivate;
class Q_QUICK_PRIVATE_EXPORT QSGRhiLayer : public QSGLayer
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QSGRhiLayer)
+
public:
QSGRhiLayer(QSGRenderContext *context);
~QSGRhiLayer();
@@ -77,6 +76,8 @@ public:
void bind() override;
int textureId() const override;
int comparisonKey() const override;
+ QRhiTexture *rhiTexture() const override;
+ void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
void setItem(QSGNode *item) override;
void setRect(const QRectF &rect) override;
@@ -130,14 +131,6 @@ private:
uint m_mirrorVertical : 1;
};
-class QSGRhiLayerPrivate : public QSGTexturePrivate
-{
- Q_DECLARE_PUBLIC(QSGRhiLayer)
-public:
- QRhiTexture *rhiTexture() const override;
- void updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
-};
-
QT_END_NAMESPACE
#endif // QSGRHILAYER_P_H
diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
index 240966d29d..9ec9e040fb 100644
--- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp
+++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
@@ -393,7 +393,7 @@ void QSGRhiShaderEffectMaterialShader::updateSampledImage(RenderState &state, in
QSGTextureProvider *tp = mat->m_textureProviders.at(binding);
if (tp) {
if (QSGTexture *t = tp->texture()) {
- t->updateRhiTexture(state.rhi(), state.resourceUpdateBatch());
+ t->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
if (t->isAtlasTexture() && !mat->m_geometryUsesTextureSubRect) {
// Why the hassle with the batch: while removedFromAtlas() is
// able to operate with its own resource update batch (which is
@@ -419,7 +419,7 @@ void QSGRhiShaderEffectMaterialShader::updateSampledImage(RenderState &state, in
QImage img(128, 128, QImage::Format_ARGB32_Premultiplied);
img.fill(0);
mat->m_dummyTexture->setImage(img);
- mat->m_dummyTexture->updateRhiTexture(state.rhi(), state.resourceUpdateBatch());
+ mat->m_dummyTexture->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
}
*texture = mat->m_dummyTexture;
}
diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
index f15ea67b46..cd8426db97 100644
--- a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
+++ b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
#define QT_MINIMUM_DYNAMIC_FBO_SIZE 64U
QSGPainterTexture::QSGPainterTexture()
- : QSGPlainTexture(*(new QSGPainterTexturePrivate))
+ : QSGPlainTexture(*(new QSGPlainTexturePrivate))
{
m_retain_image = true;
}
@@ -73,14 +73,13 @@ void QSGPainterTexture::bind()
m_dirty_rect = QRect();
}
-void QSGPainterTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
+void QSGPainterTexture::commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
{
- Q_Q(QSGPainterTexture);
- if (!q->m_dirty_rect.isNull()) {
- q->setImage(q->m_image);
- q->m_dirty_rect = QRect();
+ if (!m_dirty_rect.isNull()) {
+ setImage(m_image);
+ m_dirty_rect = QRect();
}
- QSGPlainTexturePrivate::updateRhiTexture(rhi, resourceUpdates);
+ QSGPlainTexture::commitTextureOperations(rhi, resourceUpdates);
}
QSGDefaultPainterNode::QSGDefaultPainterNode(QQuickPaintedItem *item)
diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode_p.h b/src/quick/scenegraph/util/qsgdefaultpainternode_p.h
index dc103648ff..b2402dc70e 100644
--- a/src/quick/scenegraph/util/qsgdefaultpainternode_p.h
+++ b/src/quick/scenegraph/util/qsgdefaultpainternode_p.h
@@ -64,29 +64,21 @@ QT_BEGIN_NAMESPACE
class QOpenGLFramebufferObject;
class QOpenGLPaintDevice;
class QSGDefaultRenderContext;
-class QSGPainterTexturePrivate;
class Q_QUICK_PRIVATE_EXPORT QSGPainterTexture : public QSGPlainTexture
{
- Q_DECLARE_PRIVATE(QSGPainterTexture)
public:
QSGPainterTexture();
void setDirtyRect(const QRect &rect) { m_dirty_rect = rect; }
void bind() override;
+ void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
private:
QRect m_dirty_rect;
};
-class QSGPainterTexturePrivate : public QSGPlainTexturePrivate
-{
- Q_DECLARE_PUBLIC(QSGPainterTexture)
-public:
- void updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
-};
-
class Q_QUICK_PRIVATE_EXPORT QSGDefaultPainterNode : public QSGPainterNode
{
public:
diff --git a/src/quick/scenegraph/util/qsgplaintexture.cpp b/src/quick/scenegraph/util/qsgplaintexture.cpp
index 45018de872..037cf8c254 100644
--- a/src/quick/scenegraph/util/qsgplaintexture.cpp
+++ b/src/quick/scenegraph/util/qsgplaintexture.cpp
@@ -317,66 +317,65 @@ int QSGPlainTexture::comparisonKey() const
return int(qintptr(this));
}
-QRhiTexture *QSGPlainTexturePrivate::rhiTexture() const
+QRhiTexture *QSGPlainTexture::rhiTexture() const
{
- Q_Q(const QSGPlainTexture);
- return q->m_texture;
+ return m_texture;
}
-void QSGPlainTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
+void QSGPlainTexture::commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
{
- Q_Q(QSGPlainTexture);
+ Q_D(QSGPlainTexture);
- const bool hasMipMaps = q->mipmapFiltering() != QSGTexture::None;
- const bool mipmappingChanged = q->m_texture && ((hasMipMaps && !q->m_texture->flags().testFlag(QRhiTexture::MipMapped)) // did not have it before
- || (!hasMipMaps && q->m_texture->flags().testFlag(QRhiTexture::MipMapped))); // does not have it anymore
+ const bool hasMipMaps = mipmapFiltering() != QSGTexture::None;
+ const bool mipmappingChanged = m_texture && ((hasMipMaps && !m_texture->flags().testFlag(QRhiTexture::MipMapped)) // did not have it before
+ || (!hasMipMaps && m_texture->flags().testFlag(QRhiTexture::MipMapped))); // does not have it anymore
- if (!q->m_dirty_texture) {
- if (!q->m_texture)
+ if (!m_dirty_texture) {
+ if (!m_texture)
return;
- if (q->m_texture && !mipmappingChanged) {
- if (hasMipMaps && !q->m_mipmaps_generated) {
- resourceUpdates->generateMips(q->m_texture);
- q->m_mipmaps_generated = true;
+ if (m_texture && !mipmappingChanged) {
+ if (hasMipMaps && !m_mipmaps_generated) {
+ resourceUpdates->generateMips(m_texture);
+ m_mipmaps_generated = true;
}
return;
}
}
- if (q->m_image.isNull()) {
- if (!q->m_dirty_texture && mipmappingChanged) {
+ if (m_image.isNull()) {
+ if (!m_dirty_texture && mipmappingChanged) {
// Full Mipmap Panic!
- if (!q->m_mipmap_warned) {
+ if (!m_mipmap_warned) {
qWarning("QSGPlainTexture: Mipmap settings changed without having image data available. "
"Call setImage() again or enable m_retain_image. "
"Falling back to previous mipmap filtering mode.");
- q->m_mipmap_warned = true;
+ m_mipmap_warned = true;
}
// leave the texture valid and rather ignore the mipmap mode change attempt
- q->setMipmapFiltering(m_last_mipmap_filter);
+ setMipmapFiltering(d->m_last_mipmap_filter);
return;
}
- if (q->m_texture && q->m_owns_texture)
- delete q->m_texture;
+ if (m_texture && m_owns_texture)
+ delete m_texture;
- q->m_texture = nullptr;
- q->m_texture_size = QSize();
- q->m_has_alpha = false;
+ m_texture = nullptr;
+ m_texture_size = QSize();
+ m_has_alpha = false;
- q->m_dirty_texture = false;
+ m_dirty_texture = false;
return;
}
- q->m_dirty_texture = false;
+ m_dirty_texture = false;
QImage tmp;
bool bgra = false;
bool needsConvert = false;
- if (q->m_image.format() == QImage::Format_RGB32 || q->m_image.format() == QImage::Format_ARGB32_Premultiplied) {
+ if (m_image.format() == QImage::Format_RGB32 || m_image.format() == QImage::Format_ARGB32_Premultiplied) {
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
if (rhi->isTextureFormatSupported(QRhiTexture::BGRA8)) {
- tmp = q->m_image;
+ tmp = m_image;
bgra = true;
} else {
needsConvert = true;
@@ -384,14 +383,14 @@ void QSGPlainTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch
#else
needsConvert = true;
#endif
- } else if (q->m_image.format() == QImage::Format_RGBX8888 || q->m_image.format() == QImage::Format_RGBA8888_Premultiplied) {
- tmp = q->m_image;
+ } else if (m_image.format() == QImage::Format_RGBX8888 || m_image.format() == QImage::Format_RGBA8888_Premultiplied) {
+ tmp = m_image;
} else {
needsConvert = true;
}
if (needsConvert)
- tmp = q->m_image.convertToFormat(QImage::Format_RGBA8888_Premultiplied);
+ tmp = m_image.convertToFormat(QImage::Format_RGBA8888_Premultiplied);
// Downscale the texture to fit inside the max texture limit if it is too big.
// It would be better if the image was already downscaled to the right size,
@@ -403,45 +402,45 @@ void QSGPlainTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch
const int max = rhi->resourceLimit(QRhi::TextureSizeMax);
if (tmp.width() > max || tmp.height() > max) {
tmp = tmp.scaled(qMin(max, tmp.width()), qMin(max, tmp.height()), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- q->m_texture_size = tmp.size();
+ m_texture_size = tmp.size();
}
- if ((q->mipmapFiltering() != QSGTexture::None
- || q->horizontalWrapMode() != QSGTexture::ClampToEdge
- || q->verticalWrapMode() != QSGTexture::ClampToEdge)
+ if ((mipmapFiltering() != QSGTexture::None
+ || horizontalWrapMode() != QSGTexture::ClampToEdge
+ || verticalWrapMode() != QSGTexture::ClampToEdge)
&& !rhi->isFeatureSupported(QRhi::NPOTTextureRepeat))
{
const int w = qNextPowerOfTwo(tmp.width() - 1);
const int h = qNextPowerOfTwo(tmp.height() - 1);
if (tmp.width() != w || tmp.height() != h) {
tmp = tmp.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- q->m_texture_size = tmp.size();
+ m_texture_size = tmp.size();
}
}
- bool needsRebuild = q->m_texture && q->m_texture->pixelSize() != q->m_texture_size;
+ bool needsRebuild = m_texture && m_texture->pixelSize() != m_texture_size;
if (mipmappingChanged) {
- QRhiTexture::Flags f = q->m_texture->flags();
+ QRhiTexture::Flags f = m_texture->flags();
f.setFlag(QRhiTexture::MipMapped, hasMipMaps);
f.setFlag(QRhiTexture::UsedWithGenerateMips, hasMipMaps);
- q->m_texture->setFlags(f);
+ m_texture->setFlags(f);
needsRebuild = true;
}
- if (!q->m_texture) {
+ if (!m_texture) {
QRhiTexture::Flags f;
if (hasMipMaps)
f |= QRhiTexture::MipMapped | QRhiTexture::UsedWithGenerateMips;
- q->m_texture = rhi->newTexture(bgra ? QRhiTexture::BGRA8 : QRhiTexture::RGBA8, q->m_texture_size, 1, f);
+ m_texture = rhi->newTexture(bgra ? QRhiTexture::BGRA8 : QRhiTexture::RGBA8, m_texture_size, 1, f);
needsRebuild = true;
}
if (needsRebuild) {
- if (!q->m_texture->build()) {
+ if (!m_texture->build()) {
qWarning("Failed to build texture for QSGPlainTexture (size %dx%d)",
- q->m_texture_size.width(), q->m_texture_size.height());
+ m_texture_size.width(), m_texture_size.height());
return;
}
}
@@ -449,18 +448,18 @@ void QSGPlainTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch
if (tmp.width() * 4 != tmp.bytesPerLine())
tmp = tmp.copy();
- resourceUpdates->uploadTexture(q->m_texture, tmp);
+ resourceUpdates->uploadTexture(m_texture, tmp);
if (hasMipMaps) {
- resourceUpdates->generateMips(q->m_texture);
- q->m_mipmaps_generated = true;
+ resourceUpdates->generateMips(m_texture);
+ m_mipmaps_generated = true;
}
- m_last_mipmap_filter = q->mipmapFiltering();
- q->m_texture_rect = QRectF(0, 0, 1, 1);
+ d->m_last_mipmap_filter = mipmapFiltering();
+ m_texture_rect = QRectF(0, 0, 1, 1);
- if (!q->m_retain_image)
- q->m_image = QImage();
+ if (!m_retain_image)
+ m_image = QImage();
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgplaintexture_p.h b/src/quick/scenegraph/util/qsgplaintexture_p.h
index 4ef9f0ce0a..4bde505ec4 100644
--- a/src/quick/scenegraph/util/qsgplaintexture_p.h
+++ b/src/quick/scenegraph/util/qsgplaintexture_p.h
@@ -87,6 +87,9 @@ public:
void bind() override;
+ QRhiTexture *rhiTexture() const override;
+ void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
+
void setTexture(QRhiTexture *texture);
void setTextureFromNativeObject(QRhi *rhi, QQuickWindow::NativeObjectType type,
const void *nativeObjectPtr, int nativeLayout,
@@ -121,9 +124,6 @@ class QSGPlainTexturePrivate : public QSGTexturePrivate
{
Q_DECLARE_PUBLIC(QSGPlainTexture)
public:
- QRhiTexture *rhiTexture() const override;
- void updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
-
QSGTexture::Filtering m_last_mipmap_filter = QSGTexture::None;
};
diff --git a/src/quick/scenegraph/util/qsgrhiatlastexture.cpp b/src/quick/scenegraph/util/qsgrhiatlastexture.cpp
index 75577a9bd8..172cfc4791 100644
--- a/src/quick/scenegraph/util/qsgrhiatlastexture.cpp
+++ b/src/quick/scenegraph/util/qsgrhiatlastexture.cpp
@@ -184,7 +184,7 @@ void AtlasBase::invalidate()
m_texture = nullptr;
}
-void AtlasBase::updateRhiTexture(QRhiResourceUpdateBatch *resourceUpdates)
+void AtlasBase::commitTextureOperations(QRhiResourceUpdateBatch *resourceUpdates)
{
if (!m_allocated) {
m_allocated = true;
@@ -381,7 +381,7 @@ void Atlas::enqueueTextureUpload(TextureBase *t, QRhiResourceUpdateBatch *resour
}
TextureBase::TextureBase(AtlasBase *atlas, const QRect &textureRect)
- : QSGTexture(*(new TextureBasePrivate))
+ : QSGTexture(*(new QSGTexturePrivate))
, m_allocated_rect(textureRect)
, m_atlas(atlas)
{
@@ -405,20 +405,18 @@ int TextureBase::comparisonKey() const
return int(qintptr(m_atlas));
}
-QRhiTexture *TextureBasePrivate::rhiTexture() const
+QRhiTexture *TextureBase::rhiTexture() const
{
- Q_Q(const TextureBase);
- return q->m_atlas->m_texture;
+ return m_atlas->m_texture;
}
-void TextureBasePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
+void TextureBase::commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates)
{
- Q_Q(TextureBase);
#ifdef QT_NO_DEBUG
Q_UNUSED(rhi);
#endif
- Q_ASSERT(rhi == q->m_atlas->m_rhi);
- q->m_atlas->updateRhiTexture(resourceUpdates);
+ Q_ASSERT(rhi == m_atlas->m_rhi);
+ m_atlas->commitTextureOperations(resourceUpdates);
}
Texture::Texture(Atlas *atlas, const QRect &textureRect, const QImage &image)
diff --git a/src/quick/scenegraph/util/qsgrhiatlastexture_p.h b/src/quick/scenegraph/util/qsgrhiatlastexture_p.h
index fb8d5257d1..739498f137 100644
--- a/src/quick/scenegraph/util/qsgrhiatlastexture_p.h
+++ b/src/quick/scenegraph/util/qsgrhiatlastexture_p.h
@@ -71,7 +71,6 @@ namespace QSGRhiAtlasTexture
class Texture;
class TextureBase;
-class TextureBasePrivate;
class Atlas;
class Manager : public QObject
@@ -105,7 +104,7 @@ public:
~AtlasBase();
void invalidate();
- void updateRhiTexture(QRhiResourceUpdateBatch *resourceUpdates);
+ void commitTextureOperations(QRhiResourceUpdateBatch *resourceUpdates);
void remove(TextureBase *t);
QSGDefaultRenderContext *renderContext() const { return m_rc; }
@@ -153,7 +152,6 @@ private:
class TextureBase : public QSGTexture
{
- Q_DECLARE_PRIVATE(TextureBase)
Q_OBJECT
public:
TextureBase(AtlasBase *atlas, const QRect &textureRect);
@@ -162,6 +160,8 @@ public:
int comparisonKey() const override;
int textureId() const override { return 0; } // not used
void bind() override { } // not used
+ QRhiTexture *rhiTexture() const override;
+ void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
bool isAtlasTexture() const override { return true; }
QRect atlasSubRect() const { return m_allocated_rect; }
@@ -171,14 +171,6 @@ protected:
AtlasBase *m_atlas;
};
-class TextureBasePrivate : public QSGTexturePrivate
-{
- Q_DECLARE_PUBLIC(TextureBase)
-public:
- QRhiTexture *rhiTexture() const override;
- void updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
-};
-
class Texture : public TextureBase
{
Q_OBJECT
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp
index b4ac0c4d1d..e6311fc652 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp
@@ -168,7 +168,7 @@ void QSGOpaqueTextureMaterialRhiShader::updateSampledImage(RenderState &state, i
}
}
- t->updateRhiTexture(state.rhi(), state.resourceUpdateBatch());
+ t->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
*texture = t;
}
diff --git a/src/quickshapes/qquickshapegenericrenderer.cpp b/src/quickshapes/qquickshapegenericrenderer.cpp
index 50cdc60d52..9fbff8fdda 100644
--- a/src/quickshapes/qquickshapegenericrenderer.cpp
+++ b/src/quickshapes/qquickshapegenericrenderer.cpp
@@ -852,7 +852,7 @@ void QQuickShapeLinearGradientRhiShader::updateSampledImage(RenderState &state,
QQuickShapeGenericStrokeFillNode *node = m->node();
const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, node->m_fillGradient.spread);
QSGTexture *t = QQuickShapeGradientCache::cacheForRhi(state.rhi())->get(cacheKey);
- t->updateRhiTexture(state.rhi(), state.resourceUpdateBatch());
+ t->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
*texture = t;
}
@@ -1044,7 +1044,7 @@ void QQuickShapeRadialGradientRhiShader::updateSampledImage(RenderState &state,
QQuickShapeGenericStrokeFillNode *node = m->node();
const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, node->m_fillGradient.spread);
QSGTexture *t = QQuickShapeGradientCache::cacheForRhi(state.rhi())->get(cacheKey);
- t->updateRhiTexture(state.rhi(), state.resourceUpdateBatch());
+ t->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
*texture = t;
}
@@ -1218,7 +1218,7 @@ void QQuickShapeConicalGradientRhiShader::updateSampledImage(RenderState &state,
QQuickShapeGenericStrokeFillNode *node = m->node();
const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, node->m_fillGradient.spread);
QSGTexture *t = QQuickShapeGradientCache::cacheForRhi(state.rhi())->get(cacheKey);
- t->updateRhiTexture(state.rhi(), state.resourceUpdateBatch());
+ t->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
*texture = t;
}