uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp
branchRCL_3
changeset 8 10534483575f
parent 7 433cbbb6a04b
child 10 88b23e2e82e1
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Fri Mar 12 15:47:04 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Mon Mar 15 12:43:37 2010 +0200
@@ -771,19 +771,21 @@
     else
         {
         // First clear
-        TRgb clearColor(KRgbBlack);
-        clearColor.SetAlpha(0);
-        iTempBitmapGc->SetPenColor(clearColor);
-        iTempBitmapGc->SetBrushColor(clearColor);
+        TRgb clearColor;
         if (iTempBitmap->DisplayMode() == EColor16MA)
             {
+            clearColor = aTextImage.iGcParams.iPenColor;
             iTempBitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
             }
         else
             {
+            clearColor = KRgbBlack;
             iTempBitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
             }
-                            	    
+
+        clearColor.SetAlpha(0);
+        iTempBitmapGc->SetPenColor(clearColor);
+        iTempBitmapGc->SetBrushColor(clearColor);                            	    
 	    iTempBitmapGc->Clear();                  
 
         // Set correct gc settings
@@ -1228,19 +1230,20 @@
     touchCountChanged |= volatileBitmapOrMask;
     touchCountChanged |= (aImage.iBitmapTouchCount != bitmapTouchCount);
     touchCountChanged |= (aImage.iMaskTouchCount != maskTouchCount);
-
+    TBool serialNumberChanged = (aImage.iSerialNumber != bitmap->SerialNumber());
+    
     // Is touch count check enabled ?
     TBool touchCountCheckEnabled = CHuiStatic::Env().CanvasTextureCache().IsTouchCountCheckEnabled();
     
     // Has it old content at all ?
     TBool hasContent = aImage.iTexture->HasContent();
     
-    if (!hasContent || (touchCountCheckEnabled && touchCountChanged))
+    if (!hasContent || (touchCountCheckEnabled && touchCountChanged) || serialNumberChanged)
         {
         // Upload bitmap content...this may be slow depending on used HW acceleration !
         if (bitmap->SizeInPixels().iWidth > 0 && 
             bitmap->SizeInPixels().iHeight > 0 &&
-            (!mask || (mask->SizeInPixels().iWidth > 0 && mask->SizeInPixels().iHeight)))
+            (!mask || (mask->SizeInPixels().iWidth > 0 && mask->SizeInPixels().iHeight > 0)))
             {
             // EHuiTextureUploadFlagDoNotRetainResolution should be removed when 
             // texturecoordinates with segmented textures work.
@@ -1255,6 +1258,9 @@
             CHuiTexture* texture = aImage.iTexture;
             texture->UploadL(*bitmap, mask, uploadFlags);
 
+            // Save the bitmap's serial number to the cached item
+            aImage.iSerialNumber = bitmap->SerialNumber();
+
 #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
             TTime endTime;
             endTime.UniversalTime();
@@ -1274,6 +1280,11 @@
                 {
                 RDebug::Print(_L(">>> CHuiCanvasGraphicImageRasterizer::UpdateCachedImageL: Reason for uploading is iMaskTouchCount %i, old was %i "), maskTouchCount, aImage.iMaskTouchCount);                     
                 }
+            
+            if (serialNumberChanged)
+                {
+                RDebug::Print(_L(">>> CHuiCanvasGraphicImageRasterizer::UpdateCachedImageL: Reason for uploading is changed bitmap serial number %li, old was %li "), bitmap->SerialNumber(), aImage.iSerialNumber);
+                }
 
             RDebug::Print(_L(">>> CHuiCanvasGraphicImageRasterizer::UpdateCachedImageL: Upload of %ix%i %i+%i took %i ms"), 
                 texture->Size().iWidth, 
@@ -2077,7 +2088,7 @@
 //
 CHuiCanvasTextureCache::CHuiCanvasTextureCache()
     {
-    EnableLowMemoryState(EFalse);
+    SetMemoryLevel(EHuiMemoryLevelNormal);
     CHuiStatic::Env().AddLowMemoryObserver(this);
     }