summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-06-23 12:43:50 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-09-14 07:02:18 +0200
commit614252bcba29e5ac4909869b5dac00aee2dec778 (patch)
tree051d21f1eae98cf0f8333fdaebe5c622c0cd50bf
parentb676e4b7ecbc047d2ddd090bcf5803cfb3ee3699 (diff)
QWaylandQuickItem: Fix buffer formats with multiple planes
We create the QSGTexture at the same time as the OpenGLTexture and store it in the material for later updates. Task-number: QTBUG-78673 Change-Id: I09a0e073f538934798cb80e1ff98d1d786225c89 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp38
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem_p.h6
2 files changed, 33 insertions, 11 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index bffa358b2..93fa97b0d 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -167,17 +167,16 @@ void QWaylandBufferMaterialShader::updateSampledImage(RenderState &state, int bi
{
Q_UNUSED(state);
- QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(newMaterial); //###@@@???
- Q_UNUSED(material);
+ QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(newMaterial);
switch (binding) {
case 1:
- // *texture = ?? where do we get a QSGTexture wrapping the QOpenGLTexture's underlying texture from?
+ *texture = material->m_scenegraphTextures.at(0);
break;
case 2:
- // *texture = ??
+ *texture = material->m_scenegraphTextures.at(1);
break;
case 3:
- // *texture = ??
+ *texture = material->m_scenegraphTextures.at(2);
break;
default:
return;
@@ -198,9 +197,12 @@ QWaylandBufferMaterial::QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEg
QWaylandBufferMaterial::~QWaylandBufferMaterial()
{
+ qDeleteAll(m_scenegraphTextures);
}
-void QWaylandBufferMaterial::setTextureForPlane(int plane, QOpenGLTexture *texture)
+void QWaylandBufferMaterial::setTextureForPlane(int plane,
+ QOpenGLTexture *texture,
+ QSGTexture *scenegraphTexture)
{
if (plane < 0 || plane >= bufferTypes[m_format].planeCount) {
qWarning("plane index is out of range");
@@ -212,10 +214,15 @@ void QWaylandBufferMaterial::setTextureForPlane(int plane, QOpenGLTexture *textu
ensureTextures(plane - 1);
- if (m_textures.size() <= plane)
+ if (m_textures.size() <= plane) {
m_textures << texture;
- else
+ m_scenegraphTextures << scenegraphTexture;
+ } else {
+ delete m_scenegraphTextures[plane];
+
m_textures[plane] = texture;
+ m_scenegraphTextures[plane] = scenegraphTexture;
+ }
}
void QWaylandBufferMaterial::bind()
@@ -263,6 +270,7 @@ void QWaylandBufferMaterial::ensureTextures(int count)
{
for (int plane = m_textures.size(); plane < count; plane++) {
m_textures << nullptr;
+ m_scenegraphTextures << nullptr;
}
}
#endif // QT_CONFIG(opengl)
@@ -1379,8 +1387,18 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat
if (d->newTexture) {
d->newTexture = false;
for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++)
- if (auto texture = ref.toOpenGLTexture(plane))
- material->setTextureForPlane(plane, texture);
+ if (auto texture = ref.toOpenGLTexture(plane)) {
+ QQuickWindow::CreateTextureOptions opt;
+ QWaylandQuickSurface *waylandSurface = qobject_cast<QWaylandQuickSurface *>(surface());
+ if (waylandSurface != nullptr && waylandSurface->useTextureAlpha())
+ opt |= QQuickWindow::TextureHasAlphaChannel;
+ QSGTexture *scenegraphTexture = QPlatformInterface::QSGOpenGLTexture::fromNative(texture->textureId(),
+ window(),
+ ref.size(),
+ opt);
+ scenegraphTexture->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest);
+ material->setTextureForPlane(plane, texture, scenegraphTexture);
+ }
material->bind();
}
diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h
index 6ee267f75..4ee3ca056 100644
--- a/src/compositor/compositor_api/qwaylandquickitem_p.h
+++ b/src/compositor/compositor_api/qwaylandquickitem_p.h
@@ -75,19 +75,23 @@ public:
QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEgl format);
~QWaylandBufferMaterial() override;
- void setTextureForPlane(int plane, QOpenGLTexture *texture);
+ void setTextureForPlane(int plane, QOpenGLTexture *texture, QSGTexture *scenegraphTexture);
void bind();
+ void updateScenegraphTextures(QRhi *rhi);
QSGMaterialType *type() const override;
QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
private:
+ friend QWaylandBufferMaterialShader;
+
void setTextureParameters(GLenum target);
void ensureTextures(int count);
const QWaylandBufferRef::BufferFormatEgl m_format;
QVarLengthArray<QOpenGLTexture*, 3> m_textures;
+ QVarLengthArray<QSGTexture*, 3> m_scenegraphTextures;
};
#endif // QT_CONFIG(opengl)