src/hbservers/hbthemeserver/hbicondatacache_p.cpp
changeset 5 627c4a0fd0e7
parent 3 11d3954df52a
child 7 923ff622b8b9
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
   655         // Keep removing  items from the cache till there is
   655         // Keep removing  items from the cache till there is
   656         // enough space to accomdate the new item
   656         // enough space to accomdate the new item
   657         int freedMemory = 0;
   657         int freedMemory = 0;
   658         while (itemCost > freedMemory) {
   658         while (itemCost > freedMemory) {
   659             HbIconCacheItem *itemToRemove = gpuLruList.removeFront();
   659             HbIconCacheItem *itemToRemove = gpuLruList.removeFront();
       
   660             if ( itemToRemove == 0 ){
       
   661                 return ;
       
   662             }    
   660             // Decrement the Size by the cost of the removed icon's data cost
   663             // Decrement the Size by the cost of the removed icon's data cost
   661 #ifdef HB_SGIMAGE_ICON
   664 #ifdef HB_SGIMAGE_ICON
   662 #ifdef HB_ICON_CACHE_DEBUG
   665 #ifdef HB_ICON_CACHE_DEBUG
   663             qDebug() << "HbIconDataCache : Calling SgImage Close. Cost = %d  "
   666             qDebug() << "HbIconDataCache : Calling SgImage Close. Cost = %d  "
   664                      << itemToRemove->rasterIconDataCost;
   667                      << itemToRemove->rasterIconDataCost;
   779 void HbIconDataCache::memoryGood()
   782 void HbIconDataCache::memoryGood()
   780 {
   783 {
   781     goodMemory = true;
   784     goodMemory = true;
   782 }
   785 }
   783 
   786 
   784 void HbIconDataCache::freeGpuRam(int bytes)
   787 void HbIconDataCache::freeGpuRam(int bytes, bool useSwRendering)
   785 {
   788 {
   786     goodMemory = false;
   789     goodMemory = false;
   787     if (bytes  <= gpuLruListSize) {
   790     if (bytes  <= gpuLruListSize) {
   788         createGpuCacheSpace(bytes);
   791         createGpuCacheSpace(bytes);
   789     } else {
   792     } else {
   790         createGpuCacheSpace(gpuLruListSize);
   793         createGpuCacheSpace(gpuLruListSize);
   791     }
   794     }
   792     
   795     
       
   796     if (useSwRendering) {
   793     // Iterate through the cache and remove any active SgImages, before the context
   797     // Iterate through the cache and remove any active SgImages, before the context
   794     // is destroyed.
   798     // is destroyed.
   795     QHash<HbIconKey, HbIconCacheItem*>::const_iterator itEnd(cache->constEnd());
   799     QHash<HbIconKey, HbIconCacheItem*>::const_iterator itEnd(cache->constEnd());
   796     for (QHash<HbIconKey,
   800     for (QHash<HbIconKey,
   797             HbIconCacheItem *>::const_iterator iter = cache->constBegin();
   801             HbIconCacheItem *>::const_iterator iter = cache->constBegin();
   801         if( temp->rasterIconData.type == SGIMAGE ){
   805         if( temp->rasterIconData.type == SGIMAGE ){
   802 #ifdef HB_SGIMAGE_ICON
   806 #ifdef HB_SGIMAGE_ICON
   803             HbSgImageRenderer::removeSgImageFromHash(temp->rasterIconData.sgImageData.id);
   807             HbSgImageRenderer::removeSgImageFromHash(temp->rasterIconData.sgImageData.id);
   804 #endif
   808 #endif
   805             temp->rasterIconData.type = INVALID_FORMAT;
   809             temp->rasterIconData.type = INVALID_FORMAT;
   806             temp->gpuLink.setNext(0);
       
   807             temp->gpuLink.setPrev(0);
       
   808             currentGpuCacheSize -= temp->rasterIconDataCost;
   810             currentGpuCacheSize -= temp->rasterIconDataCost;
   809         }
   811         }
   810     }
   812     }
       
   813     gpuLruList.removeAll();
       
   814     gpuLruListSize = 0;
       
   815     }    	    
   811 }
   816 }
   812 
   817 
   813 /*!
   818 /*!
   814     \fn HbIconDataCache::freeUnusedGpuResources()
   819     \fn HbIconDataCache::freeUnusedGpuResources()
   815     This function internally calls createGpuCacheSpace() which will free up
   820     This function internally calls createGpuCacheSpace() which will free up