Paste P597

Masterwork From Distant Lands
ActivePublic

Authored by apol on May 12 2020, 4:29 PM.
diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp
index a9817b4b5..af9781764 100644
--- a/effects/screenshot/screenshot.cpp
+++ b/effects/screenshot/screenshot.cpp
@@ -302,10 +302,10 @@ void ScreenShotEffect::postPaintScreen()
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,7 +721,7 @@ QImage ScreenShotEffect::blitScreenshot(const QRect &geometry, const qreal scale
width = static_cast<int>(width * scale);
height = static_cast<int>(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);
@@ -730,10 +730,10 @@ QImage ScreenShotEffect::blitScreenshot(const QRect &geometry, const qreal scale
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, static_cast<GLvoid*>(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 @@ void ScreenShotEffect::grabPointerImage(QImage& snapshot, int offsetx, int offse
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<uint *>(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<uint *>(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();
apol edited the content of this paste. (Show Details)May 12 2020, 4:29 PM
apol changed the title of this paste from untitled to Masterwork From Distant Lands.