From a3f5d4310010dd6fb2f4d1359d0490cbc31c783f Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 27 Nov 2020 01:24:16 +0000 Subject: [PATCH] screencating: query for dmabuf availability before we start streaming As things are right now, we can only do 32bit textures for dmabuf (see gbm_bo_format in gbm.h). This means that we were lying to our receivers when we had 24bit textures by then giving a 32bit texture instead. This changes it so we request a dummy texture before starting and if we are offered one we assume they're available and offer a 32bits stream directly (i.e. BGRA). (cherry picked from commit cea2781318c9a24b25d3f4a43e2efccc32a5e371) --- screencast/pipewirestream.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/screencast/pipewirestream.cpp b/screencast/pipewirestream.cpp index 4a376bbf1e..ff813b7c45 100644 --- a/screencast/pipewirestream.cpp +++ b/screencast/pipewirestream.cpp @@ -235,7 +235,10 @@ bool PipeWireStream::createStream() spa_rectangle resolution = SPA_RECTANGLE(uint32_t(m_resolution.width()), uint32_t(m_resolution.height())); - const auto format = m_hasAlpha ? SPA_VIDEO_FORMAT_BGRA : SPA_VIDEO_FORMAT_BGR; + auto canCreateDmaBuf = [this] () -> bool { + return QSharedPointer(kwinApp()->platform()->createDmaBufTexture(m_resolution)); + }; + const auto format = m_hasAlpha || canCreateDmaBuf() ? SPA_VIDEO_FORMAT_BGRA : SPA_VIDEO_FORMAT_BGR; const spa_pod *param = (spa_pod*)spa_pod_builder_add_object(&podBuilder, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,