summaryrefslogtreecommitdiff
path: root/src/compositor/compositor_api/qwaylandquickitem.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-08-13 08:13:57 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-08-31 15:19:50 +0200
commit307a82a2de4de48cae05a6aed26c7310d5325d12 (patch)
treec6f296a292595d226ca9aa10fb6f7190d31d96e2 /src/compositor/compositor_api/qwaylandquickitem.cpp
parent3ff4cd600454d1589228aeb68230336d6b721839 (diff)
downloadqtwayland-307a82a2de4de48cae05a6aed26c7310d5325d12.tar.gz
Keep reference to buffer until it has been replaced
For the code path which uses QWaylandBufferMaterial, the buffer could potentially be deleted before the material had been updated, which could cause issues if the render thread was currently using the textures. In the default code path this was handled by keeping a reference to the buffer in the texture provider, but in the alternative YUV format code path, we did not increase the reference count of the buffer, so it would be deleted immediately when it was replaced rather than wait for the sync with the render thread. Task-number: QTBUG-95715 Change-Id: Ic6038ea8281e2a2e292d12150d1fffedb5c3b76e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> (cherry picked from commit 6b9a27d77e226a3d0ce9fa9b4974f70c9ef4a30e)
Diffstat (limited to 'src/compositor/compositor_api/qwaylandquickitem.cpp')
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index 95bf0f91..3064a20e 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -253,6 +253,16 @@ void QWaylandBufferMaterial::ensureTextures(int count)
m_textures << nullptr;
}
}
+
+void QWaylandBufferMaterial::setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref)
+{
+ Q_UNUSED(surfaceItem);
+ m_bufferRef = ref;
+ for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++)
+ if (auto texture = ref.toOpenGLTexture(plane))
+ setTextureForPlane(plane, texture);
+ bind();
+}
#endif // QT_CONFIG(opengl)
QMutex *QWaylandQuickItemPrivate::mutex = nullptr;
@@ -1411,10 +1421,7 @@ 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);
- material->bind();
+ material->setBufferRef(this, ref);
}
const QSize surfaceSize = ref.size() / surface()->bufferScale();