virtual: fix screencasting by output

Properly notify when the output changes.
Forward the texture that holds the output when requested.
This commit is contained in:
Aleix Pol 2023-02-13 19:05:24 +01:00 committed by Aleix Pol Gonzalez
parent 1ede84f4fe
commit 309c9100fa
2 changed files with 16 additions and 4 deletions

View file

@ -32,9 +32,9 @@ VirtualEglLayer::VirtualEglLayer(Output *output, VirtualEglBackend *backend)
VirtualEglLayer::~VirtualEglLayer() = default; VirtualEglLayer::~VirtualEglLayer() = default;
GLTexture *VirtualEglLayer::texture() const std::shared_ptr<GLTexture> VirtualEglLayer::texture() const
{ {
return m_texture.get(); return m_texture;
} }
std::optional<OutputLayerBeginFrameInfo> VirtualEglLayer::beginFrame() std::optional<OutputLayerBeginFrameInfo> VirtualEglLayer::beginFrame()
@ -57,6 +57,7 @@ std::optional<OutputLayerBeginFrameInfo> VirtualEglLayer::beginFrame()
bool VirtualEglLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) bool VirtualEglLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion)
{ {
glFlush(); // flush pending rendering commands. glFlush(); // flush pending rendering commands.
Q_EMIT m_output->outputChange(damagedRegion);
return true; return true;
} }
@ -202,4 +203,13 @@ void VirtualEglBackend::present(Output *output)
static_cast<VirtualOutput *>(output)->vsyncMonitor()->arm(); static_cast<VirtualOutput *>(output)->vsyncMonitor()->arm();
} }
std::shared_ptr<GLTexture> VirtualEglBackend::textureForOutput(Output *output) const
{
auto it = m_outputs.find(output);
if (it == m_outputs.end()) {
return nullptr;
}
return it->second->texture();
}
} // namespace } // namespace

View file

@ -10,6 +10,7 @@
#include "abstract_egl_backend.h" #include "abstract_egl_backend.h"
#include "core/outputlayer.h" #include "core/outputlayer.h"
#include <memory>
namespace KWin namespace KWin
{ {
@ -27,13 +28,13 @@ public:
std::optional<OutputLayerBeginFrameInfo> beginFrame() override; std::optional<OutputLayerBeginFrameInfo> beginFrame() override;
bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override;
GLTexture *texture() const; std::shared_ptr<GLTexture> texture() const;
private: private:
VirtualEglBackend *const m_backend; VirtualEglBackend *const m_backend;
Output *m_output; Output *m_output;
std::unique_ptr<GLFramebuffer> m_fbo; std::unique_ptr<GLFramebuffer> m_fbo;
std::unique_ptr<GLTexture> m_texture; std::shared_ptr<GLTexture> m_texture;
}; };
/** /**
@ -48,6 +49,7 @@ public:
~VirtualEglBackend() override; ~VirtualEglBackend() override;
std::unique_ptr<SurfaceTexture> createSurfaceTextureInternal(SurfacePixmapInternal *pixmap) override; std::unique_ptr<SurfaceTexture> createSurfaceTextureInternal(SurfacePixmapInternal *pixmap) override;
std::unique_ptr<SurfaceTexture> createSurfaceTextureWayland(SurfacePixmapWayland *pixmap) override; std::unique_ptr<SurfaceTexture> createSurfaceTextureWayland(SurfacePixmapWayland *pixmap) override;
std::shared_ptr<GLTexture> textureForOutput(Output *output) const override;
OutputLayer *primaryLayer(Output *output) override; OutputLayer *primaryLayer(Output *output) override;
void present(Output *output) override; void present(Output *output) override;
void init() override; void init() override;