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
This commit is contained in:
Bhushan Shah 2018-11-10 18:02:18 +05:30
parent 21aee588af
commit e455e34969

View file

@ -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());
}