diff options
author | Trond Kjernåsen <trond@trolltech.com> | 2009-04-29 09:57:32 (GMT) |
---|---|---|
committer | Trond Kjernåsen <trond@trolltech.com> | 2009-04-29 09:59:54 (GMT) |
commit | d07de7568cdfb1889e4b64fcbe3fcbfa120ae264 (patch) | |
tree | 9b054c079ecc4065dd910407a4c27fc74a94170b /src/opengl/qgl.cpp | |
parent | e9af6b7befd099c71acabe32b3da0f7b0e93446c (diff) | |
download | Qt-d07de7568cdfb1889e4b64fcbe3fcbfa120ae264.zip Qt-d07de7568cdfb1889e4b64fcbe3fcbfa120ae264.tar.gz Qt-d07de7568cdfb1889e4b64fcbe3fcbfa120ae264.tar.bz2 |
Get rid of an unnecessary image copy when grabbing a GL framebuffer.
Task-number: Related to 241466
Reviewed-by: Samuel
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r-- | src/opengl/qgl.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 8ffee87..04bc611 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1327,13 +1327,21 @@ QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include // This is an old legacy fix for PowerPC based Macs, which // we shouldn't remove while (p < end) { - *p = 0xFF000000 | (*p>>8); + *p = 0xff000000 | (*p>>8); ++p; } } } else { // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB - img = img.rgbSwapped(); + for (int y = 0; y < h; y++) { + uint *q = (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++; + } + } + } return img.mirrored(); } |