--- a/uifw/AvKon/src/AknSmileyImage.cpp Fri Feb 19 23:04:46 2010 +0200
+++ b/uifw/AvKon/src/AknSmileyImage.cpp Fri Mar 12 15:43:43 2010 +0200
@@ -16,7 +16,6 @@
*/
-
#include <AknUtils.h>
#include <AknsUtils.h>
#include <AknIconUtils.h>
@@ -24,9 +23,9 @@
#include "AknSmileyImage.h"
-const TInt KFrameMaxInterval = 3*1000*1000; // 30s
+const TInt KFrameMaxInterval = 3*1000*1000; // 3s
const TInt KFrameMonitorStep = 5; // monitor once per 5 call, for increase performence
-const TInt KMaxSameFrameRepeat = 6; // 5 * 6, animation frame keep same for 6 times will be stopped
+const TInt KMaxSameFrameRepeat = 6; // 5 * 6, animation whose frame keep the same for 6 times call back, it will be stopped
#define DELZ(ptr) {delete (ptr); (ptr)=NULL;}
@@ -64,7 +63,7 @@
TBool BmpUtils::BitmpIsSame(const CFbsBitmap* aDesBmp, const CFbsBitmap* aSrcBmp)
{
- if(!aDesBmp || !aSrcBmp) return FALSE;
+ if(!aDesBmp || !aSrcBmp) return EFalse;
if(aDesBmp->SizeInPixels() == aSrcBmp->SizeInPixels())
{
@@ -75,13 +74,13 @@
aDesBmp->BeginDataAccess();
aSrcBmp->BeginDataAccess();
TInt result = Mem::Compare((TUint8*)aDesBmp->DataAddress(), length, (TUint8*)aSrcBmp->DataAddress(), length);
- aSrcBmp->EndDataAccess(TRUE);
- aDesBmp->EndDataAccess(TRUE);
+ aSrcBmp->EndDataAccess(ETrue);
+ aDesBmp->EndDataAccess(ETrue);
- if(result == KErrNone) return TRUE;
+ if(result == KErrNone) return ETrue;
}
- return FALSE;
+ return EFalse;
}
@@ -121,11 +120,11 @@
}
CSmileyImage::CSmileyImage(const TAknsItemID& aSkinImage, TInt aPkgImage, TBool aIsAnimation, MSmileyImageObserver* aObserver) :
-iImagePkgItem(aPkgImage),
+iImageMifPkgItemId(aPkgImage),
iIsAnimation(aIsAnimation),
iImageObserver(aObserver)
{
- iImageSkinItem.Set(aSkinImage);
+ iImageSkinItemId.Set(aSkinImage);
}
CSmileyImage::~CSmileyImage()
@@ -137,7 +136,16 @@
void CSmileyImage::LoadL(TInt aRepeat, TInt aDelay)
{
- StartLoadAsynchronousL(aRepeat, aDelay);
+ iRepeatCount = aRepeat;
+
+ if(aDelay > 0)
+ {
+ StartLoadAsynchronousL(aDelay);
+ }
+ else
+ {
+ DoLoadL();
+ }
}
void CSmileyImage::Release()
@@ -179,69 +187,13 @@
void CSmileyImage::BitmapChanged(CFbsBitmap* aBitmap)
{
- iReadyToDraw = TRUE; // animation is ready
+ iReadyToDraw = ETrue; // animation is ready
if(iImageObserver) iImageObserver->BitmapChanged(this, aBitmap);
TRAP_IGNORE(MonitorAnimationEndedL());
}
-void CSmileyImage::DoLoadL()
- {
- StopAnyAsynchronousTask();
-
- if(iFrame) return;
-
- TFileName smileyMifName;
- SmileyUtils::GetCustomizableResPath(smileyMifName, KSmileyMif);
- if(iImageSkinItem.iMinor > 0)
- {
- MAknsSkinInstance* skin = AknsUtils::SkinInstance();
- TRAP_IGNORE( AknsUtils::CreateColorIconL(skin, iImageSkinItem,
- KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19,
- iFrame, iFrameMask,
- smileyMifName, iImagePkgItem, iImagePkgItem,
- AKN_LAF_COLOR(215)));
- }
- else
- {
- TRAP_IGNORE( AknIconUtils::CreateIconL(iFrame, iFrameMask, smileyMifName, iImagePkgItem, iImagePkgItem));
- }
-
- if(iIsAnimation) // the first frame of animation svg is blank without correct content
- {
- iReadyToDraw = FALSE;
- AknIconUtils::SetObserver(iFrame, this);
-
- StopAnimationAsynchronousL(KFrameMaxInterval);
- }
- else // the first frame of static svg has correct content
- {
- iReadyToDraw = TRUE;
- if(iImageObserver) iImageObserver->BitmapChanged(this, iFrame);
- }
-
- AknIconUtils::SetSize(iFrame, iSize);
- }
-
-void CSmileyImage::DoRelease()
- {
- StopAnyAsynchronousTask();
-
- if(!iFrame) return;
-
- DELZ(iFrame);
- DELZ(iFrameMask);
- iFrameSnap->Reset();
-
- iReadyToDraw = FALSE;
- }
-
-void CSmileyImage::StopAnyAsynchronousTask()
- {
- iAsynchronousTaskTimer->Cancel();
- }
-
void CSmileyImage::MonitorAnimationEndedL()
{
// for animation doesn't call back
@@ -251,13 +203,16 @@
iFrameCounter++;
if(iFrameCounter % KFrameMonitorStep) return;
+ // for not call back any more
+ StopAnimationAsynchronousL(KFrameMaxInterval);
+
// monitor the end of animation clip, replay or stop animation if ended
if(BmpUtils::BitmpIsSame(iFrameSnap, iFrame))
{
iSameFrameCounter++;
if(iSameFrameCounter > KMaxSameFrameRepeat)
{
- StopAnimationAsynchronousL();
+ StopAnimationAsynchronousL(); // can not stop animation synchronously
}
}
else
@@ -267,7 +222,59 @@
}
}
-void CSmileyImage::HandleAnimationEndedL()
+void CSmileyImage::DoLoadL()
+ {
+ StopAsynchronousTaskTimer();
+
+ if(iFrame) return;
+
+ TFileName smileyMifName;
+ SmileyUtils::GetCustomizableResPath(smileyMifName, KSmileyMif);
+
+ if(iImageSkinItemId.iMinor > 0)
+ {
+ MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+ TRAPD(err, AknsUtils::CreateColorIconL(skin, iImageSkinItemId,
+ KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19,
+ iFrame, iFrameMask,
+ smileyMifName, iImageMifPkgItemId, iImageMifPkgItemId,
+ AKN_LAF_COLOR(215)));
+ }
+ else
+ {
+ TRAPD(err, AknIconUtils::CreateIconL(iFrame, iFrameMask, smileyMifName, iImageMifPkgItemId, iImageMifPkgItemId));
+ }
+
+ if(iIsAnimation) // the first frame of animation svg is blank without correct content
+ {
+ iReadyToDraw = EFalse;
+ AknIconUtils::SetObserver(iFrame, this);
+ StopAnimationAsynchronousL(KFrameMaxInterval); // monitor for no callback
+ }
+ else // the first frame of static svg has correct content
+ {
+ iReadyToDraw = ETrue;
+ if(iImageObserver) iImageObserver->BitmapChanged(this, iFrame);
+ }
+
+ AknIconUtils::SetSize(iFrame, iSize);
+ TUid i = iFrame->ExtendedBitmapType();
+ }
+
+void CSmileyImage::DoRelease()
+ {
+ StopAsynchronousTaskTimer();
+
+ if(!iFrame) return;
+
+ DELZ(iFrame);
+ DELZ(iFrameMask);
+ iFrameSnap->Reset();
+
+ iReadyToDraw = EFalse;
+ }
+
+void CSmileyImage::DoHandleEndedL()
{
DoRelease();
@@ -278,33 +285,36 @@
}
}
-void CSmileyImage::StartLoadAsynchronousL(TInt aRepeat, TInt aDelayMicroSeconds)
+void CSmileyImage::StopAsynchronousTaskTimer()
{
- iRepeatCount = aRepeat;
+ iAsynchronousTaskTimer->Cancel();
+ }
- iAsynchronousTaskTimer->Cancel();
+void CSmileyImage::StartLoadAsynchronousL(TInt aDelayMicroSeconds)
+ {
+ StopAsynchronousTaskTimer();
iAsynchronousTaskTimer->Start(aDelayMicroSeconds, 1, TCallBack(StartLoadAsynchronousCallBackL,this));
}
TInt CSmileyImage::StartLoadAsynchronousCallBackL(TAny* aPtr)
{
CSmileyImage* self = (CSmileyImage*)aPtr;
- self->StopAnyAsynchronousTask();
+ self->StopAsynchronousTaskTimer();
self->DoLoadL();
return KErrNone;
}
void CSmileyImage::StopAnimationAsynchronousL(TInt aDelayMicroSeconds)
{
- iAsynchronousTaskTimer->Cancel();
+ StopAsynchronousTaskTimer();
iAsynchronousTaskTimer->Start(aDelayMicroSeconds, 1, TCallBack(StopAnimationAsynchronousCallBackL,this));
}
TInt CSmileyImage::StopAnimationAsynchronousCallBackL(TAny* aPtr)
{
CSmileyImage* self = (CSmileyImage*)aPtr;
- self->StopAnyAsynchronousTask();
- self->HandleAnimationEndedL();
+ self->StopAsynchronousTaskTimer();
+ self->DoHandleEndedL();
return KErrNone;
}