summaryrefslogtreecommitdiffstats
path: root/src/core/render_widget_host_view_qt_delegate_item.cpp
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2022-10-27 14:33:16 +0200
committerPeter Varga <pvarga@inf.u-szeged.hu>2022-11-10 09:42:16 +0100
commitb32f5e5b495ef73f25d3156d24a83fffd33f02be (patch)
tree5651504ad55f3609163c85879e0ac6d726c6db27 /src/core/render_widget_host_view_qt_delegate_item.cpp
parent6fb80f47941b555f1a9455d3bd3d189b90092b60 (diff)
Add Vulkan rendering support
Updates 3rdparty: * 8b7ce4ef70d Make GrVkImage external Task-number: QTBUG-107669 Change-Id: If7fbe1f20538598dd1d4f3a67be17c9f7d06a3cd Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/render_widget_host_view_qt_delegate_item.cpp')
-rw-r--r--src/core/render_widget_host_view_qt_delegate_item.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/core/render_widget_host_view_qt_delegate_item.cpp b/src/core/render_widget_host_view_qt_delegate_item.cpp
index a44046aac..f90a201b6 100644
--- a/src/core/render_widget_host_view_qt_delegate_item.cpp
+++ b/src/core/render_widget_host_view_qt_delegate_item.cpp
@@ -29,6 +29,7 @@ RenderWidgetHostViewQtDelegateItem::RenderWidgetHostViewQtDelegateItem(RenderWid
RenderWidgetHostViewQtDelegateItem::~RenderWidgetHostViewQtDelegateItem()
{
+ releaseVulkanResources();
if (m_widgetDelegate) {
m_widgetDelegate->Unbind();
m_widgetDelegate->Destroy();
@@ -315,6 +316,12 @@ void RenderWidgetHostViewQtDelegateItem::itemChange(ItemChange change, const Ite
this, &RenderWidgetHostViewQtDelegateItem::onBeforeRendering, Qt::DirectConnection));
m_windowConnections.append(connect(value.window, SIGNAL(xChanged(int)), SLOT(onWindowPosChanged())));
m_windowConnections.append(connect(value.window, SIGNAL(yChanged(int)), SLOT(onWindowPosChanged())));
+#if QT_CONFIG(webengine_vulkan)
+ m_windowConnections.append(
+ connect(value.window, &QQuickWindow::sceneGraphAboutToStop, this,
+ &RenderWidgetHostViewQtDelegateItem::releaseVulkanResources,
+ Qt::DirectConnection));
+#endif
if (!m_isPopup)
m_windowConnections.append(connect(value.window, SIGNAL(closing(QQuickCloseEvent *)), SLOT(onHide())));
}
@@ -362,6 +369,18 @@ QSGNode *RenderWidgetHostViewQtDelegateItem::updatePaintNode(QSGNode *oldNode, U
node->setTexture(QNativeInterface::QSGOpenGLTexture::fromNative(texId, win, texSize, texOpts));
node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
#endif
+#if QT_CONFIG(webengine_vulkan)
+ } else if (comp->type() == Compositor::Type::Vulkan) {
+ QQuickWindow::CreateTextureOptions texOpts;
+ if (comp->hasAlphaChannel())
+ texOpts.setFlag(QQuickWindow::TextureHasAlphaChannel);
+
+ VkImage image = comp->vkImage(win);
+ VkImageLayout layout = comp->vkImageLayout();
+ node->setTexture(QNativeInterface::QSGVulkanTexture::fromNative(image, layout, win, texSize,
+ texOpts));
+ node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
+#endif // QT_CONFIG(webengine_vulkan)
} else {
Q_UNREACHABLE();
}
@@ -372,7 +391,7 @@ QSGNode *RenderWidgetHostViewQtDelegateItem::updatePaintNode(QSGNode *oldNode, U
void RenderWidgetHostViewQtDelegateItem::onBeforeRendering()
{
auto comp = compositor();
- if (!comp || comp->type() != Compositor::Type::OpenGL)
+ if (!comp || comp->type() == Compositor::Type::Software)
return;
comp->waitForTexture();
}
@@ -388,6 +407,17 @@ void RenderWidgetHostViewQtDelegateItem::onHide()
m_client->forwardEvent(&event);
}
+void RenderWidgetHostViewQtDelegateItem::releaseVulkanResources()
+{
+#if QT_CONFIG(webengine_vulkan)
+ auto comp = compositor();
+ if (!comp || comp->type() != Compositor::Type::Vulkan)
+ return;
+
+ comp->releaseVulkanResources(QQuickItem::window());
+#endif
+}
+
void RenderWidgetHostViewQtDelegateItem::adapterClientChanged(WebContentsAdapterClient *client)
{
m_adapterClient = client;