aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/compressedtexture
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/quick/scenegraph/compressedtexture
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/quick/scenegraph/compressedtexture')
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp40
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h13
2 files changed, 21 insertions, 32 deletions
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: