From 309c9100fa6b1ce0f17e0f927091ff851dd5c06d Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 13 Feb 2023 19:05:24 +0100 Subject: [PATCH] virtual: fix screencasting by output Properly notify when the output changes. Forward the texture that holds the output when requested. --- src/backends/virtual/virtual_egl_backend.cpp | 14 ++++++++++++-- src/backends/virtual/virtual_egl_backend.h | 6 ++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/backends/virtual/virtual_egl_backend.cpp b/src/backends/virtual/virtual_egl_backend.cpp index 1215f6ff03..e0e5678fba 100644 --- a/src/backends/virtual/virtual_egl_backend.cpp +++ b/src/backends/virtual/virtual_egl_backend.cpp @@ -32,9 +32,9 @@ VirtualEglLayer::VirtualEglLayer(Output *output, VirtualEglBackend *backend) VirtualEglLayer::~VirtualEglLayer() = default; -GLTexture *VirtualEglLayer::texture() const +std::shared_ptr VirtualEglLayer::texture() const { - return m_texture.get(); + return m_texture; } std::optional VirtualEglLayer::beginFrame() @@ -57,6 +57,7 @@ std::optional VirtualEglLayer::beginFrame() bool VirtualEglLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) { glFlush(); // flush pending rendering commands. + Q_EMIT m_output->outputChange(damagedRegion); return true; } @@ -202,4 +203,13 @@ void VirtualEglBackend::present(Output *output) static_cast(output)->vsyncMonitor()->arm(); } +std::shared_ptr VirtualEglBackend::textureForOutput(Output *output) const +{ + auto it = m_outputs.find(output); + if (it == m_outputs.end()) { + return nullptr; + } + return it->second->texture(); +} + } // namespace diff --git a/src/backends/virtual/virtual_egl_backend.h b/src/backends/virtual/virtual_egl_backend.h index cd34d2e388..ac5ccd1b55 100644 --- a/src/backends/virtual/virtual_egl_backend.h +++ b/src/backends/virtual/virtual_egl_backend.h @@ -10,6 +10,7 @@ #include "abstract_egl_backend.h" #include "core/outputlayer.h" +#include namespace KWin { @@ -27,13 +28,13 @@ public: std::optional beginFrame() override; bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; - GLTexture *texture() const; + std::shared_ptr texture() const; private: VirtualEglBackend *const m_backend; Output *m_output; std::unique_ptr m_fbo; - std::unique_ptr m_texture; + std::shared_ptr m_texture; }; /** @@ -48,6 +49,7 @@ public: ~VirtualEglBackend() override; std::unique_ptr createSurfaceTextureInternal(SurfacePixmapInternal *pixmap) override; std::unique_ptr createSurfaceTextureWayland(SurfacePixmapWayland *pixmap) override; + std::shared_ptr textureForOutput(Output *output) const override; OutputLayer *primaryLayer(Output *output) override; void present(Output *output) override; void init() override;