From 7b4925f761cdadb2d19d5d7ee2c3ac0cc7156280 Mon Sep 17 00:00:00 2001 From: Bhushan Shah Date: Tue, 3 Nov 2020 07:43:36 +0000 Subject: [PATCH] effects/screenshot: fix the screenshot on GLES We want to multiply the width/height by scale weather or not we are using GLES or not, otherwise this will only provide part of screen when used with e.g fullscreen screenshot. (cherry picked from commit 5e6c81eea015d207438ea48450fc2a60b713f043) --- effects/screenshot/screenshot.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp index 41bf6c6c61..4b87c9bed3 100644 --- a/effects/screenshot/screenshot.cpp +++ b/effects/screenshot/screenshot.cpp @@ -694,15 +694,12 @@ QImage ScreenShotEffect::blitScreenshot(const QRect &geometry, const qreal scale QImage img; if (effects->isOpenGLCompositing()) { - int width = geometry.width(); - int height = geometry.height(); + const QSize nativeSize = geometry.size() * scale; + if (GLRenderTarget::blitSupported() && !GLPlatform::instance()->isGLES()) { - width = static_cast(width * scale); - height = static_cast(height * scale); - - img = QImage(width, height, QImage::Format_ARGB32); - GLTexture tex(GL_RGBA8, width, height); + img = QImage(nativeSize.width(), nativeSize.height(), QImage::Format_ARGB32); + GLTexture tex(GL_RGBA8, nativeSize.width(), nativeSize.height()); GLRenderTarget target(tex); target.blitFromFramebuffer(geometry); // copy content from framebuffer into image @@ -710,10 +707,10 @@ QImage ScreenShotEffect::blitScreenshot(const QRect &geometry, const qreal scale glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, static_cast(img.bits())); tex.unbind(); } else { - img = QImage(width, height, QImage::Format_ARGB32); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); + img = QImage(nativeSize.width(), nativeSize.height(), QImage::Format_ARGB32); + glReadPixels(0, 0, nativeSize.width(), nativeSize.height(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); } - ScreenShotEffect::convertFromGLImage(img, width, height); + ScreenShotEffect::convertFromGLImage(img, nativeSize.width(), nativeSize.height()); } #ifdef KWIN_HAVE_XRENDER_COMPOSITING