diff options
-rw-r--r-- | src/compositor/compositor_api/qwaylandquickitem.cpp | 52 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandquickitem_p.h | 2 |
2 files changed, 32 insertions, 22 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index ecaf4e67f..eb326a294 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -361,6 +361,35 @@ void QWaylandBufferMaterial::ensureTextures(int count) m_scenegraphTextures << nullptr; } } + +void QWaylandBufferMaterial::setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref) +{ + m_bufferRef = ref; + for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++) { + if (auto texture = ref.toOpenGLTexture(plane)) { + QQuickWindow::CreateTextureOptions opt; + QWaylandQuickSurface *waylandSurface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface()); + if (waylandSurface != nullptr && waylandSurface->useTextureAlpha()) + opt |= QQuickWindow::TextureHasAlphaChannel; + QSGTexture *scenegraphTexture; + if (ref.bufferFormatEgl() == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES) { + scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNativeExternalOES(texture->textureId(), + surfaceItem->window(), + ref.size(), + opt); + } else { + scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNative(texture->textureId(), + surfaceItem->window(), + ref.size(), + opt); + } + scenegraphTexture->setFiltering(surfaceItem->smooth() ? QSGTexture::Linear : QSGTexture::Nearest); + setTextureForPlane(plane, texture, scenegraphTexture); + } + } + + bind(); +} #endif // QT_CONFIG(opengl) QMutex *QWaylandQuickItemPrivate::mutex = nullptr; @@ -1503,28 +1532,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)) { - QQuickWindow::CreateTextureOptions opt; - QWaylandQuickSurface *waylandSurface = qobject_cast<QWaylandQuickSurface *>(surface()); - if (waylandSurface != nullptr && waylandSurface->useTextureAlpha()) - opt |= QQuickWindow::TextureHasAlphaChannel; - QSGTexture *scenegraphTexture; - if (ref.bufferFormatEgl() == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES) { - scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNativeExternalOES(texture->textureId(), - window(), - ref.size(), - opt); - } else { - scenegraphTexture = QNativeInterface::QSGOpenGLTexture::fromNative(texture->textureId(), - window(), - ref.size(), - opt); - } - scenegraphTexture->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest); - material->setTextureForPlane(plane, texture, scenegraphTexture); - } - material->bind(); + material->setBufferRef(this, ref); } const QSize surfaceSize = ref.size() / surface()->bufferScale(); diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index 34acdeab7..09b9f6785 100644 --- a/src/compositor/compositor_api/qwaylandquickitem_p.h +++ b/src/compositor/compositor_api/qwaylandquickitem_p.h @@ -77,6 +77,7 @@ public: ~QWaylandBufferMaterial() override; void setTextureForPlane(int plane, QOpenGLTexture *texture, QSGTexture *scenegraphTexture); + void setBufferRef(QWaylandQuickItem *surfaceItem, const QWaylandBufferRef &ref); void bind(); void updateScenegraphTextures(QRhi *rhi); @@ -93,6 +94,7 @@ private: const QWaylandBufferRef::BufferFormatEgl m_format; QVarLengthArray<QOpenGLTexture*, 3> m_textures; QVarLengthArray<QSGTexture*, 3> m_scenegraphTextures; + QWaylandBufferRef m_bufferRef; }; #endif // QT_CONFIG(opengl) |