uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
changeset 13 8f67d927ea57
parent 0 15bf7259bb7c
child 14 83d2d132aa58
equal deleted inserted replaced
0:15bf7259bb7c 13:8f67d927ea57
    21 #include "alf/alfappui.h"
    21 #include "alf/alfappui.h"
    22 #include "alf/alfappserver.h"
    22 #include "alf/alfappserver.h"
    23 #include <uiacceltk/HuiEnv.h>
    23 #include <uiacceltk/HuiEnv.h>
    24 #include <aknenv.h>
    24 #include <aknenv.h>
    25 #include <AknsConstants.h>
    25 #include <AknsConstants.h>
    26 #include <s32mem.h>
       
    27 #include <uiacceltk/HuiSkin.h>
    26 #include <uiacceltk/HuiSkin.h>
    28 #include <uiacceltk/HuiDisplay.h>
    27 #include <uiacceltk/HuiDisplay.h>
    29 #include <uiacceltk/HuiControl.h>
    28 #include <uiacceltk/HuiControl.h>
    30 #include <uiacceltk/HuiControlGroup.h>
    29 #include <uiacceltk/HuiControlGroup.h>
    31 #include <uiacceltk/HuiEvent.h>
    30 #include <uiacceltk/HuiEvent.h>
    67 #include "huieffectable.h"
    66 #include "huieffectable.h"
    68 #include <akntranseffect.h>
    67 #include <akntranseffect.h>
    69 #include "HuiRenderPlugin.h"
    68 #include "HuiRenderPlugin.h"
    70 #include "huicanvasgc.h"
    69 #include "huicanvasgc.h"
    71 #include "huicanvasrenderbuffer.h"
    70 #include "huicanvasrenderbuffer.h"
       
    71 #include "alfeffectutils.h"
       
    72 #include "alfrenderstageutils.h" // for KAlfPSUidSynchronizer & KAlfPSKeySynchronizer
    72 
    73 
    73 #ifdef HUI_DEBUG_TRACK_DRAWING
    74 #ifdef HUI_DEBUG_TRACK_DRAWING
    74 #include <alfcommanddebug.h>
    75 #include <alfcommanddebug.h>
    75 #endif
    76 #endif
    76 
    77 
    86 
    87 
    87 const TReal32 KAlfVisualDefaultOpacity = 1.0f;
    88 const TReal32 KAlfVisualDefaultOpacity = 1.0f;
    88 //const TReal32 KAlfVisualDefaultOpacity = 0.5f;
    89 //const TReal32 KAlfVisualDefaultOpacity = 0.5f;
    89 
    90 
    90 _LIT8(KAlfWindowGroupContainerControlTag, "WGROUP");
    91 _LIT8(KAlfWindowGroupContainerControlTag, "WGROUP");
    91 const TInt KAlfNumberOfFixedControlGroups = 2;
    92 
    92 
    93 // #define USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
    93 // This debug option prints window group order with __ALFLOGSTRING
       
    94 //#define ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
       
    95 
       
    96 // This debug option shows window groups in a grid
    94 // This debug option shows window groups in a grid
    97 //#define ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
    95 //#define ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
    98 
    96 
    99 
    97 
   100 const TInt KFadeAction = 6000;
    98 const TInt KFadeAction = 6000;
   101 
       
   102 const TInt KRosterFreezeEndTimeoutInMs = 400;
       
   103 
       
   104 // Timer to send finish full screen effect
       
   105 // ---------------------------------------------------------
       
   106 // CAlfFinishTimer
       
   107 // ---------------------------------------------------------
       
   108 //
       
   109 NONSHARABLE_CLASS( CAlfRosterFreezeEndTimer ):public CTimer
       
   110     {
       
   111     public:  // Constructors and destructor
       
   112         static CAlfRosterFreezeEndTimer* NewL( CAlfBridge& aBridge );
       
   113         virtual ~CAlfRosterFreezeEndTimer();
       
   114 
       
   115     public: // New functions
       
   116         void Start( TTimeIntervalMicroSeconds32 aPeriod );
       
   117         
       
   118     protected:  // Functions from base classes
       
   119         void DoCancel();
       
   120 
       
   121     private:
       
   122         CAlfRosterFreezeEndTimer( CAlfBridge& aBridge );
       
   123         void ConstructL();
       
   124         void RunL();
       
   125       
       
   126     private:    // Data
       
   127         CAlfBridge& iBridge;
       
   128                 
       
   129     };
       
   130 
       
   131 
       
   132 // ---------------------------------------------------------
       
   133 // CAlfRosterFreezeEndTimer
       
   134 // ---------------------------------------------------------
       
   135 //
       
   136 CAlfRosterFreezeEndTimer::CAlfRosterFreezeEndTimer( CAlfBridge& aBridge )
       
   137     :CTimer ( EPriorityStandard ),
       
   138     iBridge( aBridge )
       
   139     {   
       
   140     }
       
   141 
       
   142 void CAlfRosterFreezeEndTimer::ConstructL()
       
   143     {
       
   144     CTimer::ConstructL();
       
   145     CActiveScheduler::Add( this );
       
   146     }
       
   147 
       
   148 CAlfRosterFreezeEndTimer* CAlfRosterFreezeEndTimer::NewL( CAlfBridge& aBridge )
       
   149     {
       
   150     CAlfRosterFreezeEndTimer* self = new ( ELeave ) CAlfRosterFreezeEndTimer( aBridge );
       
   151     CleanupStack::PushL( self );
       
   152     self->ConstructL();
       
   153     CleanupStack::Pop( self );
       
   154     return self;
       
   155     }
       
   156 
       
   157 CAlfRosterFreezeEndTimer::~CAlfRosterFreezeEndTimer()
       
   158     {
       
   159     Cancel();        
       
   160     }
       
   161 
       
   162 void CAlfRosterFreezeEndTimer::Start( TTimeIntervalMicroSeconds32 aPeriod )
       
   163     {
       
   164     if (!IsActive())
       
   165         {
       
   166         After( aPeriod );
       
   167         }
       
   168     }
       
   169 
       
   170 void CAlfRosterFreezeEndTimer::RunL()
       
   171     {
       
   172     iBridge.iHuiEnv->Display(0).SetDirty();
       
   173     TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
       
   174     iBridge.SetVisualTreeVisibilityChanged(ETrue);    
       
   175     }
       
   176 
       
   177 void CAlfRosterFreezeEndTimer::DoCancel()
       
   178     {
       
   179     CTimer::DoCancel();
       
   180     }
       
   181 
       
   182 // ---------------------------------------------------------
       
   183 // CAlfLayoutSwitchEffectcoordinator
       
   184 // ---------------------------------------------------------
       
   185 //
       
   186 NONSHARABLE_CLASS( CAlfLayoutSwitchEffectCoordinator ) : public CBase, public MAlfGfxEffectObserver
       
   187     {
       
   188     public:  // Constructors and destructor
       
   189         CAlfLayoutSwitchEffectCoordinator( CAlfBridge& aBridge );
       
   190         virtual ~CAlfLayoutSwitchEffectCoordinator();
       
   191     
       
   192     public: // MAlfGfxEffectObserver           
       
   193         void AlfGfxEffectEndCallBack( TInt aHandle );
       
   194     
       
   195     public:
       
   196         void BeginLayoutSwitch();
       
   197         void Cancel();
       
   198         
       
   199     private:
       
   200         AknTransEffect::TContext NextLayoutSwitchContext();
       
   201         void SetLayoutSwitchEffect(AknTransEffect::TContext aContext);
       
   202         TBool LayoutSwitchEffectsExist();
       
   203         
       
   204     private: // Data
       
   205         
       
   206         CAlfBridge& iBridge;
       
   207         AknTransEffect::TContext iLayoutSwitchEffectContext;
       
   208         TThreadPriority iOriginalPriority;
       
   209         CAlfRosterFreezeEndTimer* iRosterFreezeEndTimer;
       
   210     };
       
   211 
       
   212 CAlfLayoutSwitchEffectCoordinator::CAlfLayoutSwitchEffectCoordinator( CAlfBridge& aBridge ) :
       
   213     iBridge( aBridge ),
       
   214     iLayoutSwitchEffectContext(AknTransEffect::ENone)    
       
   215     {
       
   216     RThread me = RThread();
       
   217     iOriginalPriority = me.Priority();    
       
   218     me.Close();
       
   219     }
       
   220 
       
   221 CAlfLayoutSwitchEffectCoordinator::~CAlfLayoutSwitchEffectCoordinator()
       
   222     {   
       
   223     }
       
   224 
       
   225 // ---------------------------------------------------------
       
   226 // CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack
       
   227 //
       
   228 // This method is callback which gets called when layout 
       
   229 // switch effect has ended.
       
   230 // ---------------------------------------------------------
       
   231 //
       
   232 void CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack( TInt aHandle )
       
   233     {
       
   234     //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack"));
       
   235     if (iLayoutSwitchEffectContext == aHandle)
       
   236         {
       
   237         AknTransEffect::TContext nextContext = NextLayoutSwitchContext();
       
   238 
       
   239         // Unfreeze visible content. This reveals real roster content (in new orientation).
       
   240         if (nextContext == AknTransEffect::ELayoutSwitchExit)
       
   241             {
       
   242             #ifdef HUI_DEBUG_TRACK_DRAWING
       
   243             RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack unfreezing roster content"));
       
   244             #endif
       
   245             iBridge.iHuiEnv->Display(0).SetDirty();
       
   246             TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
       
   247             iBridge.SetVisualTreeVisibilityChanged(ETrue);
       
   248             }
       
   249         
       
   250         // Set next effect
       
   251         SetLayoutSwitchEffect(nextContext);
       
   252         
       
   253         if (nextContext == AknTransEffect::ENone)
       
   254             {
       
   255             // Restore normal priority
       
   256             RThread me = RThread();
       
   257             me.SetPriority(iOriginalPriority);    
       
   258             me.Close();
       
   259 
       
   260             // Just in case refresh everything
       
   261             iBridge.iHuiEnv->Display(0).SetDirty();
       
   262             }        
       
   263         }
       
   264     else
       
   265         {
       
   266         //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack - got different handle (normal, dont worry...) - %i"), aHandle);        
       
   267         }
       
   268     }
       
   269 
       
   270 // ---------------------------------------------------------
       
   271 // CAlfLayoutSwitchEffectCoordinator::Cancel
       
   272 // ---------------------------------------------------------
       
   273 //
       
   274 void CAlfLayoutSwitchEffectCoordinator::Cancel()
       
   275     {
       
   276     // Disable effect
       
   277     SetLayoutSwitchEffect( AknTransEffect::ENone );
       
   278 
       
   279     // Unfreeze visible content
       
   280     if ( iRosterFreezeEndTimer )
       
   281         {
       
   282 		iRosterFreezeEndTimer->Cancel();
       
   283     	}
       
   284 
       
   285     iBridge.iHuiEnv->Display(0).SetDirty();
       
   286     TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
       
   287     iBridge.SetVisualTreeVisibilityChanged(ETrue);
       
   288     
       
   289     // Restore normal priority
       
   290     RThread me = RThread();
       
   291     me.SetPriority(iOriginalPriority);    
       
   292     me.Close();
       
   293 	}
       
   294 
       
   295 // ---------------------------------------------------------
       
   296 // CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch
       
   297 //
       
   298 // This method starts the layout switch effect procedure.
       
   299 // ---------------------------------------------------------
       
   300 //
       
   301 void CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch()
       
   302     {
       
   303     // Hm. what to do if earlier is already in progress ?
       
   304     //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch"));
       
   305     if ( iBridge.iHuiEnv->MemoryLevel() <= EHuiMemoryLevelLowest )
       
   306         {
       
   307         // No effects in low memory mode
       
   308         return;
       
   309         }
       
   310     
       
   311     if (!iLayoutSwitchEffectContext)
       
   312         {
       
   313         TBool tfxOn = CAknTransitionUtils::TransitionsEnabled(AknTransEffect::ELayoutswitchTransitionsOff );
       
   314         TBool tfxExists = LayoutSwitchEffectsExist();
       
   315         if (tfxOn && tfxExists)
       
   316             {
       
   317             // Boost priority so that we are able to draw more frames for the effect
       
   318             RThread me = RThread();
       
   319             me.SetPriority(EPriorityAbsoluteHigh);    
       
   320             me.Close();
       
   321             
       
   322             // Freeze visual content
       
   323             //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch freezing roster content"));
       
   324             iBridge.iHuiEnv->Display(0).SetDirty();
       
   325             TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(ETrue));
       
   326             
       
   327             // Remove all other effects
       
   328             iBridge.HandleGfxStopEvent( EFalse );
       
   329             iBridge.RemoveAllTemporaryPresenterVisuals();
       
   330             
       
   331             // Set first layout switch effect 
       
   332             SetLayoutSwitchEffect(AknTransEffect::ELayoutSwitchStart);
       
   333             }
       
   334         else
       
   335             {
       
   336             if (!iRosterFreezeEndTimer)
       
   337                 {
       
   338                 TRAP_IGNORE(iRosterFreezeEndTimer = CAlfRosterFreezeEndTimer::NewL(iBridge));
       
   339                 }
       
   340             
       
   341             if (iRosterFreezeEndTimer)
       
   342                 {
       
   343                 iBridge.iHuiEnv->Display(0).SetDirty();
       
   344                 TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(ETrue));
       
   345                 
       
   346                 // Remove all other effects
       
   347                 iBridge.HandleGfxStopEvent( EFalse );
       
   348                 iBridge.RemoveAllTemporaryPresenterVisuals();
       
   349 
       
   350                 // Set remove freeze timer
       
   351                 iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000); 
       
   352                 }            
       
   353             //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch - tfx are set OFF -> I am not starting effect."));                        
       
   354             }
       
   355         }
       
   356     else
       
   357         {
       
   358         //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch - old effect exists - %i"), iLayoutSwitchEffectContext);
       
   359         }
       
   360     }
       
   361 
       
   362 // ---------------------------------------------------------
       
   363 // CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchContext
       
   364 //
       
   365 // This method automatically selects the next context in the 
       
   366 // layout switch procedure.
       
   367 //
       
   368 // Contextes change in the following order during layout switch:
       
   369 //
       
   370 // 1. AknTransEffect::ENone
       
   371 // 2. AknTransEffect::ELayoutSwitchStart
       
   372 // 3. AknTransEffect::ELayoutSwitchExit
       
   373 // 4. AknTransEffect::ENone
       
   374 //
       
   375 // After new context is selected, appropriate effect is set 
       
   376 // (and/or removed) from the roster.
       
   377 //
       
   378 // ---------------------------------------------------------
       
   379 //
       
   380 AknTransEffect::TContext CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchContext()
       
   381     {
       
   382     // Resolve next context based on current context
       
   383     AknTransEffect::TContext newContext = AknTransEffect::ENone;    
       
   384     switch (iLayoutSwitchEffectContext)
       
   385         {
       
   386         case AknTransEffect::ENone:
       
   387             {
       
   388             newContext = AknTransEffect::ELayoutSwitchStart;            
       
   389             break;
       
   390             }
       
   391         case AknTransEffect::ELayoutSwitchStart:
       
   392             {
       
   393             newContext = AknTransEffect::ELayoutSwitchExit;                    
       
   394             break;
       
   395             }
       
   396         case AknTransEffect::ELayoutSwitchExit: // fallthrough
       
   397         default:
       
   398             {
       
   399             newContext = AknTransEffect::ENone;            
       
   400             break;
       
   401             }              
       
   402         }
       
   403 
       
   404     //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchEffectL old ctx = %i, new ctx = %i"), iLayoutSwitchEffectContext, newContext);
       
   405     return newContext;
       
   406     }
       
   407 
       
   408 // ---------------------------------------------------------
       
   409 // CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffectL
       
   410 //
       
   411 // This method sets correct effect based on the given 
       
   412 // layout switch context.
       
   413 //
       
   414 // ---------------------------------------------------------
       
   415 //
       
   416 void CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffect(AknTransEffect::TContext aContext)
       
   417     {
       
   418     MHuiEffectable* effectable = iBridge.iHuiEnv->Display(0).Roster().Effectable();
       
   419     CHuiFxEffect* effect = NULL;
       
   420     CHuiFxEngine* engine = iBridge.iHuiEnv->EffectsEngine();
       
   421     
       
   422     if (!effectable || !engine)
       
   423         {
       
   424         return;
       
   425         }    
       
   426             
       
   427     // Update current context
       
   428     iLayoutSwitchEffectContext = aContext;           
       
   429     
       
   430     if (aContext == AknTransEffect::ENone)
       
   431         {
       
   432         // Just remove effect
       
   433         //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchEffectL - removing effect"));
       
   434         effectable->EffectSetEffect(NULL); // This calls AlfGfxEffectEndCallBack         
       
   435         }
       
   436     else
       
   437         {    
       
   438         // Load correct effect
       
   439         for ( TInt i = 0; i<iBridge.iAlfRegisteredEffects.Count(); i++ )
       
   440             {             
       
   441             if ( iBridge.iAlfRegisteredEffects[i].iAction == aContext)
       
   442                 {
       
   443                 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffectL - loading effect"));
       
   444                 TRAP_IGNORE(engine->LoadEffectL(*iBridge.iAlfRegisteredEffects[i].iEffectFile, effect, effectable, NULL, this, iLayoutSwitchEffectContext, 0 ) );                    
       
   445                 break;
       
   446                 }
       
   447             }
       
   448         }    
       
   449     }
       
   450 
       
   451 TBool CAlfLayoutSwitchEffectCoordinator::LayoutSwitchEffectsExist()
       
   452     {
       
   453     TBool appearExists = EFalse;
       
   454     TBool disAppearExists = EFalse;
       
   455     
       
   456     for ( TInt i = 0; i<iBridge.iAlfRegisteredEffects.Count(); i++ )
       
   457         {             
       
   458         if ( iBridge.iAlfRegisteredEffects[i].iAction == AknTransEffect::ELayoutSwitchStart)
       
   459             {
       
   460             disAppearExists = ETrue;
       
   461             break;
       
   462             }
       
   463         else if ( iBridge.iAlfRegisteredEffects[i].iAction == AknTransEffect::ELayoutSwitchExit)
       
   464             {
       
   465             appearExists = ETrue;
       
   466             break;
       
   467             }
       
   468         }
       
   469     
       
   470     return (appearExists || disAppearExists);    
       
   471     }
       
   472 
       
   473 // Timer to send finish full screen effect
       
   474 // ---------------------------------------------------------
       
   475 // CAlfFinishTimer
       
   476 // ---------------------------------------------------------
       
   477 //
       
   478 NONSHARABLE_CLASS( CAlfEffectEndTimer ):public CTimer
       
   479     {
       
   480     public:  // Constructors and destructor
       
   481         static CAlfEffectEndTimer* NewL( CAlfBridge& aBridge );
       
   482         virtual ~CAlfEffectEndTimer();
       
   483 
       
   484     public: // New functions
       
   485         void Start( TTimeIntervalMicroSeconds32 aPeriod, TInt aHandle );
       
   486         
       
   487     protected:  // Functions from base classes
       
   488         void DoCancel();
       
   489 
       
   490     private:
       
   491         CAlfEffectEndTimer( CAlfBridge& aBridge );
       
   492         void ConstructL();
       
   493         void RunL();
       
   494       
       
   495     private:    // Data
       
   496         CAlfBridge& iBridge;
       
   497         TInt iHandle;
       
   498                 
       
   499     };
       
   500 
       
   501 
       
   502 // ---------------------------------------------------------
       
   503 // CAlfFinishTimer
       
   504 // ---------------------------------------------------------
       
   505 //
       
   506 CAlfEffectEndTimer::CAlfEffectEndTimer( CAlfBridge& aBridge )
       
   507     :CTimer(EPriorityHigh), 
       
   508 	iBridge(aBridge)
       
   509     {   
       
   510     }
       
   511 
       
   512 void CAlfEffectEndTimer::ConstructL()
       
   513     {
       
   514     CTimer::ConstructL();
       
   515     CActiveScheduler::Add( this );
       
   516     }
       
   517 
       
   518 CAlfEffectEndTimer* CAlfEffectEndTimer::NewL( CAlfBridge& aBridge )
       
   519     {
       
   520     CAlfEffectEndTimer* self = new ( ELeave ) CAlfEffectEndTimer( aBridge );
       
   521     CleanupStack::PushL( self );
       
   522     self->ConstructL();
       
   523     CleanupStack::Pop( self );
       
   524     return self;
       
   525     }
       
   526 
       
   527 CAlfEffectEndTimer::~CAlfEffectEndTimer()
       
   528     {
       
   529     Cancel();        
       
   530     }
       
   531 
       
   532 void CAlfEffectEndTimer::Start( TTimeIntervalMicroSeconds32 aPeriod, TInt aHandle )
       
   533     {
       
   534     iHandle = aHandle;
       
   535     After( aPeriod );
       
   536     }
       
   537 
       
   538 void CAlfEffectEndTimer::RunL()
       
   539     {
       
   540     //
       
   541     // timer completes and control is returned to caller
       
   542     //
       
   543     iBridge.TransitionFinishedHandlerL( iHandle );
       
   544     // We don't become active unless we are explicitly restarted
       
   545     }
       
   546 
       
   547 void CAlfEffectEndTimer::DoCancel()
       
   548     {
       
   549     CTimer::DoCancel();
       
   550     }
       
   551 
       
   552 
    99 
   553 // ======== MEMBER FUNCTIONS ========
   100 // ======== MEMBER FUNCTIONS ========
   554 
   101 
   555 // ======== MEMBER FUNCTIONS ========
   102 // ======== MEMBER FUNCTIONS ========
   556 
   103 
   589 // ---------------------------------------------------------------------------
   136 // ---------------------------------------------------------------------------
   590 // ---------------------------------------------------------------------------
   137 // ---------------------------------------------------------------------------
   591 // 
   138 // 
   592 CAlfBridge::~CAlfBridge()
   139 CAlfBridge::~CAlfBridge()
   593 	{
   140 	{
       
   141 	delete iOrphanStorage;
   594 	delete iFadeEffectFile;
   142 	delete iFadeEffectFile;
   595 	iWindowHashArray.Close();
   143 	iWindowHashArray.Close();
   596 	for( TInt i = 0; i< iAlfRegisteredEffects.Count(); i++ )
   144 	for( TInt i = 0; i< iAlfRegisteredEffects.Count(); i++ )
   597 	    {
   145 	    {
   598 	    delete iAlfRegisteredEffects[i].iEffectFile;
   146 	    delete iAlfRegisteredEffects[i].iEffectFile;
   599 	    }
   147 	    }
   600 	iAlfRegisteredEffects.Close();
   148 	iAlfRegisteredEffects.Close();
   601     iFinishedEffects.Close();
       
   602     delete iEffectEndTimer;
   149     delete iEffectEndTimer;
   603     iDeadControlGroups.Close();
   150     iDeadControlGroups.Close();
   604     iEffectWindowGroups.Close();
   151     iEffectWindowGroups.Close();
   605     delete iFullScreenEffectData;
   152     delete iFullScreenEffectData;
   606 
   153 
   653     iCommandDebug = CAlfCommandDebug::NewL();
   200     iCommandDebug = CAlfCommandDebug::NewL();
   654 #endif
   201 #endif
   655     
   202     
   656     iLayoutSwitchEffectCoordinator = new (ELeave) CAlfLayoutSwitchEffectCoordinator(*this);
   203     iLayoutSwitchEffectCoordinator = new (ELeave) CAlfLayoutSwitchEffectCoordinator(*this);
   657     iAlfSecureId = RThread().SecureId();
   204     iAlfSecureId = RThread().SecureId();
       
   205 	
       
   206 	// Create control for the orphaned windows, which control group id deleted before them
       
   207     iOrphanStorage = new (ELeave) CHuiControl(*iHuiEnv);
       
   208     iOrphanStorage->ConstructL();
       
   209 	
   658     RegisterFadeEffectL();
   210     RegisterFadeEffectL();
   659     }
   211     }
   660 
   212 
   661 // ---------------------------------------------------------------------------
   213 // ---------------------------------------------------------------------------
   662 //  RegisterFadeEffectL
   214 //  RegisterFadeEffectL
   737     CleanupStack::Pop(screen);
   289     CleanupStack::Pop(screen);
   738 
   290 
   739 	ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFloatingSpriteControlGroup), KHuiRosterShowAtTop, screenNumber); 
   291 	ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFloatingSpriteControlGroup), KHuiRosterShowAtTop, screenNumber); 
   740 	ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFullscreenEffectControlGroup), KHuiRosterShowAtTop, screenNumber); 
   292 	ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFullscreenEffectControlGroup), KHuiRosterShowAtTop, screenNumber); 
   741     
   293     
   742 	
       
   743 	screen->iFloatingSpriteControlGroup->SetAcceptInput(EFalse);
   294 	screen->iFloatingSpriteControlGroup->SetAcceptInput(EFalse);
   744 	screen->iFullscreenEffectControlGroup->SetAcceptInput(EFalse);
   295 	screen->iFullscreenEffectControlGroup->SetAcceptInput(EFalse);
       
   296 	
       
   297 	if ( screen->iFpsControlGroup )
       
   298 	    {
       
   299 	    ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFpsControlGroup), KHuiRosterShowAtTop, screenNumber); 
       
   300 	    screen->iFpsControlGroup->SetAcceptInput(EFalse);
       
   301 	    }
   745     }
   302     }
   746 
   303 
   747 //------------------------------------------------------------------------------
   304 //------------------------------------------------------------------------------
   748 // Dumdidumdidum..
   305 // Dumdidumdidum..
   749 //------------------------------------------------------------------------------
   306 //------------------------------------------------------------------------------
   760 	ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFloatingSpriteControlGroup), KHuiRosterShowAtTop, screenNumber); 
   317 	ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFloatingSpriteControlGroup), KHuiRosterShowAtTop, screenNumber); 
   761 	ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFullscreenEffectControlGroup), KHuiRosterShowAtTop, screenNumber); 
   318 	ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFullscreenEffectControlGroup), KHuiRosterShowAtTop, screenNumber); 
   762     
   319     
   763     screen->iFloatingSpriteControlGroup->SetAcceptInput(EFalse);
   320     screen->iFloatingSpriteControlGroup->SetAcceptInput(EFalse);
   764     screen->iFullscreenEffectControlGroup->SetAcceptInput(EFalse);
   321     screen->iFullscreenEffectControlGroup->SetAcceptInput(EFalse);
       
   322     
       
   323     if ( screen->iFpsControlGroup )
       
   324 	    {
       
   325 	    ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFpsControlGroup), KHuiRosterShowAtTop, screenNumber); 
       
   326 	    screen->iFpsControlGroup->SetAcceptInput(EFalse);
       
   327 	    }
   765     }
   328     }
   766 
   329 
   767 
   330 
   768 
   331 
   769 // ---------------------------------------------------------------------------
   332 // ---------------------------------------------------------------------------
   779     __ALFFXLOGSTRING1("CAlfBridge::AddVisual 0x%x", aWindowNodeId);
   342     __ALFFXLOGSTRING1("CAlfBridge::AddVisual 0x%x", aWindowNodeId);
   780     THashVisualStruct visualStruct( aVisual, aClientSideId, aClientSideGroupId);
   343     THashVisualStruct visualStruct( aVisual, aClientSideId, aClientSideGroupId);
   781     iWindowHashArray.Insert( aWindowNodeId, visualStruct );
   344     iWindowHashArray.Insert( aWindowNodeId, visualStruct );
   782     iPreviouslySearchedVisualId = aWindowNodeId;
   345     iPreviouslySearchedVisualId = aWindowNodeId;
   783     iPreviouslySearchedVisual = aVisual;
   346     iPreviouslySearchedVisual = aVisual;
       
   347 
       
   348     AMT_INC_COUNTER( iTotalVisualCount );
   784     }
   349     }
   785 
   350 
   786 // ---------------------------------------------------------------------------
   351 // ---------------------------------------------------------------------------
   787 // RemoveVisual
   352 // RemoveVisual
   788 // ---------------------------------------------------------------------------
   353 // ---------------------------------------------------------------------------
   790 void CAlfBridge::RemoveVisual( TInt aWindowNodeId )
   355 void CAlfBridge::RemoveVisual( TInt aWindowNodeId )
   791     {
   356     {
   792     __ALFFXLOGSTRING1("CAlfBridge::RemoveVisual 0x%x", aWindowNodeId);
   357     __ALFFXLOGSTRING1("CAlfBridge::RemoveVisual 0x%x", aWindowNodeId);
   793     iWindowHashArray.Remove( aWindowNodeId );
   358     iWindowHashArray.Remove( aWindowNodeId );
   794     iPreviouslySearchedVisualId = 0;
   359     iPreviouslySearchedVisualId = 0;
       
   360     
       
   361     AMT_DEC_COUNTER( iTotalVisualCount );    
   795     }
   362     }
   796     
   363     
   797 // ---------------------------------------------------------------------------
   364 // ---------------------------------------------------------------------------
   798 // FindVisual
   365 // FindVisual
   799 // ---------------------------------------------------------------------------
   366 // ---------------------------------------------------------------------------
   937         aArray.Append(aLayout);
   504         aArray.Append(aLayout);
   938         }
   505         }
   939     }
   506     }
   940 
   507 
   941 // ---------------------------------------------------------------------------
   508 // ---------------------------------------------------------------------------
       
   509 // ResolveAfterEffectAppearingApplicationL
       
   510 // ---------------------------------------------------------------------------
       
   511 // 
       
   512 void CAlfBridge::ResolveAfterEffectAppearingApplicationL(CHuiControlGroup* aGroup)
       
   513     {
       
   514 #ifdef USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
       
   515     if (iFullScreenEffectData && iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
       
   516         {
       
   517         CHuiControlGroup *exitingGroupInEffect = FindControlGroupByAppId(iFullScreenEffectData->iToAppId);
       
   518         if (exitingGroupInEffect == aGroup)
       
   519             {
       
   520             CHuiRoster& roster = iAlfScreens[0]->iDisplay->Roster();
       
   521             CHuiControlGroup* nextToBecomeVisible = NULL;
       
   522             // resolve who is under this application in roster
       
   523             for (TInt i = 0 ; i < roster.Count() ; i++)
       
   524                 {
       
   525                 if (&roster.ControlGroup(i) == exitingGroupInEffect && i > 1)
       
   526                     {
       
   527                     __ALFFXLOGSTRING("CAlfBridge::ResolveAfterEffectAppearingApplicationL - Found underneath control group");
       
   528                     nextToBecomeVisible = &roster.ControlGroup(i-1);
       
   529                     break;
       
   530                     }
       
   531                 }
       
   532                 // resolve, to which application this maps to
       
   533             if (nextToBecomeVisible)
       
   534                 {
       
   535                 for(TInt j = 0 ; j < iAlfScreens[0]->iControlGroups.Count() - 1 ; j++)
       
   536                     {
       
   537                     if (iAlfScreens[0]->iControlGroups[j].iControlGroup == nextToBecomeVisible)
       
   538                         {
       
   539                         iFullScreenEffectData->iFromAppId = iAlfScreens[0]->iControlGroups[j].iSecureId;
       
   540                         __ALFFXLOGSTRING1("CAlfBridge::ResolveAfterEffectAppearingApplicationL - Found underneath application uid: 0x%x. Start track drawing for exit effect.", iFullScreenEffectData->iFromAppId );
       
   541                         break;
       
   542                         }
       
   543                     }
       
   544                 }
       
   545             }
       
   546         }
       
   547 #endif    
       
   548     }
       
   549 
       
   550 // ---------------------------------------------------------------------------
   942 // ---------------------------------------------------------------------------
   551 // ---------------------------------------------------------------------------
   943 // 
   552 // 
   944 void CAlfBridge::DeleteControlGroupL(TInt aWindowGroupNodeId, TInt aScreenNumber )
   553 void CAlfBridge::DeleteControlGroupL(TInt aWindowGroupNodeId, TInt aScreenNumber )
   945     {
   554     {
   946     for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++)
   555     for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++)
   947         {
   556         {
   948         if (iAlfScreens[aScreenNumber]->iControlGroups[i].iWindowGroupNodeId == aWindowGroupNodeId)
   557         if (iAlfScreens[aScreenNumber]->iControlGroups[i].iWindowGroupNodeId == aWindowGroupNodeId)
   949             {
   558             {
   950             if (iAlfScreens[aScreenNumber]->iDisplay)
   559             if (iAlfScreens[aScreenNumber]->iDisplay)
   951                 {
   560                 {
   952                 CHuiControl& control = iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup->Control(0);
   561                 CHuiControlGroup* controlGroup = iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup;
       
   562                 CHuiControl& control = controlGroup->Control(0);
   953                 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
   563                 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
       
   564                 ResolveAfterEffectAppearingApplicationL(controlGroup);
   954                 // wserv has notifed that this control group and its layout should be destroyed. However, we might be
   565                 // wserv has notifed that this control group and its layout should be destroyed. However, we might be
   955                 // have effect on the layout itself or layout is being drawn as external content. This indicates that
   566                 // have effect on the layout itself or layout is being drawn as external content. This indicates that
   956                 // we should not delete the control group at this point, but add it to iDeadControlGroup list, which 
   567                 // we should not delete the control group at this point, but add it to iDeadControlGroup list, which 
   957                 // is cleared when effect has finished.
   568                 // is cleared when effect has finished.
   958                 RPointerArray<CHuiLayout> familyTree;
   569                 RPointerArray<CHuiLayout> familyTree;
   959                 ListFamilyTreeL(familyTree, layout); // recursively dig the family tree
   570                 ListFamilyTreeL(familyTree, layout); // recursively dig the family tree
       
   571                 TBool anyVisualHasEffect(EFalse);
       
   572                 TInt familyIndex(0);
       
   573                 TInt familySize = familyTree.Count();
       
   574                 while(familyIndex < familySize && !anyVisualHasEffect)
       
   575                     {
       
   576                     anyVisualHasEffect = HasActiveEffect(familyTree[familyIndex++]);
       
   577                     }
   960                 
   578                 
   961                 if (HasActiveEffect(layout))
   579                 if (anyVisualHasEffect)
   962                     {
   580                     {
   963                     __ALFFXLOGSTRING1("Layout 0x%x has external content", layout);
   581                     __ALFFXLOGSTRING1("Layout 0x%x has external content", layout);
   964                     // EHuiVisualFlagShouldDestroy destroy flag should have come for the windows in this layout already
   582                     // EHuiVisualFlagShouldDestroy destroy flag should have come for the windows in this layout already
   965                     layout->SetFlags(EHuiVisualFlagShouldDestroy);
   583                     layout->SetFlags(EHuiVisualFlagShouldDestroy);
   966                     // move this layout to effect control group, where it can still be shown. this control group may be deleted.
   584                     // move this layout to effect control group, where it can still be shown. this control group may be deleted.
   991                     // check once more, that the windows in this group are not having effects. 
   609                     // check once more, that the windows in this group are not having effects. 
   992                     // the layout is not have effect, but some child window might.
   610                     // the layout is not have effect, but some child window might.
   993                     // in this case, the child window effects WILL BE REMOVED.
   611                     // in this case, the child window effects WILL BE REMOVED.
   994                      for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++)
   612                      for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++)
   995                          {
   613                          {
   996                          RemoveTemporaryPresenterVisual(familyTree[familyIndex]);
   614                          CHuiLayout* removedVisual = familyTree[familyIndex];
       
   615                          RemoveTemporaryPresenterVisual(removedVisual);
       
   616           
       
   617                          if ( removedVisual != layout ) // let control group delete the layout
       
   618 					         {
       
   619 					         control.Remove(removedVisual); // remove ownership from the original control (group)
       
   620 					         if ( removedVisual->Layout() == layout ) 
       
   621 					             {
       
   622 					             iOrphanStorage->AppendL( removedVisual );
       
   623 					             } 
       
   624 					         else 
       
   625 					             {
       
   626                                  removedVisual->SetOwner(*iOrphanStorage);
       
   627 					             }
       
   628                              }
   997                          }
   629                          }
   998                     }
   630                     }
   999                 familyTree.Close();
   631                 familyTree.Close();
  1000                 iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup);
   632                 iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup);
  1001                 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group");
   633                 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group");
  1002                 iAlfScreens[aScreenNumber]->iControlGroups.Remove(i);
   634                 iAlfScreens[aScreenNumber]->iControlGroups.Remove(i);
  1003                 iHuiEnv->DeleteControlGroup(aWindowGroupNodeId);
   635                 iHuiEnv->DeleteControlGroup(aWindowGroupNodeId);
  1004                 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group done");
   636                 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group done");
  1005                 }
   637                 }
       
   638             
       
   639             AMT_DEC_COUNTER( iTotalControlGroupCount );            
       
   640             
  1006             break;
   641             break;
  1007             }
   642             }
  1008         }        
   643         }        
  1009     }
   644     }
  1010 
   645 
  1077         iAlfScreens[aScreenNumber]->iControlGroups.Append(entry);
   712         iAlfScreens[aScreenNumber]->iControlGroups.Append(entry);
  1078         CleanupStack::Pop(group);                
   713         CleanupStack::Pop(group);                
  1079 
   714 
  1080         if (iAlfScreens[aScreenNumber]->iDisplay)
   715         if (iAlfScreens[aScreenNumber]->iDisplay)
  1081             ShowControlGroupL(iAlfScreens[aScreenNumber]->iDisplay->Roster(), *group, KHuiRosterShowAtTop, aScreenNumber); 
   716             ShowControlGroupL(iAlfScreens[aScreenNumber]->iDisplay->Roster(), *group, KHuiRosterShowAtTop, aScreenNumber); 
       
   717         
       
   718         AMT_INC_COUNTER( iTotalControlGroupCount );
  1082         }
   719         }
  1083     
   720     
  1084 
   721 
  1085     return *group;       
   722     return *group;       
  1086     }
   723     }
  1118             {
   755             {
  1119             // The case where the application control group is deleted by window server
   756             // The case where the application control group is deleted by window server
  1120             // has been solved by deleting the tag when window server wants to delete
   757             // has been solved by deleting the tag when window server wants to delete
  1121             // the group. Window server no longer has it, but we keep it alive for a while
   758             // the group. Window server no longer has it, but we keep it alive for a while
  1122             // to show the effect. The group will be deleted when the effect ends.
   759             // to show the effect. The group will be deleted when the effect ends.
  1123             aWhere = aRoster.Count() - KAlfNumberOfFixedControlGroups;
   760             aWhere = aRoster.Count() - screen->FixedControlGroupCount();
  1124             }
   761             }
  1125         }
   762         }
  1126 
   763 
  1127     if (aGroup.Control(0).Role() == EAlfWindowGroupContainer)      
   764     if (aGroup.Control(0).Role() == EAlfWindowGroupContainer)      
  1128         {
   765         {
  1144 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER        
   781 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER        
  1145         DebugPrintControlGroupOrder(*screen, aRoster, aGroup);
   782         DebugPrintControlGroupOrder(*screen, aRoster, aGroup);
  1146 #endif
   783 #endif
  1147 
   784 
  1148 #ifdef ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
   785 #ifdef ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
  1149         VisualizeControlGroupOrderL(aRoster, aGroup);
   786         VisualizeControlGroupOrderL(*screen, aRoster, aGroup);
  1150 #endif
   787 #endif
  1151     
   788     
  1152     }
   789     }
  1153 
   790 
  1154 // ---------------------------------------------------------------------------
   791 // ---------------------------------------------------------------------------
  1238         aRoster.ShowL(aGroup, KHuiRosterShowAtBottom);    
   875         aRoster.ShowL(aGroup, KHuiRosterShowAtBottom);    
  1239         }
   876         }
  1240     else if (aWhere == KHuiRosterShowAtTop)
   877     else if (aWhere == KHuiRosterShowAtTop)
  1241         {
   878         {
  1242         // Topmost
   879         // Topmost
  1243         aRoster.ShowL(aGroup, aRoster.Count() - KAlfNumberOfFixedControlGroups);
   880         aRoster.ShowL(aGroup, aRoster.Count() - screen->FixedControlGroupCount());
  1244         }
   881         }
  1245     else
   882     else
  1246         {
   883         {
  1247         TInt index = 0; // Index for Window group control groups
   884         TInt index = 0; // Index for Window group control groups
  1248         TBool added = EFalse;
   885         TBool added = EFalse;
  1249         for (TInt i=0; i<aRoster.Count() - KAlfNumberOfFixedControlGroups; i++)
   886         for (TInt i=0; i<aRoster.Count() - screen->FixedControlGroupCount(); i++)
  1250             {
   887             {
  1251             if (index == aWhere)
   888             if (index == aWhere)
  1252                 {
   889                 {
  1253                 aRoster.ShowL(aGroup, i);        
   890                 TBool lSyncAlfAppAndAlfEventGroup = EFalse;
       
   891                 if ( i>0 &&  aRoster.ControlGroup(i).iAlfApp && aRoster.ControlGroup(i-1).ResourceId() == iAlfWindowGroupNodeId  && &aRoster.ControlGroup(i) != &aGroup)
       
   892                     {
       
   893                     lSyncAlfAppAndAlfEventGroup = ETrue;
       
   894                     }
       
   895                 aRoster.ShowL(aGroup, i);
  1254                 added = ETrue;
   896                 added = ETrue;
       
   897                 if (lSyncAlfAppAndAlfEventGroup && i< (aRoster.Count()-1) )
       
   898                 {
       
   899                 CHuiControlGroup &lGroup = aRoster.ControlGroup(i+1);
       
   900                 TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
       
   901                 iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
       
   902                 }
       
   903                 
  1255                 break;
   904                 break;
  1256                 }
   905                 }
  1257 
   906 
  1258             if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer &&
   907             if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer &&
  1259                 &aRoster.ControlGroup(i) != &aGroup)
   908                 &aRoster.ControlGroup(i) != &aGroup)
  1264         
   913         
  1265         // Too large index was given, just add it to topmost    
   914         // Too large index was given, just add it to topmost    
  1266         if (!added)
   915         if (!added)
  1267             {
   916             {
  1268             // Topmost
   917             // Topmost
  1269             for (TInt i=aRoster.Count()-KAlfNumberOfFixedControlGroups; i >= 0; i--)
   918             for (TInt i=aRoster.Count() - screen->FixedControlGroupCount(); i >= 0; i--)
  1270                 {
   919                 {
  1271                 if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer)
   920                 if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer)
  1272                     {
   921                     {
  1273                     aRoster.ShowL(aGroup, i); 
   922                     aRoster.ShowL(aGroup, i); 
  1274                     break;
   923                     break;
  1453     {
  1102     {
  1454     return aEffect && !(aEffect->EffectFlags() & KHuiFadeEffectFlag);
  1103     return aEffect && !(aEffect->EffectFlags() & KHuiFadeEffectFlag);
  1455     }
  1104     }
  1456 
  1105 
  1457 // ---------------------------------------------------------------------------
  1106 // ---------------------------------------------------------------------------
       
  1107 // Check if effect has been flagged as opaque
       
  1108 // ---------------------------------------------------------------------------
       
  1109 // 
       
  1110 static TBool IsOpaqueEffect(CHuiFxEffect* aEffect)
       
  1111     {
       
  1112     return aEffect && (aEffect->EffectFlags() & KHuiFxOpaqueHint);
       
  1113     }
       
  1114 
       
  1115 // ---------------------------------------------------------------------------
  1458 // ---------------------------------------------------------------------------
  1116 // ---------------------------------------------------------------------------
  1459 // 
  1117 // 
  1460 TBool CAlfBridge::IsVisualOpaque(CHuiVisual& aVisual)
  1118 TBool CAlfBridge::IsVisualOpaque(CHuiVisual& aVisual)
  1461     {
  1119     {
       
  1120     // Effect with opaque hint overrides everything else.
       
  1121     if (IsOpaqueEffect( aVisual.Effect() ))
       
  1122         {
       
  1123         return ETrue; // Opaque
       
  1124         }    
       
  1125 
  1462     TBool transparent = EFalse;
  1126     TBool transparent = EFalse;
  1463     
  1127     
  1464     // TODO: We should check transformation too and perhaps parent transformations as well ?
  1128     // TODO: We should check transformation too and perhaps parent transformations as well ?
  1465     //transparent |= aVisual.IsTransformed(); 
  1129     //transparent |= aVisual.IsTransformed(); 
  1466 
  1130 
  1590     
  1254     
  1591     TBool fullscreenCovered = EFalse;
  1255     TBool fullscreenCovered = EFalse;
  1592     //iActiveVisualCount = 0;
  1256     //iActiveVisualCount = 0;
  1593     iBgSurfaceFound = EFalse;
  1257     iBgSurfaceFound = EFalse;
  1594     //iPaintedArea = 0;  
  1258     //iPaintedArea = 0;  
       
  1259     
       
  1260     // Check if effect group has an effect with opaque hint.
       
  1261     CHuiControlGroup& fxcontrolgroup = *(iAlfScreens[aScreenNumber]->iFullscreenEffectControlGroup);
       
  1262     CHuiControl& fxcontrol = fxcontrolgroup.Control(0);
       
  1263     CHuiCanvasVisual* fxlayout = (CHuiCanvasVisual*)&fxcontrol.Visual(0);
       
  1264     CHuiVisual* fxExternalContent = fxlayout->ExternalContent();
       
  1265     
       
  1266     if (fxlayout && IsOpaqueEffect(fxlayout->Effect()))
       
  1267         {
       
  1268         fullscreenCovered = ETrue;    
       
  1269         }
       
  1270     else if (fxExternalContent && IsOpaqueEffect(fxExternalContent->Effect()))
       
  1271         {
       
  1272         fullscreenCovered = ETrue;
       
  1273         }    
       
  1274     
       
  1275     #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
       
  1276     iTempTotalActiveVisualCount = 0;
       
  1277     iTempTotalPassiveVisualCount = 0;
       
  1278     #endif
       
  1279 	
  1595     // skip the topmost (effect) layer, start from floating sprite group
  1280     // skip the topmost (effect) layer, start from floating sprite group
  1596     for (TInt j=screen->iDisplay->Roster().Count() - 2; j>=0; j--)
  1281     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
  1597         {                
  1282         {                
  1598 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1283 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1599         TInt activevisualcount = 0;
  1284         activevisualcount = 0;
  1600         TInt passivevisualcount = 0;
  1285         passivevisualcount = 0;
  1601 #endif
  1286 #endif
  1602 
  1287 
  1603         CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
  1288         CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
  1604         CHuiControl& control = controlgroup.Control(0);
  1289         CHuiControl& control = controlgroup.Control(0);
       
  1290 
       
  1291         if (control.Role() == EAlfFpsIndicatorContainer)
       
  1292             {
       
  1293             // FPS container doesn't contain canvas visuals
       
  1294             continue;
       
  1295             }
       
  1296 
  1605         CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
  1297         CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
  1606 #ifdef HUI_DEBUG_TRACK_DRAWING	
  1298 #ifdef HUI_DEBUG_TRACK_DRAWING	
  1607         if ( layout->Tracking() )
  1299         if ( layout->Tracking() )
  1608             {
  1300             {
  1609             RDebug::Print(_L("CAlfBridge::HandleVisualVisibility: tracked visual 0x%x"), canvasVisual);
  1301             RDebug::Print(_L("CAlfBridge::HandleVisualVisibility: tracked visual 0x%x"), canvasVisual);
  1610             }
  1302             }
  1611 #endif            
  1303 #endif            
  1612 
  1304             
  1613         // Dont mess with alf control group visuals, alf session handling does it for us
  1305         // Dont mess with alf control group visuals, alf session handling does it for us
  1614         // just add the rect to covered region because alf draws solid background.
  1306         // just add the rect to covered region because alf draws solid background.
  1615         if (control.Role() == EAlfSessionContainer)
  1307         if (control.Role() == EAlfSessionContainer)
  1616             {
  1308             {
  1617             iTempRegion.AddRect(fullscreen);
  1309             iTempRegion.AddRect(fullscreen);
  1639             }
  1331             }
  1640         
  1332         
  1641         TBool subTreeCovered = EFalse;
  1333         TBool subTreeCovered = EFalse;
  1642         TBool hasActiveVisualsInVisualTree = HandleLayoutVisualVisibility( layout, controlgroup, control, fullscreenCovered, fullscreen, screen, subTreeCovered, IsVisualOpaque(*layout)  );    
  1334         TBool hasActiveVisualsInVisualTree = HandleLayoutVisualVisibility( layout, controlgroup, control, fullscreenCovered, fullscreen, screen, subTreeCovered, IsVisualOpaque(*layout)  );    
  1643         TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
  1335         TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
       
  1336 
       
  1337         // If root visuals effect is marked as opaque, then add whole screen area as covered.
       
  1338         if (!fullscreenCovered)
       
  1339             {
       
  1340             fullscreenCovered = IsOpaqueEffect(layout->Effect());
       
  1341             }                    
  1644         
  1342         
  1645 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1343 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1646 		// flagged as containing fade effect, then run the setup as well so that effects which
  1344 		// flagged as containing fade effect, then run the setup as well so that effects which
  1647 		// are no more needed get removed.
  1345 		// are no more needed get removed.
  1648         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1346         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1706     // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others
  1404     // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others
  1707     // would clear the screen areas where they do not really draw.
  1405     // would clear the screen areas where they do not really draw.
  1708     if (fadeEffectInScreen)
  1406     if (fadeEffectInScreen)
  1709         {
  1407         {
  1710         TBool firstFadedWindowGroupFound = EFalse;
  1408         TBool firstFadedWindowGroupFound = EFalse;
  1711         for (TInt j=0; j<screen->iDisplay->Roster().Count() - 2; j++) // skip the topmost (effect) layer 
  1409         for (TInt j=0; j<screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j++) // skip the topmost (effect) layer 
  1712             {                
  1410             {                
  1713             CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
  1411             CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
  1714             CHuiControl& control = controlgroup.Control(0);
  1412             CHuiControl& control = controlgroup.Control(0);
  1715             CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
  1413             CHuiVisual* layout = &control.Visual(0);
  1716             if (layout->Effect() && (layout->Effect()->EffectFlags() & KHuiFadeEffectFlag))
  1414             if (layout->Effect() && (layout->Effect()->EffectFlags() & KHuiFadeEffectFlag))
  1717                 {
  1415                 {
  1718                 if (firstFadedWindowGroupFound)
  1416                 if (firstFadedWindowGroupFound)
  1719                     {
  1417                     {
  1720                     TInt flags = layout->Effect()->EffectFlags();
  1418                     TInt flags = layout->Effect()->EffectFlags();
  1721                     flags |= KHuiFxAlwaysBlend;
  1419                     flags |= KHuiFxAlwaysBlend; // Workaround for opaque layout canvasvisual.
  1722                     layout->Effect()->SetEffectFlags(flags);
  1420                     layout->Effect()->SetEffectFlags(flags);
  1723                     }
  1421                     }
       
  1422                 
       
  1423                 if ((controlgroup.ResourceId() == iAlfWindowGroupNodeId))
       
  1424                     {
       
  1425                     // Special handling for ALF fading...fading happens via empty alf originated event window group
       
  1426                     TInt flags = layout->Effect()->EffectFlags();
       
  1427                     flags |= KHuiFxEnableBackgroundInAllLayers; // This forces effect to happen to background pixels that are read from surface. 
       
  1428                     flags |= KHuiFxFrozenBackground; // To get optimal UI performance, we ignore changes in ALF scene when it is faded.
       
  1429                     layout->Effect()->SetEffectFlags(flags);                            
       
  1430                     }
       
  1431                 
  1724                 firstFadedWindowGroupFound = ETrue;
  1432                 firstFadedWindowGroupFound = ETrue;
  1725                 }
  1433                 }
  1726             }
  1434             }
  1727         }
  1435         }
       
  1436 
       
  1437     AMT_FUNC_EXC(AMT_DATA()->iActiveVisualCount = iTempTotalActiveVisualCount;
       
  1438                  AMT_DATA()->iPassiveVisualCount = iTempTotalPassiveVisualCount;
       
  1439                  AMT_DATA()->PrintState()
       
  1440                  );
  1728     }
  1441     }
  1729 
  1442 
  1730 TBool CAlfBridge::HandleLayoutVisualVisibility(
  1443 TBool CAlfBridge::HandleLayoutVisualVisibility(
  1731         CHuiLayout* aLayout, 
  1444         CHuiLayout* aLayout, 
  1732         CHuiControlGroup& aControlGroup,
  1445         CHuiControlGroup& aControlGroup,
  1849             if (!wasInactive)
  1562             if (!wasInactive)
  1850                 {
  1563                 {
  1851                 aScreen->iDisplay->SetDirty();
  1564                 aScreen->iDisplay->SetDirty();
  1852                 }                
  1565                 }                
  1853             
  1566             
  1854     #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1567             #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
  1855             passivevisualcount++;
  1568             iTempTotalPassiveVisualCount++;
  1856     #endif
  1569             #endif
       
  1570             
       
  1571             #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
       
  1572                     passivevisualcount++;
       
  1573             #endif
  1857             }
  1574             }
  1858         else
  1575         else
  1859             {
  1576             {
  1860 			aSubtreeVisible = ETrue;
  1577 			aSubtreeVisible = ETrue;
  1861             canvasVisual->ClearFlags( 
  1578             canvasVisual->ClearFlags( 
  1900 
  1617 
  1901             if (wasInactive)
  1618             if (wasInactive)
  1902                 {
  1619                 {
  1903                 canvasVisual->SetChanged();
  1620                 canvasVisual->SetChanged();
  1904                 }
  1621                 }
  1905     #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1622             #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
       
  1623             iTempTotalActiveVisualCount++;
       
  1624             #endif
       
  1625 
       
  1626             #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1906             activevisualcount++;
  1627             activevisualcount++;
  1907     #endif
  1628             #endif
  1908             }
  1629             }
  1909             
  1630             
  1910         // Finally check the area that this visual covers and add it to covered region
  1631         // Finally check the area that this visual covers and add it to covered region
  1911         visualIsActive = !(canvasVisual->Flags() & EHuiVisualFlagInactive);
  1632         visualIsActive = !(canvasVisual->Flags() & EHuiVisualFlagInactive);
  1912     
  1633     
  1944     #endif
  1665     #endif
  1945                     iTempRegion.AddRect(coveredRect);
  1666                     iTempRegion.AddRect(coveredRect);
  1946                     iTempRegion.Tidy();                                    
  1667                     iTempRegion.Tidy();                                    
  1947                     }
  1668                     }
  1948                 }
  1669                 }
       
  1670             
       
  1671             // If effect is marked as opaque, then add whole visual area as covered.
       
  1672             if (IsOpaqueEffect(canvasVisual->Effect()))
       
  1673                 {
       
  1674                 iTempRegion.AddRect(visualDisplayRect);
       
  1675                 iTempRegion.Tidy();
       
  1676                 }            
  1949             }                                        
  1677             }                                        
  1950         }
  1678         visualTreeActive |= visualIsActive;
  1951     
  1679         } // for loop end : children checking loop
  1952     visualTreeActive |= visualIsActive; 
  1680      
  1953     return visualTreeActive;
  1681     return visualTreeActive;
  1954     }
  1682     }
  1955 
  1683 
  1956 
  1684 
  1957 // ---------------------------------------------------------------------------
  1685 // ---------------------------------------------------------------------------
  1961     {
  1689     {
  1962     if (!iAlfScreens.Count())
  1690     if (!iAlfScreens.Count())
  1963         return;
  1691         return;
  1964             
  1692             
  1965     CAlfScreen* screen = iAlfScreens[0]; // TODO  
  1693     CAlfScreen* screen = iAlfScreens[0]; // TODO  
  1966     for (TInt j=screen->iDisplay->Roster().Count() - 2; j>=0; j--) // skip the topmost (effect) layer 
  1694     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--) // skip the topmost (effect) layer 
  1967         {                
  1695         {                
  1968         CHuiControlGroup& controlgroup = iAlfScreens[0]->iDisplay->Roster().ControlGroup(j);
  1696         CHuiControlGroup& controlgroup = iAlfScreens[0]->iDisplay->Roster().ControlGroup(j);
  1969         CHuiControl& control = controlgroup.Control(0);
  1697         CHuiControl& control = controlgroup.Control(0);
  1970 
  1698 
  1971         if ( control.Role() == EAlfSessionContainer )
  1699         if ( control.Role() == EAlfSessionContainer ||
       
  1700              control.Role() == EAlfFpsIndicatorContainer )
  1972             {
  1701             {
  1973             continue;
  1702             continue;
  1974             }
  1703             }
  1975         
  1704         
  1976         CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
  1705         CHuiVisual* layout = &control.Visual(0);
  1977         for (TInt i=layout->Count()-1; i >= 0; i--)
  1706         for (TInt i=layout->Count()-1; i >= 0; i--)
  1978             {
  1707             {
  1979             CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&layout->Visual(i));
  1708             CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&layout->Visual(i));
  1980             if (!aInactiveOnly)
  1709             if (!aInactiveOnly)
  1981                 {
  1710                 {
  2044         // dispatch
  1773         // dispatch
  2045         __ALFLOGSTRING1( "CAlfBridge::DoDispatchL: %d",data.iOp );
  1774         __ALFLOGSTRING1( "CAlfBridge::DoDispatchL: %d",data.iOp );
  2046 
  1775 
  2047         switch (data.iOp)
  1776         switch (data.iOp)
  2048             {
  1777             {
       
  1778             case EAlfDSSynchronize:
       
  1779                 {
       
  1780                 TInt id = data.iInt1;
       
  1781                 if ( iHuiEnv )
       
  1782                     {
       
  1783                     iHuiEnv->Synchronize( id, this );
       
  1784                     }
       
  1785                 }
       
  1786                 break;
       
  1787                 
  2049             case EAlfDSCreateNewDisplay:
  1788             case EAlfDSCreateNewDisplay:
  2050                 {
  1789                 {
  2051                 AddNewScreenL(NULL);
  1790                 AddNewScreenL(NULL);
  2052                 break;
  1791                 break;
  2053                 }
  1792                 }
  2328     // TODO: Following delete iAlfScreens[aScreenNumber] crashes when display is trying to delete roster. 
  2067     // TODO: Following delete iAlfScreens[aScreenNumber] crashes when display is trying to delete roster. 
  2329     // RosterEntry is trying to refer to display, which is appareantly alrady destroyed. The roster should have no iRootVisual when display is removed. 
  2068     // RosterEntry is trying to refer to display, which is appareantly alrady destroyed. The roster should have no iRootVisual when display is removed. 
  2330     
  2069     
  2331     iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*(iAlfScreens[aScreenNumber]->iFloatingSpriteControlGroup)); 
  2070     iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*(iAlfScreens[aScreenNumber]->iFloatingSpriteControlGroup)); 
  2332     iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*(iAlfScreens[aScreenNumber]->iFullscreenEffectControlGroup));
  2071     iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*(iAlfScreens[aScreenNumber]->iFullscreenEffectControlGroup));
       
  2072     if ( iAlfScreens[aScreenNumber]->iFpsControlGroup )
       
  2073         {
       
  2074         iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*(iAlfScreens[aScreenNumber]->iFpsControlGroup));
       
  2075         }
  2333     delete iAlfScreens[aScreenNumber];
  2076     delete iAlfScreens[aScreenNumber];
  2334     iAlfScreens.Remove( aScreenNumber );
  2077     iAlfScreens.Remove( aScreenNumber );
  2335     }
  2078     }
  2336 
  2079 
  2337 // ---------------------------------------------------------------------------
  2080 // ---------------------------------------------------------------------------
  2462 // HandleDestroyWindow
  2205 // HandleDestroyWindow
  2463 // ---------------------------------------------------------------------------
  2206 // ---------------------------------------------------------------------------
  2464 // 
  2207 // 
  2465 void CAlfBridge::DestroyWindow(CHuiVisual* aVisual, TBool aUseForce)
  2208 void CAlfBridge::DestroyWindow(CHuiVisual* aVisual, TBool aUseForce)
  2466     {
  2209     {
  2467     if ( !aUseForce && HasActiveEffect(aVisual) )
  2210     TInt index;
       
  2211     TBool visualParticipatingInEffect = HasActiveEffect(aVisual, index);
       
  2212     
       
  2213     TBool effectIsExitEffect(ETrue);
       
  2214     if (index != KErrNotFound)
       
  2215         {
       
  2216         effectIsExitEffect = iEffectCleanupStack[index].iHideWhenFinished;
       
  2217         }
       
  2218     // effects inside application may need to destroy window to get the new content visible. 
       
  2219     // Even when there is effect on the layout, destruction of a child window must be allowed.
       
  2220     if ( !aUseForce && visualParticipatingInEffect && effectIsExitEffect )
  2468         {
  2221         {
  2469         // this visual will be destroyed on the effect call back.
  2222         // this visual will be destroyed on the effect call back.
  2470         __ALFFXLOGSTRING1("CAlfBridge::DestroyWindow - not destroying 0x%x", aVisual);
  2223         __ALFFXLOGSTRING1("CAlfBridge::DestroyWindow - not destroying 0x%x", aVisual);
  2471         aVisual->SetFlag(EHuiVisualFlagShouldDestroy);
  2224         aVisual->SetFlag(EHuiVisualFlagShouldDestroy);
  2472         // TODO: Revise
  2225         // TODO: Revise
  2486     aVisual->Owner().Remove(aVisual);
  2239     aVisual->Owner().Remove(aVisual);
  2487     __ALFLOGSTRING1("CAlfBridge::HandleDestroyWindow - destroying visual 0x%x", aVisual);
  2240     __ALFLOGSTRING1("CAlfBridge::HandleDestroyWindow - destroying visual 0x%x", aVisual);
  2488     // check if visual is having an effect at the moment. This could occur, if options menu is exited (with effect) and then 
  2241     // check if visual is having an effect at the moment. This could occur, if options menu is exited (with effect) and then 
  2489     // application is exited. EHuiVisualFlagDrawOnlyAsExternalContent is indication that
  2242     // application is exited. EHuiVisualFlagDrawOnlyAsExternalContent is indication that
  2490     // there might be effect on this visual. It is not guaranteen.
  2243     // there might be effect on this visual. It is not guaranteen.
  2491 
  2244     
       
  2245     if (!aUseForce)
       
  2246         {
       
  2247         // we can remove from iEffectCleanupStack only when this method was called from HandleDestroyWindow. Otherwise
       
  2248         // messing iEffectCleanupStack is likely to cause forever loop in some RemoveTemporaryPresenterVisuals method
       
  2249         for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
       
  2250             {
       
  2251             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
       
  2252             if (aVisual == effectItem.iEffectedVisual)
       
  2253                 {
       
  2254                 iEffectCleanupStack.Remove(i);
       
  2255                 break;
       
  2256                 }
       
  2257             }
       
  2258         }
  2492     delete aVisual;
  2259     delete aVisual;
  2493     }
  2260     }
  2494 // ---------------------------------------------------------------------------
  2261 // ---------------------------------------------------------------------------
  2495 // HandleDestroyWindowL
  2262 // HandleDestroyWindowL
  2496 // ---------------------------------------------------------------------------
  2263 // ---------------------------------------------------------------------------
  2529 			viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  2296 			viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  2530 			CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
  2297 			CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
  2531 		     // Sprite is in its own group, and can be deleted normally.
  2298 		     // Sprite is in its own group, and can be deleted normally.
  2532 			if ( !controlGroup  && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite )
  2299 			if ( !controlGroup  && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite )
  2533 			    {
  2300 			    {
  2534 			    __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.!");
  2301 			    __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.");
  2535 			    // the group containing this visual has been destroyed. Thus the visual itself has been destroyed by 
  2302 			    // the group containing this visual has been destroyed. 
  2536 			    // the group. Ignore this.
  2303                 if ( viz ) 
       
  2304 				    {
       
  2305 				    DestroyWindow(viz);
       
  2306 					}
  2537 			    }
  2307 			    }
  2538 			else
  2308 			else
  2539 			    {
  2309 			    {
  2540 			    // = (CHuiCanvasVisual*)de(windowNodeId, windowGroupNodeId,screenNumber);
  2310 			    // = (CHuiCanvasVisual*)de(windowNodeId, windowGroupNodeId,screenNumber);
  2541 			    if (viz)
  2311 			    if (viz)
  2592 		}
  2362 		}
  2593 	else
  2363 	else
  2594 		{
  2364 		{
  2595 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowPosL, EAlfDSSetWindowPos: Visual not found!");    
  2365 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowPosL, EAlfDSSetWindowPos: Visual not found!");    
  2596 		}   
  2366 		}   
       
  2367 
       
  2368     AMT_INC_COUNTER_IF( viz, iVisualPositionChangedCount );
       
  2369     AMT_SET_VALUE_IF( viz, iLatestVisualExtentRect, TRect( windowAttributes->iPosition, windowAttributes->iSize ) );
  2597 	}
  2370 	}
  2598 
  2371 
  2599 // ---------------------------------------------------------------------------
  2372 // ---------------------------------------------------------------------------
  2600 // HandleSetWindowSizeL
  2373 // HandleSetWindowSizeL
  2601 // ---------------------------------------------------------------------------
  2374 // ---------------------------------------------------------------------------
  2620 	else
  2393 	else
  2621 		{
  2394 		{
  2622 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!");    
  2395 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!");    
  2623 		}   
  2396 		}   
  2624     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  2397     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
       
  2398     
       
  2399     AMT_INC_COUNTER_IF(viz, iVisualSizeChangedCount );
       
  2400     AMT_SET_VALUE_IF(viz, iLatestVisualExtentRect, TRect( windowAttributes->iPosition, windowAttributes->iSize ) );        
  2625 	}
  2401 	}
  2626 
  2402 
  2627 // ---------------------------------------------------------------------------
  2403 // ---------------------------------------------------------------------------
  2628 // HandleSetWindowRotationL
  2404 // HandleSetWindowRotationL
  2629 // ---------------------------------------------------------------------------
  2405 // ---------------------------------------------------------------------------
  2709 				}    
  2485 				}    
  2710 			#endif
  2486 			#endif
  2711 
  2487 
  2712 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  2488 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  2713 			
  2489 			
  2714                         if (!controlGroup)
  2490             if (!controlGroup)
  2715                             {
  2491                 {
  2716                             User::Leave(KErrNotFound);
  2492                 User::Leave(KErrNotFound);
  2717                             }
  2493                 }
  2718 
  2494             ResolveAfterEffectAppearingApplicationL(controlGroup); // does nothing, if effect is not active on this control group
  2719 			// Window server nodes are in inverted Z-order, we switch it here.
  2495 			// Window server nodes are in inverted Z-order, we switch it here.
  2720 			iAlfScreens[screenNumber]->iDisplay->Roster().Hide(*controlGroup);                            
  2496 			iAlfScreens[screenNumber]->iDisplay->Roster().Hide(*controlGroup);                            
  2721 			TInt wsWindowGroupCount = 0;
  2497 			TInt wsWindowGroupCount = 0;
  2722 			for (TInt i=0; i<iAlfScreens[screenNumber]->iDisplay->Roster().Count();i++)
  2498 			for (TInt i=0; i<iAlfScreens[screenNumber]->iDisplay->Roster().Count();i++)
  2723 				{
  2499 				{
  2884 		}
  2660 		}
  2885 	else
  2661 	else
  2886 		{
  2662 		{
  2887 		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
  2663 		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
  2888 		}    
  2664 		}    
       
  2665 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
       
  2666 	    if (iFullScreenEffectData 
       
  2667 	            && iFullScreenEffectData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
       
  2668 	            && !iFullScreenEffectData->iEndFullScreen)
       
  2669 	        {
       
  2670             TInt toAppUid; 
       
  2671             if (iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
       
  2672                 {
       
  2673                 toAppUid = iFullScreenEffectData->iFromAppId;
       
  2674                 }
       
  2675             else
       
  2676                 {
       
  2677                 toAppUid = iFullScreenEffectData->iToAppId;
       
  2678                 }
       
  2679             
       
  2680             CHuiControlGroup *to_group = FindControlGroupByAppId(toAppUid);
       
  2681 	    
       
  2682 	        // 1. if we get drawing commands after BeginFullScreen, we need to generate EndFullScreen call.
       
  2683 	        // 2. only the first drawing commands will trigger EndFullScreen
       
  2684 	        // (this mechanism is here because we want to remove delay from fullscreen effects - and EndFullScreens are coming from application too late)
       
  2685 	        
       
  2686 	        if (viz->Owner().ControlGroup() == to_group)
       
  2687 	            {
       
  2688                 iFullScreenEffectData->ResetTimerL(this);
       
  2689                 iFullScreenEffectData->iDisplaySize = iAlfScreens[0]->Size(); 
       
  2690                 THuiCanvasPaintedArea p = viz->PaintedArea(0);
       
  2691 	            iFullScreenEffectData->iPaintedRegion.AddRect( p.iPaintedRect.Round() );
       
  2692 	            TRect b = iFullScreenEffectData->iPaintedRegion.BoundingRect();
       
  2693 	            __ALFFXLOGSTRING3(
       
  2694 	                    "CAlfBridge::HandlePostCanvasBufferL : Effect to visual 0x%x, Covered rect: iTl.iX: %d , iTl.iY: %d",
       
  2695 	                    viz, 
       
  2696 	                    b.iTl.iX, 
       
  2697 	                    b.iTl.iY);
       
  2698 	            __ALFFXLOGSTRING2("CAlfBridge::HandlePostCanvasBufferL : iBr.iX: %d, iBr.iY: %d", b.iBr.iX, b.iBr.iY);
       
  2699 	                        }
       
  2700 	        }
       
  2701 	        // END TP HACK
       
  2702 #endif
  2889 	}
  2703 	}
  2890 
  2704 
  2891 // ---------------------------------------------------------------------------
  2705 // ---------------------------------------------------------------------------
       
  2706 // HandleGfxEndFullScreenTimeout
       
  2707 // ---------------------------------------------------------------------------
       
  2708 // 
       
  2709 void CAlfBridge::HandleGfxEndFullScreenTimeout(CFullScreenEffectState* aFullScreenEffectData)
       
  2710     {
       
  2711     if (aFullScreenEffectData->iEndFullScreen)
       
  2712         {
       
  2713         return;
       
  2714         }
       
  2715     CHuiControlGroup *to_group = FindControlGroupByAppId(aFullScreenEffectData->iToAppId);
       
  2716     CHuiControlGroup *from_group = FindControlGroupByAppId( aFullScreenEffectData->iFromAppId );
       
  2717     CHuiLayout *to_layout = NULL;
       
  2718     CHuiLayout *from_layout = NULL;
       
  2719     if (!to_group) // group has been destroyed and moved to effectControlGroup for waiting the application exit effect EndFullScreen trigger 
       
  2720          {
       
  2721         to_layout = FindLayoutByEffectHandle(aFullScreenEffectData->iHandle);
       
  2722          }
       
  2723      else
       
  2724          {
       
  2725          CHuiControl& control = to_group->Control(0);
       
  2726          to_layout = (CHuiLayout*)&control.Visual(0);
       
  2727          }
       
  2728         
       
  2729     if (from_group)
       
  2730         {
       
  2731         CHuiControl& control = from_group->Control(0);
       
  2732         from_layout = (CHuiLayout*)&control.Visual(0);
       
  2733         }
       
  2734     aFullScreenEffectData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
       
  2735     if (to_layout)
       
  2736         {
       
  2737         // from layout may be undefined
       
  2738         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEndFullScreenTimeout : Enough app drawing. Trigger EndFullScreen for layout 0x%x", to_layout);    
       
  2739         HandleGfxEventL( *aFullScreenEffectData, to_layout, from_layout );
       
  2740         }
       
  2741 
       
  2742     aFullScreenEffectData->iEndFullScreen = ETrue;
       
  2743     }
       
  2744 
       
  2745 // ---------------------------------------------------------------------------
  2892 // SetWindowActiveL
  2746 // SetWindowActiveL
  2893 // ---------------------------------------------------------------------------
  2747 // ---------------------------------------------------------------------------
  2894 // 
  2748 // 
  2895 void CAlfBridge::SetWindowActiveL(CHuiVisual* aVisual, TBool aActive)
  2749 void CAlfBridge::SetWindowActiveL(CHuiVisual* aVisual, TBool aActive)
  2896     {
  2750     {
  2897     if (!HasActiveEffect(aVisual))
  2751     TInt effectIndex;
       
  2752     if (!HasActiveEffect(aVisual, effectIndex))
  2898         {
  2753         {
  2899         // Does not have effect
  2754         // Does not have effect
  2900         if (aActive)
  2755         if (aActive)
  2901             {
  2756             {
  2902             aVisual->ClearFlags(EHuiVisualFlagShouldBeHidden | EHuiVisualFlagShouldBeShown);
  2757             aVisual->ClearFlags(EHuiVisualFlagShouldBeHidden | EHuiVisualFlagShouldBeShown);
  2913         // Has effect
  2768         // Has effect
  2914 		// these flags are put to action in RemoveTemporaryPresenterItem
  2769 		// these flags are put to action in RemoveTemporaryPresenterItem
  2915         if (aActive)
  2770         if (aActive)
  2916             {
  2771             {
  2917 			// this prevents windows appearing before their "effected" time
  2772 			// this prevents windows appearing before their "effected" time
  2918             aVisual->SetFlag(EHuiVisualFlagShouldBeShown);
  2773             if (!iEffectCleanupStack[effectIndex].iHideWhenFinished)
       
  2774                 {
       
  2775                 // this is appear effect. Lets show it
       
  2776                 aVisual->iOpacity.Set(KAlfVisualDefaultOpacity);
       
  2777                 }
       
  2778             else
       
  2779                 {
       
  2780                 aVisual->SetFlag(EHuiVisualFlagShouldBeShown);
       
  2781                 }
  2919             aVisual->ClearFlag(EHuiVisualFlagShouldBeHidden);
  2782             aVisual->ClearFlag(EHuiVisualFlagShouldBeHidden);
  2920             }
  2783             }
  2921         else
  2784         else
  2922             {
  2785             {
  2923 			// this prevents windows disappearing before their effect has finished
  2786 			// this prevents windows disappearing before their effect has finished
  3538     }
  3401     }
  3539 
  3402 
  3540 TBool CAlfBridge::HasActiveFadedChildren( CHuiCanvasVisual& aVisual )
  3403 TBool CAlfBridge::HasActiveFadedChildren( CHuiCanvasVisual& aVisual )
  3541     {
  3404     {
  3542     TBool has = EFalse;
  3405     TBool has = EFalse;
       
  3406     has |= IsAlfOriginatedWindow(aVisual);
       
  3407     
  3543     TInt count = aVisual.Count();        
  3408     TInt count = aVisual.Count();        
  3544     for (TInt i=0; i<count; i++)
  3409     for (TInt i=0; i<count; i++)
  3545         {
  3410         {
  3546         CHuiCanvasVisual* child = (CHuiCanvasVisual*) (&aVisual.Visual(i)); 
  3411         CHuiCanvasVisual* child = (CHuiCanvasVisual*) (&aVisual.Visual(i)); 
  3547         TBool active = !(child->Flags() & EHuiVisualFlagInactive);            
  3412         TBool active = !(child->Flags() & EHuiVisualFlagInactive);            
  3548         TBool faded = child->CanvasFlags() & EHuiCanvasFlagExternalFade; 
  3413         TBool faded = child->CanvasFlags() & EHuiCanvasFlagExternalFade; 
  3549         
  3414         
  3550         if (active && faded && child->PaintedAreaCount())
  3415         if (active && faded && (child->PaintedAreaCount() || IsAlfOriginatedWindow(*child)))
  3551             {
  3416             {
  3552             has = ETrue;
  3417             has = ETrue;
  3553             break;
  3418             break;
  3554             }        
  3419             }        
  3555         }    
  3420         }    
  3585         
  3450         
  3586         // Avoid interrupting other effects. 
  3451         // Avoid interrupting other effects. 
  3587         TBool otherEffectActive = aVisual.Effect() && !(aVisual.Effect()->EffectFlags() & KHuiFadeEffectFlag);
  3452         TBool otherEffectActive = aVisual.Effect() && !(aVisual.Effect()->EffectFlags() & KHuiFadeEffectFlag);
  3588 
  3453 
  3589         // Check if we really need to fade. Note the order of if-conditions, fastest checks first to optimize performance.
  3454         // Check if we really need to fade. Note the order of if-conditions, fastest checks first to optimize performance.
  3590         if (visualIsActive && !alreadyFaded && !otherEffectActive && !IsFadedByParent(aVisual) && HasActivePaintedAreas(aVisual, fadesChildren))
  3455         if (visualIsActive && !alreadyFaded && !otherEffectActive && !IsFadedByParent(aVisual) && (HasActivePaintedAreas(aVisual, fadesChildren) || IsAlfOriginatedWindow(aVisual)))
  3591         	{        
  3456         	{        
  3592         	CHuiFxEffect* effect = NULL;
  3457         	CHuiFxEffect* effect = NULL;
  3593         	CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
  3458         	CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
  3594 
  3459 
  3595             if (engine && iFadeEffectFile )
  3460             if (engine && iFadeEffectFile )
  3659 // 
  3524 // 
  3660 void CAlfBridge::HandleSetFadeEffectL( TAlfBridgerData& aData )
  3525 void CAlfBridge::HandleSetFadeEffectL( TAlfBridgerData& aData )
  3661     {
  3526     {
  3662     TInt windowNodeId = aData.iInt1;  
  3527     TInt windowNodeId = aData.iInt1;  
  3663     TBool faded = aData.iInt2;
  3528     TBool faded = aData.iInt2;
  3664 
  3529     MWsWindowTreeNode::TType type = (MWsWindowTreeNode::TType)(TInt)aData.iPtr;
  3665     CHuiVisual* viz = (CHuiVisual*)FindVisual(windowNodeId);    
  3530     CHuiVisual* viz = NULL;
  3666     if (!viz)
  3531     if (type != MWsWindowTreeNode::EWinTreeNodeGroup)
  3667         {
  3532         {
  3668         // Visual not found, it could be window group. It must be searched with other method.
  3533         viz = (CHuiVisual*)FindVisual(windowNodeId);
       
  3534         }
       
  3535     else
       
  3536         {
  3669         CHuiControlGroup* cg = FindControlGroup(windowNodeId, 0); // TODO: Screen            
  3537         CHuiControlGroup* cg = FindControlGroup(windowNodeId, 0); // TODO: Screen            
  3670         if (cg) 
  3538         if (cg) 
  3671             {
  3539             {
  3672             CHuiControl& control = cg->Control(0);
  3540             CHuiControl& control = cg->Control(0);
  3673             viz = &control.Visual(0);
  3541             viz = &control.Visual(0);
  3755         }
  3623         }
  3756     else
  3624     else
  3757         {
  3625         {
  3758         __ALFLOGSTRING1("CAlfBridge::HandleSetCursorDataL - WARNING! Cursor node 0x%x not found!", windowNodeId);
  3626         __ALFLOGSTRING1("CAlfBridge::HandleSetCursorDataL - WARNING! Cursor node 0x%x not found!", windowNodeId);
  3759         }
  3627         }
       
  3628     
       
  3629     AMT_INC_COUNTER_IF(viz, iTotalVisualAttributeChangedCount);   
  3760     }
  3630     }
  3761 
  3631 
  3762 // ---------------------------------------------------------------------------
  3632 // ---------------------------------------------------------------------------
  3763 // HandleSetNodeTracking
  3633 // HandleSetNodeTracking
  3764 // ---------------------------------------------------------------------------
  3634 // ---------------------------------------------------------------------------
  3838             {
  3708             {
  3839             case MAlfGfxEffectPlugin::EBeginFullscreen:
  3709             case MAlfGfxEffectPlugin::EBeginFullscreen:
  3840                 {
  3710                 {
  3841                 aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  3711                 aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  3842                 TBool needStoredBuffers = NeedsStoredBuffers(engine, *aEvent.iEffectName);
  3712                 TBool needStoredBuffers = NeedsStoredBuffers(engine, *aEvent.iEffectName);
       
  3713                 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - EBeginFullScreen: %d, Take screenhot: %d", aEvent.iHandle, needStoredBuffers);
  3843                 if (needStoredBuffers)
  3714                 if (needStoredBuffers)
  3844                     {
  3715                     {
  3845                     TRAP(err,StoreRenderBufferStartL(aToLayout));
  3716                     TRAP(err,StoreRenderBufferStartL(aToLayout));
       
  3717                     __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - EBeginFullScreen: Screenshot result: KErrNone == %d", err);
  3846                     if (err == KErrNone)
  3718                     if (err == KErrNone)
  3847                         {
  3719                         {
  3848                         aToLayout->SetFreezeState(ETrue);
  3720                         aToLayout->SetFreezeState(ETrue);
  3849                         }
  3721                         }
  3850                     else
  3722                     else
  3858                     case AknTransEffect::EApplicationStart:
  3730                     case AknTransEffect::EApplicationStart:
  3859                     case AknTransEffect::EApplicationStartRect:
  3731                     case AknTransEffect::EApplicationStartRect:
  3860                         {
  3732                         {
  3861                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that yet dont have anything to show
  3733                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that yet dont have anything to show
  3862                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  3734                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
       
  3735                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  3863                         break;
  3736                         break;
  3864                         }
  3737                         }
  3865                     case AknTransEffect::EApplicationStartSwitch:
  3738                     case AknTransEffect::EApplicationStartSwitch:
  3866                     case AknTransEffect::EApplicationStartSwitchRect:
  3739                     case AknTransEffect::EApplicationStartSwitchRect:
  3867                         {
  3740                         {
  3868                         aToLayout->iOpacity.Set(0.0f);    // this is meant for applications that are in the background.
  3741                         aToLayout->iOpacity.Set(0.0f);    // this is meant for applications that are in the background.
  3869                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  3742                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
       
  3743                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  3870                         break;
  3744                         break;
  3871                         }
  3745                         }
  3872 
  3746 
  3873                     case AknTransEffect::EApplicationExit:
  3747                     case AknTransEffect::EApplicationExit:
  3874                         {
  3748                         {
       
  3749                         aEvent.iEffectType = CFullScreenEffectState::EExitEffect;
  3875                         // The effect should start when the new view is ready,
  3750                         // The effect should start when the new view is ready,
  3876                         // but we have no signal telling us that, so we just have to do our best
  3751                         // but we have no signal telling us that, so we just have to do our best
  3877 
  3752 
  3878                         // Effect end observer is given to engine in LoadEffectL
  3753                         // Effect end observer is given to engine in LoadEffectL
  3879                         // It will be set to effect there and called when the effect ends or is deleted
  3754                         // It will be set to effect there and called when the effect ends or is deleted
  3885                             // effect on a layout must be an application start effect. 
  3760                             // effect on a layout must be an application start effect. 
  3886                             // External content visual is not used for that.
  3761                             // External content visual is not used for that.
  3887                             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Found effect on layout 0x%x. Removing effect 0x%x", aToLayout, aToLayout->Effect());
  3762                             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Found effect on layout 0x%x. Removing effect 0x%x", aToLayout, aToLayout->Effect());
  3888                             aToLayout->SetEffect(NULL);
  3763                             aToLayout->SetEffect(NULL);
  3889                             }
  3764                             }
  3890                         if (!(aToLayout->Flags() & EHuiVisualFlagInactive))
  3765                         if ( aEvent.iAction == AknTransEffect::EApplicationExit && !(aToLayout->Flags() & EHuiVisualFlagInactive)) 
  3891                             {
  3766                             {
  3892                             // this will tag the visual, that they cannot be hidden by HandleVisualVisibility
  3767                             // this will tag the visual, that they cannot be hidden by HandleVisualVisibility
  3893                             // Initialize layout for the exit effect  
  3768                             // Initialize layout for the exit effect  
  3894                             iLayoutInitializedForExitEffect = SetupEffectLayoutContainerL(aEvent.iHandle, aToLayout, ETrue);
  3769                             iLayoutInitializedForExitEffect = SetupEffectLayoutContainerL(aEvent.iHandle, aToLayout, ETrue);
       
  3770                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - EBeginFullscreen - iLayoutInitializedForExitEffect: %d", iLayoutInitializedForExitEffect);
  3895                             aEvent.iSetupDone = iLayoutInitializedForExitEffect; 
  3771                             aEvent.iSetupDone = iLayoutInitializedForExitEffect; 
  3896                             }
  3772                             }
  3897                         else
  3773                         else
  3898                             {
  3774                             {
  3899                             iLayoutInitializedForExitEffect = EFalse;
  3775                             iLayoutInitializedForExitEffect = EFalse;
       
  3776                             aEvent.iSetupDone = EFalse;
  3900                             }
  3777                             }
  3901                          return failed;
  3778                          return failed;
  3902                          }
  3779                          }
  3903                     default:
  3780                     default:
  3904                         break;
  3781                         break;
  3911                 if (aEvent.iAction != 5000)
  3788                 if (aEvent.iAction != 5000)
  3912                     {
  3789                     {
  3913                     if ( aEvent.iAction != AknTransEffect::EApplicationExit && aToLayout->Flags() & EHuiVisualFlagInactive)
  3790                     if ( aEvent.iAction != AknTransEffect::EApplicationExit && aToLayout->Flags() & EHuiVisualFlagInactive)
  3914                         {
  3791                         {
  3915                         aToLayout->iOpacity.Set(1.0f);
  3792                         aToLayout->iOpacity.Set(1.0f);
  3916                         failed = ETrue;
       
  3917                         return failed;
       
  3918                         }
  3793                         }
  3919                         
  3794                         
  3920                     if (aToLayout)
  3795                     if (aToLayout)
  3921                         {
  3796                         {
  3922                         aToLayout->iOpacity.Set(1.0f);
  3797                         aToLayout->iOpacity.Set(1.0f);
  3923                         __ALFFXLOGSTRING1("HandleGfxEventL - loading effect, handle %d", aEvent.iHandle );
  3798                         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - loading effect, handle %d", aEvent.iHandle );
  3924                         if (aEvent.iAction == AknTransEffect::EApplicationExit)
  3799                         if (aEvent.iAction == AknTransEffect::EApplicationExit)
  3925                             {
  3800                             {
  3926                         	// Exit effect was initialized earlier with EBeginFullscreen event
  3801                             // Exit effect was initialized earlier with EBeginFullscreen event
  3927 						    layoutEffectable = iLayoutInitializedForExitEffect;
  3802 						    layoutEffectable = aEvent.iSetupDone;
       
  3803 						    __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - EEndFullScreen: %d", layoutEffectable);
  3928                             }
  3804                             }
  3929                         else
  3805                         else
  3930                         	{
  3806                         	{
  3931                             // add visuals to visual cleanupstack
  3807                             // add visuals to visual cleanupstack
  3932                             aToLayout->SetStoredRenderBufferModificationsEnabled(EFalse);
  3808                             aToLayout->SetStoredRenderBufferModificationsEnabled(EFalse);
  3934                             aEvent.iSetupDone = layoutEffectable; 
  3810                             aEvent.iSetupDone = layoutEffectable; 
  3935                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  3811                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  3936                             }
  3812                             }
  3937 
  3813 
  3938                         if (layoutEffectable)
  3814                         if (layoutEffectable)
  3939                             {
  3815                             {                        
       
  3816                             TInt effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
       
  3817                             if (NeedsStoredBuffers(iHuiEnv->EffectsEngine(), *aEvent.iEffectName))
       
  3818                                 {
       
  3819                                 // Performance improvement, but this would be better to be a special hint param in the fxml
       
  3820                                 effectFlags |= KHuiFxOpaqueHint;
       
  3821                                 }
       
  3822                             
  3940                             if (aEvent.iRect != TRect())
  3823                             if (aEvent.iRect != TRect())
  3941                                 {
  3824                                 {
  3942                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), &aEvent.iRect, this, aEvent.iHandle ) );
  3825                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), &aEvent.iRect, this, aEvent.iHandle, effectFlags ));
  3943                                 }
  3826                                 }
  3944                             else
  3827                             else
  3945                                 {
  3828                                 {
  3946                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle ) );
  3829                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle, effectFlags ) );
  3947                                 }
  3830                                 }
  3948                             effect = NULL;
  3831                             effect = NULL;
  3949                             // only use the effect if the effect file was correctly parsed
  3832                             // only use the effect if the effect file was correctly parsed
  3950                             if (err != KErrNone)
  3833                             if (err != KErrNone)
  3951                                 {
  3834                                 {
  3978 void CAlfBridge::FreezeLayoutUntilEffectDestroyedL(CHuiLayout* aLayout, TInt aHandle)
  3861 void CAlfBridge::FreezeLayoutUntilEffectDestroyedL(CHuiLayout* aLayout, TInt aHandle)
  3979     {
  3862     {
  3980     if (aLayout)
  3863     if (aLayout)
  3981         {
  3864         {
  3982 		TRAPD(err, StoreRenderBufferStartL(aLayout));
  3865 		TRAPD(err, StoreRenderBufferStartL(aLayout));
       
  3866 		__ALFFXLOGSTRING2("CAlfBridge::FreezeLayoutUntilEffectDestroyed - StoreRenderBufferStartL call returned: %d for layout 0x%x", err, aLayout);
  3983 		if (err == KErrNone)
  3867 		if (err == KErrNone)
  3984 			{
  3868 			{
  3985             // Freeze only, if buffer was reserved succesfully 
  3869             // Freeze only, if buffer was reserved succesfully 
  3986             aLayout->SetFreezeState(ETrue);
  3870             aLayout->SetFreezeState(ETrue);
  3987         	TBool itemsDestroyed;
  3871         	TBool itemsDestroyed;
  4051             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - layout visual: 0x%x ; handle: %d ", layout, handle);
  3935             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - layout visual: 0x%x ; handle: %d ", layout, handle);
  4052             RemoveTemporaryPresenterVisual(NULL, handle);
  3936             RemoveTemporaryPresenterVisual(NULL, handle);
  4053             }
  3937             }
  4054         layout->iOpacity.Set(1.0f); 
  3938         layout->iOpacity.Set(1.0f); 
  4055         }
  3939         }
  4056     }
       
  4057 
       
  4058 CAlfBridge::CEffectState::CEffectState()
       
  4059     {
       
  4060     // CBase clears all variables
       
  4061     }
       
  4062 
       
  4063 CAlfBridge::CEffectState::~CEffectState()
       
  4064     {
       
  4065     delete iEffectName;
       
  4066     }
       
  4067 
       
  4068 void CAlfBridge::CEffectState::ResolveFileNameL(RMemReadStream& aStream)
       
  4069     {
       
  4070     HBufC* effectDirectory = HBufC::NewLC(aStream, 256);
       
  4071     HBufC* effectFile = HBufC::NewLC(aStream, 256);
       
  4072 
       
  4073     // Add one extra because we want to be able to append a number to the filename
       
  4074     HBufC* effectFullName = HBufC::NewL(effectDirectory->Des().Length()
       
  4075             + effectFile->Des().Length() + 1);
       
  4076     CleanupStack::PushL(effectFullName);
       
  4077 
       
  4078     effectFullName->Des().Copy(*(effectDirectory));
       
  4079     effectFullName->Des().Append(*(effectFile));
       
  4080     delete iEffectName;
       
  4081     iEffectName = effectFullName; // ownership transferred
       
  4082     CleanupStack::Pop(effectFullName);
       
  4083     CleanupStack::PopAndDestroy(2, effectDirectory);
       
  4084     }
       
  4085 
       
  4086 void CAlfBridge::CFullScreenEffectState::ConstructL(
       
  4087         TInt aAction,
       
  4088         RMemReadStream& aStream)
       
  4089     {
       
  4090     iAction = aAction;
       
  4091 
       
  4092     iHandle = aStream.ReadInt32L();
       
  4093 
       
  4094     iType = aStream.ReadInt32L();
       
  4095     iWg1 = aStream.ReadInt32L();
       
  4096     iWg2 = aStream.ReadInt32L();
       
  4097     iToAppId = aStream.ReadInt32L();
       
  4098     iFromAppId = aStream.ReadInt32L();
       
  4099 
       
  4100     if (iType == AknTransEffect::EParameterType)
       
  4101         {
       
  4102         /*screen1 =*/aStream.ReadInt32L();
       
  4103         /*screen2 =*/aStream.ReadInt32L();
       
  4104         }
       
  4105     /*TInt flags =*/
       
  4106     aStream.ReadInt32L();
       
  4107     iRect.iTl.iX = aStream.ReadInt32L();
       
  4108     iRect.iTl.iY = aStream.ReadInt32L();
       
  4109     iRect.iBr.iX = aStream.ReadInt32L();
       
  4110     iRect.iBr.iY = aStream.ReadInt32L();
       
  4111 
       
  4112     ResolveFileNameL(aStream);
       
  4113 
       
  4114     iCompletionHandle = iHandle;
       
  4115     }
       
  4116 
       
  4117 void CAlfBridge::CControlEffectState::ConstructL(TInt aAction,
       
  4118         RMemReadStream& aStream)
       
  4119     {
       
  4120     iAction = aAction;
       
  4121     TInt operation = aStream.ReadInt32L();
       
  4122     iHandle = aStream.ReadInt32L();
       
  4123     iClientHandle = aStream.ReadInt32L();
       
  4124     iClientGroupHandle = aStream.ReadInt32L();
       
  4125     TInt screenNumber = aStream.ReadInt32L(); // this has always value 0 
       
  4126     // Are Symbian full filename+directory combinations still max 256 characters long?
       
  4127     ResolveFileNameL(aStream);
       
  4128     }
  3940     }
  4129 
  3941 
  4130 // ---------------------------------------------------------------------------
  3942 // ---------------------------------------------------------------------------
  4131 // HandleGfxEffectsL
  3943 // HandleGfxEffectsL
  4132 // ---------------------------------------------------------------------------
  3944 // ---------------------------------------------------------------------------
  4219             return;
  4031             return;
  4220             }
  4032             }
  4221 
  4033 
  4222         __ALFFXLOGSTRING("HandleGfxEffectsL - process end");
  4034         __ALFFXLOGSTRING("HandleGfxEffectsL - process end");
  4223         iFullScreenEffectData->iEndFullScreen = ETrue;
  4035         iFullScreenEffectData->iEndFullScreen = ETrue;
       
  4036 
       
  4037 #ifdef USE_APPLICATION_ENDFULLSCREEN_TIMEOUT		
       
  4038         if (iFullScreenEffectData->iDrawingCompleteTimer)
       
  4039             {
       
  4040             iFullScreenEffectData->iDrawingCompleteTimer->Cancel();
       
  4041             }
       
  4042 #endif			
  4224         }
  4043         }
  4225 
  4044 
  4226     CFullScreenEffectState* fxData = iFullScreenEffectData;
  4045     CFullScreenEffectState* fxData = iFullScreenEffectData;
  4227     fxData->iOperation = operation;
  4046     fxData->iOperation = operation;
  4228     fxData->iWaitingWindowGroup = EFalse;
  4047     fxData->iWaitingWindowGroup = EFalse;
  4422         TBool aIsExitEffect)
  4241         TBool aIsExitEffect)
  4423     {
  4242     {
  4424     CHuiCanvasVisual* temporaryPresenterVisual = NULL;
  4243     CHuiCanvasVisual* temporaryPresenterVisual = NULL;
  4425     TInt enableEffect = ETrue;
  4244     TInt enableEffect = ETrue;
  4426     
  4245     
       
  4246     if (aSourceVisual->iOpacity.Now() >= 0.01)
       
  4247         {
       
  4248         aSourceVisual->SetFlag(EHuiVisualFlagShouldBeShown);
       
  4249         }
       
  4250     
  4427     aSourceVisual->ClearFlags(EHuiVisualFlagShouldBeInactive | EHuiVisualFlagShouldBeUnderOpaqueHint);
  4251     aSourceVisual->ClearFlags(EHuiVisualFlagShouldBeInactive | EHuiVisualFlagShouldBeUnderOpaqueHint);
  4428     if (aIsExitEffect) 
  4252     if (aIsExitEffect) 
  4429         {
  4253         {
  4430         aSourceVisual->SetFlag(EHuiVisualFlagAlwaysDraw);   // forces drawing during exit effect. handlevisualvisibility will set the EShouldbeInactive flag, if visual is determined inactive while this flag is set 
  4254         aSourceVisual->SetFlag(EHuiVisualFlagAlwaysDraw);   // forces drawing during exit effect. handlevisualvisibility will set the EShouldbeInactive flag, if visual is determined inactive while this flag is set 
  4431         }
  4255         }
  4461             TEffectCleanupStruct item = TEffectCleanupStruct(
  4285             TEffectCleanupStruct item = TEffectCleanupStruct(
  4462                     aEffectHandle,
  4286                     aEffectHandle,
  4463                     aSourceVisual, 
  4287                     aSourceVisual, 
  4464                     temporaryPresenterVisual,
  4288                     temporaryPresenterVisual,
  4465                     ETrue,
  4289                     ETrue,
  4466                     EFalse);
  4290                     aIsExitEffect);
  4467             iEffectCleanupStack.AppendL(item);
  4291             iEffectCleanupStack.AppendL(item);
  4468             }
  4292             }
  4469         else
  4293         else
  4470             {
  4294             {
  4471             // this will be a child of another visual, and draw by its parent external content visual
  4295             // this will be a child of another visual, and draw by its parent external content visual
  4472             // aSourceVisual->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  4296             // aSourceVisual->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  4473             TEffectCleanupStruct item = TEffectCleanupStruct(aEffectHandle,
  4297             TEffectCleanupStruct item = TEffectCleanupStruct(aEffectHandle,
  4474                         aSourceVisual, NULL, EFalse,
  4298                         aSourceVisual, NULL, EFalse,
  4475                         EFalse);
  4299                         aIsExitEffect);
  4476             iEffectCleanupStack.AppendL(item);
  4300             iEffectCleanupStack.AppendL(item);
  4477             }
  4301             }
  4478      }
  4302      }
  4479     return temporaryPresenterVisual;
  4303     return temporaryPresenterVisual;
  4480     }
  4304     }
  4508     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
  4332     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
  4509     }
  4333     }
  4510 
  4334 
  4511 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect)
  4335 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect)
  4512     {
  4336     {
       
  4337     __ALFFXLOGSTRING3("CAlfBridge::SetupEffectLayoutContainerL - aHandle: %d, aSourceLayout: 0x%x, aIsExitEffect: % d >>", aHandle, aSourceLayout, aIsExitEffect );
       
  4338     
  4513     if (aSourceLayout->Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)
  4339     if (aSourceLayout->Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)
  4514         {
  4340         {
  4515         // the requested visual is already having an effect. 
  4341         // the requested visual is already having an effect. 
  4516         __ALFFXLOGSTRING("CAlfBridge::SetupEffectLayoutContainerL - WE ARE ALREADY HAVING EFFECT! WHAT TO DO??");
  4342         __ALFFXLOGSTRING("CAlfBridge::SetupEffectLayoutContainerL - WE ARE ALREADY HAVING EFFECT! WHAT TO DO??");
  4517         // layout is having already effect. this is tricky. This might be place to panic. Resolve later. 
  4343         // layout is having already effect. this is tricky. This might be place to panic. Resolve later. 
  4531         aSourceLayout->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  4357         aSourceLayout->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  4532         __ALFFXLOGSTRING3("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout)-> 0x%x (presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout, temporaryPresenterVisual);
  4358         __ALFFXLOGSTRING3("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout)-> 0x%x (presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout, temporaryPresenterVisual);
  4533         }
  4359         }
  4534     else
  4360     else
  4535         {
  4361         {
  4536         AddEffectItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, ETrue, itemsDestroyed, EFalse);
  4362         AddEffectItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, EFalse, itemsDestroyed, EFalse);
  4537         __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout), NO presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout);
  4363         __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout), NO presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout);
  4538         }
  4364         }
  4539     iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue;
  4365     iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue;
  4540     iAlfScreens[0]->iDisplay->SetDirty();
  4366     iAlfScreens[0]->iDisplay->SetDirty();
  4541     if (itemsDestroyed)
  4367     if (itemsDestroyed)
  4571     __ALFFXLOGSTRING3("CAlfBridge::SetupEffectContainerL - adding handle: %d, 0x%x (source visual)-> 0x%x (presenter visual)", aHandle, aSourceVisual, temporaryPresenterVisual);
  4397     __ALFFXLOGSTRING3("CAlfBridge::SetupEffectContainerL - adding handle: %d, 0x%x (source visual)-> 0x%x (presenter visual)", aHandle, aSourceVisual, temporaryPresenterVisual);
  4572     }
  4398     }
  4573 
  4399 
  4574 void CAlfBridge::HandleGfxControlEffectsL( TAlfBridgerData data )
  4400 void CAlfBridge::HandleGfxControlEffectsL( TAlfBridgerData data )
  4575     {
  4401     {
  4576     TInt err = KErrNone;
       
  4577     TInt action = data.iInt1;
  4402     TInt action = data.iInt1;
  4578     TInt length = data.iInt2;
  4403     TInt length = data.iInt2;
  4579     __ALFFXLOGSTRING1("HandleGfxControlEffectsL - Reading bridge data %d", (TInt)data.iPtr);
  4404     __ALFFXLOGSTRING1("HandleGfxControlEffectsL - Reading bridge data %d", (TInt)data.iPtr);
  4580     void* bridgeBuffer = (void*) (*iHost)->GetEffectsDataL((TInt) data.iPtr);
  4405     void* bridgeBuffer = (void*) (*iHost)->GetEffectsDataL((TInt) data.iPtr);
  4581     RMemReadStream stream(bridgeBuffer, length);
  4406     RMemReadStream stream(bridgeBuffer, length);
  4610                 iControlEffectData->iClientHandle, 
  4435                 iControlEffectData->iClientHandle, 
  4611                 iControlEffectData->iClientGroupHandle);
  4436                 iControlEffectData->iClientGroupHandle);
  4612         return;
  4437         return;
  4613         }
  4438         }
  4614     iAlfScreens[0]->iDisplay->SetDirty();
  4439     iAlfScreens[0]->iDisplay->SetDirty();
  4615 
       
  4616     iHuiEnv->ContinueRefresh();
  4440     iHuiEnv->ContinueRefresh();
  4617 
       
  4618     if (visual && err != KErrNone)
       
  4619         {
       
  4620         // if the effect loading failed too soon, we must call our callback ourselves
       
  4621         //        RDebug::Print(_L("HandleGfxControlEffectsL - effect not set - going directly to callback"));
       
  4622         AlfGfxEffectEndCallBack(fxData->iHandle);
       
  4623         }
       
  4624 
  4441 
  4625     delete iControlEffectData;
  4442     delete iControlEffectData;
  4626     iControlEffectData = NULL;
  4443     iControlEffectData = NULL;
  4627 
  4444 
  4628     __ALFFXLOGSTRING("HandleGfxControlEffectsL - end");
  4445     __ALFFXLOGSTRING("HandleGfxControlEffectsL - end");
  4673             {
  4490             {
  4674             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse);
  4491             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse);
  4675             }
  4492             }
  4676         if (layoutEffectable)
  4493         if (layoutEffectable)
  4677             {
  4494             {
  4678             TRAP( err, engine->LoadGroupEffectL(*aEvent.iEffectName, effect, aCanvasVisual->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle ) );
  4495             TRAP( err, engine->LoadGroupEffectL(*aEvent.iEffectName, effect, aCanvasVisual->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle, KHuiFxDelayRunUntilFirstFrameHasBeenDrawn ) );
  4679             }
  4496             }
  4680         else
  4497         else
  4681             {
  4498             {
  4682             err = KErrNotFound;
  4499             err = KErrNotFound;
  4683             }
  4500             }
  4729         {
  4546         {
  4730         // this was exit effect, and window was not really destroyed.
  4547         // this was exit effect, and window was not really destroyed.
  4731         sourceViz->iOpacity.Set(0.0f);
  4548         sourceViz->iOpacity.Set(0.0f);
  4732         sourceViz->ClearFlag(EHuiVisualFlagShouldBeHidden); // it is now hidden
  4549         sourceViz->ClearFlag(EHuiVisualFlagShouldBeHidden); // it is now hidden
  4733         }
  4550         }
  4734 	else
  4551 	
  4735 		{
       
  4736         // visual may be transparent after manipulation of the effect
       
  4737 	   	sourceViz->iOpacity.Set(KAlfVisualDefaultOpacity); 
       
  4738 		}
       
  4739     if (showVisual)
  4552     if (showVisual)
  4740         {
  4553         {
  4741         sourceViz->iOpacity.Set(KAlfVisualDefaultOpacity);
  4554         sourceViz->iOpacity.Set(KAlfVisualDefaultOpacity);
  4742         sourceViz->ClearFlag(EHuiVisualFlagShouldBeShown); // it is now hidden
  4555         sourceViz->ClearFlag(EHuiVisualFlagShouldBeShown); // it is now hidden
  4743         }
  4556         }
  4873     return NULL;
  4686     return NULL;
  4874     }
  4687     }
  4875 
  4688 
  4876 TBool CAlfBridge::HasActiveEffect(CHuiVisual* aVisual)
  4689 TBool CAlfBridge::HasActiveEffect(CHuiVisual* aVisual)
  4877     {
  4690     {
       
  4691     TInt dummy;
       
  4692     return HasActiveEffect(aVisual, dummy);
       
  4693     }
       
  4694 
       
  4695 TBool CAlfBridge::HasActiveEffect(CHuiVisual* aVisual, TInt& aIndex)
       
  4696     {
       
  4697     aIndex = KErrNotFound;
  4878     for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  4698     for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  4879         {
  4699         {
  4880         if (aVisual == iEffectCleanupStack[i].iEffectedVisual)
  4700         if (aVisual == iEffectCleanupStack[i].iEffectedVisual)
  4881             {
  4701             {
       
  4702             aIndex = i;
  4882             return ETrue;
  4703             return ETrue;
  4883             }
  4704             }
  4884         }
  4705         }
  4885     return EFalse;
  4706     return EFalse;
  4886     }
  4707     }
  4933                 {
  4754                 {
  4934                 if (RemoveTemporaryPresenterItem(effectItem))
  4755                 if (RemoveTemporaryPresenterItem(effectItem))
  4935                     {
  4756                     {
  4936                     itemsRemoved++;
  4757                     itemsRemoved++;
  4937                     }
  4758                     }
  4938                 iEffectCleanupStack.Remove(i);
  4759                 if (iEffectCleanupStack.Count() > i)
       
  4760                     {
       
  4761                     iEffectCleanupStack.Remove(i);
       
  4762                     }
  4939                 iFinishedCleanupStackEffects.Remove(0);
  4763                 iFinishedCleanupStackEffects.Remove(0);
  4940                 i--;
  4764                 i--;
  4941                 }
  4765                 }
  4942             }
  4766             }
  4943         }
  4767         }
  4968 
  4792 
  4969 void CAlfBridge::AlfGfxEffectEndCallBack(TInt aHandle)
  4793 void CAlfBridge::AlfGfxEffectEndCallBack(TInt aHandle)
  4970     {
  4794     {
  4971     // We need a delay to prevent the refresh from being messed up
  4795     // We need a delay to prevent the refresh from being messed up
  4972     // We try a short delay before clearing everything up.
  4796     // We try a short delay before clearing everything up.
  4973     __ALFFXLOGSTRING1("AlfGfxEffectEndCallBack, append handle %d", aHandle );
  4797     __ALFFXLOGSTRING1("AlfGfxEffectEndCallBack, handle %d", aHandle );
  4974     //    RDebug::Print(_L("AlfGfxEffectEndCallBack, append handle %d"), aHandle );
  4798     //    RDebug::Print(_L("AlfGfxEffectEndCallBack, append handle %d"), aHandle );
  4975     // If the handle cannot be appended, the function returns an error.
  4799     // If the handle cannot be appended, the function returns an error.
  4976     // However, if the memory is low, there is nothing we can do about it.
  4800     // However, if the memory is low, there is nothing we can do about it.
  4977     // We try to handle the transition finish anyway.
  4801     // We try to handle the transition finish anyway.
  4978     // If there are already other handles in the queue, the handler will not
  4802     // If there are already other handles in the queue, the handler will not
  4979     // be called for this handle, but all handles that have been left hanging
  4803     // be called for this handle, but all handles that have been left hanging
  4980     // around will be cleared when HandleGfxStopEffectsL is called
  4804     // around will be cleared when HandleGfxStopEffectsL is called
  4981   
  4805 
  4982     
       
  4983     iFinishedEffects.Append(aHandle);
       
  4984     	
       
  4985     // iFinishedCleanupStackEffects.Append(aHandle);
  4806     // iFinishedCleanupStackEffects.Append(aHandle);
  4986     if (!iEffectEndTimer->IsActive())
  4807     if (!iEffectEndTimer->IsActive())
  4987         {
  4808         {
  4988         iEffectEndTimer->Start( 10000, aHandle );
  4809         iEffectEndTimer->Start( 10000, aHandle );
  4989         }
  4810         }
  5070             {
  4891             {
  5071             if (aRoster.ControlGroup(i).ResourceId() == iAlfWindowGroupNodeId)
  4892             if (aRoster.ControlGroup(i).ResourceId() == iAlfWindowGroupNodeId)
  5072                 {
  4893                 {
  5073 #ifdef  HUI_DEBUG_TRACK_DRAWING
  4894 #ifdef  HUI_DEBUG_TRACK_DRAWING
  5074                 __ALFLOGSTRING2(">> %d WINDOW GROUP (ALF), %d", i, clientWindowGroupId);                                    
  4895                 __ALFLOGSTRING2(">> %d WINDOW GROUP (ALF), %d", i, clientWindowGroupId);                                    
       
  4896 #else
       
  4897                 __ALFLOGSTRING1(">> %d WINDOW GROUP (ALF)", i);                                                    
  5075 #endif         
  4898 #endif         
  5076                 }
  4899                 }
  5077             else
  4900             else
  5078                 {
  4901                 {
  5079 #ifdef  HUI_DEBUG_TRACK_DRAWING
  4902 #ifdef  HUI_DEBUG_TRACK_DRAWING
  5085             }
  4908             }
  5086         else if (indexedGroup.Control(0).Role() == EAlfSessionContainer)
  4909         else if (indexedGroup.Control(0).Role() == EAlfSessionContainer)
  5087             {
  4910             {
  5088 #ifdef  HUI_DEBUG_TRACK_DRAWING
  4911 #ifdef  HUI_DEBUG_TRACK_DRAWING
  5089             __ALFLOGSTRING2(">> %d ALF GROUP, %d", i, clientWindowGroupId);                        
  4912             __ALFLOGSTRING2(">> %d ALF GROUP, %d", i, clientWindowGroupId);                        
       
  4913 #else
       
  4914             __ALFLOGSTRING1(">> %d ALF GROUP", i);                                    
  5090 #endif
  4915 #endif
  5091             }
  4916             }
  5092         else if (indexedGroup.Control(0).Role() == EAlfWindowFloatingSpriteContainer)
  4917         else if (indexedGroup.Control(0).Role() == EAlfWindowFloatingSpriteContainer)
  5093             {
  4918             {
  5094 #ifdef  HUI_DEBUG_TRACK_DRAWING			
  4919 #ifdef  HUI_DEBUG_TRACK_DRAWING			
  5103             __ALFLOGSTRING3(">> %d EFFECT GROUP %S, %d", i, &processName, clientWindowGroupId );                                                                
  4928             __ALFLOGSTRING3(">> %d EFFECT GROUP %S, %d", i, &processName, clientWindowGroupId );                                                                
  5104 #else
  4929 #else
  5105             __ALFLOGSTRING1(">> %d EFFECT GROUP", i);                                                                
  4930             __ALFLOGSTRING1(">> %d EFFECT GROUP", i);                                                                
  5106 #endif
  4931 #endif
  5107             }
  4932             }
       
  4933         else if (indexedGroup.Control(0).Role() == EAlfFpsIndicatorContainer)
       
  4934             {
       
  4935 #ifdef  HUI_DEBUG_TRACK_DRAWING
       
  4936             __ALFLOGSTRING3(">> %d FPS GROUP %S, %d", i, &processName, clientWindowGroupId );                                                                
       
  4937 #else
       
  4938             __ALFLOGSTRING1(">> %d FPS GROUP", i);                                                                
       
  4939 #endif
       
  4940             }
  5108         else 
  4941         else 
  5109             {
  4942             {
  5110 #ifdef  HUI_DEBUG_TRACK_DRAWING
  4943 #ifdef  HUI_DEBUG_TRACK_DRAWING
  5111             __ALFLOGSTRING3(">> %d UNKNOWN GROUP ?!!? %S, %d", i, &processName, clientWindowGroupId );
  4944             __ALFLOGSTRING3(">> %d UNKNOWN GROUP ?!!? %S, %d", i, &processName, clientWindowGroupId );
       
  4945 #else
       
  4946             __ALFLOGSTRING1(">> %d UNKNOWN GROUP ?!!?", i);                                                                            
  5112 #endif
  4947 #endif
  5113             }                                                
  4948             }                                                
  5114 
  4949 
  5115         if (&indexedGroup == &aGroup)
  4950         if (&indexedGroup == &aGroup)
  5116             {
  4951             {
  5144     {
  4979     {
  5145     }
  4980     }
  5146 #endif        
  4981 #endif        
  5147 
  4982 
  5148 #ifdef ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
  4983 #ifdef ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
  5149 void CAlfBridge::VisualizeControlGroupOrderL(CHuiRoster& aRoster, CHuiControlGroup& /*aGroup*/)
  4984 void CAlfBridge::VisualizeControlGroupOrderL(CAlfScreen& aScreen, CHuiRoster& aRoster, CHuiControlGroup& /*aGroup*/)
  5150     {       
  4985     {       
  5151     TInt nbrofcolums = 3;
  4986     TInt nbrofcolums = 3;
  5152     TInt nbrofrows = 3;
  4987     TInt nbrofrows = 3;
  5153     TInt gridIndex = 0;
  4988     TInt gridIndex = 0;
  5154     TBool skipEmpty = EFalse;
  4989     TBool skipEmpty = EFalse;
  5155     if (aRoster.Count() > 3)
  4990     TInt skipCount = aScreen.FixedControlGroupCount() + 1;
  5156         {
  4991     if (aRoster.Count() > skipCount)
  5157         for (TInt i=aRoster.Count() - 3; i>0; i--)
  4992         {
       
  4993         for (TInt i=aRoster.Count() - skipCount; i>0; i--)
  5158             {
  4994             {
  5159             CHuiControl& control = aRoster.ControlGroup(i).Control(0);
  4995             CHuiControl& control = aRoster.ControlGroup(i).Control(0);
  5160             if (skipEmpty)
  4996             if (skipEmpty)
  5161                 {                        
  4997                 {                        
  5162                 TBool empty = ETrue;
  4998                 TBool empty = ETrue;
  5185             }                        
  5021             }                        
  5186         }
  5022         }
  5187     iAlfScreens[0]->iDisplay->SetClearBackgroundL(CHuiDisplay::EClearWithSkinBackground);            
  5023     iAlfScreens[0]->iDisplay->SetClearBackgroundL(CHuiDisplay::EClearWithSkinBackground);            
  5188     }
  5024     }
  5189 #else
  5025 #else
  5190 void CAlfBridge::VisualizeControlGroupOrderL(CHuiRoster& /*aRoster*/, CHuiControlGroup& /*aGroup*/)
  5026 void CAlfBridge::VisualizeControlGroupOrderL(CAlfScreen& /*aScreen*/, CHuiRoster& /*aRoster*/, CHuiControlGroup& /*aGroup*/)
  5191     {       
  5027     {       
  5192     }
  5028     }
  5193 #endif    
  5029 #endif    
  5194 
  5030 
  5195 // ---------------------------------------------------------------------------
  5031 // ---------------------------------------------------------------------------
  5342             CHuiTexture* texture = CHuiTexture::NewL();
  5178             CHuiTexture* texture = CHuiTexture::NewL();
  5343             CleanupStack::PushL(texture);
  5179             CleanupStack::PushL(texture);
  5344             iAlfScreens[i]->iDisplay->SetForegroundBitmapL( iAlfScreens[i]->iSwRenderingTarget );
  5180             iAlfScreens[i]->iDisplay->SetForegroundBitmapL( iAlfScreens[i]->iSwRenderingTarget );
  5345             CleanupStack::Pop(texture);
  5181             CleanupStack::Pop(texture);
  5346             iAlfScreens[i]->iDisplay->SetForegroundTexture(texture);
  5182             iAlfScreens[i]->iDisplay->SetForegroundTexture(texture);
  5347             iAlfScreens[i]->iDisplay->iRosterObservers.AppendL(*this);
       
  5348             }
  5183             }
  5349         else
  5184         else
  5350             {
  5185             {
  5351             iAlfScreens[i]->iDisplay->SetForegroundBitmapL(NULL);            
  5186             iAlfScreens[i]->iDisplay->SetForegroundBitmapL(NULL);            
  5352             iAlfScreens[i]->iDisplay->SetForegroundTexture(NULL);
  5187             iAlfScreens[i]->iDisplay->SetForegroundTexture(NULL);
  5353             iAlfScreens[i]->iDisplay->iRosterObservers.Remove(*this);            
       
  5354             }
  5188             }
  5355             
  5189             
  5356         // SetCapturingBufferL is called from HandleVisualVisibility.
  5190         // SetCapturingBufferL is called from HandleVisualVisibility.
  5357         iAlfScreens[i]->SetVisualTreeVisibilityChanged(ETrue);
  5191         iAlfScreens[i]->SetVisualTreeVisibilityChanged(ETrue);
  5358         }
       
  5359     }
       
  5360 
       
  5361 // ---------------------------------------------------------------------------
       
  5362 // ---------------------------------------------------------------------------
       
  5363 // 
       
  5364 void CAlfBridge::UploadSwRenderingTargetL(CAlfScreen* aScreen)
       
  5365     {
       
  5366     if (iSwRenderingEnabled)
       
  5367         {
       
  5368         CHuiTexture* texture = aScreen->iDisplay->ForegroundTexture();                        
       
  5369         if (texture && aScreen->iSwRenderingTarget)
       
  5370             {
       
  5371             texture->UploadL(*aScreen->iSwRenderingTarget, NULL);                
       
  5372             }           
       
  5373         }
  5192         }
  5374     }
  5193     }
  5375 
  5194 
  5376 // ---------------------------------------------------------------------------
  5195 // ---------------------------------------------------------------------------
  5377 // ---------------------------------------------------------------------------
  5196 // ---------------------------------------------------------------------------
  5387             {
  5206             {
  5388             // screen owns this bitmap
  5207             // screen owns this bitmap
  5389             aScreen->iSwRenderingTarget = new CFbsBitmap;
  5208             aScreen->iSwRenderingTarget = new CFbsBitmap;
  5390             if (aScreen->iSwRenderingTarget)
  5209             if (aScreen->iSwRenderingTarget)
  5391                 {
  5210                 {
  5392                 aScreen->iSwRenderingTarget->Create(aScreen->Size(), EColor16MA);
  5211                 aScreen->iSwRenderingTarget->Create(aScreen->Size(), EColor16MAP); 
  5393                 modified = ETrue;
  5212                 modified = ETrue;
  5394                 }
  5213                 }
  5395             }
  5214             }
  5396         
  5215         
  5397         if (aScreen->iSwRenderingTarget)
  5216         if (aScreen->iSwRenderingTarget)
  5494 	}
  5313 	}
  5495 
  5314 
  5496 // ---------------------------------------------------------------------------
  5315 // ---------------------------------------------------------------------------
  5497 // ---------------------------------------------------------------------------
  5316 // ---------------------------------------------------------------------------
  5498 // 
  5317 // 
  5499 void CAlfBridge::NotifyRosterDrawStart(CHuiDisplay& /*aDisplay*/)
  5318 void CAlfBridge::Synchronized(TInt aId)
  5500     {
  5319     {
  5501     // Do nothing
  5320     // Use P&S for now.
  5502     }
  5321     RProperty::Set( KAlfPSUidSynchronizer, KAlfPSKeySynchronizer, aId );
  5503 
  5322     }
  5504 // ---------------------------------------------------------------------------
  5323 
  5505 // ---------------------------------------------------------------------------
  5324 void CAlfBridge::SetWindowGroupAsAlfApp(TInt aId)
  5506 // 
  5325     {
  5507 void CAlfBridge::NotifyRosterDrawEnd(CHuiDisplay& aDisplay)
  5326    TBool lBreak = EFalse;
  5508     {
  5327     
  5509     TInt screenNumber = ResolveScreenNumber(aDisplay);    
  5328     for ( TInt j = 0; j < iAlfScreens.Count(); j++ )
  5510     TRAP_IGNORE(UploadSwRenderingTargetL(iAlfScreens[screenNumber]));
  5329             {
       
  5330             for ( TInt i = 0; i < iAlfScreens[j]->iControlGroups.Count(); i++ )
       
  5331                 {
       
  5332                 if ( iAlfScreens[j]->iControlGroups[i].iClientWindowGroupId == aId )
       
  5333                     {
       
  5334                     iAlfScreens[j]->iControlGroups[i].iControlGroup->iAlfApp = ETrue;
       
  5335                     lBreak = ETrue;
       
  5336                     break;
       
  5337                     }
       
  5338                 }   
       
  5339             if ( lBreak )
       
  5340                break;
       
  5341             }
       
  5342             
       
  5343     }
       
  5344 
       
  5345 // ---------------------------------------------------------------------------
       
  5346 // ---------------------------------------------------------------------------
       
  5347 // 
       
  5348 TBool CAlfBridge::IsAlfOriginatedWindow(CHuiCanvasVisual& aVisual)
       
  5349     {
       
  5350     return (aVisual.Owner().ControlGroup()->ResourceId() == iAlfWindowGroupNodeId);
  5511     }
  5351     }
  5512 
  5352 
  5513 // end of file
  5353 // end of file