summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-05-15 08:54:27 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-05-15 08:54:27 (GMT)
commit7f0b4d3b99bb767724a09234768104e18aa52b0e (patch)
tree57207daff9c2af31a7cc55eeb2de834f9c726ef8
parent521c5cc3910bffe566e0fb653041f159ecb5b6d5 (diff)
downloadQt-7f0b4d3b99bb767724a09234768104e18aa52b0e.zip
Qt-7f0b4d3b99bb767724a09234768104e18aa52b0e.tar.gz
Qt-7f0b4d3b99bb767724a09234768104e18aa52b0e.tar.bz2
Fix GL2 paint engine builds on Big-endian machines
Reviewed-by: Trond
-rw-r--r--src/opengl/gl2paintengineex/qglgradientcache.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/opengl/gl2paintengineex/qglgradientcache.cpp b/src/opengl/gl2paintengineex/qglgradientcache.cpp
index 59d4bf8..2239c2f 100644
--- a/src/opengl/gl2paintengineex/qglgradientcache.cpp
+++ b/src/opengl/gl2paintengineex/qglgradientcache.cpp
@@ -109,21 +109,18 @@ GLuint QGL2GradientCache::addCacheElement(quint64 hash_val, const QGradient &gra
}
-// GL's expects pixels in RGBA, bin-endian (ABGR on x86).
-// Qt stores in ARGB using whatever byte-order the mancine uses.
+// GL's expects pixels in RGBA (when using GL_RGBA), bin-endian (ABGR on x86).
+// Qt always stores in ARGB reguardless of the byte-order the mancine uses.
static inline uint qtToGlColor(uint c)
{
uint o;
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- o = c & 0xFF00FF00; // alpha & green already in the right place
- o |= (c >> 16) & 0x000000FF; // red
- o |= (c << 16) & 0x00FF0000; // blue
-
+ o = (c & 0xff00ff00) // alpha & green already in the right place
+ | ((c >> 16) & 0x000000ff) // red
+ | ((c << 16) & 0x00ff0000); // blue
#else //Q_BIG_ENDIAN
- o = c & 0x00FF00FF; // alpha & green already in the right place
- o |= (c << 16) & 0xFF000000; // red
- o |= (c >> 16) & 0x0000FF00; // blue
-#error big endian not tested with QGLGraphicsContext
+ o = (c << 8)
+ | ((c >> 24) & 0x000000ff);
#endif // Q_BYTE_ORDER
return o;
}
@@ -136,7 +133,7 @@ void QGL2GradientCache::generateGradientColorTable(const QGradient& gradient, ui
QVector<uint> colors(s.size());
for (int i = 0; i < s.size(); ++i)
- colors[i] = s[i].second.rgba(); // Qt LIES! It returns ARGB
+ colors[i] = s[i].second.rgba(); // Qt LIES! It returns ARGB (on little-endian AND on big-endian)
bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation);