--- a/uigraphics/AknIcon/SvgtFbsRasterizer/src/SvgtFbsRasterizer.cpp Fri Jun 11 14:37:39 2010 +0300
+++ b/uigraphics/AknIcon/SvgtFbsRasterizer/src/SvgtFbsRasterizer.cpp Wed Jun 23 19:20:17 2010 +0300
@@ -28,6 +28,8 @@
#include <bitstd.h>
#include <bitdev.h>
+#include "SvgtRasterizerOOMPropertyMonitor.h"
+
TBool operator==(const CFbsRasterizer::TBitmapDesc& aBitmapDesc1,
const CFbsRasterizer::TBitmapDesc& aBitmapDesc2)
{
@@ -64,11 +66,10 @@
/** Constructor */
CSvgtFbsRasterizer::CSvgtFbsRasterizer()
- :iRegisteredBmps(_FOFF(CSvgtRegisteredBitmap, iLink)), iRecentBmps(_FOFF(CSvgtRegisteredBitmap, iLink))
- {
- RProcess currentProcess;
- iCacheLimit = GetCacheLimit(currentProcess.SecureId());
- }
+:iRegisteredBmps(_FOFF(CSvgtRegisteredBitmap, iLink)), iRecentBmps(_FOFF(CSvgtRegisteredBitmap, iLink))
+ {
+
+ }
CSvgtFbsRasterizer::~CSvgtFbsRasterizer()
{
@@ -87,6 +88,18 @@
{
RestoreMatrices();
}
+ delete iMonitor;//OOM
+ }
+
+void CSvgtFbsRasterizer::ChangeCacheLimit( TBool aChangeCacheLimit )//OOM
+ {
+ iCacheLimit = KMaxRecentBmpCacheSize;
+
+ if(aChangeCacheLimit)
+ {
+ RProcess currentProcess;
+ iCacheLimit = GetCacheLimit(currentProcess.SecureId());
+ }
}
/** Register a bitmap with this rasterizer for rendering. In this example the extended
@@ -206,11 +219,28 @@
/** No extension interaces are available, KErrNotSupported for all aInterfaceId passed.
@see CFbsRasterizer::GetInterface()
*/
-TInt CSvgtFbsRasterizer::GetInterface(TUid /*aInterfaceId*/, TAny*& aInterface)
- {
- aInterface = NULL;
- return KErrExtensionNotSupported;
- }
+TInt CSvgtFbsRasterizer::GetInterface(TUid aInterfaceId, TAny*& aInterface)
+ {
+ aInterface = NULL;
+ TInt err = KErrNone;
+
+ switch (aInterfaceId.iUid)
+ {
+ case KUidFbsRasterizerClearCache:
+ aInterface = static_cast<MFbsRasterizerClearCache*>(this);
+ break;
+ case KUidEnableSvgtRasterizer:
+ aInterface = static_cast<MSvgtRasterizerCacheLimitHandler*>(this);
+ break;
+ default:
+ err = KErrExtensionNotSupported;
+ break;
+ }
+
+ return err;
+
+
+ }
/** Gets a bitmap that has been registered with this rasterizer.
@@ -253,6 +283,16 @@
void CSvgtFbsRasterizer::InitializeRasterizer()
{
+ TBool cacheEnabled=TRUE;
+ RProperty::Get(KSvgtPropertyCategory, ESvgtPropertyBool, cacheEnabled);
+ iCacheLimit = KMaxRecentBmpCacheSize;
+ if(cacheEnabled)
+ {
+ RProcess currentProcess;
+ iCacheLimit = GetCacheLimit(currentProcess.SecureId());
+ }
+ TRAPD(err, iMonitor = CSvgtRasterizerOOMPropertyMonitor::NewL());
+ iIsRasterizerValidState = ( err == KErrNone);
}
void CSvgtFbsRasterizer::RenderBitmapL(CSvgtRegisteredBitmap& aPixMap, CFbsBitmap * aMask,
@@ -639,11 +679,11 @@
}
TInt CSvgtFbsRasterizer::GetCacheLimit(TUid aProcessUID) const
- {
+{
TInt cacheLimit = KMaxRecentBmpCacheSize;
-
+
RProcess currentProcess;
-
+
if(aProcessUID == TUid::Uid(0x10003B20)) // Alf
{
cacheLimit = 0x600000;
@@ -654,4 +694,17 @@
}
return cacheLimit;
+}
+void CSvgtFbsRasterizer::ClearCache()//OOM
+ {
+ CSvgtRegisteredBitmap* regBmp=NULL;
+ if(iCacheLimit>KMaxRecentBmpCacheSize)
+ {
+ while (!iRecentBmps.IsEmpty()&&(iTotalRecentBmpSize > KMaxRecentBmpCacheSize))
+ {
+ regBmp = iRecentBmps.Last();
+ iTotalRecentBmpSize -= regBmp->DataSize();
+ delete regBmp;
+ }
+ }
}