uigraphics/AknIcon/SvgtFbsRasterizer/src/SvgtFbsRasterizer.cpp
changeset 81 92450c1e1512
parent 50 c6286dcf6040
equal deleted inserted replaced
53:8f0f421d3d0f 81:92450c1e1512
    26 #include <vgcontext.h>
    26 #include <vgcontext.h>
    27 #include <e32cmn.h>
    27 #include <e32cmn.h>
    28 #include <bitstd.h>
    28 #include <bitstd.h>
    29 #include <bitdev.h>
    29 #include <bitdev.h>
    30 
    30 
       
    31 #include "SvgtRasterizerOOMPropertyMonitor.h"
       
    32 
    31 TBool operator==(const CFbsRasterizer::TBitmapDesc& aBitmapDesc1, 
    33 TBool operator==(const CFbsRasterizer::TBitmapDesc& aBitmapDesc1, 
    32 				 const CFbsRasterizer::TBitmapDesc& aBitmapDesc2)
    34 				 const CFbsRasterizer::TBitmapDesc& aBitmapDesc2)
    33 	{
    35 	{
    34 	return ((&aBitmapDesc1 == &aBitmapDesc2)
    36 	return ((&aBitmapDesc1 == &aBitmapDesc2)
    35 			|| (aBitmapDesc1.iSizeInPixels == aBitmapDesc2.iSizeInPixels
    37 			|| (aBitmapDesc1.iSizeInPixels == aBitmapDesc2.iSizeInPixels
    62 	return self;
    64 	return self;
    63 	}
    65 	}
    64 
    66 
    65 /** Constructor */
    67 /** Constructor */
    66 CSvgtFbsRasterizer::CSvgtFbsRasterizer()
    68 CSvgtFbsRasterizer::CSvgtFbsRasterizer()
    67     :iRegisteredBmps(_FOFF(CSvgtRegisteredBitmap, iLink)), iRecentBmps(_FOFF(CSvgtRegisteredBitmap, iLink))
    69 :iRegisteredBmps(_FOFF(CSvgtRegisteredBitmap, iLink)), iRecentBmps(_FOFF(CSvgtRegisteredBitmap, iLink))
    68 	{
    70 	            {
    69 	    RProcess currentProcess;
    71 
    70 	    iCacheLimit = GetCacheLimit(currentProcess.SecureId());
    72 	            }
    71 	    }
       
    72 
    73 
    73 CSvgtFbsRasterizer::~CSvgtFbsRasterizer()
    74 CSvgtFbsRasterizer::~CSvgtFbsRasterizer()
    74     {
    75     {
    75     while (!iRegisteredBmps.IsEmpty())
    76     while (!iRegisteredBmps.IsEmpty())
    76         {
    77         {
    84     delete iNvgEngine;
    85     delete iNvgEngine;
    85     delete iGraphicsInterface;
    86     delete iGraphicsInterface;
    86     if ( iMatricesUpdated )
    87     if ( iMatricesUpdated )
    87         {
    88         {
    88         RestoreMatrices();
    89         RestoreMatrices();
       
    90         }
       
    91     delete iMonitor;//OOM
       
    92     }
       
    93 
       
    94 void CSvgtFbsRasterizer::ChangeCacheLimit( TBool aChangeCacheLimit )//OOM
       
    95     {
       
    96     iCacheLimit = KMaxRecentBmpCacheSize;
       
    97 
       
    98     if(aChangeCacheLimit)
       
    99         {
       
   100         RProcess currentProcess;
       
   101         iCacheLimit = GetCacheLimit(currentProcess.SecureId());
    89         }
   102         }
    90     }
   103     }
    91 
   104 
    92 /** Register a bitmap with this rasterizer for rendering. In this example the extended 
   105 /** Register a bitmap with this rasterizer for rendering. In this example the extended 
    93 bitmap data is just a buffer that is copied when BeginBitmap() is called and deleted when
   106 bitmap data is just a buffer that is copied when BeginBitmap() is called and deleted when
   204 	}
   217 	}
   205 
   218 
   206 /**  No extension interaces are available, KErrNotSupported for all aInterfaceId passed.
   219 /**  No extension interaces are available, KErrNotSupported for all aInterfaceId passed.
   207 @see CFbsRasterizer::GetInterface()
   220 @see CFbsRasterizer::GetInterface()
   208  */
   221  */
   209 TInt CSvgtFbsRasterizer::GetInterface(TUid /*aInterfaceId*/, TAny*& aInterface)
   222 TInt CSvgtFbsRasterizer::GetInterface(TUid aInterfaceId, TAny*& aInterface)
   210 	{
   223     {
   211 	aInterface = NULL;
   224     aInterface = NULL;
   212 	return KErrExtensionNotSupported;
   225     TInt err = KErrNone;
   213 	}
   226 
       
   227     switch (aInterfaceId.iUid)
       
   228         {
       
   229         case KUidFbsRasterizerClearCache:
       
   230             aInterface = static_cast<MFbsRasterizerClearCache*>(this);
       
   231             break;
       
   232         case KUidEnableSvgtRasterizer:
       
   233             aInterface = static_cast<MSvgtRasterizerCacheLimitHandler*>(this);
       
   234             break;
       
   235         default:
       
   236             err = KErrExtensionNotSupported;                        
       
   237             break;
       
   238         }
       
   239 
       
   240     return err;
       
   241 
       
   242 
       
   243     }
   214 
   244 
   215 
   245 
   216 /** Gets a bitmap that has been registered with this rasterizer.
   246 /** Gets a bitmap that has been registered with this rasterizer.
   217 
   247 
   218 @param aBitmapId The ID of the bitmap to check for.
   248 @param aBitmapId The ID of the bitmap to check for.
   251     return NULL;
   281     return NULL;
   252     }
   282     }
   253 
   283 
   254 void CSvgtFbsRasterizer::InitializeRasterizer()
   284 void CSvgtFbsRasterizer::InitializeRasterizer()
   255     {
   285     {
       
   286     TBool cacheEnabled=TRUE;
       
   287     RProperty::Get(KSvgtPropertyCategory, ESvgtPropertyBool, cacheEnabled);
       
   288     iCacheLimit = KMaxRecentBmpCacheSize;
       
   289     if(cacheEnabled)
       
   290         {
       
   291         RProcess currentProcess;
       
   292         iCacheLimit = GetCacheLimit(currentProcess.SecureId());
       
   293         }
       
   294     TRAPD(err, iMonitor = CSvgtRasterizerOOMPropertyMonitor::NewL());
       
   295     iIsRasterizerValidState = ( err == KErrNone);
   256     }
   296     }
   257 
   297 
   258 void CSvgtFbsRasterizer::RenderBitmapL(CSvgtRegisteredBitmap& aPixMap, CFbsBitmap * aMask, 
   298 void CSvgtFbsRasterizer::RenderBitmapL(CSvgtRegisteredBitmap& aPixMap, CFbsBitmap * aMask, 
   259                                         const TBitmapDesc& aBitmapDesc, TPtr8& aDataPtr8, TAknIconHeader& aIconHeader)
   299                                         const TBitmapDesc& aBitmapDesc, TPtr8& aDataPtr8, TAknIconHeader& aIconHeader)
   260     {
   300     {
   637         }
   677         }
   638 
   678 
   639     }
   679     }
   640 
   680 
   641 TInt CSvgtFbsRasterizer::GetCacheLimit(TUid aProcessUID) const
   681 TInt CSvgtFbsRasterizer::GetCacheLimit(TUid aProcessUID) const
   642     {
   682 {
   643     TInt cacheLimit = KMaxRecentBmpCacheSize;
   683     TInt cacheLimit = KMaxRecentBmpCacheSize;
   644 
   684     
   645     RProcess currentProcess;
   685     RProcess currentProcess;
   646    
   686     
   647     if(aProcessUID == TUid::Uid(0x10003B20)) // Alf 
   687     if(aProcessUID == TUid::Uid(0x10003B20)) // Alf 
   648         {
   688         {
   649         cacheLimit = 0x600000; 
   689         cacheLimit = 0x600000; 
   650         }
   690         }
   651     else if(aProcessUID == TUid::Uid(0x10281855)) // Peninputserver
   691     else if(aProcessUID == TUid::Uid(0x10281855)) // Peninputserver
   652         {
   692         {
   653         cacheLimit = 0x133333;
   693         cacheLimit = 0x133333;
   654         }
   694         }
   655     
   695     
   656     return cacheLimit;
   696     return cacheLimit;
   657     }
   697 }
       
   698 void CSvgtFbsRasterizer::ClearCache()//OOM 
       
   699     {
       
   700     CSvgtRegisteredBitmap* regBmp=NULL;
       
   701     if(iCacheLimit>KMaxRecentBmpCacheSize)
       
   702         { 
       
   703         while (!iRecentBmps.IsEmpty()&&(iTotalRecentBmpSize > KMaxRecentBmpCacheSize))
       
   704             {
       
   705             regBmp = iRecentBmps.Last();
       
   706             iTotalRecentBmpSize -= regBmp->DataSize();
       
   707             delete regBmp;
       
   708             }
       
   709         }
       
   710     }