| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/image/qpixmapcache.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | static int cache_limit = 10240; | - | ||||||||||||||||||
| 4 | QPixmapCache::Key::Key() : d(0) | - | ||||||||||||||||||
| 5 | { | - | ||||||||||||||||||
| 6 | } never executed: end of block | 0 | ||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | QPixmapCache::Key::Key(const Key &other) | - | ||||||||||||||||||
| 13 | { | - | ||||||||||||||||||
| 14 | if (other.d
| 0 | ||||||||||||||||||
| 15 | ++( never executed: other.d->ref);++(other.d->ref);never executed: ++(other.d->ref); | 0 | ||||||||||||||||||
| 16 | d = other.d; | - | ||||||||||||||||||
| 17 | } never executed: end of block | 0 | ||||||||||||||||||
| 18 | - | |||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | QPixmapCache::Key::~Key() | - | ||||||||||||||||||
| 23 | { | - | ||||||||||||||||||
| 24 | if (d
| 0 | ||||||||||||||||||
| 25 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 26 | } never executed: end of block | 0 | ||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | bool QPixmapCache::Key::operator ==(const Key &key) const | - | ||||||||||||||||||
| 35 | { | - | ||||||||||||||||||
| 36 | return never executed: (d == key.d);return (d == key.d);never executed: return (d == key.d); | 0 | ||||||||||||||||||
| 37 | } | - | ||||||||||||||||||
| 38 | bool QPixmapCache::Key::isValid() const noexcept | - | ||||||||||||||||||
| 39 | { | - | ||||||||||||||||||
| 40 | return never executed: d && d->isValid;return d && d->isValid;never executed: return d && d->isValid; | 0 | ||||||||||||||||||
| 41 | } | - | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | QPixmapCache::Key &QPixmapCache::Key::operator =(const Key &other) | - | ||||||||||||||||||
| 47 | { | - | ||||||||||||||||||
| 48 | if (d != other.d
| 0 | ||||||||||||||||||
| 49 | if (other.d
| 0 | ||||||||||||||||||
| 50 | ++( never executed: other.d->ref);++(other.d->ref);never executed: ++(other.d->ref); | 0 | ||||||||||||||||||
| 51 | if (d
| 0 | ||||||||||||||||||
| 52 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 53 | d = other.d; | - | ||||||||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||||||||
| 55 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||
| 56 | } | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | class QPMCache : public QObject, public QCache<QPixmapCache::Key, QPixmapCacheEntry> | - | ||||||||||||||||||
| 59 | { | - | ||||||||||||||||||
| 60 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - | ||||||||||||||||||
| 61 | #pragma GCC diagnostic push | - | ||||||||||||||||||
| 62 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||||||||
| 63 | #pragma GCC diagnostic pop | - | ||||||||||||||||||
| 64 | struct QPrivateSignal {}; | - | ||||||||||||||||||
| 65 | public: | - | ||||||||||||||||||
| 66 | QPMCache(); | - | ||||||||||||||||||
| 67 | ~QPMCache(); | - | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | void timerEvent(QTimerEvent *) override; | - | ||||||||||||||||||
| 70 | bool insert(const QString& key, const QPixmap &pixmap, int cost); | - | ||||||||||||||||||
| 71 | QPixmapCache::Key insert(const QPixmap &pixmap, int cost); | - | ||||||||||||||||||
| 72 | bool replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int cost); | - | ||||||||||||||||||
| 73 | bool remove(const QString &key); | - | ||||||||||||||||||
| 74 | bool remove(const QPixmapCache::Key &key); | - | ||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | void resizeKeyArray(int size); | - | ||||||||||||||||||
| 77 | QPixmapCache::Key createKey(); | - | ||||||||||||||||||
| 78 | void releaseKey(const QPixmapCache::Key &key); | - | ||||||||||||||||||
| 79 | void clear(); | - | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | QPixmap *object(const QString &key) const; | - | ||||||||||||||||||
| 82 | QPixmap *object(const QPixmapCache::Key &key) const; | - | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | static inline QPixmapCache::KeyData *get(const QPixmapCache::Key &key) | - | ||||||||||||||||||
| 85 | {return never executed: key.d;return key.d;never executed: }return key.d; | 0 | ||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | static QPixmapCache::KeyData* getKeyData(QPixmapCache::Key *key); | - | ||||||||||||||||||
| 88 | - | |||||||||||||||||||
| 89 | bool flushDetachedPixmaps(bool nt); | - | ||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | private: | - | ||||||||||||||||||
| 92 | enum { soon_time = 10000, flush_time = 30000 }; | - | ||||||||||||||||||
| 93 | int *keyArray; | - | ||||||||||||||||||
| 94 | int theid; | - | ||||||||||||||||||
| 95 | int ps; | - | ||||||||||||||||||
| 96 | int keyArraySize; | - | ||||||||||||||||||
| 97 | int freeKey; | - | ||||||||||||||||||
| 98 | QHash<QString, QPixmapCache::Key> cacheKeys; | - | ||||||||||||||||||
| 99 | bool t; | - | ||||||||||||||||||
| 100 | }; | - | ||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | - | |||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | uint qHash(const QPixmapCache::Key &k) | - | ||||||||||||||||||
| 106 | { | - | ||||||||||||||||||
| 107 | return never executed: qHash(QPMCache::get(k)->key);return qHash(QPMCache::get(k)->key);never executed: return qHash(QPMCache::get(k)->key); | 0 | ||||||||||||||||||
| 108 | } | - | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | QPMCache::QPMCache() | - | ||||||||||||||||||
| 111 | : QObject(0), | - | ||||||||||||||||||
| 112 | QCache<QPixmapCache::Key, QPixmapCacheEntry>(cache_limit * 1024), | - | ||||||||||||||||||
| 113 | keyArray(0), theid(0), ps(0), keyArraySize(0), freeKey(0), t(false) | - | ||||||||||||||||||
| 114 | { | - | ||||||||||||||||||
| 115 | } never executed: end of block | 0 | ||||||||||||||||||
| 116 | QPMCache::~QPMCache() | - | ||||||||||||||||||
| 117 | { | - | ||||||||||||||||||
| 118 | clear(); | - | ||||||||||||||||||
| 119 | free(keyArray); | - | ||||||||||||||||||
| 120 | } never executed: end of block | 0 | ||||||||||||||||||
| 121 | bool QPMCache::flushDetachedPixmaps(bool nt) | - | ||||||||||||||||||
| 122 | { | - | ||||||||||||||||||
| 123 | int mc = maxCost(); | - | ||||||||||||||||||
| 124 | setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1); | - | ||||||||||||||||||
| 125 | setMaxCost(mc); | - | ||||||||||||||||||
| 126 | ps = totalCost(); | - | ||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | bool any = false; | - | ||||||||||||||||||
| 129 | QHash<QString, QPixmapCache::Key>::iterator it = cacheKeys.begin(); | - | ||||||||||||||||||
| 130 | while (it != cacheKeys.end()
| 0 | ||||||||||||||||||
| 131 | if (!contains(it.value())
| 0 | ||||||||||||||||||
| 132 | releaseKey(it.value()); | - | ||||||||||||||||||
| 133 | it = cacheKeys.erase(it); | - | ||||||||||||||||||
| 134 | any = true; | - | ||||||||||||||||||
| 135 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 136 | ++it; | - | ||||||||||||||||||
| 137 | } never executed: end of block | 0 | ||||||||||||||||||
| 138 | } | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | return never executed: any;return any;never executed: return any; | 0 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | void QPMCache::timerEvent(QTimerEvent *) | - | ||||||||||||||||||
| 144 | { | - | ||||||||||||||||||
| 145 | bool nt = totalCost() == ps; | - | ||||||||||||||||||
| 146 | if (!flushDetachedPixmaps(nt)
| 0 | ||||||||||||||||||
| 147 | killTimer(theid); | - | ||||||||||||||||||
| 148 | theid = 0; | - | ||||||||||||||||||
| 149 | } never executed: else if (nt != tend of block
| 0 | ||||||||||||||||||
| 150 | killTimer(theid); | - | ||||||||||||||||||
| 151 | theid = startTimer(nt ? soon_time : flush_time); | - | ||||||||||||||||||
| 152 | t = nt; | - | ||||||||||||||||||
| 153 | } never executed: end of block | 0 | ||||||||||||||||||
| 154 | } never executed: end of block | 0 | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | QPixmap *QPMCache::object(const QString &key) const | - | ||||||||||||||||||
| 158 | { | - | ||||||||||||||||||
| 159 | QPixmapCache::Key cacheKey = cacheKeys.value(key); | - | ||||||||||||||||||
| 160 | if (!cacheKey.d
| 0 | ||||||||||||||||||
| 161 | const_cast<QPMCache *>(this)->cacheKeys.remove(key); | - | ||||||||||||||||||
| 162 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 163 | } | - | ||||||||||||||||||
| 164 | QPixmap *ptr = QCache<QPixmapCache::Key, QPixmapCacheEntry>::object(cacheKey); | - | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | if (!ptr
| 0 | ||||||||||||||||||
| 167 | const_cast<QPMCache *>(this)->cacheKeys.remove(key); | - | ||||||||||||||||||
| 168 | } never executed: end of block | 0 | ||||||||||||||||||
| 169 | return never executed: ptr;return ptr;never executed: return ptr; | 0 | ||||||||||||||||||
| 170 | } | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | QPixmap *QPMCache::object(const QPixmapCache::Key &key) const | - | ||||||||||||||||||
| 173 | { | - | ||||||||||||||||||
| 174 | ((!(key.d->isValid)) ? qt_assert("key.d->isValid",__FILE__,317) : qt_noop()); | - | ||||||||||||||||||
| 175 | QPixmap *ptr = QCache<QPixmapCache::Key, QPixmapCacheEntry>::object(key); | - | ||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | if (!ptr
| 0 | ||||||||||||||||||
| 178 | const_cast< never executed: QPMCache *>(this)->releaseKey(key);const_cast<QPMCache *>(this)->releaseKey(key);never executed: const_cast<QPMCache *>(this)->releaseKey(key); | 0 | ||||||||||||||||||
| 179 | return never executed: ptr;return ptr;never executed: return ptr; | 0 | ||||||||||||||||||
| 180 | } | - | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost) | - | ||||||||||||||||||
| 183 | { | - | ||||||||||||||||||
| 184 | QPixmapCache::Key cacheKey; | - | ||||||||||||||||||
| 185 | QPixmapCache::Key oldCacheKey = cacheKeys.value(key); | - | ||||||||||||||||||
| 186 | - | |||||||||||||||||||
| 187 | if (oldCacheKey.d
| 0 | ||||||||||||||||||
| 188 | QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(oldCacheKey); | - | ||||||||||||||||||
| 189 | cacheKeys.remove(key); | - | ||||||||||||||||||
| 190 | } never executed: end of block | 0 | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | cacheKey = createKey(); | - | ||||||||||||||||||
| 194 | - | |||||||||||||||||||
| 195 | bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); | - | ||||||||||||||||||
| 196 | if (success
| 0 | ||||||||||||||||||
| 197 | cacheKeys.insert(key, cacheKey); | - | ||||||||||||||||||
| 198 | if (!theid
| 0 | ||||||||||||||||||
| 199 | theid = startTimer(flush_time); | - | ||||||||||||||||||
| 200 | t = false; | - | ||||||||||||||||||
| 201 | } never executed: end of block | 0 | ||||||||||||||||||
| 202 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | releaseKey(cacheKey); | - | ||||||||||||||||||
| 205 | } never executed: end of block | 0 | ||||||||||||||||||
| 206 | return never executed: success;return success;never executed: return success; | 0 | ||||||||||||||||||
| 207 | } | - | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) | - | ||||||||||||||||||
| 210 | { | - | ||||||||||||||||||
| 211 | QPixmapCache::Key cacheKey = createKey(); | - | ||||||||||||||||||
| 212 | bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); | - | ||||||||||||||||||
| 213 | if (success
| 0 | ||||||||||||||||||
| 214 | if (!theid
| 0 | ||||||||||||||||||
| 215 | theid = startTimer(flush_time); | - | ||||||||||||||||||
| 216 | t = false; | - | ||||||||||||||||||
| 217 | } never executed: end of block | 0 | ||||||||||||||||||
| 218 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | releaseKey(cacheKey); | - | ||||||||||||||||||
| 221 | } never executed: end of block | 0 | ||||||||||||||||||
| 222 | return never executed: cacheKey;return cacheKey;never executed: return cacheKey; | 0 | ||||||||||||||||||
| 223 | } | - | ||||||||||||||||||
| 224 | - | |||||||||||||||||||
| 225 | bool QPMCache::replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int cost) | - | ||||||||||||||||||
| 226 | { | - | ||||||||||||||||||
| 227 | ((!(key.d->isValid)) ? qt_assert("key.d->isValid",__FILE__,370) : qt_noop()); | - | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(key); | - | ||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | QPixmapCache::Key cacheKey = createKey(); | - | ||||||||||||||||||
| 232 | - | |||||||||||||||||||
| 233 | bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); | - | ||||||||||||||||||
| 234 | if (success
| 0 | ||||||||||||||||||
| 235 | if(!theid
| 0 | ||||||||||||||||||
| 236 | theid = startTimer(flush_time); | - | ||||||||||||||||||
| 237 | t = false; | - | ||||||||||||||||||
| 238 | } never executed: end of block | 0 | ||||||||||||||||||
| 239 | const_cast<QPixmapCache::Key&>(key) = cacheKey; | - | ||||||||||||||||||
| 240 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | releaseKey(cacheKey); | - | ||||||||||||||||||
| 243 | } never executed: end of block | 0 | ||||||||||||||||||
| 244 | return never executed: success;return success;never executed: return success; | 0 | ||||||||||||||||||
| 245 | } | - | ||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | bool QPMCache::remove(const QString &key) | - | ||||||||||||||||||
| 248 | { | - | ||||||||||||||||||
| 249 | QPixmapCache::Key cacheKey = cacheKeys.value(key); | - | ||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | if (!cacheKey.d
| 0 | ||||||||||||||||||
| 252 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 253 | cacheKeys.remove(key); | - | ||||||||||||||||||
| 254 | return never executed: QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey);return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey);never executed: return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey); | 0 | ||||||||||||||||||
| 255 | } | - | ||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | bool QPMCache::remove(const QPixmapCache::Key &key) | - | ||||||||||||||||||
| 258 | { | - | ||||||||||||||||||
| 259 | return never executed: QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(key);return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(key);never executed: return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(key); | 0 | ||||||||||||||||||
| 260 | } | - | ||||||||||||||||||
| 261 | - | |||||||||||||||||||
| 262 | void QPMCache::resizeKeyArray(int size) | - | ||||||||||||||||||
| 263 | { | - | ||||||||||||||||||
| 264 | if (size <= keyArraySize
| 0 | ||||||||||||||||||
| 265 | return; never executed: return; | 0 | ||||||||||||||||||
| 266 | keyArray = q_check_ptr(reinterpret_cast<int *>(realloc(keyArray, | - | ||||||||||||||||||
| 267 | size * sizeof(int)))); | - | ||||||||||||||||||
| 268 | for (int i = keyArraySize; i != size
| 0 | ||||||||||||||||||
| 269 | keyArray[i] = i + 1; never executed: keyArray[i] = i + 1; | 0 | ||||||||||||||||||
| 270 | keyArraySize = size; | - | ||||||||||||||||||
| 271 | } never executed: end of block | 0 | ||||||||||||||||||
| 272 | - | |||||||||||||||||||
| 273 | QPixmapCache::Key QPMCache::createKey() | - | ||||||||||||||||||
| 274 | { | - | ||||||||||||||||||
| 275 | if (freeKey == keyArraySize
| 0 | ||||||||||||||||||
| 276 | resizeKeyArray(keyArraySize ? keyArraySize << 1 : 2); never executed: resizeKeyArray(keyArraySize ? keyArraySize << 1 : 2); | 0 | ||||||||||||||||||
| 277 | int id = freeKey; | - | ||||||||||||||||||
| 278 | freeKey = keyArray[id]; | - | ||||||||||||||||||
| 279 | QPixmapCache::Key key; | - | ||||||||||||||||||
| 280 | QPixmapCache::KeyData *d = QPMCache::getKeyData(&key); | - | ||||||||||||||||||
| 281 | d->key = ++id; | - | ||||||||||||||||||
| 282 | return never executed: key;return key;never executed: return key; | 0 | ||||||||||||||||||
| 283 | } | - | ||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | void QPMCache::releaseKey(const QPixmapCache::Key &key) | - | ||||||||||||||||||
| 286 | { | - | ||||||||||||||||||
| 287 | if (key.d->key > keyArraySize
| 0 | ||||||||||||||||||
| 288 | return; never executed: return; | 0 | ||||||||||||||||||
| 289 | key.d->key--; | - | ||||||||||||||||||
| 290 | keyArray[key.d->key] = freeKey; | - | ||||||||||||||||||
| 291 | freeKey = key.d->key; | - | ||||||||||||||||||
| 292 | key.d->isValid = false; | - | ||||||||||||||||||
| 293 | key.d->key = 0; | - | ||||||||||||||||||
| 294 | } never executed: end of block | 0 | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | void QPMCache::clear() | - | ||||||||||||||||||
| 297 | { | - | ||||||||||||||||||
| 298 | free(keyArray); | - | ||||||||||||||||||
| 299 | keyArray = 0; | - | ||||||||||||||||||
| 300 | freeKey = 0; | - | ||||||||||||||||||
| 301 | keyArraySize = 0; | - | ||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | QList<QPixmapCache::Key> keys = QCache<QPixmapCache::Key, QPixmapCacheEntry>::keys(); | - | ||||||||||||||||||
| 304 | for (int i = 0; i < keys.size()
| 0 | ||||||||||||||||||
| 305 | keys.at(i).d->isValid = false; never executed: keys.at(i).d->isValid = false; | 0 | ||||||||||||||||||
| 306 | QCache<QPixmapCache::Key, QPixmapCacheEntry>::clear(); | - | ||||||||||||||||||
| 307 | } never executed: end of block | 0 | ||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key) | - | ||||||||||||||||||
| 310 | { | - | ||||||||||||||||||
| 311 | if (!key->d
| 0 | ||||||||||||||||||
| 312 | key->d = new QPixmapCache::KeyData; never executed: key->d = new QPixmapCache::KeyData; | 0 | ||||||||||||||||||
| 313 | return never executed: key->d;return key->d;never executed: return key->d; | 0 | ||||||||||||||||||
| 314 | } | - | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | namespace { namespace Q_QGS_pm_cache { typedef QPMCache 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<QPMCache, Q_QGS_pm_cache::innerFunction, Q_QGS_pm_cache::guard> pm_cache;return &holder.value; | 0 | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | int __attribute__((visibility("default"))) q_QPixmapCache_keyHashSize() | - | ||||||||||||||||||
| 319 | { | - | ||||||||||||||||||
| 320 | return never executed: pm_cache()->size();return pm_cache()->size();never executed: return pm_cache()->size(); | 0 | ||||||||||||||||||
| 321 | } | - | ||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | QPixmapCacheEntry::~QPixmapCacheEntry() | - | ||||||||||||||||||
| 324 | { | - | ||||||||||||||||||
| 325 | pm_cache()->releaseKey(key); | - | ||||||||||||||||||
| 326 | } never executed: end of block | 0 | ||||||||||||||||||
| 327 | QPixmap *QPixmapCache::find(const QString &key) | - | ||||||||||||||||||
| 328 | { | - | ||||||||||||||||||
| 329 | return never executed: pm_cache()->object(key);return pm_cache()->object(key);never executed: return pm_cache()->object(key); | 0 | ||||||||||||||||||
| 330 | } | - | ||||||||||||||||||
| 331 | bool QPixmapCache::find(const QString &key, QPixmap& pixmap) | - | ||||||||||||||||||
| 332 | { | - | ||||||||||||||||||
| 333 | return never executed: find(key, &pixmap);return find(key, &pixmap);never executed: return find(key, &pixmap); | 0 | ||||||||||||||||||
| 334 | } | - | ||||||||||||||||||
| 335 | bool QPixmapCache::find(const QString &key, QPixmap* pixmap) | - | ||||||||||||||||||
| 336 | { | - | ||||||||||||||||||
| 337 | QPixmap *ptr = pm_cache()->object(key); | - | ||||||||||||||||||
| 338 | if (ptr
| 0 | ||||||||||||||||||
| 339 | * never executed: pixmap = *ptr;*pixmap = *ptr;never executed: *pixmap = *ptr; | 0 | ||||||||||||||||||
| 340 | return never executed: ptr != 0;return ptr != 0;never executed: return ptr != 0; | 0 | ||||||||||||||||||
| 341 | } | - | ||||||||||||||||||
| 342 | bool QPixmapCache::find(const Key &key, QPixmap* pixmap) | - | ||||||||||||||||||
| 343 | { | - | ||||||||||||||||||
| 344 | - | |||||||||||||||||||
| 345 | if (!key.d
| 0 | ||||||||||||||||||
| 346 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 347 | QPixmap *ptr = pm_cache()->object(key); | - | ||||||||||||||||||
| 348 | if (ptr
| 0 | ||||||||||||||||||
| 349 | * never executed: pixmap = *ptr;*pixmap = *ptr;never executed: *pixmap = *ptr; | 0 | ||||||||||||||||||
| 350 | return never executed: ptr != 0;return ptr != 0;never executed: return ptr != 0; | 0 | ||||||||||||||||||
| 351 | } | - | ||||||||||||||||||
| 352 | bool QPixmapCache::insert(const QString &key, const QPixmap &pixmap) | - | ||||||||||||||||||
| 353 | { | - | ||||||||||||||||||
| 354 | return never executed: pm_cache()->insert(key, pixmap, pixmap.width() * pixmap.height() * pixmap.depth() / 8);return pm_cache()->insert(key, pixmap, pixmap.width() * pixmap.height() * pixmap.depth() / 8);never executed: return pm_cache()->insert(key, pixmap, pixmap.width() * pixmap.height() * pixmap.depth() / 8); | 0 | ||||||||||||||||||
| 355 | } | - | ||||||||||||||||||
| 356 | QPixmapCache::Key QPixmapCache::insert(const QPixmap &pixmap) | - | ||||||||||||||||||
| 357 | { | - | ||||||||||||||||||
| 358 | return never executed: pm_cache()->insert(pixmap, pixmap.width() * pixmap.height() * pixmap.depth() / 8);return pm_cache()->insert(pixmap, pixmap.width() * pixmap.height() * pixmap.depth() / 8);never executed: return pm_cache()->insert(pixmap, pixmap.width() * pixmap.height() * pixmap.depth() / 8); | 0 | ||||||||||||||||||
| 359 | } | - | ||||||||||||||||||
| 360 | bool QPixmapCache::replace(const Key &key, const QPixmap &pixmap) | - | ||||||||||||||||||
| 361 | { | - | ||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | if (!key.d
| 0 | ||||||||||||||||||
| 364 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 365 | return never executed: pm_cache()->replace(key, pixmap, pixmap.width() * pixmap.height() * pixmap.depth() / 8);return pm_cache()->replace(key, pixmap, pixmap.width() * pixmap.height() * pixmap.depth() / 8);never executed: return pm_cache()->replace(key, pixmap, pixmap.width() * pixmap.height() * pixmap.depth() / 8); | 0 | ||||||||||||||||||
| 366 | } | - | ||||||||||||||||||
| 367 | int QPixmapCache::cacheLimit() | - | ||||||||||||||||||
| 368 | { | - | ||||||||||||||||||
| 369 | return never executed: cache_limit;return cache_limit;never executed: return cache_limit; | 0 | ||||||||||||||||||
| 370 | } | - | ||||||||||||||||||
| 371 | void QPixmapCache::setCacheLimit(int n) | - | ||||||||||||||||||
| 372 | { | - | ||||||||||||||||||
| 373 | cache_limit = n; | - | ||||||||||||||||||
| 374 | pm_cache()->setMaxCost(1024 * cache_limit); | - | ||||||||||||||||||
| 375 | } never executed: end of block | 0 | ||||||||||||||||||
| 376 | - | |||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | void QPixmapCache::remove(const QString &key) | - | ||||||||||||||||||
| 381 | { | - | ||||||||||||||||||
| 382 | pm_cache()->remove(key); | - | ||||||||||||||||||
| 383 | } never executed: end of block | 0 | ||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | - | |||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | - | |||||||||||||||||||
| 389 | - | |||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | void QPixmapCache::remove(const Key &key) | - | ||||||||||||||||||
| 392 | { | - | ||||||||||||||||||
| 393 | - | |||||||||||||||||||
| 394 | if (!key.d
| 0 | ||||||||||||||||||
| 395 | return; never executed: return; | 0 | ||||||||||||||||||
| 396 | pm_cache()->remove(key); | - | ||||||||||||||||||
| 397 | } never executed: end of block | 0 | ||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | - | |||||||||||||||||||
| 400 | - | |||||||||||||||||||
| 401 | - | |||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | void QPixmapCache::clear() | - | ||||||||||||||||||
| 404 | { | - | ||||||||||||||||||
| 405 | if (true) { | - | ||||||||||||||||||
| 406 | if (pm_cache.exists()
| 0 | ||||||||||||||||||
| 407 | pm_cache->clear(); never executed: pm_cache->clear(); | 0 | ||||||||||||||||||
| 408 | } never executed: else {end of blockdead code: { } | - | ||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | } dead code: { } | - | ||||||||||||||||||
| 412 | } | - | ||||||||||||||||||
| 413 | - | |||||||||||||||||||
| 414 | void QPixmapCache::flushDetachedPixmaps() | - | ||||||||||||||||||
| 415 | { | - | ||||||||||||||||||
| 416 | pm_cache()->flushDetachedPixmaps(true); | - | ||||||||||||||||||
| 417 | } never executed: end of block | 0 | ||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | int QPixmapCache::totalUsed() | - | ||||||||||||||||||
| 420 | { | - | ||||||||||||||||||
| 421 | return never executed: (pm_cache()->totalCost()+1023) / 1024;return (pm_cache()->totalCost()+1023) / 1024;never executed: return (pm_cache()->totalCost()+1023) / 1024; | 0 | ||||||||||||||||||
| 422 | } | - | ||||||||||||||||||
| 423 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |