equal
deleted
inserted
replaced
398 Actual removal of the cache item from the cache only occurs when the cache has reached a max limit and a new request for |
398 Actual removal of the cache item from the cache only occurs when the cache has reached a max limit and a new request for |
399 insert comes. |
399 insert comes. |
400 \a key denotes the unique identifier for the cache item whose ref count is to be decremented in the cache. |
400 \a key denotes the unique identifier for the cache item whose ref count is to be decremented in the cache. |
401 |
401 |
402 */ |
402 */ |
403 bool HbIconDataCache::remove(const HbIconKey& key) |
403 bool HbIconDataCache::remove(const HbIconKey& key, bool keepInCache) |
404 { |
404 { |
405 if (key.filename.isEmpty() || !cache->contains(key)) { |
405 if (key.filename.isEmpty() || !cache->contains(key)) { |
406 return false; |
406 return false; |
407 } |
407 } |
408 HbIconCacheItem* item = (*cache)[(key)]; |
408 HbIconCacheItem* item = (*cache)[(key)]; |
413 remRfCount = item->refCount; |
413 remRfCount = item->refCount; |
414 #endif |
414 #endif |
415 |
415 |
416 if (item->refCount == 0) { |
416 if (item->refCount == 0) { |
417 if (item->rasterIconData.type == SGIMAGE) { |
417 if (item->rasterIconData.type == SGIMAGE) { |
418 gpuLruList.insertBack(item); |
418 if (keepInCache) { |
419 updateGpuLruSize(item->rasterIconDataCost); |
419 gpuLruList.insertBack(item); |
|
420 updateGpuLruSize(item->rasterIconDataCost); |
|
421 } else { |
|
422 releaseRasterItem(item); |
|
423 removeFromCache(key, item); |
|
424 return true; |
|
425 } |
420 } |
426 } |
421 |
427 |
422 if (item->rasterIconData.type == OTHER_SUPPORTED_FORMATS) { |
428 if (item->rasterIconData.type == OTHER_SUPPORTED_FORMATS) { |
423 cpuLruList.insertBack(item); |
429 if (keepInCache) { |
424 updateCpuLruSize(item->rasterIconDataCost); |
430 cpuLruList.insertBack(item); |
|
431 updateCpuLruSize(item->rasterIconDataCost); |
|
432 } else { |
|
433 releaseRasterItem(item); |
|
434 removeFromCache(key, item); |
|
435 return true; |
|
436 } |
425 } |
437 } |
426 |
438 |
427 |
439 |
428 //Debug Code for Test Purpose |
440 //Debug Code for Test Purpose |
429 #ifdef HB_ICON_CACHE_DEBUG |
441 #ifdef HB_ICON_CACHE_DEBUG |
465 if (currentCpuCacheSize < 0) { |
477 if (currentCpuCacheSize < 0) { |
466 currentCpuCacheSize = 0; |
478 currentCpuCacheSize = 0; |
467 } |
479 } |
468 } else { |
480 } else { |
469 #endif |
481 #endif |
470 |
482 if (keepInCache) { |
471 cpuLruList.insertBack(item); |
483 cpuLruList.insertBack(item); |
472 updateCpuLruSize(item->vectorIconDataCost); |
484 updateCpuLruSize(item->vectorIconDataCost); |
473 |
485 } else { |
|
486 releaseVectorItem(item); |
|
487 removeFromCache(key, item); |
|
488 return true; |
|
489 } |
474 //Debug Code for Test Purpose |
490 //Debug Code for Test Purpose |
475 #ifdef HB_ICON_CACHE_DEBUG |
491 #ifdef HB_ICON_CACHE_DEBUG |
476 vectorLruListCount++; |
492 vectorLruListCount++; |
477 } |
493 } |
478 #endif |
494 #endif |
776 } else { |
792 } else { |
777 createGpuCacheSpace(gpuLruListSize); |
793 createGpuCacheSpace(gpuLruListSize); |
778 } |
794 } |
779 } |
795 } |
780 |
796 |
|
797 QVector<const HbIconKey *> HbIconDataCache::getKeys(const QString &filename) const |
|
798 { |
|
799 QVector<const HbIconKey *> keys; |
|
800 QHash<HbIconKey, HbIconCacheItem*>::const_iterator itEnd(cache->constEnd()); |
|
801 for (QHash < HbIconKey, |
|
802 HbIconCacheItem* >::const_iterator iter = cache->constBegin(); |
|
803 iter != itEnd; |
|
804 ++iter) { |
|
805 const HbIconKey *key = &iter.key(); |
|
806 if (key->filename == filename) { |
|
807 keys.append(key); |
|
808 } |
|
809 } |
|
810 return keys; |
|
811 } |
|
812 |
781 //Debug Code for Test Purpose |
813 //Debug Code for Test Purpose |
782 #ifdef HB_ICON_CACHE_DEBUG |
814 #ifdef HB_ICON_CACHE_DEBUG |
783 void HbIconDataCache::cleanVectorLRUList() |
815 void HbIconDataCache::cleanVectorLRUList() |
784 { |
816 { |
785 |
817 |
811 |
843 |
812 // release item from cache |
844 // release item from cache |
813 removeFromCache(cache->key(itemToRemove), itemToRemove); |
845 removeFromCache(cache->key(itemToRemove), itemToRemove); |
814 } |
846 } |
815 } |
847 } |
|
848 #endif // HB_ICON_CACHE_DEBUG |
816 |
849 |
817 void HbIconDataCache::releaseVectorItem(HbIconCacheItem* releaseItem) |
850 void HbIconDataCache::releaseVectorItem(HbIconCacheItem* releaseItem) |
818 { |
851 { |
819 if (!releaseItem) { |
852 if (!releaseItem) { |
820 return; |
853 return; |
834 releaseItem->vectorIconData.type = INVALID_FORMAT; |
867 releaseItem->vectorIconData.type = INVALID_FORMAT; |
835 releaseItem->cpuLink.setNext(0); |
868 releaseItem->cpuLink.setNext(0); |
836 releaseItem->cpuLink.setPrev(0); |
869 releaseItem->cpuLink.setPrev(0); |
837 } |
870 } |
838 |
871 |
|
872 #ifdef HB_ICON_CACHE_DEBUG |
839 void HbIconDataCache::cleanRasterLRUList() |
873 void HbIconDataCache::cleanRasterLRUList() |
840 { |
874 { |
841 |
875 |
842 // remove all the items from the gpu LRU list |
876 // remove all the items from the gpu LRU list |
843 while (gpuLruList.front()) { |
877 while (gpuLruList.front()) { |
867 |
901 |
868 // relese from the cache. |
902 // relese from the cache. |
869 removeFromCache(cache->key(itemToRemove), itemToRemove); |
903 removeFromCache(cache->key(itemToRemove), itemToRemove); |
870 } |
904 } |
871 } |
905 } |
|
906 #endif // HB_ICON_CACHE_DEBUG |
872 |
907 |
873 void HbIconDataCache::releaseRasterItem(HbIconCacheItem* releaseItem) |
908 void HbIconDataCache::releaseRasterItem(HbIconCacheItem* releaseItem) |
874 { |
909 { |
875 if (!releaseItem) { |
910 if (!releaseItem) { |
876 return; |
911 return; |
892 cache->remove(key); |
927 cache->remove(key); |
893 delete releaseItem; |
928 delete releaseItem; |
894 } |
929 } |
895 } |
930 } |
896 |
931 |
|
932 #ifdef HB_ICON_CACHE_DEBUG |
897 int HbIconDataCache::count() const |
933 int HbIconDataCache::count() const |
898 { |
934 { |
899 return cache->count(); |
935 return cache->count(); |
900 } |
936 } |
901 |
937 |