diff -r 6ef40bf8fd34 -r 08459e712984 uigraphics/AknIcon/SvgtFbsRasterizer/src/SvgtFbsRasterizer.cpp --- a/uigraphics/AknIcon/SvgtFbsRasterizer/src/SvgtFbsRasterizer.cpp Wed Apr 14 17:02:13 2010 +0300 +++ b/uigraphics/AknIcon/SvgtFbsRasterizer/src/SvgtFbsRasterizer.cpp Tue Apr 27 17:41:10 2010 +0300 @@ -28,6 +28,8 @@ #include #include +#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(this); + break; + case KUidEnableSvgtRasterizer: + aInterface = static_cast(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, @@ -551,7 +591,7 @@ TReal R = 1.0; TInt HaN = Ha; - const TInt lastColumn = aSize.iWidth - 1; + const TInt lastColumn = aSize.iHeight - 1; for ( TInt curRow = 0; curRow < validMargin; curRow++ ) { const TInt y = (aSize.iHeight - 1) - curRow; // h - 1 is the last line @@ -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; + } + } }