Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/virtual/egl_gbm_backend.cpp
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | |||||
189 | 189 | | |||
190 | static void convertFromGLImage(QImage &img, int w, int h) | 190 | static void convertFromGLImage(QImage &img, int w, int h) | ||
191 | { | 191 | { | ||
192 | // from QtOpenGL/qgl.cpp | 192 | // from QtOpenGL/qgl.cpp | ||
193 | // Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 193 | // Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | ||
194 | // see https://github.com/qt/qtbase/blob/dev/src/opengl/qgl.cpp | 194 | // see https://github.com/qt/qtbase/blob/dev/src/opengl/qgl.cpp | ||
195 | if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { | 195 | if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { | ||
196 | // OpenGL gives RGBA; Qt wants ARGB | 196 | // OpenGL gives RGBA; Qt wants ARGB | ||
197 | uint *p = (uint*)img.bits(); | 197 | uint *p = reinterpret_cast<uint *>(img.bits()); | ||
zzag: nit: add whitespace before `*` | |||||
198 | uint *end = p + w * h; | 198 | uint *end = p + w * h; | ||
199 | while (p < end) { | 199 | while (p < end) { | ||
200 | uint a = *p << 24; | 200 | uint a = *p << 24; | ||
201 | *p = (*p >> 8) | a; | 201 | *p = (*p >> 8) | a; | ||
202 | p++; | 202 | p++; | ||
203 | } | 203 | } | ||
204 | } else { | 204 | } else { | ||
205 | // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB | 205 | // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB | ||
206 | for (int y = 0; y < h; y++) { | 206 | for (int y = 0; y < h; y++) { | ||
207 | uint *q = (uint*)img.scanLine(y); | 207 | uint *q = reinterpret_cast<uint*>(img.scanLine(y)); | ||
208 | for (int x = 0; x < w; ++x) { | 208 | for (int x = 0; x < w; ++x) { | ||
209 | const uint pixel = *q; | 209 | const uint pixel = *q; | ||
210 | *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | 210 | *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | ||
211 | | (pixel & 0xff00ff00); | 211 | | (pixel & 0xff00ff00); | ||
212 | 212 | | |||
213 | q++; | 213 | q++; | ||
214 | } | 214 | } | ||
215 | } | 215 | } | ||
Show All 36 Lines |
nit: add whitespace before *