diff --git a/effects/screenshot/screenshot.h b/effects/screenshot/screenshot.h --- a/effects/screenshot/screenshot.h +++ b/effects/screenshot/screenshot.h @@ -54,7 +54,6 @@ } static bool supported(); - static void convertFromGLImage(QImage &img, int w, int h); public Q_SLOTS: Q_SCRIPTABLE void screenshotForWindow(qulonglong winid, int mask = 0); /** diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp --- a/effects/screenshot/screenshot.cpp +++ b/effects/screenshot/screenshot.cpp @@ -302,10 +302,10 @@ effects->drawWindow(m_scheduledScreenshot, mask, infiniteRegion(), d); // copy content from framebuffer into image - img = QImage(QSize(width, height), QImage::Format_ARGB32); + img = QImage(QSize(width, height), QImage::Format_RGBA8888); glReadnPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, img.sizeInBytes(), (GLvoid*)img.bits()); + img = img.mirrored(); GLRenderTarget::popRenderTarget(); - ScreenShotEffect::convertFromGLImage(img, width, height); } #ifdef KWIN_HAVE_XRENDER_COMPOSITING xcb_image_t *xImage = nullptr; @@ -721,19 +721,19 @@ width = static_cast(width * scale); height = static_cast(height * scale); - img = QImage(width, height, QImage::Format_ARGB32); + img = QImage(width, height, QImage::Format_RGBA8888); GLTexture tex(GL_RGBA8, width, 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, static_cast(img.bits())); tex.unbind(); } else { - img = QImage(width, height, QImage::Format_ARGB32); + img = QImage(width, height, QImage::Format_RGBA8888); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); } - ScreenShotEffect::convertFromGLImage(img, width, height); + img = img.mirrored(); } #ifdef KWIN_HAVE_XRENDER_COMPOSITING @@ -763,37 +763,6 @@ painter.drawImage(effects->cursorPos() - cursor.hotSpot() - QPoint(offsetx, offsety), cursor.image()); } -void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h) -{ - // from QtOpenGL/qgl.cpp - // Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) - // see https://github.com/qt/qtbase/blob/dev/src/opengl/qgl.cpp - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - // OpenGL gives RGBA; Qt wants ARGB - uint *p = reinterpret_cast(img.bits()); - uint *end = p + w * h; - while (p < end) { - uint a = *p << 24; - *p = (*p >> 8) | a; - p++; - } - } else { - // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB - for (int y = 0; y < h; y++) { - uint *q = reinterpret_cast(img.scanLine(y)); - for (int x = 0; x < w; ++x) { - const uint pixel = *q; - *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) - | (pixel & 0xff00ff00); - - q++; - } - } - - } - img = img.mirrored(); -} - bool ScreenShotEffect::isActive() const { return (m_scheduledScreenshot != nullptr || !m_scheduledGeometry.isNull()) && !effects->isScreenLocked();