equal
deleted
inserted
replaced
221 HbIconCacheItem *HbIconDataCache::getCacheItem(const HbIconKey &key, |
221 HbIconCacheItem *HbIconDataCache::getCacheItem(const HbIconKey &key, |
222 HbRenderingMode currentRenderingMode, |
222 HbRenderingMode currentRenderingMode, |
223 bool isMultiIconPiece) |
223 bool isMultiIconPiece) |
224 { |
224 { |
225 HbIconCacheItem *item = 0; |
225 HbIconCacheItem *item = 0; |
226 |
|
227 if (!cache->contains(key)) { |
226 if (!cache->contains(key)) { |
228 return 0; |
227 return 0; |
229 } |
228 } |
230 // Get the cache item associated with the key |
229 // Get the cache item associated with the key |
231 item = (*cache)[(key)]; |
230 item = (*cache)[key]; |
232 |
|
233 if ((item->vectorIconData.type == INVALID_FORMAT) && |
|
234 (item->rasterIconData.type == INVALID_FORMAT)) { |
|
235 cache->remove(key); |
|
236 delete item; |
|
237 return 0; |
|
238 } |
|
239 |
231 |
240 //Debug Code for Test Purpose |
232 //Debug Code for Test Purpose |
241 #ifdef HB_ICON_CACHE_DEBUG |
233 #ifdef HB_ICON_CACHE_DEBUG |
242 addedItemMem = item->rasterIconDataCost; |
234 addedItemMem = item->rasterIconDataCost; |
243 cacheHit++; |
235 cacheHit++; |
376 } else { |
368 } else { |
377 createCpuCacheSpace(item->rasterIconDataCost); |
369 createCpuCacheSpace(item->rasterIconDataCost); |
378 currentCpuCacheSize += item->rasterIconDataCost; |
370 currentCpuCacheSize += item->rasterIconDataCost; |
379 } |
371 } |
380 } |
372 } |
381 if (item->vectorIconData.type != INVALID_FORMAT) { |
373 if (item->vectorIconData.type != INVALID_FORMAT |
|
374 || item->blobIconData.type != INVALID_FORMAT) { |
382 // Increment the CPU cache size |
375 // Increment the CPU cache size |
383 if (item->vectorIconDataCost <= (maxCpuCacheLimit - currentCpuCacheSize)) { |
376 if (item->vectorIconDataCost <= (maxCpuCacheLimit - currentCpuCacheSize)) { |
384 currentCpuCacheSize += item->vectorIconDataCost; |
377 currentCpuCacheSize += item->vectorIconDataCost; |
385 } else { |
378 } else { |
386 // New item's icon data cost is more than available free CPU cahe size |
379 // New item's icon data cost is more than available free CPU cahe size |
495 #ifdef HB_ICON_CACHE_DEBUG |
488 #ifdef HB_ICON_CACHE_DEBUG |
496 rasterLruListCount++; |
489 rasterLruListCount++; |
497 } |
490 } |
498 #endif |
491 #endif |
499 |
492 |
500 if ((item->vectorIconData.type != INVALID_FORMAT) && item->refCount == 0) { |
493 if (item->vectorIconData.type != INVALID_FORMAT |
|
494 && item->blobIconData.type != INVALID_FORMAT) { |
501 |
495 |
502 //Debug Code for Test Purpose |
496 //Debug Code for Test Purpose |
503 #ifdef HB_ICON_CACHE_DEBUG |
497 #ifdef HB_ICON_CACHE_DEBUG |
504 if (! enableCaching) { |
498 if (! enableCaching) { |
505 currentCpuCacheSize -= item->vectorIconDataCost; |
499 currentCpuCacheSize -= item->vectorIconDataCost; |
657 } else { |
651 } else { |
658 return (item->rasterIconDataCost <= (maxCpuCacheLimit - currentCpuCacheSize) |
652 return (item->rasterIconDataCost <= (maxCpuCacheLimit - currentCpuCacheSize) |
659 + cpuLruListSize); |
653 + cpuLruListSize); |
660 } |
654 } |
661 } |
655 } |
662 if (item->vectorIconData.type != INVALID_FORMAT) { |
656 if (item->vectorIconData.type != INVALID_FORMAT |
|
657 || item->blobIconData.type != INVALID_FORMAT) { |
663 if (item->vectorIconDataCost <= 0 || item->vectorIconDataCost > maxCpuCacheLimit) { |
658 if (item->vectorIconDataCost <= 0 || item->vectorIconDataCost > maxCpuCacheLimit) { |
664 return false; |
659 return false; |
665 } |
660 } |
666 if (item->vectorIconDataCost <= (maxCpuCacheLimit - currentCpuCacheSize)) { |
661 if (item->vectorIconDataCost <= (maxCpuCacheLimit - currentCpuCacheSize)) { |
667 return true; |
662 return true; |
961 manager->free(releaseItem->vectorIconData.picData.offset); |
956 manager->free(releaseItem->vectorIconData.picData.offset); |
962 } else if (releaseItem->vectorIconData.type == NVG) { |
957 } else if (releaseItem->vectorIconData.type == NVG) { |
963 manager->free(releaseItem->vectorIconData.nvgData.offset); |
958 manager->free(releaseItem->vectorIconData.nvgData.offset); |
964 } else if (releaseItem->blobIconData.type == BLOB) { |
959 } else if (releaseItem->blobIconData.type == BLOB) { |
965 manager->free(releaseItem->blobIconData.blobData.offset); |
960 manager->free(releaseItem->blobIconData.blobData.offset); |
|
961 releaseItem->blobIconData.type = INVALID_FORMAT; |
966 } |
962 } |
967 releaseItem->vectorIconData.type = INVALID_FORMAT; |
963 releaseItem->vectorIconData.type = INVALID_FORMAT; |
968 releaseItem->cpuLink.setNext(0); |
964 releaseItem->cpuLink.setNext(0); |
969 releaseItem->cpuLink.setPrev(0); |
965 releaseItem->cpuLink.setPrev(0); |
970 } |
966 } |