uiacceltk/hitchcock/ServerCore/Src/alfeffectutils.cpp
branchRCL_3
changeset 41 cd0ae4656946
parent 34 3a60ebea00d0
child 50 1801340c26a2
equal deleted inserted replaced
34:3a60ebea00d0 41:cd0ae4656946
    18 #include <s32mem.h>
    18 #include <s32mem.h>
    19 #include "alfeffectutils.h"
    19 #include "alfeffectutils.h"
    20 #include <akntransitionutils.h>
    20 #include <akntransitionutils.h>
    21 #include <alflogger.h>
    21 #include <alflogger.h>
    22 
    22 
       
    23 // Delay after which first end check is performed.
    23 const TInt KRosterFreezeEndTimeoutInMs = 100;
    24 const TInt KRosterFreezeEndTimeoutInMs = 100;
       
    25 // Interval between end checks.
       
    26 const TInt KRosterFreezeEndIntervalInMs = 50;
       
    27 // Maximum amount of end checks to be performed. 
       
    28 // This can be lower, should be visible enough to see, if heuristics fail.
       
    29 const TInt KRosterFreezeEndAttempts = 50;
    24 
    30 
    25 // ---------------------------------------------------------
    31 // ---------------------------------------------------------
    26 // CAlfRosterFreezeEndTimer
    32 // CAlfRosterFreezeEndTimer
    27 // ---------------------------------------------------------
    33 // ---------------------------------------------------------
    28 //
    34 //
    57     iCallBack = aCallBack;
    63     iCallBack = aCallBack;
    58     __ALFLOGSTRING("CAlfRosterFreezeEndTimer::Start");
    64     __ALFLOGSTRING("CAlfRosterFreezeEndTimer::Start");
    59     if (!IsActive())
    65     if (!IsActive())
    60         {
    66         {
    61         iSafeCounter = 0;
    67         iSafeCounter = 0;
       
    68         iSafeCounterDelta = Min(1, aPeriod.Int() / (KRosterFreezeEndIntervalInMs*1000));
    62         After( aPeriod );
    69         After( aPeriod );
    63         }
    70         }
    64     }
    71     }
    65 
    72 
    66 void CAlfRosterFreezeEndTimer::RunL()
    73 void CAlfRosterFreezeEndTimer::RunL()
    69 	
    76 	
    70 	TBool timeout = EFalse;
    77 	TBool timeout = EFalse;
    71 	
    78 	
    72 	if (iSafeCounter >= 0)	
    79 	if (iSafeCounter >= 0)	
    73 	    {
    80 	    {
    74 		iSafeCounter++;
    81 		iSafeCounter += iSafeCounterDelta;
    75 		if (iSafeCounter == 100) // can be lower, 100 should be visible enough to see, if heuristics fail
    82 		if (iSafeCounter >= KRosterFreezeEndAttempts)
    76 			{
    83 			{
    77 			timeout = ETrue;
    84 			timeout = ETrue;
    78 			iSafeCounter = 0;
    85 			iSafeCounter = 0;
    79 			}
    86 			}
    80 		}
    87 		}
    81 
    88 
    82     if (!iBridge.IsFullScreenDrawn(0) && !timeout)
    89     if (!iBridge.IsLayoutSwitchReady(iSafeCounter) && !timeout)
    83         {
    90         {
    84         __ALFLOGSTRING("CAlfRosterFreezeEndTimer::RunL - Not ready in new orientation. waiting 50ms more");
    91         __ALFLOGSTRING("CAlfRosterFreezeEndTimer::RunL - Not ready in new orientation. waiting 50ms more");
    85         After( 50000 );
    92         iSafeCounterDelta = 1;
       
    93         After( KRosterFreezeEndIntervalInMs * 1000 );
    86         return;
    94         return;
    87         }
    95         }
    88     else
    96     else
    89         {
    97         {
       
    98         __ALFLOGSTRING("CAlfRosterFreezeEndTimer::RunL - Ready in new orientation.");
    90         iCallBack.CallBack();
    99         iCallBack.CallBack();
    91         }
   100         }
    92     }
   101     }
    93 
   102 
    94 void CAlfRosterFreezeEndTimer::DoCancel()
   103 void CAlfRosterFreezeEndTimer::DoCancel()
   166     // From EStateIdle:
   175     // From EStateIdle:
   167     // - EEventBlankOn: EStateBlankFx
   176     // - EEventBlankOn: EStateBlankFx
   168     // - EEventLayoutSwitch: If effect available, EStateThemeFx. Otherwise EStateFreezeFx.
   177     // - EEventLayoutSwitch: If effect available, EStateThemeFx. Otherwise EStateFreezeFx.
   169     //
   178     //
   170     // From EStateFreezeFx:
   179     // From EStateFreezeFx:
   171     // - EEventBlankOn: EStateBlankFx
       
   172     // - implicit Finish - EStateIdle
   180     // - implicit Finish - EStateIdle
   173     //
   181     //
   174     // From EStateBlankFx:
   182     // From EStateBlankFx:
   175     // - EEventBlankOff: EStateFreezeFx (we use freeze to ensure that result is ok)
   183     // - EEventBlankOff: EStateFreezeFx (we use freeze to ensure that result is ok)
   176     // - EEventLayoutSwitch: If effect available, EStateThemeFx.
   184     // - EEventLayoutSwitch: If effect available, EStateThemeFx. Otherwise EStateFreezeFx.
   177     //
   185     //
   178     // From EStateThemeFx:
   186     // From EStateThemeFx:
   179     // - EEventLowMemory: If blank still on, EStateBlankFx. Otherwise EStateFreezeFx.
   187     // - EEventLowMemory: If blank still on, EStateBlankFx. Otherwise EStateFreezeFx.
   180     // - implicit Finish - EStateIdle
   188     // - implicit Finish - EStateIdle
       
   189     //
       
   190     // There is special handling if layout switch event is received while previous
       
   191     // layout switch is ongoing.
   181 
   192 
   182     TState nextState = EStateIdle;
   193     TState nextState = EStateIdle;
   183     
   194     
   184     switch ( iCurrentState )
   195     switch ( iCurrentState )
   185         {    
   196         {    
   203     
   214     
   204     if ( nextState != iCurrentState )
   215     if ( nextState != iCurrentState )
   205         {
   216         {
   206         Transition( nextState, iCurrentState );
   217         Transition( nextState, iCurrentState );
   207         }
   218         }
       
   219     else
       
   220         {
       
   221         // We stay in the same state, but still need special handling in a couple of scenarios
       
   222         if ( nextState == EStateFreezeFx )
       
   223             {
       
   224             HandleFreezeEvent( aEvent );
       
   225             }
       
   226         if ( nextState == EStateThemeFx )
       
   227             {
       
   228             HandleThemeEvent( aEvent );
       
   229             }                        
       
   230         }
       
   231     }
       
   232 
       
   233 // ---------------------------------------------------------
       
   234 // CAlfLayoutSwitchEffectCoordinator::HandleFreezeEvent
       
   235 // Special handling for Freeze effect.
       
   236 // ---------------------------------------------------------
       
   237 //
       
   238 void CAlfLayoutSwitchEffectCoordinator::HandleFreezeEvent(TEvent aEvent)
       
   239     {
       
   240     if ( aEvent == EEventLayoutSwitch && iRosterFreezeEndTimer && iRosterFreezeEndTimer->IsActive() )
       
   241         {                                
       
   242         // New layout switch while previous is ongoing => restart freeze end timer.
       
   243         __ALFLOGSTRING("CAlfLayoutSwitchEffectCoordinator::HandleFreezeEvent restart timer");
       
   244         iRosterFreezeEndTimer->Cancel();
       
   245         iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000, TCallBack(DoFreezeFinished, this));                
       
   246         }
       
   247     }
       
   248 
       
   249 // ---------------------------------------------------------
       
   250 // CAlfLayoutSwitchEffectCoordinator::HandleFreezeEvent
       
   251 // Special handling for Theme effect.
       
   252 // ---------------------------------------------------------
       
   253 //
       
   254 void CAlfLayoutSwitchEffectCoordinator::HandleThemeEvent(TEvent aEvent)
       
   255     {
       
   256     if ( aEvent == EEventLayoutSwitch )
       
   257         {                                
       
   258         // If layout switch occurs while freeze end timer is ongoing, restart.
       
   259         if ( iRosterFreezeEndTimer && iRosterFreezeEndTimer->IsActive() )
       
   260             {
       
   261             __ALFLOGSTRING("CAlfLayoutSwitchEffectCoordinator::HandleThemeEvent restart timer");
       
   262             iRosterFreezeEndTimer->Cancel();
       
   263             iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000, TCallBack(DoNextLayoutSwitchContext, this));                
       
   264             }
       
   265 
       
   266         // If layout switch occurs while theme effect is ongoing in exit phase, restart.
       
   267         if ( iLayoutSwitchEffectContext == AknTransEffect::ELayoutSwitchExit )
       
   268             {
       
   269             __ALFLOGSTRING("CAlfLayoutSwitchEffectCoordinator::HandleThemeEvent restart themefx");
       
   270             TBool oldLayoutSwitchNotCompleted = iLayoutSwitchNotCompleted;
       
   271             iLayoutSwitchNotCompleted = EFalse;
       
   272                 
       
   273             Transition( EStateIdle, iCurrentState );
       
   274             Transition( EStateThemeFx, iCurrentState );
       
   275                 
       
   276             if (oldLayoutSwitchNotCompleted)
       
   277                 {
       
   278                 iLayoutSwitchNotCompleted = ETrue;
       
   279                 }  
       
   280             }
       
   281         }
   208     }
   282     }
   209 
   283 
   210 // ---------------------------------------------------------
   284 // ---------------------------------------------------------
   211 // CAlfLayoutSwitchEffectCoordinator::Transition
   285 // CAlfLayoutSwitchEffectCoordinator::Transition
   212 // ---------------------------------------------------------
   286 // ---------------------------------------------------------
   213 //
   287 //
   214 void CAlfLayoutSwitchEffectCoordinator::Transition(
   288 void CAlfLayoutSwitchEffectCoordinator::Transition(
   215         TState aNewState, TState aPreviousState)
   289         TState aNewState, TState aPreviousState)
   216     {
   290     {
   217     __ALFLOGSTRING2("CAlfLayoutSwitchEffectCoordinator::Transition from: %d to: %d", aNewState, aPreviousState);
   291     __ALFLOGSTRING2("CAlfLayoutSwitchEffectCoordinator::Transition from: %d to: %d", aPreviousState, aNewState);
   218     iCurrentState = aNewState;
   292     iCurrentState = aNewState;
   219         
   293         
   220     // Undo previous state - don't unfreeze roster.
   294     // Undo previous state - don't unfreeze roster.
   221     switch ( aPreviousState )
   295     switch ( aPreviousState )
   222         {
   296         {
   267             
   341             
   268             FreezeRoster(ETrue);
   342             FreezeRoster(ETrue);
   269                 
   343                 
   270             // Remove all other effects
   344             // Remove all other effects
   271             iBridge.HandleGfxStopEvent( EFalse );
   345             iBridge.HandleGfxStopEvent( EFalse );
   272             iBridge.RemoveAllTemporaryPresenterVisuals();
   346             iBridge.CleanAllFxVisuals();
   273 
   347 
   274             // Set remove freeze timer
   348             // Set remove freeze timer
   275             __ALFLOGSTRING("CAlfLayoutSwitchEffectCoordinator::Transition - Freeze timer started");
   349             __ALFLOGSTRING("CAlfLayoutSwitchEffectCoordinator::Transition - Freeze timer started");
   276             iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000, TCallBack(DoFreezeFinished, this)); 
   350             iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000, TCallBack(DoFreezeFinished, this)); 
   277             }
   351             }
   297         iBridge.iHuiEnv->Display(0).SetDirty();
   371         iBridge.iHuiEnv->Display(0).SetDirty();
   298         FreezeRoster(ETrue);
   372         FreezeRoster(ETrue);
   299             
   373             
   300         // Remove all other effects
   374         // Remove all other effects
   301         iBridge.HandleGfxStopEvent( EFalse );
   375         iBridge.HandleGfxStopEvent( EFalse );
   302         iBridge.RemoveAllTemporaryPresenterVisuals();
   376         iBridge.CleanAllFxVisuals();
   303             
   377             
   304         // Set first layout switch effect 
   378         // Set first layout switch effect 
   305         SetLayoutSwitchEffect(AknTransEffect::ELayoutSwitchStart);
   379         SetLayoutSwitchEffect(AknTransEffect::ELayoutSwitchStart);
   306         }
   380         }
   307         break;
   381         break;
   322         
   396         
   323         iBridge.iHuiEnv->iPauseDrawing = EFalse;
   397         iBridge.iHuiEnv->iPauseDrawing = EFalse;
   324         FreezeRoster(EFalse);
   398         FreezeRoster(EFalse);
   325         iBridge.iHuiEnv->Display(0).SetDirty();
   399         iBridge.iHuiEnv->Display(0).SetDirty();
   326         iBridge.SetVisualTreeVisibilityChanged(ETrue);
   400         iBridge.SetVisualTreeVisibilityChanged(ETrue);
       
   401         iBridge.AsynchRefresh();
   327         }
   402         }
   328         break;
   403         break;
   329         }    
   404         }    
   330     
   405     
   331     // Inform bridge about layout switch actions
   406     // Inform bridge about layout switch actions
   392     TState state = EStateFreezeFx;
   467     TState state = EStateFreezeFx;
   393     
   468     
   394     switch ( aEvent )
   469     switch ( aEvent )
   395         {
   470         {
   396     case EEventBlankOn:
   471     case EEventBlankOn:
   397         state = EStateBlankFx;
       
   398         break;
       
   399     
       
   400     case EEventLayoutSwitch:    
   472     case EEventLayoutSwitch:    
   401     case EEventBlankOff:
   473     case EEventBlankOff:
   402     case EEventLowMemory:
   474     case EEventLowMemory:
   403     default:
   475     default:
   404         break;     
   476         break;     
   421         {
   493         {
   422     case EEventLayoutSwitch:
   494     case EEventLayoutSwitch:
   423         if ( IsThemeEffectEnabled() )
   495         if ( IsThemeEffectEnabled() )
   424             {
   496             {
   425             state = EStateThemeFx;
   497             state = EStateThemeFx;
       
   498             }
       
   499         else
       
   500             {
       
   501             state = EStateFreezeFx;
   426             }
   502             }
   427         break;
   503         break;
   428     
   504     
   429     case EEventBlankOff:
   505     case EEventBlankOff:
   430         state = EStateFreezeFx;
   506         state = EStateFreezeFx;
   590 // (and/or removed) from the roster.
   666 // (and/or removed) from the roster.
   591 //
   667 //
   592 // ---------------------------------------------------------
   668 // ---------------------------------------------------------
   593 //
   669 //
   594 // todo: rename
   670 // todo: rename
   595 TInt DoNextLayoutSwitchContext(TAny* aLayoutSwitchCoordinator)
   671 TInt CAlfLayoutSwitchEffectCoordinator::DoNextLayoutSwitchContext(
       
   672         TAny* aLayoutSwitchCoordinator)
   596     {
   673     {
   597     CAlfLayoutSwitchEffectCoordinator* coordinator = (CAlfLayoutSwitchEffectCoordinator*)aLayoutSwitchCoordinator;
   674     CAlfLayoutSwitchEffectCoordinator* coordinator = (CAlfLayoutSwitchEffectCoordinator*)aLayoutSwitchCoordinator;
   598     coordinator->AlfGfxEffectEndCallBack(KErrNotFound);
   675     coordinator->AlfGfxEffectEndCallBack(KErrNotFound);
   599     return 0;
   676     return 0;
   600     }
   677     }
   801     }
   878     }
   802 
   879 
   803 
   880 
   804 CFullScreenEffectState::~CFullScreenEffectState()
   881 CFullScreenEffectState::~CFullScreenEffectState()
   805     {
   882     {
   806     iPaintedRegion.Close();
       
   807     if (iDrawingCompleteTimer)
       
   808         {
       
   809         iDrawingCompleteTimer->Cancel();
       
   810         delete iDrawingCompleteTimer;
       
   811         iDrawingCompleteTimer = NULL;
       
   812         }
       
   813     }
   883     }
   814 
   884 
   815 void CFullScreenEffectState::ConstructL(const CFullScreenEffectState& aEffectState)
   885 void CFullScreenEffectState::ConstructL(const CFullScreenEffectState& aEffectState)
   816     {
   886     {
   817     iAction = aEffectState.iAction;
   887     iAction = aEffectState.iAction;
   870 
   940 
   871 void CFullScreenEffectState::SetState(TEffectState aState)
   941 void CFullScreenEffectState::SetState(TEffectState aState)
   872     {
   942     {
   873     if (aState >= iState)
   943     if (aState >= iState)
   874         {
   944         {
       
   945         __ALFFXLOGSTRING2("CFullScreenEffectState::SetState - Set %d -> %d", iState, aState);
   875         iState = aState;
   946         iState = aState;
   876         }
   947         }
   877     else
   948     else
   878         {
   949         {
   879         __ALFFXLOGSTRING2("CFullScreenEffectState::SetState - WARNING! Trying to set to previous state. %d -> %d", iState, aState);
   950         __ALFFXLOGSTRING2("CFullScreenEffectState::SetState - WARNING! Trying to set to previous state. %d -> %d", iState, aState);
   880         }
   951         }
   881     };
   952     };
   882         
   953         
   883 TEffectState CFullScreenEffectState::State()
   954 TEffectState CFullScreenEffectState::State()
   884     {
   955     {
       
   956     __ALFFXLOGSTRING1("CFullScreenEffectState::State - %d", iState);
   885     return iState;
   957     return iState;
   886     }
   958     }
   887       
   959       
   888 
   960 
   889 void CControlEffectState::ConstructL(TInt aAction,
   961 void CControlEffectState::ConstructL(TInt aAction,