769 iTempBitmapGc->Clear(); |
769 iTempBitmapGc->Clear(); |
770 } |
770 } |
771 else |
771 else |
772 { |
772 { |
773 // First clear |
773 // First clear |
774 TRgb clearColor(KRgbBlack); |
774 TRgb clearColor; |
|
775 if (iTempBitmap->DisplayMode() == EColor16MA) |
|
776 { |
|
777 clearColor = aTextImage.iGcParams.iPenColor; |
|
778 iTempBitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
779 } |
|
780 else |
|
781 { |
|
782 clearColor = KRgbBlack; |
|
783 iTempBitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
784 } |
|
785 |
775 clearColor.SetAlpha(0); |
786 clearColor.SetAlpha(0); |
776 iTempBitmapGc->SetPenColor(clearColor); |
787 iTempBitmapGc->SetPenColor(clearColor); |
777 iTempBitmapGc->SetBrushColor(clearColor); |
788 iTempBitmapGc->SetBrushColor(clearColor); |
778 if (iTempBitmap->DisplayMode() == EColor16MA) |
|
779 { |
|
780 iTempBitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
781 } |
|
782 else |
|
783 { |
|
784 iTempBitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
785 } |
|
786 |
|
787 iTempBitmapGc->Clear(); |
789 iTempBitmapGc->Clear(); |
788 |
790 |
789 // Set correct gc settings |
791 // Set correct gc settings |
790 if (!outlinefont && KHuiCanvasTextUseColorModulation) |
792 if (!outlinefont && KHuiCanvasTextUseColorModulation) |
791 { |
793 { |
1226 // Bitmap has changed, must be updated ? |
1228 // Bitmap has changed, must be updated ? |
1227 TBool touchCountChanged = EFalse; |
1229 TBool touchCountChanged = EFalse; |
1228 touchCountChanged |= volatileBitmapOrMask; |
1230 touchCountChanged |= volatileBitmapOrMask; |
1229 touchCountChanged |= (aImage.iBitmapTouchCount != bitmapTouchCount); |
1231 touchCountChanged |= (aImage.iBitmapTouchCount != bitmapTouchCount); |
1230 touchCountChanged |= (aImage.iMaskTouchCount != maskTouchCount); |
1232 touchCountChanged |= (aImage.iMaskTouchCount != maskTouchCount); |
1231 |
1233 TBool serialNumberChanged = (aImage.iSerialNumber != bitmap->SerialNumber()); |
|
1234 |
1232 // Is touch count check enabled ? |
1235 // Is touch count check enabled ? |
1233 TBool touchCountCheckEnabled = CHuiStatic::Env().CanvasTextureCache().IsTouchCountCheckEnabled(); |
1236 TBool touchCountCheckEnabled = CHuiStatic::Env().CanvasTextureCache().IsTouchCountCheckEnabled(); |
1234 |
1237 |
1235 // Has it old content at all ? |
1238 // Has it old content at all ? |
1236 TBool hasContent = aImage.iTexture->HasContent(); |
1239 TBool hasContent = aImage.iTexture->HasContent(); |
1237 |
1240 |
1238 if (!hasContent || (touchCountCheckEnabled && touchCountChanged)) |
1241 if (!hasContent || (touchCountCheckEnabled && touchCountChanged) || serialNumberChanged) |
1239 { |
1242 { |
1240 // Upload bitmap content...this may be slow depending on used HW acceleration ! |
1243 // Upload bitmap content...this may be slow depending on used HW acceleration ! |
1241 if (bitmap->SizeInPixels().iWidth > 0 && |
1244 if (bitmap->SizeInPixels().iWidth > 0 && |
1242 bitmap->SizeInPixels().iHeight > 0 && |
1245 bitmap->SizeInPixels().iHeight > 0 && |
1243 (!mask || (mask->SizeInPixels().iWidth > 0 && mask->SizeInPixels().iHeight))) |
1246 (!mask || (mask->SizeInPixels().iWidth > 0 && mask->SizeInPixels().iHeight > 0))) |
1244 { |
1247 { |
1245 // EHuiTextureUploadFlagDoNotRetainResolution should be removed when |
1248 // EHuiTextureUploadFlagDoNotRetainResolution should be removed when |
1246 // texturecoordinates with segmented textures work. |
1249 // texturecoordinates with segmented textures work. |
1247 // This flag causes ugly scaling to happen with small textures. |
1250 // This flag causes ugly scaling to happen with small textures. |
1248 THuiTextureUploadFlags uploadFlags = THuiTextureUploadFlags(EHuiTextureUploadFlagDoNotRetainResolution | EHuiTextureUploadFlagRetainColorDepth); |
1251 THuiTextureUploadFlags uploadFlags = THuiTextureUploadFlags(EHuiTextureUploadFlagDoNotRetainResolution | EHuiTextureUploadFlagRetainColorDepth); |
1252 startTime.UniversalTime(); |
1255 startTime.UniversalTime(); |
1253 #endif |
1256 #endif |
1254 |
1257 |
1255 CHuiTexture* texture = aImage.iTexture; |
1258 CHuiTexture* texture = aImage.iTexture; |
1256 texture->UploadL(*bitmap, mask, uploadFlags); |
1259 texture->UploadL(*bitmap, mask, uploadFlags); |
|
1260 |
|
1261 // Save the bitmap's serial number to the cached item |
|
1262 aImage.iSerialNumber = bitmap->SerialNumber(); |
1257 |
1263 |
1258 #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL |
1264 #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL |
1259 TTime endTime; |
1265 TTime endTime; |
1260 endTime.UniversalTime(); |
1266 endTime.UniversalTime(); |
1261 TInt uploadTimeInMilliSeconds = endTime.MicroSecondsFrom( startTime ).Int64()/1000; |
1267 TInt uploadTimeInMilliSeconds = endTime.MicroSecondsFrom( startTime ).Int64()/1000; |
1271 } |
1277 } |
1272 |
1278 |
1273 if (aImage.iMaskTouchCount != maskTouchCount) |
1279 if (aImage.iMaskTouchCount != maskTouchCount) |
1274 { |
1280 { |
1275 RDebug::Print(_L(">>> CHuiCanvasGraphicImageRasterizer::UpdateCachedImageL: Reason for uploading is iMaskTouchCount %i, old was %i "), maskTouchCount, aImage.iMaskTouchCount); |
1281 RDebug::Print(_L(">>> CHuiCanvasGraphicImageRasterizer::UpdateCachedImageL: Reason for uploading is iMaskTouchCount %i, old was %i "), maskTouchCount, aImage.iMaskTouchCount); |
|
1282 } |
|
1283 |
|
1284 if (serialNumberChanged) |
|
1285 { |
|
1286 RDebug::Print(_L(">>> CHuiCanvasGraphicImageRasterizer::UpdateCachedImageL: Reason for uploading is changed bitmap serial number %li, old was %li "), bitmap->SerialNumber(), aImage.iSerialNumber); |
1276 } |
1287 } |
1277 |
1288 |
1278 RDebug::Print(_L(">>> CHuiCanvasGraphicImageRasterizer::UpdateCachedImageL: Upload of %ix%i %i+%i took %i ms"), |
1289 RDebug::Print(_L(">>> CHuiCanvasGraphicImageRasterizer::UpdateCachedImageL: Upload of %ix%i %i+%i took %i ms"), |
1279 texture->Size().iWidth, |
1290 texture->Size().iWidth, |
1280 texture->Size().iHeight, |
1291 texture->Size().iHeight, |
2075 // Constructor |
2086 // Constructor |
2076 // --------------------------------------------------------------------------- |
2087 // --------------------------------------------------------------------------- |
2077 // |
2088 // |
2078 CHuiCanvasTextureCache::CHuiCanvasTextureCache() |
2089 CHuiCanvasTextureCache::CHuiCanvasTextureCache() |
2079 { |
2090 { |
2080 EnableLowMemoryState(EFalse); |
2091 SetMemoryLevel(EHuiMemoryLevelNormal); |
2081 CHuiStatic::Env().AddLowMemoryObserver(this); |
2092 CHuiStatic::Env().AddLowMemoryObserver(this); |
2082 } |
2093 } |
2083 |
2094 |
2084 // --------------------------------------------------------------------------- |
2095 // --------------------------------------------------------------------------- |
2085 // Destructor |
2096 // Destructor |