diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp --- a/effects/screenshot/screenshot.cpp +++ b/effects/screenshot/screenshot.cpp @@ -607,35 +607,50 @@ QImage ScreenShotEffect::blitScreenshot(const QRect &geometry) { QImage img; + qreal scale = 1; + auto scaledGeometry = geometry; + if (effects->isOpenGLCompositing()) { - img = QImage(geometry.size(), QImage::Format_ARGB32); + int width = geometry.width(); + int height = geometry.height(); if (GLRenderTarget::blitSupported() && !GLPlatform::instance()->isGLES()) { - GLTexture tex(GL_RGBA8, geometry.width(), geometry.height()); + // HARDCODED, need to get this properly + // tried QGuiApplication::primaryScreen() + // and GLRenderTarget::virtualScreenScale() + scale = 2; + width = static_cast(width * scale); + height = static_cast(height * scale); + img = QImage(width, height, QImage::Format_ARGB32); + GLTexture tex(GL_RGBA8, width, height); GLRenderTarget target(tex); - target.blitFromFramebuffer(geometry); + const auto deviceGeometry = QRect(static_cast(geometry.x() * scale), + static_cast(geometry.y() * scale), + width, height); + target.blitFromFramebuffer(geometry, deviceGeometry); // copy content from framebuffer into image tex.bind(); - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, static_cast(img.bits())); tex.unbind(); } else { - glReadPixels(0, 0, img.width(), img.height(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); + img = QImage(width, height, QImage::Format_ARGB32); + glReadPixels(0, 0, img.width(), img.height(), GL_RGBA, GL_UNSIGNED_BYTE, static_cast(img.bits())); } - ScreenShotEffect::convertFromGLImage(img, geometry.width(), geometry.height()); + ScreenShotEffect::convertFromGLImage(img, width, height); } #ifdef KWIN_HAVE_XRENDER_COMPOSITING if (effects->compositingType() == XRenderCompositing) { xcb_image_t *xImage = nullptr; - img = xPictureToImage(effects->xrenderBufferPicture(), geometry, &xImage); + img = xPictureToImage(effects->xrenderBufferPicture(), scaledGeometry, &xImage); if (xImage) { xcb_image_destroy(xImage); } } #endif if (m_captureCursor) { - grabPointerImage(img, geometry.x(), geometry.y()); + grabPointerImage(img, static_cast(geometry.x() * scale), static_cast(geometry.y() * scale)); } return img;