uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp
branchRCL_3
changeset 17 3ac8bf5c5014
parent 11 46927d61fef3
child 24 f93c875b566e
equal deleted inserted replaced
11:46927d61fef3 17:3ac8bf5c5014
    79     NotifyEffectEndObserver();
    79     NotifyEffectEndObserver();
    80     
    80     
    81     ReleaseCachedRenderTarget();
    81     ReleaseCachedRenderTarget();
    82     
    82     
    83     iEngine->RemoveEffect(this);
    83     iEngine->RemoveEffect(this);
    84     if (iEngine && iGroupId != KErrNotFound && !iNotifiedEffectReady)
    84     if (iEngine && iGroupId != KErrNotFound && !(iFlags & KHuiReadyToDrawNotified))
    85         {
    85         {
    86         // if effect was deleted before it was drawn, the group must be notified. If this was the last effect in the group
    86         // if effect was deleted before it was drawn, the group must be notified. If this was the last effect in the group
    87         // the group will be removed by the EffectReadyToStart
    87         // the group will be removed by the EffectReadyToStart
    88         // effect group does not not know, which effects have notified about themselves. thus iNotifiedEffectReady flag is used.
    88         // effect group does not not know, which effects have notified about themselves.
    89         iNotifiedEffectReady = ETrue;
    89         SetEffectFlag(KHuiReadyToDrawNotified);
    90         iEngine->NotifyEffectReady(iGroupId);
    90         iEngine->NotifyEffectReady(iGroupId);
    91         }
    91         }
    92     
    92     
    93 #ifdef HUIFX_TRACE    
    93 #ifdef HUIFX_TRACE    
    94     RDebug::Print(_L("CHuiFxEffect::~CHuiFxEffect - 0x%x"), this);
    94     RDebug::Print(_L("CHuiFxEffect::~CHuiFxEffect - 0x%x"), this);
    95 #endif
    95 #endif
    96     }
    96     }
    97 
    97 
    98 void CHuiFxEffect::NotifyEffectEndObserver()
    98 TBool CHuiFxEffect::NotifyEffectEndObserver()
    99     {
    99     {
       
   100     if (iFlags & KHuiEffectObserverNotified)
       
   101         {
       
   102         return ETrue;
       
   103         }
       
   104     SetEffectFlag(KHuiEffectObserverNotified); // prevent extra notifier calls calls
   100 	// fade effect should not have observers
   105 	// fade effect should not have observers
   101     if (iFlags & KHuiFadeEffectFlag)
   106     if (iFlags & KHuiFadeEffectFlag)
   102         {
   107         {
   103         return;
   108         return ETrue; // fade effect does not have observer that would need notification
   104         }
   109         }
   105     if (iEffectEndObserver)
   110     if (iEffectEndObserver)
   106         {
   111         {
   107         // The callback can be called only once when the effect finishes
   112         // The callback can be called only once when the effect finishes
   108         MAlfGfxEffectObserver* effectEndObserver = iEffectEndObserver;
   113         MAlfGfxEffectObserver* effectEndObserver = iEffectEndObserver;
   109         iEffectEndObserver = NULL;
   114         iEffectEndObserver = NULL;
   110         // Note: The call below may synchronously delete me (CHuiFxEffect instance)
   115         // Note: The call below may synchronously delete me (CHuiFxEffect instance)
   111         effectEndObserver->AlfGfxEffectEndCallBack( iHandle );
   116         effectEndObserver->AlfGfxEffectEndCallBack( iHandle );
   112         }    
   117         return ETrue; // end observer notified
       
   118         }
       
   119     else
       
   120         {
       
   121 		// must be notified without destroying the effect first. gives alf apps chance
       
   122 		// to do their own cleanup
       
   123         return EFalse; 
       
   124         }
   113     }
   125     }
   114 
   126 
   115 EXPORT_C void CHuiFxEffect::AddLayerL(const CHuiFxLayer* aLayer)
   127 EXPORT_C void CHuiFxEffect::AddLayerL(const CHuiFxLayer* aLayer)
   116     {
   128     {
   117     iRoot->AddLayerL(aLayer);
   129     iRoot->AddLayerL(aLayer);
   505             iGroupId,
   517             iGroupId,
   506             iHandle);
   518             iHandle);
   507 #endif
   519 #endif
   508     // KHuiFxDelayRunUntilFirstFrameHasBeenDrawn flag is for giving effect chance to run
   520     // KHuiFxDelayRunUntilFirstFrameHasBeenDrawn flag is for giving effect chance to run
   509     // its whole timeline by starting the time only when first frame has been drawn.
   521     // its whole timeline by starting the time only when first frame has been drawn.
   510     iElapsedTime += aElapsedTime;
       
   511     if (iFlags & KHuiFxDelayRunUntilFirstFrameHasBeenDrawn)
   522     if (iFlags & KHuiFxDelayRunUntilFirstFrameHasBeenDrawn)
   512         {
   523         {
   513         // Sometimes the effect does not get any frames. Force the time to start, because
   524         // Sometimes the effect does not get any frames. Force the time to start, because
   514         // otherwise will jam itself and possible the group, where the effect is.
   525         // otherwise will jam itself and possible the group, where the effect is.
   515         if (iElapsedTime > 0.2 && iFramesDrawn == 0)
   526         if (iElapsedTime > 0.2 && iFramesDrawn == 0)
   534                 ClearEffectFlag(KHuiFxWaitGroupToStartSyncronized);
   545                 ClearEffectFlag(KHuiFxWaitGroupToStartSyncronized);
   535                 SetEffectFlag(KHuiFxReadyAndWaitingGroupToStartSyncronized);
   546                 SetEffectFlag(KHuiFxReadyAndWaitingGroupToStartSyncronized);
   536 				// NotifyEffectReady will clear KHuiFxReadyAndWaitingGroupToStartSyncronized flag
   547 				// NotifyEffectReady will clear KHuiFxReadyAndWaitingGroupToStartSyncronized flag
   537 				// if all items in the group are ready.
   548 				// if all items in the group are ready.
   538                 iEngine->NotifyEffectReady(iGroupId);
   549                 iEngine->NotifyEffectReady(iGroupId);
   539                 iNotifiedEffectReady = ETrue;
   550                 SetEffectFlag(KHuiReadyToDrawNotified);
   540                 return;
   551                 return;
   541                 }
   552                 }
   542 
   553 
   543             if (iFramesDrawn == 1)
   554             if (iFramesDrawn == 1)
   544                 {
   555                 {
   550         }
   561         }
   551     else
   562     else
   552         {
   563         {
   553         iRoot->AdvanceTime(aElapsedTime);
   564         iRoot->AdvanceTime(aElapsedTime);
   554         }
   565         }
       
   566     iElapsedTime += aElapsedTime;
   555     }
   567     }
   556     
   568     
   557 EXPORT_C TBool CHuiFxEffect::IsAnimated() const
   569 EXPORT_C TBool CHuiFxEffect::IsAnimated() const
   558     {
   570     {
   559     if (iRoot && iRoot->IsAnimated())
   571     if (iRoot && iRoot->IsAnimated())
   629 
   641 
   630 void CHuiFxEffect::FxmlVisualInputs(RArray<THuiFxVisualSrcType> &aArray)
   642 void CHuiFxEffect::FxmlVisualInputs(RArray<THuiFxVisualSrcType> &aArray)
   631     {
   643     {
   632     iRoot->FxmlVisualInputs(aArray);
   644     iRoot->FxmlVisualInputs(aArray);
   633     }
   645     }
       
   646 
       
   647 TBool CHuiFxEffect::FxmlUsesOpaqueHint() const
       
   648     {
       
   649     return iRoot->FxmlUsesOpaqueHint();
       
   650     }