uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp
branchRCL_3
changeset 15 cd0ae4656946
parent 12 f93c875b566e
child 17 c9d868f1e20c
equal deleted inserted replaced
13:3a60ebea00d0 15:cd0ae4656946
    67 /** Estimated bits per pixel for canvas render buffers */
    67 /** Estimated bits per pixel for canvas render buffers */
    68 const TReal32 KHuiCanvasRenderBufferEstimatedBpp = 32;
    68 const TReal32 KHuiCanvasRenderBufferEstimatedBpp = 32;
    69 
    69 
    70 /** Constant to define target how much memory UI textures should use, 
    70 /** Constant to define target how much memory UI textures should use, 
    71     this is not a hard limit but effects how long unused textures are cached */
    71     this is not a hard limit but effects how long unused textures are cached */
    72 const TInt KHuiMaxRecommendedTextureAmountInKBytes = 4096;
    72 const TInt KHuiMaxRecommendedTextureAmountInKBytes = 6114;
    73 
    73 
    74 /** Constant to define target how much memory UI render buffers should use, 
    74 /** Constant to define target how much memory UI render buffers should use, 
    75     this is not a hard limit but effects how long unused render buffers are cached */
    75     this is not a hard limit but effects how long unused render buffers are cached */
    76 const TInt KHuiMaxRecommendedRenderBufferAmountInKBytes = 0;
    76 const TInt KHuiMaxRecommendedRenderBufferAmountInKBytes = 0;
    77 
    77 
  2938     for(TInt i=aIndexEntries.Count() - 1; i >= 0; i--)
  2938     for(TInt i=aIndexEntries.Count() - 1; i >= 0; i--)
  2939         {
  2939         {
  2940         // Always delete bitmaps from unused entries, we can again duplicate pointers from handles when needed.
  2940         // Always delete bitmaps from unused entries, we can again duplicate pointers from handles when needed.
  2941         // Pointers are kept only for perfromance reasons.
  2941         // Pointers are kept only for perfromance reasons.
  2942         CHuiCanvasGraphicImage* entry = aIndexEntries[i];
  2942         CHuiCanvasGraphicImage* entry = aIndexEntries[i];
  2943 
  2943         TBool is16bit = EFalse;
       
  2944         if (entry->iBitmap && !entry->iMask && entry->iBitmap->ExtendedBitmapType() == KNullUid && entry->iBitmap->DisplayMode() == EColor64K)
       
  2945             {
       
  2946             is16bit = ETrue;
       
  2947             }
  2944         delete entry->iBitmap;    
  2948         delete entry->iBitmap;    
  2945         entry->iBitmap = NULL;
  2949         entry->iBitmap = NULL;
  2946 
  2950 
  2947         delete entry->iMask;    
  2951         delete entry->iMask;    
  2948         entry->iMask = NULL;        
  2952         entry->iMask = NULL;        
  2955             delete entry->iSubImages[j].iMask;
  2959             delete entry->iSubImages[j].iMask;
  2956             entry->iSubImages[j].iMask = NULL;    
  2960             entry->iSubImages[j].iMask = NULL;    
  2957             }
  2961             }
  2958                     
  2962                     
  2959         TSize textureSize = entry->iTexture->Size();    
  2963         TSize textureSize = entry->iTexture->Size();    
  2960         TInt textureEstimatedSizeInBytes = textureSize.iWidth * textureSize.iHeight * KHuiCanvasImageEstimatedBpp/8.f;
  2964         TInt textureEstimatedSizeInBytes = textureSize.iWidth * textureSize.iHeight * (is16bit ? KHuiCanvasImageEstimatedBpp/16.f : KHuiCanvasImageEstimatedBpp/8.f);
  2961 
  2965 
  2962         if (totalUnusedTextureBytes + textureEstimatedSizeInBytes < iUnusedCanvasImageTextureCacheSizeInKBytes*1024)
  2966         if (totalUnusedTextureBytes + textureEstimatedSizeInBytes < iUnusedCanvasImageTextureCacheSizeInKBytes*1024)
  2963             {
  2967             {
  2964             // Fits in the cache, remove from unused list, but keep zero size textures                        
  2968             // Fits in the cache, remove from unused list, but keep zero size textures                        
  2965             if (textureEstimatedSizeInBytes != 0)
  2969             if (textureEstimatedSizeInBytes != 0)
  3154     
  3158     
  3155     FindUnusedImageEntries(imageEntries);
  3159     FindUnusedImageEntries(imageEntries);
  3156 
  3160 
  3157     for(TInt i=imageEntries.Count() - 1; i >= 0; i--)
  3161     for(TInt i=imageEntries.Count() - 1; i >= 0; i--)
  3158         {
  3162         {
       
  3163         TBool is16bit = EFalse;
       
  3164         if (imageEntries[i]->iBitmap && !imageEntries[i]->iMask && imageEntries[i]->iBitmap->ExtendedBitmapType() == KNullUid &&imageEntries[i]->iBitmap->DisplayMode() == EColor64K)
       
  3165             {
       
  3166             is16bit = ETrue;
       
  3167             }
       
  3168 
  3159         TSize textureSize = imageEntries[i]->iTexture->Size();    
  3169         TSize textureSize = imageEntries[i]->iTexture->Size();    
  3160         totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * KHuiCanvasImageEstimatedBpp/8.f;
  3170         totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * (is16bit ? KHuiCanvasImageEstimatedBpp/16.f : KHuiCanvasImageEstimatedBpp/8.f);
  3161         }            
  3171         }            
  3162     
  3172     
  3163     imageEntries.Close();        
  3173     imageEntries.Close();        
  3164     
  3174     
  3165     return totalUnusedTextureBytes/1024;
  3175     return totalUnusedTextureBytes/1024;