322 |
326 |
323 // If the current thumbnail matches what is required then return the current texture otherwise |
327 // If the current thumbnail matches what is required then return the current texture otherwise |
324 // create a new one. |
328 // create a new one. |
325 if (!GetThumbnailAttributeAndIndexL(aSize, aMedia, aIdSpaceId, thumbnailIndex, thumbNailAttribute)) |
329 if (!GetThumbnailAttributeAndIndexL(aSize, aMedia, aIdSpaceId, thumbnailIndex, thumbNailAttribute)) |
326 { |
330 { |
|
331 // only texture is missing. |
|
332 if ( (NULL != iThumbnailList[thumbnailIndex].iBitmap) && (NULL == iThumbnailList[thumbnailIndex].iTexture)) |
|
333 { |
|
334 CAlfTexture* newTexture = &iAlfTextureManager.CreateTextureL( |
|
335 iThumbnailList[thumbnailIndex].iTextureId, |
|
336 this, |
|
337 EAlfTextureFlagDefault); |
|
338 iThumbnailList[thumbnailIndex].iTexture = newTexture ; |
|
339 } |
327 return *iThumbnailList[thumbnailIndex].iTexture; |
340 return *iThumbnailList[thumbnailIndex].iTexture; |
328 } |
341 } |
329 |
342 |
330 // We have 2 scenarios here. |
343 // We have 2 scenarios here. |
331 // 1) We do not have a thumbnail |
344 // 1) We do not have a thumbnail |
515 if(!aAllTexture) |
528 if(!aAllTexture) |
516 break; |
529 break; |
517 } |
530 } |
518 } |
531 } |
519 } |
532 } |
|
533 |
|
534 // ----------------------------------------------------------------------------- |
|
535 // FlushTextures Removes All Textures |
|
536 // ----------------------------------------------------------------------------- |
|
537 // |
|
538 void CGlxTextureManagerImpl::FlushTextures() |
|
539 { |
|
540 TRACER("CGlxTextureManagerImpl::FlushTextures"); |
|
541 |
|
542 TInt textureID ; |
|
543 TInt i = iThumbnailList.Count(); |
|
544 |
|
545 while(i > 0) |
|
546 { |
|
547 --i; |
|
548 textureID = iThumbnailList[i].iTextureId; |
|
549 iAlfTextureManager.UnloadTexture(textureID ); |
|
550 iThumbnailList[i].iTexture = NULL; |
|
551 } |
|
552 |
|
553 i = iIconList.Count(); |
|
554 while(i > 0) |
|
555 { |
|
556 --i; |
|
557 textureID = iIconList[i].iTextureId; |
|
558 iAlfTextureManager.UnloadTexture(textureID ); |
|
559 iIconList[i].iTexture = NULL; |
|
560 } |
|
561 |
|
562 i = iZoomedList.Count(); |
|
563 while(i > 0) |
|
564 { |
|
565 --i; |
|
566 textureID = iZoomedList[i].iTextureId; |
|
567 iAlfTextureManager.UnloadTexture(textureID ); |
|
568 iZoomedList[i].iTexture = NULL; |
|
569 } |
|
570 } |
|
571 |
520 // ----------------------------------------------------------------------------- |
572 // ----------------------------------------------------------------------------- |
521 // GetThumbnailAttributeAndIndexL |
573 // GetThumbnailAttributeAndIndexL |
522 // ----------------------------------------------------------------------------- |
574 // ----------------------------------------------------------------------------- |
523 // |
575 // |
524 TBool CGlxTextureManagerImpl::GetThumbnailAttributeAndIndexL( TSize aSize, |
576 TBool CGlxTextureManagerImpl::GetThumbnailAttributeAndIndexL( TSize aSize, |
549 // No need to do anything |
601 // No need to do anything |
550 return EFalse; |
602 return EFalse; |
551 } |
603 } |
552 } |
604 } |
553 } |
605 } |
554 |
|
555 return ETrue; |
606 return ETrue; |
556 } |
607 } |
557 |
608 // ----------------------------------------------------------------------------- |
|
609 // CreateNewTextureL |
|
610 // ----------------------------------------------------------------------------- |
|
611 CAlfTexture* CGlxTextureManagerImpl::CreateZoomedTextureL() |
|
612 { |
|
613 TRACER("CGlxTextureManagerImpl::CreateZoomedTextureL"); |
|
614 TInt count = iZoomedList.Count(); |
|
615 TInt index = 0 ; |
|
616 |
|
617 for (index = count-1; index >=0 ; index--) |
|
618 { |
|
619 if (NULL == iZoomedList[index].iTexture) |
|
620 { |
|
621 if (NULL != iZoomedList[index].iBitmap) |
|
622 { |
|
623 // If we got this far we need to create a new texture |
|
624 iZoomedList[index].iTextureId = NextTextureId(); |
|
625 iZoomedList[index].iTexture = &iAlfTextureManager.CreateTextureL( |
|
626 iZoomedList[index].iTextureId, |
|
627 this, |
|
628 EAlfTextureFlagDefault); |
|
629 return iZoomedList[index].iTexture ; |
|
630 } |
|
631 } |
|
632 } |
|
633 return NULL; |
|
634 } |
558 // ----------------------------------------------------------------------------- |
635 // ----------------------------------------------------------------------------- |
559 // CreateNewTextureL |
636 // CreateNewTextureL |
560 // ----------------------------------------------------------------------------- |
637 // ----------------------------------------------------------------------------- |
561 CAlfTexture& CGlxTextureManagerImpl::CreateNewTextureL( TSize aSize, |
638 CAlfTexture& CGlxTextureManagerImpl::CreateNewTextureL( TSize aSize, |
562 const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId, |
639 const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId, |
654 } |
730 } |
655 |
731 |
656 return *newTexture; |
732 return *newTexture; |
657 } |
733 } |
658 |
734 |
659 |
|
660 // ----------------------------------------------------------------------------- |
735 // ----------------------------------------------------------------------------- |
661 // CreateZoomedTextureL |
736 // CreateZoomedTextureL |
662 // ----------------------------------------------------------------------------- |
737 // ----------------------------------------------------------------------------- |
663 // |
738 // |
664 CAlfTexture& CGlxTextureManagerImpl::CreateZoomedTextureL( |
739 CAlfTexture& CGlxTextureManagerImpl::CreateZoomedTextureL( |
665 const TGlxMedia& aMedia, const TMPXAttribute& aAttribute, |
740 const TGlxMedia& aMedia, const TMPXAttribute& aAttribute, |
666 TGlxIdSpaceId aIdSpaceId, MGlxTextureObserver* aObserver) |
741 TGlxIdSpaceId aIdSpaceId, MGlxTextureObserver* aObserver) |
667 { |
742 { |
668 TRACER("CGlxTextureManagerImpl::CreateZoomedTextureL"); |
743 TRACER("CGlxTextureManagerImpl::CreateZoomedTextureL"); |
669 if(!iZoomDecoder) |
744 if(!iZoomDecoder) |
670 { |
745 { |
671 GLX_LOG_INFO("CGlxTextureManagerImpl:: CreateZoomedTextureL,iZoomDecoder == NULL"); |
746 GLX_LOG_INFO("CGlxTextureManagerImpl:: CreateZoomedTextureL,iZoomDecoder == NULL"); |
672 iZoomDecoder = CGlxBitmapDecoderWrapper::NewL(this); |
747 iZoomDecoder = CGlxBitmapDecoderWrapper::NewL(this); |
673 } |
748 } |
674 |
749 |
675 TGlxThumbnailIcon aThumbData; |
750 TGlxThumbnailIcon aThumbData; |
676 |
751 |
677 aThumbData.iTextureId = NextTextureId(); |
752 aThumbData.iTextureId = NextTextureId(); |
678 aThumbData.iTexture = NULL; |
753 aThumbData.iTexture = NULL; |
679 aThumbData.iAttribId = aAttribute; |
754 aThumbData.iAttribId = aAttribute; |
680 aThumbData.iMediaId = aMedia.Id(); |
755 aThumbData.iMediaId = aMedia.Id(); |
681 aThumbData.iIdSpaceId = aIdSpaceId; |
756 aThumbData.iIdSpaceId = aIdSpaceId; |
1021 TRACER("CGlxTextureManagerImpl::HandleBitmapDecodedL"); |
1099 TRACER("CGlxTextureManagerImpl::HandleBitmapDecodedL"); |
1022 CAlfTexture* newTexture = NULL; |
1100 CAlfTexture* newTexture = NULL; |
1023 TBool textureCreated = ETrue; |
1101 TBool textureCreated = ETrue; |
1024 TInt textureID = -1; |
1102 TInt textureID = -1; |
1025 TInt textureToBeUnloaded = -1; |
1103 TInt textureToBeUnloaded = -1; |
1026 |
1104 |
1027 //check if the image is decoded |
1105 //check if the image is decoded |
1028 if(aBitmap != NULL) |
1106 if(aBitmap != NULL) |
1029 { |
1107 { |
1030 iZoomedList[aThumbnailIndex].iBitmap = aBitmap; |
1108 iZoomedList[aThumbnailIndex].iBitmap = aBitmap; |
1031 |
1109 |
1032 //if we already have a texture then dont unload the texture before creating |
1110 //if we already have a texture then dont unload the texture before creating |
1033 //the next one. It might happen that because of low memory we might not be able |
1111 //the next one. It might happen that because of low memory we might not be able |
1034 //to create a new texture. |
1112 //to create a new texture. |
1035 if(iZoomedList[aThumbnailIndex].iTexture) |
1113 if(iZoomedList[aThumbnailIndex].iTexture) |
1036 { |
1114 { |
1037 textureID = NextTextureId(); |
1115 textureID = NextTextureId(); |
1038 textureToBeUnloaded = iZoomedList[aThumbnailIndex].iTextureId ; |
1116 textureToBeUnloaded = iZoomedList[aThumbnailIndex].iTextureId ; |
1039 iZoomedList[aThumbnailIndex].iTextureId = textureID ; |
1117 iZoomedList[aThumbnailIndex].iTextureId = textureID ; |
1040 } |
1118 } |
1041 else |
1119 else |
1042 { |
1120 { |
1043 textureID = iZoomedList[aThumbnailIndex].iTextureId; |
1121 textureID = iZoomedList[aThumbnailIndex].iTextureId; |
1044 } |
1122 } |
1045 |
|
1046 TRAPD(err, newTexture = &iAlfTextureManager.CreateTextureL( |
|
1047 textureID, this, EAlfTextureFlagDefault)); |
|
1048 if ( KErrNone != err && KErrNoMemory == err ) |
|
1049 { |
|
1050 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded ReleaseRam : START RAM RELEASE"); |
|
1051 iCache->ReleaseRAML(ETrue); |
|
1052 TRAPD(err, newTexture = &iAlfTextureManager.CreateTextureL(textureID, this, EAlfTextureFlagDefault)); |
|
1053 if ( KErrNone != err && KErrNoMemory == err ) |
|
1054 { |
|
1055 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded CreateTextureL : LOW MEMORY CONDITION"); |
|
1056 textureCreated = EFalse; |
|
1057 } |
|
1058 } |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 textureCreated = EFalse; |
|
1063 } |
|
1064 |
|
1065 if(iZoomedList[aThumbnailIndex].iBitmap) |
|
1066 { |
|
1067 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded delete iBitmap"); |
|
1068 delete iZoomedList[aThumbnailIndex].iBitmap; |
|
1069 iZoomedList[aThumbnailIndex].iBitmap = NULL; |
|
1070 } |
|
1071 |
1123 |
|
1124 TRAPD(err, newTexture = &iAlfTextureManager.CreateTextureL( |
|
1125 textureID, this, EAlfTextureFlagDefault)); |
|
1126 if ( KErrNone != err && KErrNoMemory == err ) |
|
1127 { |
|
1128 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded ReleaseRam : START RAM RELEASE"); |
|
1129 iCache->ReleaseRAML(ETrue); |
|
1130 TRAPD(err, newTexture = &iAlfTextureManager.CreateTextureL(textureID, this, EAlfTextureFlagDefault)); |
|
1131 if ( KErrNone != err && KErrNoMemory == err ) |
|
1132 { |
|
1133 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded CreateTextureL : LOW MEMORY CONDITION"); |
|
1134 textureCreated = EFalse; |
|
1135 } |
|
1136 } |
|
1137 } |
|
1138 else |
|
1139 { |
|
1140 textureCreated = EFalse; |
|
1141 } |
|
1142 |
|
1143 |
|
1144 |
1072 if (textureCreated && (NULL != newTexture)) |
1145 if (textureCreated && (NULL != newTexture)) |
1073 { |
1146 { |
1074 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded textureCreated && newTexture"); |
1147 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded textureCreated && newTexture"); |
1075 //If the new texture is created then unload the old texture and store the new texture and textureID. |
1148 //If the new texture is created then unload the old texture and store the new texture and textureID. |
1076 if(iZoomedList[aThumbnailIndex].iTexture) |
1149 if(iZoomedList[aThumbnailIndex].iTexture) |
1077 { |
1150 { |
1078 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded Unloading Old Texture"); |
1151 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded Unloading Old Texture"); |
1079 iAlfTextureManager.UnloadTexture(textureToBeUnloaded ); |
1152 iAlfTextureManager.UnloadTexture(textureToBeUnloaded ); |
1080 } |
1153 } |
1081 iZoomedList[aThumbnailIndex].iTextureId = textureID; |
1154 iZoomedList[aThumbnailIndex].iTextureId = textureID; |
1082 |
|
1083 iZoomedList[aThumbnailIndex].iTexture = newTexture; |
1155 iZoomedList[aThumbnailIndex].iTexture = newTexture; |
1084 } |
1156 } |
1085 |
1157 |
1086 if (iZoomedList[aThumbnailIndex].iObserver) |
1158 if (iZoomedList[aThumbnailIndex].iObserver) |
1087 { |
1159 { |
1088 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded TextureContentChangedL"); |
1160 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded TextureContentChangedL"); |
1089 iZoomedList[aThumbnailIndex].iObserver->TextureContentChangedL( textureCreated ,iZoomedList[aThumbnailIndex].iTexture); |
1161 iZoomedList[aThumbnailIndex].iObserver->TextureContentChangedL( textureCreated ,iZoomedList[aThumbnailIndex].iTexture); |
1090 } |
1162 } |