3136 // |
3136 // |
3137 TInt CHuiCanvasTextureCache::CalculateUnusedCanvasTextureUsageInKbytes() |
3137 TInt CHuiCanvasTextureCache::CalculateUnusedCanvasTextureUsageInKbytes() |
3138 { |
3138 { |
3139 // TODO: This should handle NVG textures |
3139 // TODO: This should handle NVG textures |
3140 |
3140 |
|
3141 // No need to fetch only the unused texture entries to a separate binary |
|
3142 // ordered tree (with FindUnusedEntries()), just going the cached |
|
3143 // texts & images through once is enough. |
3141 TInt totalUnusedTextureBytes = 0; |
3144 TInt totalUnusedTextureBytes = 0; |
|
3145 TSize textureSize(0,0); |
3142 |
3146 |
3143 // Texts |
3147 // Texts |
3144 RPointerArray<CHuiCanvasTextImage> textEntries; |
3148 for(TInt i = iCachedTexts.Count() - 1; i >= 0; i--) |
3145 |
3149 { |
3146 FindUnusedTextEntries(textEntries); |
3150 CHuiCanvasTextImage* entry = iCachedTexts[i]; |
3147 |
3151 // Check if the texture is being used.. |
3148 for(TInt i=textEntries.Count() - 1; i >= 0; i--) |
3152 if (!entry->iActiveUsers.Count()) |
3149 { |
3153 { |
3150 TSize textureSize = textEntries[i]->iTexture->Size(); |
3154 // ..and if not, add it to the sum. |
3151 totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * KHuiCanvasTextEstimatedBpp/8.f; |
3155 textureSize = entry->iTexture->Size(); |
3152 } |
3156 totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * KHuiCanvasTextEstimatedBpp/8.f; |
3153 |
3157 } |
3154 textEntries.Close(); |
3158 } |
3155 |
3159 |
3156 // Images |
3160 // Images, just like texts. |
3157 RPointerArray<CHuiCanvasGraphicImage> imageEntries; |
3161 for(TInt i = iCachedImages.Count() - 1; i >= 0; i--) |
3158 |
3162 { |
3159 FindUnusedImageEntries(imageEntries); |
3163 CHuiCanvasGraphicImage* entry = iCachedImages[i]; |
3160 |
3164 if (!entry->iActiveUsers.Count()) |
3161 for(TInt i=imageEntries.Count() - 1; i >= 0; i--) |
3165 { |
3162 { |
3166 TBool is16bit = EFalse; |
3163 TBool is16bit = EFalse; |
3167 if (entry->iBitmap && !entry->iMask && entry->iBitmap->ExtendedBitmapType() == KNullUid && entry->iBitmap->DisplayMode() == EColor64K) |
3164 if (imageEntries[i]->iBitmap && !imageEntries[i]->iMask && imageEntries[i]->iBitmap->ExtendedBitmapType() == KNullUid &&imageEntries[i]->iBitmap->DisplayMode() == EColor64K) |
3168 { |
3165 { |
3169 is16bit = ETrue; |
3166 is16bit = ETrue; |
3170 } |
3167 } |
3171 textureSize = entry->iTexture->Size(); |
3168 |
3172 totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * (is16bit ? KHuiCanvasImageEstimatedBpp/16.f : KHuiCanvasImageEstimatedBpp/8.f); |
3169 TSize textureSize = imageEntries[i]->iTexture->Size(); |
3173 } |
3170 totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * (is16bit ? KHuiCanvasImageEstimatedBpp/16.f : KHuiCanvasImageEstimatedBpp/8.f); |
3174 } |
3171 } |
3175 |
3172 |
|
3173 imageEntries.Close(); |
|
3174 |
|
3175 return totalUnusedTextureBytes/1024; |
3176 return totalUnusedTextureBytes/1024; |
3176 } |
3177 } |
3177 |
3178 |
3178 // --------------------------------------------------------------------------- |
3179 // --------------------------------------------------------------------------- |
3179 // |
3180 // |