Changeset 561 for trunk/src/opengl/gl2paintengineex/qglgradientcache.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/opengl/gl2paintengineex/qglgradientcache.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtOpenGL module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 45 45 #include "qglgradientcache_p.h" 46 46 47 void QGLGradientCache::cleanCache() { 47 QT_BEGIN_NAMESPACE 48 49 static void QGL2GradientCache_free(void *ptr) 50 { 51 delete reinterpret_cast<QGL2GradientCache *>(ptr); 52 } 53 54 Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_gradient_caches, (QGL2GradientCache_free)) 55 56 QGL2GradientCache *QGL2GradientCache::cacheForContext(const QGLContext *context) 57 { 58 QGL2GradientCache *p = reinterpret_cast<QGL2GradientCache *>(qt_gradient_caches()->value(context)); 59 if (!p) { 60 QGLShareContextScope scope(context); 61 p = new QGL2GradientCache; 62 qt_gradient_caches()->insert(context, p); 63 } 64 return p; 65 } 66 67 void QGL2GradientCache::cleanCache() { 48 68 QGLGradientColorTableHash::const_iterator it = cache.constBegin(); 49 69 for (; it != cache.constEnd(); ++it) { … … 54 74 } 55 75 56 GLuint QGL GradientCache::getBuffer(const QGradient &gradient, qreal opacity, const QGLContext *ctx)76 GLuint QGL2GradientCache::getBuffer(const QGradient &gradient, qreal opacity) 57 77 { 58 if (buffer_ctx && !qgl_share_reg()->checkSharing(buffer_ctx, ctx))59 cleanCache();60 61 buffer_ctx = ctx;62 63 78 quint64 hash_val = 0; 64 79 … … 85 100 86 101 87 GLuint QGL GradientCache::addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity)102 GLuint QGL2GradientCache::addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity) 88 103 { 89 104 if (cache.size() == maxCacheSize()) { … … 110 125 111 126 112 // GL's expects pixels in RGBA , bin-endian (ABGR on x86).113 // Qt stores in ARGB using whateverbyte-order the mancine uses.127 // GL's expects pixels in RGBA (when using GL_RGBA), bin-endian (ABGR on x86). 128 // Qt always stores in ARGB reguardless of the byte-order the mancine uses. 114 129 static inline uint qtToGlColor(uint c) 115 130 { 116 131 uint o; 117 132 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN 118 o = c & 0xFF00FF00; // alpha & green already in the right place 119 o |= (c >> 16) & 0x000000FF; // red 120 o |= (c << 16) & 0x00FF0000; // blue 121 133 o = (c & 0xff00ff00) // alpha & green already in the right place 134 | ((c >> 16) & 0x000000ff) // red 135 | ((c << 16) & 0x00ff0000); // blue 122 136 #else //Q_BIG_ENDIAN 123 o = c & 0x00FF00FF; // alpha & green already in the right place 124 o |= (c << 16) & 0xFF000000; // red 125 o |= (c >> 16) & 0x0000FF00; // blue 126 #error big endian not tested with QGLGraphicsContext 137 o = (c << 8) 138 | ((c >> 24) & 0x000000ff); 127 139 #endif // Q_BYTE_ORDER 128 140 return o; … … 130 142 131 143 //TODO: Let GL generate the texture using an FBO 132 void QGL GradientCache::generateGradientColorTable(const QGradient& gradient, uint *colorTable, int size, qreal opacity) const144 void QGL2GradientCache::generateGradientColorTable(const QGradient& gradient, uint *colorTable, int size, qreal opacity) const 133 145 { 134 146 int pos = 0; … … 137 149 138 150 for (int i = 0; i < s.size(); ++i) 139 colors[i] = s[i].second.rgba(); // Qt LIES! It returns ARGB 151 colors[i] = s[i].second.rgba(); // Qt LIES! It returns ARGB (on little-endian AND on big-endian) 140 152 141 153 bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation); … … 184 196 colorTable[size-1] = last_color; 185 197 } 198 199 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.