uigraphics/AknIcon/SvgtFbsRasterizer/src/SvgtFbsRasterizer.cpp
changeset 1 ba33815114d6
parent 0 05e9090e2422
child 2 abcbdabaa4c5
equal deleted inserted replaced
0:05e9090e2422 1:ba33815114d6
    91         }
    91         }
    92     while (!iRecentBmps.IsEmpty())
    92     while (!iRecentBmps.IsEmpty())
    93         {
    93         {
    94         delete iRecentBmps.First();
    94         delete iRecentBmps.First();
    95         }
    95         }
    96     delete iIdle;
       
    97     
    96     
    98     delete iNvgEngine;
    97     delete iNvgEngine;
    99     delete iGraphicsInterface;
    98     delete iGraphicsInterface;
   100     if ( iMatricesUpdated )
    99     if ( iMatricesUpdated )
   101         {
   100         {
   172 	CSvgtRegisteredBitmap* regBmp = RegisteredBitmap(aBitmapId);
   171 	CSvgtRegisteredBitmap* regBmp = RegisteredBitmap(aBitmapId);
   173 	    if (regBmp)
   172 	    if (regBmp)
   174 	        {
   173 	        {
   175 	        if (--regBmp->iRefCount == 0)
   174 	        if (--regBmp->iRefCount == 0)
   176 	            {
   175 	            {
   177 	            // Put unregistered bitmap in the cache of recently used bitmaps if wholly pre-rendered
   176             // Put unregistered bitmap in the cache of recently used bitmaps if wholly pre-rendered
   178 	            // and there is an active scheduler to add the idle-time clean-up active object to
   177             // and there is an active scheduler to add the idle-time clean-up active object to
   179 	            if (CActiveScheduler::Current())
   178 
   180 	                {
   179             regBmp->iLink.Deque();
   181 	                if (!iIdle)
   180             if (regBmp->DataSize() <= iCacheLimit)
   182 	                    {
   181                 {
   183 	                    iIdle = CIdle::New(CActive::EPriorityIdle);
   182                 iRecentBmps.AddFirst(*regBmp);
   184 	                    if (!iIdle)
   183                 iTotalRecentBmpSize += regBmp->DataSize();
   185 	                        {
   184                 }
   186 	                        delete regBmp;
   185             // Delete the least recently used bitmaps if the maximum size of the cache is exceeded
   187 	                        return;
   186             while (iTotalRecentBmpSize > iCacheLimit)
   188 	                        }
   187                 {
   189 	                    }
   188                 regBmp = iRecentBmps.Last();
   190 	                regBmp->iLink.Deque();
   189                 iTotalRecentBmpSize -= regBmp->DataSize();
   191 	                if (regBmp->DataSize() <= iCacheLimit)
   190                 delete regBmp;
   192 	                    {
   191                 }
   193 	                    iRecentBmps.AddFirst(*regBmp);
   192             }
   194 	                    iTotalRecentBmpSize += regBmp->DataSize();
   193         }
   195 	                    }
   194     }
   196 	                // Delete the least recently used bitmaps if the maximum size of the cache is exceeded
       
   197 	                while (iTotalRecentBmpSize > iCacheLimit)
       
   198 	                    {
       
   199 	                    regBmp = iRecentBmps.Last();
       
   200 	                    iTotalRecentBmpSize -= regBmp->DataSize();
       
   201 	                    delete regBmp;
       
   202 	                    }
       
   203 	                // If the cache is not empty make sure the idle-time clean-up active object is scheduled to run
       
   204 	                if (!iRecentBmps.IsEmpty() && !iIdle->IsActive())
       
   205 	                    {
       
   206 	                    iIdle->Start(TCallBack(IdleFunction, this));
       
   207 	                    }
       
   208 	                }  
       
   209 	            else
       
   210 	                {
       
   211 	                delete regBmp;
       
   212 	                }
       
   213 	            }
       
   214 	        }
       
   215 	}
       
   216 
   195 
   217 /** Return a scanline from the passed extended bitmap given it's bitmap id. 
   196 /** Return a scanline from the passed extended bitmap given it's bitmap id. 
   218  */
   197  */
   219 const TUint32* CSvgtFbsRasterizer::ScanLine(TInt64 aBitmapId, const TPoint& aPixel, TInt aLength)
   198 const TUint32* CSvgtFbsRasterizer::ScanLine(TInt64 aBitmapId, const TPoint& aPixel, TInt aLength)
   220 	{
   199 	{
   278             }
   257             }
   279         }
   258         }
   280     return NULL;
   259     return NULL;
   281     }
   260     }
   282 
   261 
   283 TInt CSvgtFbsRasterizer::IdleFunction(TAny* aPtr)
       
   284     {
       
   285      CSvgtFbsRasterizer* self = static_cast<CSvgtFbsRasterizer*>(aPtr);    
       
   286     if(self->iSpecialProcess!=true)
       
   287         {
       
   288        
       
   289         while (!self->iRecentBmps.IsEmpty())
       
   290             {
       
   291             delete self->iRecentBmps.First();
       
   292             }
       
   293         self->iTotalRecentBmpSize = 0;        
       
   294         }
       
   295     return 0;
       
   296     }
       
   297 
       
   298 void CSvgtFbsRasterizer::InitializeRasterizer()
   262 void CSvgtFbsRasterizer::InitializeRasterizer()
   299     {
   263     {
   300     }
   264     }
   301 
   265 
   302 void CSvgtFbsRasterizer::RenderBitmapL(CSvgtRegisteredBitmap& aPixMap, CFbsBitmap * aMask, 
   266 void CSvgtFbsRasterizer::RenderBitmapL(CSvgtRegisteredBitmap& aPixMap, CFbsBitmap * aMask, 
   303                                         const TBitmapDesc& aBitmapDesc, TPtr8& aDataPtr8, TAknIconHeader& aIconHeader)
   267                                         const TBitmapDesc& aBitmapDesc, TPtr8& aDataPtr8, TAknIconHeader& aIconHeader)
   304     {
   268     {
   305     TSize newSize = aBitmapDesc.iSizeInPixels;
   269     TSize newSize = aBitmapDesc.iSizeInPixels;
   306     UpdateMatrices();
   270     UpdateMatrices();
   307     iMatricesUpdated = ETrue;
   271     iMatricesUpdated = ETrue;
       
   272 
   308     TBool isMargin = aIconHeader.IsMarginCorrection();
   273     TBool isMargin = aIconHeader.IsMarginCorrection();
   309     
   274     
   310     VGImage vgImage = VG_INVALID_HANDLE;
   275     VGImage vgImage = VG_INVALID_HANDLE;
   311         
   276         
   312     if (isMargin)
   277     if (isMargin)
   459     
   424     
   460     VGfloat color[4] = { 1.0f, 1.0f, 1.0f, 0.0f };
   425     VGfloat color[4] = { 1.0f, 1.0f, 1.0f, 0.0f };
   461     vgSeti(VG_SCISSORING, VG_FALSE);
   426     vgSeti(VG_SCISSORING, VG_FALSE);
   462     vgSetfv(VG_CLEAR_COLOR, 4, color);
   427     vgSetfv(VG_CLEAR_COLOR, 4, color);
   463     vgClear(0, 0, aBitmapDesc.iSizeInPixels.iWidth, aBitmapDesc.iSizeInPixels.iHeight);
   428     vgClear(0, 0, aBitmapDesc.iSizeInPixels.iWidth, aBitmapDesc.iSizeInPixels.iHeight);
       
   429 
       
   430     vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
       
   431     vgLoadIdentity();
       
   432 
       
   433     vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
       
   434     vgLoadIdentity();
       
   435 
   464     TInt rotAngle = iconheader.GetRotation();
   436     TInt rotAngle = iconheader.GetRotation();
   465     // setting the rotation angle
   437     // setting the rotation angle
   466     iNvgEngine->Rotate(-rotAngle,  aBitmapDesc.iSizeInPixels.iWidth >> 1,aBitmapDesc.iSizeInPixels.iHeight >>1);
   438     iNvgEngine->Rotate(-rotAngle,  aBitmapDesc.iSizeInPixels.iWidth >> 1,aBitmapDesc.iSizeInPixels.iHeight >>1);
   467     
   439     
   468     //setting preserve aspect ratio
   440     //setting preserve aspect ratio