From 769a6403d482e8970c26303c80178cd00207163f Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Feb 15 2024 13:31:01 +0000 Subject: Backport patch to fix window screencasts being vertically mirrored --- diff --git a/kwin-fix-window-screencasts-being-vertically-mirrored-with-memfd.patch b/kwin-fix-window-screencasts-being-vertically-mirrored-with-memfd.patch new file mode 100644 index 0000000..7e9619b --- /dev/null +++ b/kwin-fix-window-screencasts-being-vertically-mirrored-with-memfd.patch @@ -0,0 +1,87 @@ +From a8123ff65ec552034611f3ceb38e1bcbe94d7452 Mon Sep 17 00:00:00 2001 +From: Vlad Zahorodnii +Date: Thu, 15 Feb 2024 10:54:20 +0200 +Subject: [PATCH 1/2] plugins/screencast: Fix window screencasts being + vertically mirrored with memfd + +WindowScreenCastSource::render(GLFramebuffer) renders windows with the y +axis flipped, but the offscreen has no FlipY flag set. + +BUG: 478223 +--- + src/plugins/screencast/windowscreencastsource.cpp | 13 +++++-------- + 1 file changed, 5 insertions(+), 8 deletions(-) + +diff --git a/src/plugins/screencast/windowscreencastsource.cpp b/src/plugins/screencast/windowscreencastsource.cpp +index a9dc8a4af75..f3acbeb9ba9 100644 +--- a/src/plugins/screencast/windowscreencastsource.cpp ++++ b/src/plugins/screencast/windowscreencastsource.cpp +@@ -52,24 +52,21 @@ void WindowScreenCastSource::render(spa_data *spa, spa_video_format format) + if (!offscreenTexture) { + return; + } +- GLFramebuffer offscreenTarget(offscreenTexture.get()); ++ offscreenTexture->setContentTransform(OutputTransform::FlipY); + ++ GLFramebuffer offscreenTarget(offscreenTexture.get()); + render(&offscreenTarget); + grabTexture(offscreenTexture.get(), spa, format); + } + + void WindowScreenCastSource::render(GLFramebuffer *target) + { +- const QRectF geometry = m_window->clientGeometry(); +- QMatrix4x4 projectionMatrix; +- projectionMatrix.scale(1, -1); +- projectionMatrix.ortho(geometry); ++ RenderTarget renderTarget(target); ++ RenderViewport viewport(m_window->clientGeometry(), 1, renderTarget); + + WindowPaintData data; +- data.setProjectionMatrix(projectionMatrix); ++ data.setProjectionMatrix(viewport.projectionMatrix()); + +- RenderTarget renderTarget(target); +- RenderViewport viewport(geometry, 1, renderTarget); + GLFramebuffer::pushFramebuffer(target); + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); +-- +GitLab + + +From 9a006a820e3e9e0a9726f98cea1491973d91d4fc Mon Sep 17 00:00:00 2001 +From: Vlad Zahorodnii +Date: Thu, 15 Feb 2024 10:55:23 +0200 +Subject: [PATCH 2/2] plugins/screencast: Make region screen cast nicer to + memfd + +Set the FlipY flag so when the memfd code grabs the texture contents, it +doesn't need to flip the texture on the cpu side. +--- + src/plugins/screencast/regionscreencastsource.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/plugins/screencast/regionscreencastsource.cpp b/src/plugins/screencast/regionscreencastsource.cpp +index 567c5a652bf..c81295942d3 100644 +--- a/src/plugins/screencast/regionscreencastsource.cpp ++++ b/src/plugins/screencast/regionscreencastsource.cpp +@@ -59,6 +59,7 @@ void RegionScreenCastSource::updateOutput(Output *output) + + ShaderBinder shaderBinder(ShaderTrait::MapTexture | ShaderTrait::TransformColorspace); + QMatrix4x4 projectionMatrix; ++ projectionMatrix.scale(1, -1); + projectionMatrix.ortho(m_region); + projectionMatrix.translate(outputGeometry.left(), outputGeometry.top()); + +@@ -82,6 +83,7 @@ void RegionScreenCastSource::ensureTexture() + if (!m_renderedTexture) { + return; + } ++ m_renderedTexture->setContentTransform(OutputTransform::FlipY); + m_renderedTexture->setFilter(GL_LINEAR); + m_renderedTexture->setWrapMode(GL_CLAMP_TO_EDGE); + +-- +GitLab + diff --git a/kwin.spec b/kwin.spec index 5ced062..9820eb0 100644 --- a/kwin.spec +++ b/kwin.spec @@ -3,7 +3,7 @@ Name: kwin Version: 5.93.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: KDE Window manager License: BSD-2-Clause AND BSD-3-Clause AND CC0-1.0 AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-only AND GPL-3.0-or-later AND LGPL-2.0-only AND LGPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND LGPL-3.0-only AND (GPL-2.0-only OR GPL-3.0-only) AND (LGPL-2.1-only OR LGPL-3.0-only) AND MIT @@ -16,6 +16,8 @@ Source0: http://download.kde.org/%{stable_kf6}/plasma/%{version}/%{name}-%{versi # 5.93.0: Fix for kwin that causes some strange color glitches on RC2 (Will be fixed on final) # https://invent.kde.org/plasma/kwin/-/commit/fe2ead76443a8fb347b2a507ba3086606bd38237 Patch0: kwin-drm-use-correct-uniform-type.patch +# https://invent.kde.org/plasma/kwin/-/merge_requests/5204 +Patch1: kwin-fix-window-screencasts-being-vertically-mirrored-with-memfd.patch ## proposed patches @@ -289,6 +291,9 @@ rm -v %{buildroot}%{_kf6_bindir}/kwin_x11 %{buildroot}%{_userunitdir}/plasma-kwi %changelog +* Thu Feb 15 2024 Alessandro Astone - 5.93.0-3 +- Backport patch to fix window screencasts being vertically mirrored + * Sat Feb 03 2024 Steve Cossette - 5.93.0-2 - Added patch that fixes kwin glitch with HDR and some other issues