From 17f81c4faa4c93dc9ac2d9abf1b759b38df2ed9d Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Wed, 15 Nov 2023 23:22:56 +0100 Subject: [PATCH 1/2] screencast: Fix GLES path glReadPixels reads from the bound framebuffer, so create an offscreen framebuffer and attach the texture to it Co-authored-by: Jan Grulich --- src/plugins/screencast/screencastutils.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/screencast/screencastutils.h b/src/plugins/screencast/screencastutils.h index f402c21fdf..1a57362dea 100644 --- a/src/plugins/screencast/screencastutils.h +++ b/src/plugins/screencast/screencastutils.h @@ -8,6 +8,7 @@ #include "kwinglplatform.h" #include "kwingltexture.h" +#include "kwinglutils.h" #include #include @@ -60,7 +61,10 @@ static void grabTexture(GLTexture *texture, spa_data *spa, spa_video_format form texture->bind(); if (GLPlatform::instance()->isGLES()) { + GLFramebuffer fbo(texture); + GLFramebuffer::pushFramebuffer(&fbo); glReadPixels(0, 0, size.width(), size.height(), closestGLType(format), GL_UNSIGNED_BYTE, spa->data); + GLFramebuffer::popFramebuffer(); } else if (GLPlatform::instance()->glVersion() >= kVersionNumber(4, 5)) { glGetTextureImage(texture->texture(), 0, closestGLType(format), GL_UNSIGNED_BYTE, spa->chunk->size, spa->data); } else { -- 2.41.0 From 79083bdf721dd56ace7412f89d7b80e7b9a2ba52 Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Wed, 15 Nov 2023 23:23:14 +0100 Subject: [PATCH 2/2] screencast: Make nvidia use the GLES path glGetTexImage returns a black image Fixes: BUG:476602 --- src/plugins/screencast/screencastutils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/screencast/screencastutils.h b/src/plugins/screencast/screencastutils.h index 1a57362dea..31b8a1c95c 100644 --- a/src/plugins/screencast/screencastutils.h +++ b/src/plugins/screencast/screencastutils.h @@ -60,7 +60,7 @@ static void grabTexture(GLTexture *texture, spa_data *spa, spa_video_format form } texture->bind(); - if (GLPlatform::instance()->isGLES()) { + if (GLPlatform::instance()->isGLES() || GLPlatform::instance()->driver() == Driver_NVidia) { GLFramebuffer fbo(texture); GLFramebuffer::pushFramebuffer(&fbo); glReadPixels(0, 0, size.width(), size.height(), closestGLType(format), GL_UNSIGNED_BYTE, spa->data); -- 2.41.0