Changeset 846 for trunk/src/gui/image/qpixmapcache.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/image/qpixmapcache.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 40 40 ****************************************************************************/ 41 41 42 42 43 #include "qpixmapcache.h" 43 44 #include "qobject.h" … … 195 196 static QPixmapCache::KeyData* getKeyData(QPixmapCache::Key *key); 196 197 198 199 200 197 201 private: 202 198 203 int *keyArray; 199 204 int theid; … … 233 238 cache is in active use. 234 239 235 When the last pixmap has been deleted from the cache, kill the 236 timer so Qt won't keep the CPU from going into sleep mode. 237 */ 238 void QPMCache::timerEvent(QTimerEvent *) 240 When the last detached pixmap has been deleted from the cache, kill the 241 timer so Qt won't keep the CPU from going into sleep mode. Currently 242 the timer is not restarted when the pixmap becomes unused, but it does 243 restart once something else is added (i.e. the cache space is actually needed). 244 245 Returns true if any were removed. 246 */ 247 bool QPMCache::flushDetachedPixmaps(bool nt) 239 248 { 240 249 int mc = maxCost(); 241 bool nt = totalCost() == ps;242 250 setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1); 243 251 setMaxCost(mc); 244 252 ps = totalCost(); 245 253 254 246 255 QHash<QString, QPixmapCache::Key>::iterator it = cacheKeys.begin(); 247 256 while (it != cacheKeys.end()) { … … 249 258 releaseKey(it.value()); 250 259 it = cacheKeys.erase(it); 260 251 261 } else { 252 262 ++it; … … 254 264 } 255 265 256 if (!size()) { 266 return any; 267 } 268 269 void QPMCache::timerEvent(QTimerEvent *) 270 { 271 bool nt = totalCost() == ps; 272 if (!flushDetachedPixmaps(nt)) { 257 273 killTimer(theid); 258 274 theid = 0; 259 275 } else if (nt != t) { 260 276 killTimer(theid); 261 theid = startTimer(nt ? 10000 : 30000);277 theid = startTimer(nt ? ); 262 278 t = nt; 263 279 } 264 280 } 281 265 282 266 283 QPixmap *QPMCache::object(const QString &key) const … … 306 323 cacheKeys.insert(key, cacheKey); 307 324 if (!theid) { 308 theid = startTimer( 30000);325 theid = startTimer(); 309 326 t = false; 310 327 } … … 322 339 if (success) { 323 340 if (!theid) { 324 theid = startTimer( 30000);341 theid = startTimer(); 325 342 t = false; 326 343 } … … 343 360 if (success) { 344 361 if(!theid) { 345 theid = startTimer( 30000);362 theid = startTimer(); 346 363 t = false; 347 364 } … … 423 440 } 424 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 425 456 Q_GLOBAL_STATIC(QPMCache, pm_cache) 426 457 … … 634 665 } 635 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 636 682 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.