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