| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopengltexturecache.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | class QOpenGLTextureCacheWrapper | - | ||||||||||||||||||
| 4 | { | - | ||||||||||||||||||
| 5 | public: | - | ||||||||||||||||||
| 6 | QOpenGLTextureCacheWrapper() | - | ||||||||||||||||||
| 7 | { | - | ||||||||||||||||||
| 8 | QImagePixmapCleanupHooks::instance()->addPlatformPixmapModificationHook(cleanupTexturesForPixmapData); | - | ||||||||||||||||||
| 9 | QImagePixmapCleanupHooks::instance()->addPlatformPixmapDestructionHook(cleanupTexturesForPixmapData); | - | ||||||||||||||||||
| 10 | QImagePixmapCleanupHooks::instance()->addImageHook(cleanupTexturesForCacheKey); | - | ||||||||||||||||||
| 11 | } never executed: end of block | 0 | ||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | ~QOpenGLTextureCacheWrapper() | - | ||||||||||||||||||
| 14 | { | - | ||||||||||||||||||
| 15 | QImagePixmapCleanupHooks::instance()->removePlatformPixmapModificationHook(cleanupTexturesForPixmapData); | - | ||||||||||||||||||
| 16 | QImagePixmapCleanupHooks::instance()->removePlatformPixmapDestructionHook(cleanupTexturesForPixmapData); | - | ||||||||||||||||||
| 17 | QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey); | - | ||||||||||||||||||
| 18 | } never executed: end of block | 0 | ||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | QOpenGLTextureCache *cacheForContext(QOpenGLContext *context) { | - | ||||||||||||||||||
| 21 | QMutexLocker lock(&m_mutex); | - | ||||||||||||||||||
| 22 | return never executed: m_resource.value<QOpenGLTextureCache>(context);return m_resource.value<QOpenGLTextureCache>(context);never executed: return m_resource.value<QOpenGLTextureCache>(context); | 0 | ||||||||||||||||||
| 23 | } | - | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | static void cleanupTexturesForCacheKey(qint64 key); | - | ||||||||||||||||||
| 26 | static void cleanupTexturesForPixmapData(QPlatformPixmap *pmd); | - | ||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | private: | - | ||||||||||||||||||
| 29 | QOpenGLMultiGroupSharedResource m_resource; | - | ||||||||||||||||||
| 30 | QMutex m_mutex; | - | ||||||||||||||||||
| 31 | }; | - | ||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | namespace { namespace Q_QGS_qt_texture_caches { typedef QOpenGLTextureCacheWrapper Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
never executed: }guard.store(QtGlobalStatic::Destroyed);never executed: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blocknever executed: &holder.value;return &holder.value;never executed: } } } static QGlobalStatic<QOpenGLTextureCacheWrapper, Q_QGS_qt_texture_caches::innerFunction, Q_QGS_qt_texture_caches::guard> qt_texture_caches;return &holder.value; | 0 | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | QOpenGLTextureCache *QOpenGLTextureCache::cacheForContext(QOpenGLContext *context) | - | ||||||||||||||||||
| 36 | { | - | ||||||||||||||||||
| 37 | return never executed: qt_texture_caches()->cacheForContext(context);return qt_texture_caches()->cacheForContext(context);never executed: return qt_texture_caches()->cacheForContext(context); | 0 | ||||||||||||||||||
| 38 | } | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | void QOpenGLTextureCacheWrapper::cleanupTexturesForCacheKey(qint64 key) | - | ||||||||||||||||||
| 41 | { | - | ||||||||||||||||||
| 42 | QList<QOpenGLSharedResource *> resources = qt_texture_caches()->m_resource.resources(); | - | ||||||||||||||||||
| 43 | for (QList<QOpenGLSharedResource *>::iterator it = resources.begin(); it != resources.end()
| 0 | ||||||||||||||||||
| 44 | static_cast< never executed: QOpenGLTextureCache *>(*it)->invalidate(key);static_cast<QOpenGLTextureCache *>(*it)->invalidate(key);never executed: static_cast<QOpenGLTextureCache *>(*it)->invalidate(key); | 0 | ||||||||||||||||||
| 45 | } never executed: end of block | 0 | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | void QOpenGLTextureCacheWrapper::cleanupTexturesForPixmapData(QPlatformPixmap *pmd) | - | ||||||||||||||||||
| 48 | { | - | ||||||||||||||||||
| 49 | cleanupTexturesForCacheKey(pmd->cacheKey()); | - | ||||||||||||||||||
| 50 | } never executed: end of block | 0 | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | QOpenGLTextureCache::QOpenGLTextureCache(QOpenGLContext *ctx) | - | ||||||||||||||||||
| 53 | : QOpenGLSharedResource(ctx->shareGroup()) | - | ||||||||||||||||||
| 54 | , m_cache(64 * 1024) | - | ||||||||||||||||||
| 55 | { | - | ||||||||||||||||||
| 56 | } never executed: end of block | 0 | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | QOpenGLTextureCache::~QOpenGLTextureCache() | - | ||||||||||||||||||
| 59 | { | - | ||||||||||||||||||
| 60 | } | - | ||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, const QPixmap &pixmap, BindOptions options) | - | ||||||||||||||||||
| 63 | { | - | ||||||||||||||||||
| 64 | if (pixmap.isNull()
| 0 | ||||||||||||||||||
| 65 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 66 | QMutexLocker locker(&m_mutex); | - | ||||||||||||||||||
| 67 | qint64 key = pixmap.cacheKey(); | - | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | if (!pixmap.paintingActive()
| 0 | ||||||||||||||||||
| 71 | QOpenGLCachedTexture *entry = m_cache.object(key); | - | ||||||||||||||||||
| 72 | if (entry
| 0 | ||||||||||||||||||
| 73 | context->functions()->glBindTexture(0x0DE1, entry->id()); | - | ||||||||||||||||||
| 74 | return never executed: entry->id();return entry->id();never executed: return entry->id(); | 0 | ||||||||||||||||||
| 75 | } | - | ||||||||||||||||||
| 76 | } never executed: end of block | 0 | ||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | GLuint id = bindTexture(context, key, pixmap.toImage(), options); | - | ||||||||||||||||||
| 79 | if (id > 0
| 0 | ||||||||||||||||||
| 80 | QImagePixmapCleanupHooks::enableCleanupHooks(pixmap); never executed: QImagePixmapCleanupHooks::enableCleanupHooks(pixmap); | 0 | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | return never executed: id;return id;never executed: return id; | 0 | ||||||||||||||||||
| 83 | } | - | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, const QImage &image, BindOptions options) | - | ||||||||||||||||||
| 86 | { | - | ||||||||||||||||||
| 87 | if (image.isNull()
| 0 | ||||||||||||||||||
| 88 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 89 | QMutexLocker locker(&m_mutex); | - | ||||||||||||||||||
| 90 | qint64 key = image.cacheKey(); | - | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | if (!image.paintingActive()
| 0 | ||||||||||||||||||
| 94 | QOpenGLCachedTexture *entry = m_cache.object(key); | - | ||||||||||||||||||
| 95 | if (entry
| 0 | ||||||||||||||||||
| 96 | context->functions()->glBindTexture(0x0DE1, entry->id()); | - | ||||||||||||||||||
| 97 | return never executed: entry->id();return entry->id();never executed: return entry->id(); | 0 | ||||||||||||||||||
| 98 | } | - | ||||||||||||||||||
| 99 | } never executed: end of block | 0 | ||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | QImage img = image; | - | ||||||||||||||||||
| 102 | if (!context->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures)
| 0 | ||||||||||||||||||
| 103 | - | |||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | int tx_w = qNextPowerOfTwo(image.width() - 1); | - | ||||||||||||||||||
| 107 | int tx_h = qNextPowerOfTwo(image.height() - 1); | - | ||||||||||||||||||
| 108 | if (tx_w != image.width()
| 0 | ||||||||||||||||||
| 109 | img = img.scaled(tx_w, tx_h); | - | ||||||||||||||||||
| 110 | } never executed: end of block | 0 | ||||||||||||||||||
| 111 | } never executed: end of block | 0 | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | GLuint id = bindTexture(context, key, img, options); | - | ||||||||||||||||||
| 114 | if (id > 0
| 0 | ||||||||||||||||||
| 115 | QImagePixmapCleanupHooks::enableCleanupHooks(image); never executed: QImagePixmapCleanupHooks::enableCleanupHooks(image); | 0 | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | return never executed: id;return id;never executed: return id; | 0 | ||||||||||||||||||
| 118 | } | - | ||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, qint64 key, const QImage &image, BindOptions options) | - | ||||||||||||||||||
| 121 | { | - | ||||||||||||||||||
| 122 | GLuint id; | - | ||||||||||||||||||
| 123 | QOpenGLFunctions *funcs = context->functions(); | - | ||||||||||||||||||
| 124 | funcs->glGenTextures(1, &id); | - | ||||||||||||||||||
| 125 | funcs->glBindTexture(0x0DE1, id); | - | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | QImage tx; | - | ||||||||||||||||||
| 128 | GLenum externalFormat; | - | ||||||||||||||||||
| 129 | GLenum internalFormat; | - | ||||||||||||||||||
| 130 | GLuint pixelType; | - | ||||||||||||||||||
| 131 | QImage::Format targetFormat = QImage::Format_Invalid; | - | ||||||||||||||||||
| 132 | const bool isOpenGL12orBetter = !context->isOpenGLES()
| 0 | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | switch (image.format()) { | - | ||||||||||||||||||
| 135 | case never executed: QImage::Format_RGB32:case QImage::Format_RGB32:never executed: case QImage::Format_RGB32: | 0 | ||||||||||||||||||
| 136 | case never executed: QImage::Format_ARGB32:case QImage::Format_ARGB32:never executed: case QImage::Format_ARGB32: | 0 | ||||||||||||||||||
| 137 | case never executed: QImage::Format_ARGB32_Premultiplied:case QImage::Format_ARGB32_Premultiplied:never executed: case QImage::Format_ARGB32_Premultiplied: | 0 | ||||||||||||||||||
| 138 | if (isOpenGL12orBetter
| 0 | ||||||||||||||||||
| 139 | externalFormat = 0x80E1; | - | ||||||||||||||||||
| 140 | internalFormat = 0x1908; | - | ||||||||||||||||||
| 141 | pixelType = 0x8367; | - | ||||||||||||||||||
| 142 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | if (static_cast<
| 0 | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | if (context->isOpenGLES()
| 0 | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | externalFormat = internalFormat = 0x80E1; | - | ||||||||||||||||||
| 152 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | externalFormat = 0x80E1; | - | ||||||||||||||||||
| 155 | internalFormat = 0x1908; | - | ||||||||||||||||||
| 156 | } never executed: end of block | 0 | ||||||||||||||||||
| 157 | pixelType = 0x1401; | - | ||||||||||||||||||
| 158 | } never executed: else if (context->isOpenGLES()end of block
| 0 | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | externalFormat = 0x80E1; | - | ||||||||||||||||||
| 161 | internalFormat = 0x1908; | - | ||||||||||||||||||
| 162 | pixelType = 0x1401; | - | ||||||||||||||||||
| 163 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | break; never executed: break; | 0 | ||||||||||||||||||
| 166 | } | - | ||||||||||||||||||
| 167 | } | - | ||||||||||||||||||
| 168 | targetFormat = image.format(); | - | ||||||||||||||||||
| 169 | break; never executed: break; | 0 | ||||||||||||||||||
| 170 | case never executed: QImage::Format_BGR30:case QImage::Format_BGR30:never executed: case QImage::Format_BGR30: | 0 | ||||||||||||||||||
| 171 | case never executed: QImage::Format_A2BGR30_Premultiplied:case QImage::Format_A2BGR30_Premultiplied:never executed: case QImage::Format_A2BGR30_Premultiplied: | 0 | ||||||||||||||||||
| 172 | if (isOpenGL12orBetter
| 0 | ||||||||||||||||||
| 173 | pixelType = 0x8368; | - | ||||||||||||||||||
| 174 | externalFormat = 0x1908; | - | ||||||||||||||||||
| 175 | internalFormat = 0x8059; | - | ||||||||||||||||||
| 176 | targetFormat = image.format(); | - | ||||||||||||||||||
| 177 | } never executed: end of block | 0 | ||||||||||||||||||
| 178 | break; never executed: break; | 0 | ||||||||||||||||||
| 179 | case never executed: QImage::Format_RGB30:case QImage::Format_RGB30:never executed: case QImage::Format_RGB30: | 0 | ||||||||||||||||||
| 180 | case never executed: QImage::Format_A2RGB30_Premultiplied:case QImage::Format_A2RGB30_Premultiplied:never executed: case QImage::Format_A2RGB30_Premultiplied: | 0 | ||||||||||||||||||
| 181 | if (isOpenGL12orBetter
| 0 | ||||||||||||||||||
| 182 | pixelType = 0x8368; | - | ||||||||||||||||||
| 183 | externalFormat = 0x80E1; | - | ||||||||||||||||||
| 184 | internalFormat = 0x8059; | - | ||||||||||||||||||
| 185 | targetFormat = image.format(); | - | ||||||||||||||||||
| 186 | } never executed: else if (context->isOpenGLES()end of block
| 0 | ||||||||||||||||||
| 187 | pixelType = 0x8368; | - | ||||||||||||||||||
| 188 | externalFormat = 0x1908; | - | ||||||||||||||||||
| 189 | internalFormat = 0x8059; | - | ||||||||||||||||||
| 190 | targetFormat = QImage::Format_A2BGR30_Premultiplied; | - | ||||||||||||||||||
| 191 | } never executed: end of block | 0 | ||||||||||||||||||
| 192 | break; never executed: break; | 0 | ||||||||||||||||||
| 193 | case never executed: QImage::Format_RGB444:case QImage::Format_RGB444:never executed: case QImage::Format_RGB444: | 0 | ||||||||||||||||||
| 194 | case never executed: QImage::Format_RGB555:case QImage::Format_RGB555:never executed: case QImage::Format_RGB555: | 0 | ||||||||||||||||||
| 195 | case never executed: QImage::Format_RGB16:case QImage::Format_RGB16:never executed: case QImage::Format_RGB16: | 0 | ||||||||||||||||||
| 196 | if (isOpenGL12orBetter
| 0 | ||||||||||||||||||
| 197 | externalFormat = internalFormat = 0x1907; | - | ||||||||||||||||||
| 198 | pixelType = 0x8363; | - | ||||||||||||||||||
| 199 | targetFormat = QImage::Format_RGB16; | - | ||||||||||||||||||
| 200 | } never executed: end of block | 0 | ||||||||||||||||||
| 201 | break; never executed: break; | 0 | ||||||||||||||||||
| 202 | case never executed: QImage::Format_RGB666:case QImage::Format_RGB666:never executed: case QImage::Format_RGB666: | 0 | ||||||||||||||||||
| 203 | case never executed: QImage::Format_RGB888:case QImage::Format_RGB888:never executed: case QImage::Format_RGB888: | 0 | ||||||||||||||||||
| 204 | externalFormat = internalFormat = 0x1907; | - | ||||||||||||||||||
| 205 | pixelType = 0x1401; | - | ||||||||||||||||||
| 206 | targetFormat = QImage::Format_RGB888; | - | ||||||||||||||||||
| 207 | break; never executed: break; | 0 | ||||||||||||||||||
| 208 | case never executed: QImage::Format_RGBX8888:case QImage::Format_RGBX8888:never executed: case QImage::Format_RGBX8888: | 0 | ||||||||||||||||||
| 209 | case never executed: QImage::Format_RGBA8888:case QImage::Format_RGBA8888:never executed: case QImage::Format_RGBA8888: | 0 | ||||||||||||||||||
| 210 | case never executed: QImage::Format_RGBA8888_Premultiplied:case QImage::Format_RGBA8888_Premultiplied:never executed: case QImage::Format_RGBA8888_Premultiplied: | 0 | ||||||||||||||||||
| 211 | externalFormat = internalFormat = 0x1908; | - | ||||||||||||||||||
| 212 | pixelType = 0x1401; | - | ||||||||||||||||||
| 213 | targetFormat = image.format(); | - | ||||||||||||||||||
| 214 | break; never executed: break; | 0 | ||||||||||||||||||
| 215 | case never executed: QImage::Format_Indexed8:case QImage::Format_Indexed8:never executed: case QImage::Format_Indexed8: | 0 | ||||||||||||||||||
| 216 | if (options & UseRedFor8BitBindOption
| 0 | ||||||||||||||||||
| 217 | externalFormat = internalFormat = 0x1903; | - | ||||||||||||||||||
| 218 | pixelType = 0x1401; | - | ||||||||||||||||||
| 219 | targetFormat = image.format(); | - | ||||||||||||||||||
| 220 | } never executed: end of block | 0 | ||||||||||||||||||
| 221 | break; never executed: break; | 0 | ||||||||||||||||||
| 222 | case never executed: QImage::Format_Alpha8:case QImage::Format_Alpha8:never executed: case QImage::Format_Alpha8: | 0 | ||||||||||||||||||
| 223 | if (options & UseRedFor8BitBindOption
| 0 | ||||||||||||||||||
| 224 | externalFormat = internalFormat = 0x1903; | - | ||||||||||||||||||
| 225 | pixelType = 0x1401; | - | ||||||||||||||||||
| 226 | targetFormat = image.format(); | - | ||||||||||||||||||
| 227 | } never executed: else if (context->isOpenGLES()end of block
| 0 | ||||||||||||||||||
| 228 | externalFormat = internalFormat = 0x1906; | - | ||||||||||||||||||
| 229 | pixelType = 0x1401; | - | ||||||||||||||||||
| 230 | targetFormat = image.format(); | - | ||||||||||||||||||
| 231 | } never executed: end of block | 0 | ||||||||||||||||||
| 232 | break; never executed: break; | 0 | ||||||||||||||||||
| 233 | case never executed: QImage::Format_Grayscale8:case QImage::Format_Grayscale8:never executed: case QImage::Format_Grayscale8: | 0 | ||||||||||||||||||
| 234 | if (options & UseRedFor8BitBindOption
| 0 | ||||||||||||||||||
| 235 | externalFormat = internalFormat = 0x1903; | - | ||||||||||||||||||
| 236 | pixelType = 0x1401; | - | ||||||||||||||||||
| 237 | targetFormat = image.format(); | - | ||||||||||||||||||
| 238 | } never executed: else if (context->isOpenGLES()end of block
| 0 | ||||||||||||||||||
| 239 | externalFormat = internalFormat = 0x1909; | - | ||||||||||||||||||
| 240 | pixelType = 0x1401; | - | ||||||||||||||||||
| 241 | targetFormat = image.format(); | - | ||||||||||||||||||
| 242 | } never executed: end of block | 0 | ||||||||||||||||||
| 243 | break; never executed: break; | 0 | ||||||||||||||||||
| 244 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 245 | break; never executed: break; | 0 | ||||||||||||||||||
| 246 | } | - | ||||||||||||||||||
| 247 | - | |||||||||||||||||||
| 248 | if (targetFormat == QImage::Format_Invalid
| 0 | ||||||||||||||||||
| 249 | externalFormat = internalFormat = 0x1908; | - | ||||||||||||||||||
| 250 | pixelType = 0x1401; | - | ||||||||||||||||||
| 251 | if (!image.hasAlphaChannel()
| 0 | ||||||||||||||||||
| 252 | targetFormat = QImage::Format_RGBX8888; never executed: targetFormat = QImage::Format_RGBX8888; | 0 | ||||||||||||||||||
| 253 | else | - | ||||||||||||||||||
| 254 | targetFormat = QImage::Format_RGBA8888; never executed: targetFormat = QImage::Format_RGBA8888; | 0 | ||||||||||||||||||
| 255 | } | - | ||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | if (options & PremultipliedAlphaBindOption
| 0 | ||||||||||||||||||
| 258 | if (targetFormat == QImage::Format_ARGB32
| 0 | ||||||||||||||||||
| 259 | targetFormat = QImage::Format_ARGB32_Premultiplied; never executed: targetFormat = QImage::Format_ARGB32_Premultiplied; | 0 | ||||||||||||||||||
| 260 | else if (targetFormat == QImage::Format_RGBA8888
| 0 | ||||||||||||||||||
| 261 | targetFormat = QImage::Format_RGBA8888_Premultiplied; never executed: targetFormat = QImage::Format_RGBA8888_Premultiplied; | 0 | ||||||||||||||||||
| 262 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 263 | if (targetFormat == QImage::Format_ARGB32_Premultiplied
| 0 | ||||||||||||||||||
| 264 | targetFormat = QImage::Format_ARGB32; never executed: targetFormat = QImage::Format_ARGB32; | 0 | ||||||||||||||||||
| 265 | else if (targetFormat == QImage::Format_RGBA8888_Premultiplied
| 0 | ||||||||||||||||||
| 266 | targetFormat = QImage::Format_RGBA8888; never executed: targetFormat = QImage::Format_RGBA8888; | 0 | ||||||||||||||||||
| 267 | } never executed: end of block | 0 | ||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 | if (image.format() != targetFormat
| 0 | ||||||||||||||||||
| 270 | tx = image.convertToFormat(targetFormat); never executed: tx = image.convertToFormat(targetFormat); | 0 | ||||||||||||||||||
| 271 | else | - | ||||||||||||||||||
| 272 | tx = image; never executed: tx = image; | 0 | ||||||||||||||||||
| 273 | - | |||||||||||||||||||
| 274 | funcs->glTexImage2D(0x0DE1, 0, internalFormat, tx.width(), tx.height(), 0, externalFormat, pixelType, const_cast<const QImage &>(tx).bits()); | - | ||||||||||||||||||
| 275 | - | |||||||||||||||||||
| 276 | int cost = tx.width() * tx.height() * tx.depth() / (1024 * 8); | - | ||||||||||||||||||
| 277 | m_cache.insert(key, new QOpenGLCachedTexture(id, options, context), cost); | - | ||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | return never executed: id;return id;never executed: return id; | 0 | ||||||||||||||||||
| 280 | } | - | ||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | void QOpenGLTextureCache::invalidate(qint64 key) | - | ||||||||||||||||||
| 283 | { | - | ||||||||||||||||||
| 284 | QMutexLocker locker(&m_mutex); | - | ||||||||||||||||||
| 285 | m_cache.remove(key); | - | ||||||||||||||||||
| 286 | } never executed: end of block | 0 | ||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | void QOpenGLTextureCache::invalidateResource() | - | ||||||||||||||||||
| 289 | { | - | ||||||||||||||||||
| 290 | m_cache.clear(); | - | ||||||||||||||||||
| 291 | } never executed: end of block | 0 | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | void QOpenGLTextureCache::freeResource(QOpenGLContext *) | - | ||||||||||||||||||
| 294 | { | - | ||||||||||||||||||
| 295 | ((!(false)) ? qt_assert("false",__FILE__,366) : qt_noop()); | - | ||||||||||||||||||
| 296 | } never executed: end of block | 0 | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | static void freeTexture(QOpenGLFunctions *funcs, GLuint id) | - | ||||||||||||||||||
| 299 | { | - | ||||||||||||||||||
| 300 | funcs->glDeleteTextures(1, &id); | - | ||||||||||||||||||
| 301 | } never executed: end of block | 0 | ||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | QOpenGLCachedTexture::QOpenGLCachedTexture(GLuint id, int options, QOpenGLContext *context) : m_options(options) | - | ||||||||||||||||||
| 304 | { | - | ||||||||||||||||||
| 305 | m_resource = new QOpenGLSharedResourceGuard(context, id, freeTexture); | - | ||||||||||||||||||
| 306 | } never executed: end of block | 0 | ||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |