summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex/qglgradientcache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/gl2paintengineex/qglgradientcache.cpp')
-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);