From e455e34969b757273606fcd36e7dc6820ca632bc Mon Sep 17 00:00:00 2001 From: Bhushan Shah Date: Sat, 10 Nov 2018 18:02:18 +0530 Subject: [PATCH] effects: attempt to screenshot on OpenGL ES 2.0 instead of failing Summary: Current code path was attempting to use both framebuffer blit and glReadPixels on OpenGL ES, instead change the code to use framebuffer blit and glGetTexImage on OpenGL and glReadPixels on the OpenGLES as it doesn't have glGetTexImage available. Test Plan: tested on Nexus 5X. Reviewers: #kwin, davidedmundson, graesslin Reviewed By: #kwin, graesslin Subscribers: kwin Tags: #kwin Maniphest Tasks: T10011 Differential Revision: https://phabricator.kde.org/D16802 --- effects/screenshot/screenshot.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp index 5b7c7cde3d..3139bd85dc 100644 --- a/effects/screenshot/screenshot.cpp +++ b/effects/screenshot/screenshot.cpp @@ -548,22 +548,18 @@ QImage ScreenShotEffect::blitScreenshot(const QRect &geometry) QImage img; if (effects->isOpenGLCompositing()) { - if (!GLRenderTarget::blitSupported()) { - qCDebug(KWINEFFECTS) << "Framebuffer Blit not supported"; - return img; - } - GLTexture tex(GL_RGBA8, geometry.width(), geometry.height()); - GLRenderTarget target(tex); - target.blitFromFramebuffer(geometry); - // copy content from framebuffer into image - tex.bind(); img = QImage(geometry.size(), QImage::Format_ARGB32); - if (GLPlatform::instance()->isGLES()) { - glReadPixels(0, 0, img.width(), img.height(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); - } else { + if (GLRenderTarget::blitSupported() && !GLPlatform::instance()->isGLES()) { + GLTexture tex(GL_RGBA8, geometry.width(), geometry.height()); + GLRenderTarget target(tex); + target.blitFromFramebuffer(geometry); + // copy content from framebuffer into image + tex.bind(); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); + tex.unbind(); + } else { + glReadPixels(0, 0, img.width(), img.height(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); } - tex.unbind(); ScreenShotEffect::convertFromGLImage(img, geometry.width(), geometry.height()); }