photosgallery/viewframework/texturemanager/src/glxtexturemanagerimpl.cpp
branchRCL_3
changeset 14 ce1c7ad1f18b
parent 13 71da52165949
child 18 bcb43dc84c44
equal deleted inserted replaced
13:71da52165949 14:ce1c7ad1f18b
    79         delete iIconList[i].iTexture;
    79         delete iIconList[i].iTexture;
    80         }
    80         }
    81     iIconList.Close();
    81     iIconList.Close();
    82 
    82 
    83     iThumbnailList.Close();
    83     iThumbnailList.Close();
    84 
    84     
       
    85     iAnimatedTnmList.Close();
       
    86     
    85     // delete zoom textures
    87     // delete zoom textures
    86     count = iZoomedList.Count();
    88     count = iZoomedList.Count();
    87     GLX_LOG_INFO1("CGlxTextureManagerImpl iZoomedList.Count=%d",count);
    89     GLX_LOG_INFO1("CGlxTextureManagerImpl iZoomedList.Count=%d",count);
    88     for(TInt i = count - 1; i >= 0; i--)
    90     for(TInt i = count - 1; i >= 0; i--)
    89         {
    91         {
   474                 }
   476                 }
   475             }
   477             }
   476             // iIconLIst should deleted only once in destructor as
   478             // iIconLIst should deleted only once in destructor as
   477             // they are using in full applicaiton
   479             // they are using in full applicaiton
   478         }
   480         }
       
   481     
       
   482     index = iAnimatedTnmList.Find( aTexture, &TGlxThumbnailIcon::MatchTexture );
       
   483     GLX_LOG_INFO1("CGlxTextureManagerImpl RemoveTexture iAnimatedTnmList index=%d",index);
       
   484     if ( index != KErrNotFound )
       
   485         {
       
   486         if(iAnimatedTnmList[index].iTexture)
       
   487             {
       
   488             GLX_LOG_INFO("RemoveTexture iAnimatedTnmList Stop animation");
       
   489             (iAnimatedTnmList[index].iTexture)->StopAnimation();
       
   490             }
       
   491         iAnimatedTnmList.Remove( index );        
       
   492         iAlfTextureManager.UnloadTexture( aTexture.Id() );
       
   493         }
   479     }
   494     }
   480 
   495 
   481 // -----------------------------------------------------------------------------
   496 // -----------------------------------------------------------------------------
   482 // RemoveZoomList
   497 // RemoveZoomList
   483 // -----------------------------------------------------------------------------
   498 // -----------------------------------------------------------------------------
   511 // -----------------------------------------------------------------------------
   526 // -----------------------------------------------------------------------------
   512 //
   527 //
   513 void CGlxTextureManagerImpl::RemoveTexture(const TGlxMediaId& aMediaId,TBool aAllTexture )
   528 void CGlxTextureManagerImpl::RemoveTexture(const TGlxMediaId& aMediaId,TBool aAllTexture )
   514     {
   529     {
   515     TRACER("CGlxTextureManagerImpl::RemoveTexture 2");
   530     TRACER("CGlxTextureManagerImpl::RemoveTexture 2");
   516     //Bug fix for PKAA-7NRBYZ - added bAllTexture param
   531     //Bug fix for PKAA-7NRBYZ - added aAllTexture param
   517     // Find the texture in the iThumbnailList
   532     // Find the texture in the iThumbnailList
   518     TInt i = iThumbnailList.Count();
   533     TInt i = iThumbnailList.Count();
   519     while(i > 0)
   534     while(i > 0)
   520         {
   535         {
   521         --i;
   536         --i;
   527        	//Bug fix for PKAA-7NRBYZ - Delete all the texture only if it is asked.
   542        	//Bug fix for PKAA-7NRBYZ - Delete all the texture only if it is asked.
   528             if(!aAllTexture)
   543             if(!aAllTexture)
   529                 break;
   544                 break;
   530             }
   545             }
   531         }
   546         }
       
   547     
       
   548     i = iAnimatedTnmList.Count();
       
   549     
       
   550     while(i > 0)
       
   551         {
       
   552         --i;
       
   553         if (iAnimatedTnmList[i].iMediaId == aMediaId)
       
   554             {
       
   555             GLX_LOG_INFO("RemoveTexture 2 iAnimatedTnmList MediaID found");
       
   556             TInt aTexture = iAnimatedTnmList[i].iTextureId;
       
   557             if(iAnimatedTnmList[i].iTexture)
       
   558                 {
       
   559                 GLX_LOG_INFO("RemoveTexture2 iAnimatedTnmList Stop animation");
       
   560                 (iAnimatedTnmList[i].iTexture)->StopAnimation();
       
   561                 }
       
   562             iAnimatedTnmList.Remove(i);
       
   563             iAlfTextureManager.UnloadTexture(aTexture );        
       
   564             }
       
   565         }
   532     }
   566     }
   533 
   567 
   534 // -----------------------------------------------------------------------------
   568 // -----------------------------------------------------------------------------
   535 // FlushTextures Removes All Textures
   569 // FlushTextures Removes All Textures
   536 // -----------------------------------------------------------------------------
   570 // -----------------------------------------------------------------------------
   538 void CGlxTextureManagerImpl::FlushTextures()
   572 void CGlxTextureManagerImpl::FlushTextures()
   539     {
   573     {
   540     TRACER("CGlxTextureManagerImpl::FlushTextures");
   574     TRACER("CGlxTextureManagerImpl::FlushTextures");
   541 
   575 
   542     TInt textureID ;
   576     TInt textureID ;
   543     TInt i = iThumbnailList.Count();
   577     
   544     
   578     TInt i = iThumbnailList.Count();    
   545     while(i > 0)
   579     while(i > 0)
   546         {
   580         {
   547         --i;
   581         --i;
   548         textureID = iThumbnailList[i].iTextureId;
   582         textureID = iThumbnailList[i].iTextureId;
   549         iAlfTextureManager.UnloadTexture(textureID );
   583         iAlfTextureManager.UnloadTexture(textureID );
   564         {
   598         {
   565         --i;
   599         --i;
   566         textureID = iZoomedList[i].iTextureId;
   600         textureID = iZoomedList[i].iTextureId;
   567         iAlfTextureManager.UnloadTexture(textureID );
   601         iAlfTextureManager.UnloadTexture(textureID );
   568         iZoomedList[i].iTexture = NULL;
   602         iZoomedList[i].iTexture = NULL;
       
   603         }
       
   604     
       
   605     i = iAnimatedTnmList.Count();
       
   606     while(i > 0)
       
   607         {
       
   608         --i;
       
   609         textureID = iAnimatedTnmList[i].iTextureId;  
       
   610         if(iAnimatedTnmList[i].iTexture)
       
   611             {
       
   612             GLX_LOG_INFO("FlushTextures iAnimatedTnmList Stop animation");
       
   613             (iAnimatedTnmList[i].iTexture)->StopAnimation();
       
   614             }
       
   615         iAlfTextureManager.UnloadTexture(textureID);
       
   616         iAnimatedTnmList[i].iTexture = NULL;
   569         }
   617         }
   570     }
   618     }
   571 
   619 
   572 // -----------------------------------------------------------------------------
   620 // -----------------------------------------------------------------------------
   573 // GetThumbnailAttributeAndIndexL
   621 // GetThumbnailAttributeAndIndexL
   774 // -----------------------------------------------------------------------------
   822 // -----------------------------------------------------------------------------
   775 // CreateAnimatedGifTextureL
   823 // CreateAnimatedGifTextureL
   776 // -----------------------------------------------------------------------------
   824 // -----------------------------------------------------------------------------
   777 //  
   825 //  
   778 CAlfTexture& CGlxTextureManagerImpl::CreateAnimatedGifTextureL(
   826 CAlfTexture& CGlxTextureManagerImpl::CreateAnimatedGifTextureL(
   779     const TDesC& aFilename, const TSize& aSize)
   827     const TDesC& aFilename, const TSize& aSize,const TGlxMedia& aMedia,
       
   828     TGlxIdSpaceId aIdSpaceId)
   780     { 
   829     { 
   781     TRACER("CGlxTextureManagerImpl::CreateAnimatedGifTextureL");
   830     TRACER("CGlxTextureManagerImpl::CreateAnimatedGifTextureL");
   782     return iAlfTextureManager.LoadTextureL(aFilename,aSize, 
   831     TInt thumbnailIndex = KErrNotFound;    
   783         EAlfTextureFlagDefault,NextTextureId() );
   832     
       
   833     // If the current thumbnail matches what is required then return the current texture otherwise
       
   834     // create a new one.
       
   835     if (!GetAnimatedGifThumbnailIndex( aSize, aMedia, aIdSpaceId,thumbnailIndex))
       
   836         {
       
   837         GLX_LOG_INFO("CreateAnimatedGifTextureL Texture already present");
       
   838         // only texture is missing. 
       
   839         if ((NULL == iAnimatedTnmList[thumbnailIndex].iTexture)) 
       
   840             {            
       
   841             CAlfTexture& newTexture = iAlfTextureManager.LoadTextureL(aFilename,aSize, 
       
   842                     EAlfTextureFlagDefault,iAnimatedTnmList[thumbnailIndex].iTextureId );   
       
   843             iAnimatedTnmList[thumbnailIndex].iTexture = &newTexture ;
       
   844             }
       
   845         return *iAnimatedTnmList[thumbnailIndex].iTexture;
       
   846         }
       
   847     
       
   848     TGlxThumbnailIcon thumbData;    
       
   849     thumbData.iTextureId = NextTextureId();
       
   850     thumbData.iTexture = NULL;    
       
   851     thumbData.iMediaId = aMedia.Id();
       
   852     thumbData.iIdSpaceId = aIdSpaceId;
       
   853     
       
   854     iAnimatedTnmList.ReserveL( iAnimatedTnmList.Count() + 1 );
       
   855 
       
   856     iAnimatedTnmList.Append(thumbData);
       
   857     
       
   858     CAlfTexture& newTexture = iAlfTextureManager.LoadTextureL(aFilename,aSize, 
       
   859             EAlfTextureFlagDefault,thumbData.iTextureId );    
       
   860     
       
   861     TInt index = iAnimatedTnmList.Count()-1;
       
   862     iAnimatedTnmList[index].iTexture = &newTexture;
       
   863     iAnimatedTnmList[index].iRequiredSize = aSize;
       
   864     
       
   865     return newTexture;
   784     }
   866     }
   785 
   867 
   786     
   868     
   787 // -----------------------------------------------------------------------------
   869 // -----------------------------------------------------------------------------
   788 // UpdateTexture
   870 // UpdateTexture
  1024             }
  1106             }
  1025 
  1107 
  1026         // check if rights have expired
  1108         // check if rights have expired
  1027         TBool checkViewRights = (cat==EMPXImage);
  1109         TBool checkViewRights = (cat==EMPXImage);
  1028 
  1110 
  1029         drmInvalid = !iDrmUtility->CheckDisplayRightsL(uri, checkViewRights);
  1111         //Fix for ESLM-82WJ59: Since uri can be either focused or unfocused item
       
  1112         //better call CheckOpenRightsL which doesn't modify lastconsumedUri.
       
  1113         drmInvalid = !iDrmUtility->CheckOpenRightsL(uri, checkViewRights);
       
  1114 
  1030         CGlxMedia* properties = const_cast<CGlxMedia*>(aMedia.Properties());
  1115         CGlxMedia* properties = const_cast<CGlxMedia*>(aMedia.Properties());
  1031         if( !drmInvalid )
  1116         if( !drmInvalid )
  1032             {
  1117             {
  1033             properties->SetTObjectValueL(KGlxMediaGeneralDRMRightsValid, EGlxDrmRightsValid);
  1118             properties->SetTObjectValueL(KGlxMediaGeneralDRMRightsValid, EGlxDrmRightsValid);
  1034             }
  1119             }
  1091     {
  1176     {
  1092     TRACER("CGlxTextureManagerImpl::NextTextureId");
  1177     TRACER("CGlxTextureManagerImpl::NextTextureId");
  1093     return ++iNextTextureId;
  1178     return ++iNextTextureId;
  1094     }
  1179     }
  1095 
  1180 
  1096     
  1181 
       
  1182 // -----------------------------------------------------------------------------
       
  1183 // HandleBitmapDecodedL
       
  1184 // -----------------------------------------------------------------------------
       
  1185 //
  1097 void CGlxTextureManagerImpl::HandleBitmapDecodedL(TInt aThumbnailIndex,CFbsBitmap* aBitmap)
  1186 void CGlxTextureManagerImpl::HandleBitmapDecodedL(TInt aThumbnailIndex,CFbsBitmap* aBitmap)
  1098     {
  1187     {
  1099     TRACER("CGlxTextureManagerImpl::HandleBitmapDecodedL");
  1188     TRACER("CGlxTextureManagerImpl::HandleBitmapDecodedL");
  1100     CAlfTexture* newTexture = NULL;
  1189     CAlfTexture* newTexture = NULL;
  1101     TBool textureCreated = ETrue;
  1190     TBool textureCreated = ETrue;
  1220     CleanupStack::PopAndDestroy(bitmapGc);      
  1309     CleanupStack::PopAndDestroy(bitmapGc);      
  1221     CleanupStack::PopAndDestroy(bitmapDevice);
  1310     CleanupStack::PopAndDestroy(bitmapDevice);
  1222     GLX_LOG_INFO2("===== Actual Image Size %d x %d",aSrcSize.iWidth,aSrcSize.iHeight);
  1311     GLX_LOG_INFO2("===== Actual Image Size %d x %d",aSrcSize.iWidth,aSrcSize.iHeight);
  1223     GLX_LOG_INFO2("===== Scaled Image Size %d x %d",destinationSize.iWidth,destinationSize.iHeight);
  1312     GLX_LOG_INFO2("===== Scaled Image Size %d x %d",destinationSize.iWidth,destinationSize.iHeight);
  1224     }
  1313     }
       
  1314 
       
  1315 
       
  1316 // -----------------------------------------------------------------------------
       
  1317 // GetAnimatedGifThumbnailIndex
       
  1318 // -----------------------------------------------------------------------------
       
  1319 //
       
  1320 TBool CGlxTextureManagerImpl::GetAnimatedGifThumbnailIndex( TSize aSize,
       
  1321         const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId,
       
  1322         TInt& aThumbnailIndex)
       
  1323     {
       
  1324     TRACER("CGlxTextureManagerImpl::GetAnimatedGifThumbnailIndex");    
       
  1325     aThumbnailIndex = KErrNotFound;
       
  1326     
       
  1327     TInt i = iAnimatedTnmList.Count();
       
  1328 
       
  1329     while(i > 0 && aThumbnailIndex == KErrNotFound)
       
  1330         {
       
  1331         --i;
       
  1332         if ((iAnimatedTnmList[i].iMediaId == aMedia.Id()) && 
       
  1333             (iAnimatedTnmList[i].iIdSpaceId == aIdSpaceId) &&            
       
  1334             (iAnimatedTnmList[i].iRequiredSize == aSize))
       
  1335             {
       
  1336             aThumbnailIndex = i;
       
  1337             GLX_LOG_INFO( "GetAnimatedGifThumbnailIndex textureid present" );
       
  1338             // We have found that the best match already exists
       
  1339             // No need to do anything
       
  1340             return EFalse;        
       
  1341             }
       
  1342         }
       
  1343     return ETrue;
       
  1344     }