From 1be2b8868ce8e23fcb9bc7b855799977828005d8 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 21 Feb 2023 02:55:55 +0100 Subject: [PATCH] wayland_egl: Reuse the texture we already have for textureForOutput --- src/backends/wayland/wayland_egl_backend.cpp | 18 ++++++++++++------ src/backends/wayland/wayland_egl_backend.h | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/backends/wayland/wayland_egl_backend.cpp b/src/backends/wayland/wayland_egl_backend.cpp index 0fd4ce35e0..3f3ba83c25 100644 --- a/src/backends/wayland/wayland_egl_backend.cpp +++ b/src/backends/wayland/wayland_egl_backend.cpp @@ -88,6 +88,7 @@ WaylandEglLayerBuffer::WaylandEglLayerBuffer(const QSize &size, uint32_t format, zwp_linux_buffer_params_v1_destroy(params); m_texture = backend->importDmaBufAsTexture(std::move(attributes)); + m_texture->setYInverted(false); m_framebuffer = std::make_unique(m_texture.get()); } @@ -114,6 +115,11 @@ GLFramebuffer *WaylandEglLayerBuffer::framebuffer() const return m_framebuffer.get(); } +std::shared_ptr WaylandEglLayerBuffer::texture() const +{ + return m_texture; +} + int WaylandEglLayerBuffer::age() const { return m_age; @@ -171,6 +177,11 @@ GLFramebuffer *WaylandEglPrimaryLayer::fbo() const return m_buffer->framebuffer(); } +std::shared_ptr WaylandEglPrimaryLayer::texture() const +{ + return m_buffer->texture(); +} + std::optional WaylandEglPrimaryLayer::beginFrame() { if (eglMakeCurrent(m_backend->eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, m_backend->context()) == EGL_FALSE) { @@ -387,12 +398,7 @@ bool WaylandEglBackend::initRenderingContext() std::shared_ptr WaylandEglBackend::textureForOutput(KWin::Output *output) const { - auto texture = std::make_unique(GL_RGBA8, output->pixelSize()); - GLFramebuffer::pushFramebuffer(m_outputs.at(output).primaryLayer->fbo()); - GLFramebuffer renderTarget(texture.get()); - renderTarget.blitFromFramebuffer(QRect(0, texture->height(), texture->width(), -texture->height())); - GLFramebuffer::popFramebuffer(); - return texture; + return m_outputs.at(output).primaryLayer->texture(); } std::unique_ptr WaylandEglBackend::createSurfaceTextureInternal(SurfacePixmapInternal *pixmap) diff --git a/src/backends/wayland/wayland_egl_backend.h b/src/backends/wayland/wayland_egl_backend.h index 18d1b6e0d8..784097c67c 100644 --- a/src/backends/wayland/wayland_egl_backend.h +++ b/src/backends/wayland/wayland_egl_backend.h @@ -40,6 +40,7 @@ public: wl_buffer *buffer() const; GLFramebuffer *framebuffer() const; + std::shared_ptr texture() const; int age() const; private: @@ -77,6 +78,7 @@ public: ~WaylandEglPrimaryLayer() override; GLFramebuffer *fbo() const; + std::shared_ptr texture() const; void present(); std::optional beginFrame() override;