uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
branchRCL_3
changeset 7 433cbbb6a04b
parent 3 d8a3531bc6b8
child 8 10534483575f
equal deleted inserted replaced
3:d8a3531bc6b8 7:433cbbb6a04b
    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"
    72 
    71 #include "alfeffectutils.h"
    73 #include "alfrenderstageutils.h" // for KAlfPSUidSynchronizer & KAlfPSKeySynchronizer
    72 #include "alfrenderstageutils.h" // for KAlfPSUidSynchronizer & KAlfPSKeySynchronizer
    74 
    73 
    75 #ifdef HUI_DEBUG_TRACK_DRAWING
    74 #ifdef HUI_DEBUG_TRACK_DRAWING
    76 #include <alfcommanddebug.h>
    75 #include <alfcommanddebug.h>
    77 #endif
    76 #endif
    89 const TReal32 KAlfVisualDefaultOpacity = 1.0f;
    88 const TReal32 KAlfVisualDefaultOpacity = 1.0f;
    90 //const TReal32 KAlfVisualDefaultOpacity = 0.5f;
    89 //const TReal32 KAlfVisualDefaultOpacity = 0.5f;
    91 
    90 
    92 _LIT8(KAlfWindowGroupContainerControlTag, "WGROUP");
    91 _LIT8(KAlfWindowGroupContainerControlTag, "WGROUP");
    93 
    92 
    94 // This debug option prints window group order with __ALFLOGSTRING
    93 // #define USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
    95 //#define ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
       
    96 
       
    97 // This debug option shows window groups in a grid
    94 // This debug option shows window groups in a grid
    98 //#define ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
    95 //#define ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
    99 
    96 
   100 
    97 
   101 const TInt KFadeAction = 6000;
    98 const TInt KFadeAction = 6000;
   102 
       
   103 const TInt KRosterFreezeEndTimeoutInMs = 400;
       
   104 
       
   105 // Timer to send finish full screen effect
       
   106 // ---------------------------------------------------------
       
   107 // CAlfFinishTimer
       
   108 // ---------------------------------------------------------
       
   109 //
       
   110 NONSHARABLE_CLASS( CAlfRosterFreezeEndTimer ):public CTimer
       
   111     {
       
   112     public:  // Constructors and destructor
       
   113         static CAlfRosterFreezeEndTimer* NewL( CAlfBridge& aBridge );
       
   114         virtual ~CAlfRosterFreezeEndTimer();
       
   115 
       
   116     public: // New functions
       
   117         void Start( TTimeIntervalMicroSeconds32 aPeriod );
       
   118         
       
   119     protected:  // Functions from base classes
       
   120         void DoCancel();
       
   121 
       
   122     private:
       
   123         CAlfRosterFreezeEndTimer( CAlfBridge& aBridge );
       
   124         void ConstructL();
       
   125         void RunL();
       
   126       
       
   127     private:    // Data
       
   128         CAlfBridge& iBridge;
       
   129                 
       
   130     };
       
   131 
       
   132 
       
   133 // ---------------------------------------------------------
       
   134 // CAlfRosterFreezeEndTimer
       
   135 // ---------------------------------------------------------
       
   136 //
       
   137 CAlfRosterFreezeEndTimer::CAlfRosterFreezeEndTimer( CAlfBridge& aBridge )
       
   138     :CTimer ( EPriorityStandard ),
       
   139     iBridge( aBridge )
       
   140     {   
       
   141     }
       
   142 
       
   143 void CAlfRosterFreezeEndTimer::ConstructL()
       
   144     {
       
   145     CTimer::ConstructL();
       
   146     CActiveScheduler::Add( this );
       
   147     }
       
   148 
       
   149 CAlfRosterFreezeEndTimer* CAlfRosterFreezeEndTimer::NewL( CAlfBridge& aBridge )
       
   150     {
       
   151     CAlfRosterFreezeEndTimer* self = new ( ELeave ) CAlfRosterFreezeEndTimer( aBridge );
       
   152     CleanupStack::PushL( self );
       
   153     self->ConstructL();
       
   154     CleanupStack::Pop( self );
       
   155     return self;
       
   156     }
       
   157 
       
   158 CAlfRosterFreezeEndTimer::~CAlfRosterFreezeEndTimer()
       
   159     {
       
   160     Cancel();        
       
   161     }
       
   162 
       
   163 void CAlfRosterFreezeEndTimer::Start( TTimeIntervalMicroSeconds32 aPeriod )
       
   164     {
       
   165     if (!IsActive())
       
   166         {
       
   167         After( aPeriod );
       
   168         }
       
   169     }
       
   170 
       
   171 void CAlfRosterFreezeEndTimer::RunL()
       
   172     {
       
   173     iBridge.iHuiEnv->Display(0).SetDirty();
       
   174     TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
       
   175     iBridge.SetVisualTreeVisibilityChanged(ETrue);    
       
   176     }
       
   177 
       
   178 void CAlfRosterFreezeEndTimer::DoCancel()
       
   179     {
       
   180     CTimer::DoCancel();
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------
       
   184 // CAlfLayoutSwitchEffectcoordinator
       
   185 // ---------------------------------------------------------
       
   186 //
       
   187 NONSHARABLE_CLASS( CAlfLayoutSwitchEffectCoordinator ) : public CBase, public MAlfGfxEffectObserver
       
   188     {
       
   189     public:  // Constructors and destructor
       
   190         CAlfLayoutSwitchEffectCoordinator( CAlfBridge& aBridge );
       
   191         virtual ~CAlfLayoutSwitchEffectCoordinator();
       
   192     
       
   193     public: // MAlfGfxEffectObserver           
       
   194         void AlfGfxEffectEndCallBack( TInt aHandle );
       
   195     
       
   196     public:
       
   197         void BeginLayoutSwitch();
       
   198         void Cancel();
       
   199         
       
   200     private:
       
   201         AknTransEffect::TContext NextLayoutSwitchContext();
       
   202         void SetLayoutSwitchEffect(AknTransEffect::TContext aContext);
       
   203         TBool LayoutSwitchEffectsExist();
       
   204         
       
   205     private: // Data
       
   206         
       
   207         CAlfBridge& iBridge;
       
   208         AknTransEffect::TContext iLayoutSwitchEffectContext;
       
   209         TThreadPriority iOriginalPriority;
       
   210         CAlfRosterFreezeEndTimer* iRosterFreezeEndTimer;
       
   211     };
       
   212 
       
   213 CAlfLayoutSwitchEffectCoordinator::CAlfLayoutSwitchEffectCoordinator( CAlfBridge& aBridge ) :
       
   214     iBridge( aBridge ),
       
   215     iLayoutSwitchEffectContext(AknTransEffect::ENone)    
       
   216     {
       
   217     RThread me = RThread();
       
   218     iOriginalPriority = me.Priority();    
       
   219     me.Close();
       
   220     }
       
   221 
       
   222 CAlfLayoutSwitchEffectCoordinator::~CAlfLayoutSwitchEffectCoordinator()
       
   223     {   
       
   224     }
       
   225 
       
   226 // ---------------------------------------------------------
       
   227 // CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack
       
   228 //
       
   229 // This method is callback which gets called when layout 
       
   230 // switch effect has ended.
       
   231 // ---------------------------------------------------------
       
   232 //
       
   233 void CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack( TInt aHandle )
       
   234     {
       
   235     //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack"));
       
   236     if (iLayoutSwitchEffectContext == aHandle)
       
   237         {
       
   238         AknTransEffect::TContext nextContext = NextLayoutSwitchContext();
       
   239 
       
   240         // Unfreeze visible content. This reveals real roster content (in new orientation).
       
   241         if (nextContext == AknTransEffect::ELayoutSwitchExit)
       
   242             {
       
   243             #ifdef HUI_DEBUG_TRACK_DRAWING
       
   244             RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack unfreezing roster content"));
       
   245             #endif
       
   246             iBridge.iHuiEnv->Display(0).SetDirty();
       
   247             TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
       
   248             iBridge.SetVisualTreeVisibilityChanged(ETrue);
       
   249             }
       
   250         
       
   251         // Set next effect
       
   252         SetLayoutSwitchEffect(nextContext);
       
   253         
       
   254         if (nextContext == AknTransEffect::ENone)
       
   255             {
       
   256             // Restore normal priority
       
   257             RThread me = RThread();
       
   258             me.SetPriority(iOriginalPriority);    
       
   259             me.Close();
       
   260 
       
   261             // Just in case refresh everything
       
   262             iBridge.iHuiEnv->Display(0).SetDirty();
       
   263             }        
       
   264         }
       
   265     else
       
   266         {
       
   267         //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack - got different handle (normal, dont worry...) - %i"), aHandle);        
       
   268         }
       
   269     }
       
   270 
       
   271 // ---------------------------------------------------------
       
   272 // CAlfLayoutSwitchEffectCoordinator::Cancel
       
   273 // ---------------------------------------------------------
       
   274 //
       
   275 void CAlfLayoutSwitchEffectCoordinator::Cancel()
       
   276     {
       
   277     // Disable effect
       
   278     SetLayoutSwitchEffect( AknTransEffect::ENone );
       
   279 
       
   280     // Unfreeze visible content
       
   281     if ( iRosterFreezeEndTimer )
       
   282         {
       
   283 		iRosterFreezeEndTimer->Cancel();
       
   284     	}
       
   285 
       
   286     iBridge.iHuiEnv->Display(0).SetDirty();
       
   287     TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
       
   288     iBridge.SetVisualTreeVisibilityChanged(ETrue);
       
   289     
       
   290     // Restore normal priority
       
   291     RThread me = RThread();
       
   292     me.SetPriority(iOriginalPriority);    
       
   293     me.Close();
       
   294 	}
       
   295 
       
   296 // ---------------------------------------------------------
       
   297 // CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch
       
   298 //
       
   299 // This method starts the layout switch effect procedure.
       
   300 // ---------------------------------------------------------
       
   301 //
       
   302 void CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch()
       
   303     {
       
   304     // Hm. what to do if earlier is already in progress ?
       
   305     //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch"));
       
   306     if ( iBridge.iHuiEnv->MemoryLevel() <= EHuiMemoryLevelLowest )
       
   307         {
       
   308         // No effects in low memory mode
       
   309         return;
       
   310         }
       
   311     
       
   312     if (!iLayoutSwitchEffectContext)
       
   313         {
       
   314         TBool tfxOn = CAknTransitionUtils::TransitionsEnabled(AknTransEffect::ELayoutswitchTransitionsOff );
       
   315         TBool tfxExists = LayoutSwitchEffectsExist();
       
   316         if (tfxOn && tfxExists)
       
   317             {
       
   318             // Boost priority so that we are able to draw more frames for the effect
       
   319             RThread me = RThread();
       
   320             me.SetPriority(EPriorityAbsoluteHigh);    
       
   321             me.Close();
       
   322             
       
   323             // Freeze visual content
       
   324             //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch freezing roster content"));
       
   325             iBridge.iHuiEnv->Display(0).SetDirty();
       
   326             TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(ETrue));
       
   327             
       
   328             // Remove all other effects
       
   329             iBridge.HandleGfxStopEvent( EFalse );
       
   330             iBridge.RemoveAllTemporaryPresenterVisuals();
       
   331             
       
   332             // Set first layout switch effect 
       
   333             SetLayoutSwitchEffect(AknTransEffect::ELayoutSwitchStart);
       
   334             }
       
   335         else
       
   336             {
       
   337             if (!iRosterFreezeEndTimer)
       
   338                 {
       
   339                 TRAP_IGNORE(iRosterFreezeEndTimer = CAlfRosterFreezeEndTimer::NewL(iBridge));
       
   340                 }
       
   341             
       
   342             if (iRosterFreezeEndTimer)
       
   343                 {
       
   344                 iBridge.iHuiEnv->Display(0).SetDirty();
       
   345                 TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(ETrue));
       
   346                 
       
   347                 // Remove all other effects
       
   348                 iBridge.HandleGfxStopEvent( EFalse );
       
   349                 iBridge.RemoveAllTemporaryPresenterVisuals();
       
   350 
       
   351                 // Set remove freeze timer
       
   352                 iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000); 
       
   353                 }            
       
   354             //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch - tfx are set OFF -> I am not starting effect."));                        
       
   355             }
       
   356         }
       
   357     else
       
   358         {
       
   359         //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch - old effect exists - %i"), iLayoutSwitchEffectContext);
       
   360         }
       
   361     }
       
   362 
       
   363 // ---------------------------------------------------------
       
   364 // CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchContext
       
   365 //
       
   366 // This method automatically selects the next context in the 
       
   367 // layout switch procedure.
       
   368 //
       
   369 // Contextes change in the following order during layout switch:
       
   370 //
       
   371 // 1. AknTransEffect::ENone
       
   372 // 2. AknTransEffect::ELayoutSwitchStart
       
   373 // 3. AknTransEffect::ELayoutSwitchExit
       
   374 // 4. AknTransEffect::ENone
       
   375 //
       
   376 // After new context is selected, appropriate effect is set 
       
   377 // (and/or removed) from the roster.
       
   378 //
       
   379 // ---------------------------------------------------------
       
   380 //
       
   381 AknTransEffect::TContext CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchContext()
       
   382     {
       
   383     // Resolve next context based on current context
       
   384     AknTransEffect::TContext newContext = AknTransEffect::ENone;    
       
   385     switch (iLayoutSwitchEffectContext)
       
   386         {
       
   387         case AknTransEffect::ENone:
       
   388             {
       
   389             newContext = AknTransEffect::ELayoutSwitchStart;            
       
   390             break;
       
   391             }
       
   392         case AknTransEffect::ELayoutSwitchStart:
       
   393             {
       
   394             newContext = AknTransEffect::ELayoutSwitchExit;                    
       
   395             break;
       
   396             }
       
   397         case AknTransEffect::ELayoutSwitchExit: // fallthrough
       
   398         default:
       
   399             {
       
   400             newContext = AknTransEffect::ENone;            
       
   401             break;
       
   402             }              
       
   403         }
       
   404 
       
   405     //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchEffectL old ctx = %i, new ctx = %i"), iLayoutSwitchEffectContext, newContext);
       
   406     return newContext;
       
   407     }
       
   408 
       
   409 // ---------------------------------------------------------
       
   410 // CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffectL
       
   411 //
       
   412 // This method sets correct effect based on the given 
       
   413 // layout switch context.
       
   414 //
       
   415 // ---------------------------------------------------------
       
   416 //
       
   417 void CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffect(AknTransEffect::TContext aContext)
       
   418     {
       
   419     MHuiEffectable* effectable = iBridge.iHuiEnv->Display(0).Roster().Effectable();
       
   420     CHuiFxEffect* effect = NULL;
       
   421     CHuiFxEngine* engine = iBridge.iHuiEnv->EffectsEngine();
       
   422     
       
   423     if (!effectable || !engine)
       
   424         {
       
   425         return;
       
   426         }    
       
   427             
       
   428     // Update current context
       
   429     iLayoutSwitchEffectContext = aContext;           
       
   430     
       
   431     if (aContext == AknTransEffect::ENone)
       
   432         {
       
   433         // Just remove effect
       
   434         //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchEffectL - removing effect"));
       
   435         effectable->EffectSetEffect(NULL); // This calls AlfGfxEffectEndCallBack         
       
   436         }
       
   437     else
       
   438         {    
       
   439         // Load correct effect
       
   440         for ( TInt i = 0; i<iBridge.iAlfRegisteredEffects.Count(); i++ )
       
   441             {             
       
   442             if ( iBridge.iAlfRegisteredEffects[i].iAction == aContext)
       
   443                 {
       
   444                 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffectL - loading effect"));
       
   445                 TRAP_IGNORE(engine->LoadEffectL(*iBridge.iAlfRegisteredEffects[i].iEffectFile, effect, effectable, NULL, this, iLayoutSwitchEffectContext, 0 ) );                    
       
   446                 break;
       
   447                 }
       
   448             }
       
   449         }    
       
   450     }
       
   451 
       
   452 TBool CAlfLayoutSwitchEffectCoordinator::LayoutSwitchEffectsExist()
       
   453     {
       
   454     TBool appearExists = EFalse;
       
   455     TBool disAppearExists = EFalse;
       
   456     
       
   457     for ( TInt i = 0; i<iBridge.iAlfRegisteredEffects.Count(); i++ )
       
   458         {             
       
   459         if ( iBridge.iAlfRegisteredEffects[i].iAction == AknTransEffect::ELayoutSwitchStart)
       
   460             {
       
   461             disAppearExists = ETrue;
       
   462             break;
       
   463             }
       
   464         else if ( iBridge.iAlfRegisteredEffects[i].iAction == AknTransEffect::ELayoutSwitchExit)
       
   465             {
       
   466             appearExists = ETrue;
       
   467             break;
       
   468             }
       
   469         }
       
   470     
       
   471     return (appearExists || disAppearExists);    
       
   472     }
       
   473 
       
   474 // Timer to send finish full screen effect
       
   475 // ---------------------------------------------------------
       
   476 // CAlfFinishTimer
       
   477 // ---------------------------------------------------------
       
   478 //
       
   479 NONSHARABLE_CLASS( CAlfEffectEndTimer ):public CTimer
       
   480     {
       
   481     public:  // Constructors and destructor
       
   482         static CAlfEffectEndTimer* NewL( CAlfBridge& aBridge );
       
   483         virtual ~CAlfEffectEndTimer();
       
   484 
       
   485     public: // New functions
       
   486         void Start( TTimeIntervalMicroSeconds32 aPeriod, TInt aHandle );
       
   487         
       
   488     protected:  // Functions from base classes
       
   489         void DoCancel();
       
   490 
       
   491     private:
       
   492         CAlfEffectEndTimer( CAlfBridge& aBridge );
       
   493         void ConstructL();
       
   494         void RunL();
       
   495       
       
   496     private:    // Data
       
   497         CAlfBridge& iBridge;
       
   498         TInt iHandle;
       
   499                 
       
   500     };
       
   501 
       
   502 
       
   503 // ---------------------------------------------------------
       
   504 // CAlfFinishTimer
       
   505 // ---------------------------------------------------------
       
   506 //
       
   507 CAlfEffectEndTimer::CAlfEffectEndTimer( CAlfBridge& aBridge )
       
   508     :CTimer(EPriorityHigh), 
       
   509 	iBridge(aBridge)
       
   510     {   
       
   511     }
       
   512 
       
   513 void CAlfEffectEndTimer::ConstructL()
       
   514     {
       
   515     CTimer::ConstructL();
       
   516     CActiveScheduler::Add( this );
       
   517     }
       
   518 
       
   519 CAlfEffectEndTimer* CAlfEffectEndTimer::NewL( CAlfBridge& aBridge )
       
   520     {
       
   521     CAlfEffectEndTimer* self = new ( ELeave ) CAlfEffectEndTimer( aBridge );
       
   522     CleanupStack::PushL( self );
       
   523     self->ConstructL();
       
   524     CleanupStack::Pop( self );
       
   525     return self;
       
   526     }
       
   527 
       
   528 CAlfEffectEndTimer::~CAlfEffectEndTimer()
       
   529     {
       
   530     Cancel();        
       
   531     }
       
   532 
       
   533 void CAlfEffectEndTimer::Start( TTimeIntervalMicroSeconds32 aPeriod, TInt aHandle )
       
   534     {
       
   535     iHandle = aHandle;
       
   536     After( aPeriod );
       
   537     }
       
   538 
       
   539 void CAlfEffectEndTimer::RunL()
       
   540     {
       
   541     //
       
   542     // timer completes and control is returned to caller
       
   543     //
       
   544     iBridge.TransitionFinishedHandlerL( iHandle );
       
   545     // We don't become active unless we are explicitly restarted
       
   546     }
       
   547 
       
   548 void CAlfEffectEndTimer::DoCancel()
       
   549     {
       
   550     CTimer::DoCancel();
       
   551     }
       
   552 
       
   553 
    99 
   554 // ======== MEMBER FUNCTIONS ========
   100 // ======== MEMBER FUNCTIONS ========
   555 
   101 
   556 // ======== MEMBER FUNCTIONS ========
   102 // ======== MEMBER FUNCTIONS ========
   557 
   103 
   590 // ---------------------------------------------------------------------------
   136 // ---------------------------------------------------------------------------
   591 // ---------------------------------------------------------------------------
   137 // ---------------------------------------------------------------------------
   592 // 
   138 // 
   593 CAlfBridge::~CAlfBridge()
   139 CAlfBridge::~CAlfBridge()
   594 	{
   140 	{
       
   141 	delete iOrphanStorage;
   595 	delete iFadeEffectFile;
   142 	delete iFadeEffectFile;
   596 	iWindowHashArray.Close();
   143 	iWindowHashArray.Close();
   597 	for( TInt i = 0; i< iAlfRegisteredEffects.Count(); i++ )
   144 	for( TInt i = 0; i< iAlfRegisteredEffects.Count(); i++ )
   598 	    {
   145 	    {
   599 	    delete iAlfRegisteredEffects[i].iEffectFile;
   146 	    delete iAlfRegisteredEffects[i].iEffectFile;
   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
   790     __ALFFXLOGSTRING1("CAlfBridge::AddVisual 0x%x", aWindowNodeId);
   342     __ALFFXLOGSTRING1("CAlfBridge::AddVisual 0x%x", aWindowNodeId);
   791     THashVisualStruct visualStruct( aVisual, aClientSideId, aClientSideGroupId);
   343     THashVisualStruct visualStruct( aVisual, aClientSideId, aClientSideGroupId);
   792     iWindowHashArray.Insert( aWindowNodeId, visualStruct );
   344     iWindowHashArray.Insert( aWindowNodeId, visualStruct );
   793     iPreviouslySearchedVisualId = aWindowNodeId;
   345     iPreviouslySearchedVisualId = aWindowNodeId;
   794     iPreviouslySearchedVisual = aVisual;
   346     iPreviouslySearchedVisual = aVisual;
       
   347 
       
   348     AMT_INC_COUNTER( iTotalVisualCount );
   795     }
   349     }
   796 
   350 
   797 // ---------------------------------------------------------------------------
   351 // ---------------------------------------------------------------------------
   798 // RemoveVisual
   352 // RemoveVisual
   799 // ---------------------------------------------------------------------------
   353 // ---------------------------------------------------------------------------
   801 void CAlfBridge::RemoveVisual( TInt aWindowNodeId )
   355 void CAlfBridge::RemoveVisual( TInt aWindowNodeId )
   802     {
   356     {
   803     __ALFFXLOGSTRING1("CAlfBridge::RemoveVisual 0x%x", aWindowNodeId);
   357     __ALFFXLOGSTRING1("CAlfBridge::RemoveVisual 0x%x", aWindowNodeId);
   804     iWindowHashArray.Remove( aWindowNodeId );
   358     iWindowHashArray.Remove( aWindowNodeId );
   805     iPreviouslySearchedVisualId = 0;
   359     iPreviouslySearchedVisualId = 0;
       
   360     
       
   361     AMT_DEC_COUNTER( iTotalVisualCount );    
   806     }
   362     }
   807     
   363     
   808 // ---------------------------------------------------------------------------
   364 // ---------------------------------------------------------------------------
   809 // FindVisual
   365 // FindVisual
   810 // ---------------------------------------------------------------------------
   366 // ---------------------------------------------------------------------------
   948         aArray.Append(aLayout);
   504         aArray.Append(aLayout);
   949         }
   505         }
   950     }
   506     }
   951 
   507 
   952 // ---------------------------------------------------------------------------
   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 // ---------------------------------------------------------------------------
   953 // ---------------------------------------------------------------------------
   551 // ---------------------------------------------------------------------------
   954 // 
   552 // 
   955 void CAlfBridge::DeleteControlGroupL(TInt aWindowGroupNodeId, TInt aScreenNumber )
   553 void CAlfBridge::DeleteControlGroupL(TInt aWindowGroupNodeId, TInt aScreenNumber )
   956     {
   554     {
   957     for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++)
   555     for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++)
   958         {
   556         {
   959         if (iAlfScreens[aScreenNumber]->iControlGroups[i].iWindowGroupNodeId == aWindowGroupNodeId)
   557         if (iAlfScreens[aScreenNumber]->iControlGroups[i].iWindowGroupNodeId == aWindowGroupNodeId)
   960             {
   558             {
   961             if (iAlfScreens[aScreenNumber]->iDisplay)
   559             if (iAlfScreens[aScreenNumber]->iDisplay)
   962                 {
   560                 {
   963                 CHuiControl& control = iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup->Control(0);
   561                 CHuiControlGroup* controlGroup = iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup;
       
   562                 CHuiControl& control = controlGroup->Control(0);
   964                 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
   563                 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
       
   564                 ResolveAfterEffectAppearingApplicationL(controlGroup);
   965                 // 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
   966                 // 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
   967                 // 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 
   968                 // is cleared when effect has finished.
   568                 // is cleared when effect has finished.
   969                 RPointerArray<CHuiLayout> familyTree;
   569                 RPointerArray<CHuiLayout> familyTree;
  1009                     // 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. 
  1010                     // the layout is not have effect, but some child window might.
   610                     // the layout is not have effect, but some child window might.
  1011                     // in this case, the child window effects WILL BE REMOVED.
   611                     // in this case, the child window effects WILL BE REMOVED.
  1012                      for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++)
   612                      for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++)
  1013                          {
   613                          {
  1014                          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                              }
  1015                          }
   629                          }
  1016                     }
   630                     }
  1017                 familyTree.Close();
   631                 familyTree.Close();
  1018                 iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup);
   632                 iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup);
  1019                 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group");
   633                 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group");
  1020                 iAlfScreens[aScreenNumber]->iControlGroups.Remove(i);
   634                 iAlfScreens[aScreenNumber]->iControlGroups.Remove(i);
  1021                 iHuiEnv->DeleteControlGroup(aWindowGroupNodeId);
   635                 iHuiEnv->DeleteControlGroup(aWindowGroupNodeId);
  1022                 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group done");
   636                 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group done");
  1023                 }
   637                 }
       
   638             
       
   639             AMT_DEC_COUNTER( iTotalControlGroupCount );            
       
   640             
  1024             break;
   641             break;
  1025             }
   642             }
  1026         }        
   643         }        
  1027     }
   644     }
  1028 
   645 
  1095         iAlfScreens[aScreenNumber]->iControlGroups.Append(entry);
   712         iAlfScreens[aScreenNumber]->iControlGroups.Append(entry);
  1096         CleanupStack::Pop(group);                
   713         CleanupStack::Pop(group);                
  1097 
   714 
  1098         if (iAlfScreens[aScreenNumber]->iDisplay)
   715         if (iAlfScreens[aScreenNumber]->iDisplay)
  1099             ShowControlGroupL(iAlfScreens[aScreenNumber]->iDisplay->Roster(), *group, KHuiRosterShowAtTop, aScreenNumber); 
   716             ShowControlGroupL(iAlfScreens[aScreenNumber]->iDisplay->Roster(), *group, KHuiRosterShowAtTop, aScreenNumber); 
       
   717         
       
   718         AMT_INC_COUNTER( iTotalControlGroupCount );
  1100         }
   719         }
  1101     
   720     
  1102 
   721 
  1103     return *group;       
   722     return *group;       
  1104     }
   723     }
  1266         TBool added = EFalse;
   885         TBool added = EFalse;
  1267         for (TInt i=0; i<aRoster.Count() - screen->FixedControlGroupCount(); i++)
   886         for (TInt i=0; i<aRoster.Count() - screen->FixedControlGroupCount(); i++)
  1268             {
   887             {
  1269             if (index == aWhere)
   888             if (index == aWhere)
  1270                 {
   889                 {
  1271                 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);
  1272                 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                 
  1273                 break;
   904                 break;
  1274                 }
   905                 }
  1275 
   906 
  1276             if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer &&
   907             if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer &&
  1277                 &aRoster.ControlGroup(i) != &aGroup)
   908                 &aRoster.ControlGroup(i) != &aGroup)
  1648 	
  1279 	
  1649     // skip the topmost (effect) layer, start from floating sprite group
  1280     // skip the topmost (effect) layer, start from floating sprite group
  1650     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
  1281     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
  1651         {                
  1282         {                
  1652 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1283 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1653         TInt activevisualcount = 0;
  1284         activevisualcount = 0;
  1654         TInt passivevisualcount = 0;
  1285         passivevisualcount = 0;
  1655 #endif
  1286 #endif
  1656 
  1287 
  1657         CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
  1288         CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
  1658         CHuiControl& control = controlgroup.Control(0);
  1289         CHuiControl& control = controlgroup.Control(0);
  1659 
  1290 
  1783             if (layout->Effect() && (layout->Effect()->EffectFlags() & KHuiFadeEffectFlag))
  1414             if (layout->Effect() && (layout->Effect()->EffectFlags() & KHuiFadeEffectFlag))
  1784                 {
  1415                 {
  1785                 if (firstFadedWindowGroupFound)
  1416                 if (firstFadedWindowGroupFound)
  1786                     {
  1417                     {
  1787                     TInt flags = layout->Effect()->EffectFlags();
  1418                     TInt flags = layout->Effect()->EffectFlags();
  1788                     flags |= KHuiFxAlwaysBlend;
  1419                     flags |= KHuiFxAlwaysBlend; // Workaround for opaque layout canvasvisual.
  1789                     layout->Effect()->SetEffectFlags(flags);
  1420                     layout->Effect()->SetEffectFlags(flags);
  1790                     }
  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                 
  1791                 firstFadedWindowGroupFound = ETrue;
  1432                 firstFadedWindowGroupFound = ETrue;
  1792                 }
  1433                 }
  1793             }
  1434             }
  1794         }
  1435         }
  1795 
  1436 
  1925             
  1566             
  1926             #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
  1567             #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
  1927             iTempTotalPassiveVisualCount++;
  1568             iTempTotalPassiveVisualCount++;
  1928             #endif
  1569             #endif
  1929             
  1570             
  1930     #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1571             #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1931             passivevisualcount++;
  1572                     passivevisualcount++;
  1932     #endif
  1573             #endif
  1933             }
  1574             }
  1934         else
  1575         else
  1935             {
  1576             {
  1936 			aSubtreeVisible = ETrue;
  1577 			aSubtreeVisible = ETrue;
  1937             canvasVisual->ClearFlags( 
  1578             canvasVisual->ClearFlags( 
  1976 
  1617 
  1977             if (wasInactive)
  1618             if (wasInactive)
  1978                 {
  1619                 {
  1979                 canvasVisual->SetChanged();
  1620                 canvasVisual->SetChanged();
  1980                 }
  1621                 }
  1981     #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
  1982             activevisualcount++;
  1627             activevisualcount++;
  1983     #endif
  1628             #endif
  1984             }
  1629             }
  1985             
  1630             
  1986         // 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
  1987         visualIsActive = !(canvasVisual->Flags() & EHuiVisualFlagInactive);
  1632         visualIsActive = !(canvasVisual->Flags() & EHuiVisualFlagInactive);
  1988     
  1633     
  2605             {
  2250             {
  2606             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  2251             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  2607             if (aVisual == effectItem.iEffectedVisual)
  2252             if (aVisual == effectItem.iEffectedVisual)
  2608                 {
  2253                 {
  2609                 iEffectCleanupStack.Remove(i);
  2254                 iEffectCleanupStack.Remove(i);
  2610                 AMT_DEC_COUNTER(iAlfBridgeEffectCleanupStackCount);
       
  2611                 break;
  2255                 break;
  2612                 }
  2256                 }
  2613             }
  2257             }
  2614         }
  2258         }
  2615     delete aVisual;
  2259     delete aVisual;
  2652 			viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  2296 			viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  2653 			CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
  2297 			CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
  2654 		     // Sprite is in its own group, and can be deleted normally.
  2298 		     // Sprite is in its own group, and can be deleted normally.
  2655 			if ( !controlGroup  && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite )
  2299 			if ( !controlGroup  && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite )
  2656 			    {
  2300 			    {
  2657 			    __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.!");
  2301 			    __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.");
  2658 			    // 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. 
  2659 			    // the group. Ignore this.
  2303                 if ( viz ) 
       
  2304 				    {
       
  2305 				    DestroyWindow(viz);
       
  2306 					}
  2660 			    }
  2307 			    }
  2661 			else
  2308 			else
  2662 			    {
  2309 			    {
  2663 			    // = (CHuiCanvasVisual*)de(windowNodeId, windowGroupNodeId,screenNumber);
  2310 			    // = (CHuiCanvasVisual*)de(windowNodeId, windowGroupNodeId,screenNumber);
  2664 			    if (viz)
  2311 			    if (viz)
  2715 		}
  2362 		}
  2716 	else
  2363 	else
  2717 		{
  2364 		{
  2718 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowPosL, EAlfDSSetWindowPos: Visual not found!");    
  2365 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowPosL, EAlfDSSetWindowPos: Visual not found!");    
  2719 		}   
  2366 		}   
       
  2367 
       
  2368     AMT_INC_COUNTER_IF( viz, iVisualPositionChangedCount );
       
  2369     AMT_SET_VALUE_IF( viz, iLatestVisualExtentRect, TRect( windowAttributes->iPosition, windowAttributes->iSize ) );
  2720 	}
  2370 	}
  2721 
  2371 
  2722 // ---------------------------------------------------------------------------
  2372 // ---------------------------------------------------------------------------
  2723 // HandleSetWindowSizeL
  2373 // HandleSetWindowSizeL
  2724 // ---------------------------------------------------------------------------
  2374 // ---------------------------------------------------------------------------
  2743 	else
  2393 	else
  2744 		{
  2394 		{
  2745 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!");    
  2395 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!");    
  2746 		}   
  2396 		}   
  2747     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 ) );        
  2748 	}
  2401 	}
  2749 
  2402 
  2750 // ---------------------------------------------------------------------------
  2403 // ---------------------------------------------------------------------------
  2751 // HandleSetWindowRotationL
  2404 // HandleSetWindowRotationL
  2752 // ---------------------------------------------------------------------------
  2405 // ---------------------------------------------------------------------------
  2832 				}    
  2485 				}    
  2833 			#endif
  2486 			#endif
  2834 
  2487 
  2835 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  2488 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  2836 			
  2489 			
  2837                         if (!controlGroup)
  2490             if (!controlGroup)
  2838                             {
  2491                 {
  2839                             User::Leave(KErrNotFound);
  2492                 User::Leave(KErrNotFound);
  2840                             }
  2493                 }
  2841 
  2494             ResolveAfterEffectAppearingApplicationL(controlGroup); // does nothing, if effect is not active on this control group
  2842 			// 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.
  2843 			iAlfScreens[screenNumber]->iDisplay->Roster().Hide(*controlGroup);                            
  2496 			iAlfScreens[screenNumber]->iDisplay->Roster().Hide(*controlGroup);                            
  2844 			TInt wsWindowGroupCount = 0;
  2497 			TInt wsWindowGroupCount = 0;
  2845 			for (TInt i=0; i<iAlfScreens[screenNumber]->iDisplay->Roster().Count();i++)
  2498 			for (TInt i=0; i<iAlfScreens[screenNumber]->iDisplay->Roster().Count();i++)
  2846 				{
  2499 				{
  3007 		}
  2660 		}
  3008 	else
  2661 	else
  3009 		{
  2662 		{
  3010 		__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 );                                 
  3011 		}    
  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
  3012 	}
  2703 	}
       
  2704 
       
  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     }
  3013 
  2744 
  3014 // ---------------------------------------------------------------------------
  2745 // ---------------------------------------------------------------------------
  3015 // SetWindowActiveL
  2746 // SetWindowActiveL
  3016 // ---------------------------------------------------------------------------
  2747 // ---------------------------------------------------------------------------
  3017 // 
  2748 // 
  3670     }
  3401     }
  3671 
  3402 
  3672 TBool CAlfBridge::HasActiveFadedChildren( CHuiCanvasVisual& aVisual )
  3403 TBool CAlfBridge::HasActiveFadedChildren( CHuiCanvasVisual& aVisual )
  3673     {
  3404     {
  3674     TBool has = EFalse;
  3405     TBool has = EFalse;
       
  3406     has |= IsAlfOriginatedWindow(aVisual);
       
  3407     
  3675     TInt count = aVisual.Count();        
  3408     TInt count = aVisual.Count();        
  3676     for (TInt i=0; i<count; i++)
  3409     for (TInt i=0; i<count; i++)
  3677         {
  3410         {
  3678         CHuiCanvasVisual* child = (CHuiCanvasVisual*) (&aVisual.Visual(i)); 
  3411         CHuiCanvasVisual* child = (CHuiCanvasVisual*) (&aVisual.Visual(i)); 
  3679         TBool active = !(child->Flags() & EHuiVisualFlagInactive);            
  3412         TBool active = !(child->Flags() & EHuiVisualFlagInactive);            
  3680         TBool faded = child->CanvasFlags() & EHuiCanvasFlagExternalFade; 
  3413         TBool faded = child->CanvasFlags() & EHuiCanvasFlagExternalFade; 
  3681         
  3414         
  3682         if (active && faded && child->PaintedAreaCount())
  3415         if (active && faded && (child->PaintedAreaCount() || IsAlfOriginatedWindow(*child)))
  3683             {
  3416             {
  3684             has = ETrue;
  3417             has = ETrue;
  3685             break;
  3418             break;
  3686             }        
  3419             }        
  3687         }    
  3420         }    
  3717         
  3450         
  3718         // Avoid interrupting other effects. 
  3451         // Avoid interrupting other effects. 
  3719         TBool otherEffectActive = aVisual.Effect() && !(aVisual.Effect()->EffectFlags() & KHuiFadeEffectFlag);
  3452         TBool otherEffectActive = aVisual.Effect() && !(aVisual.Effect()->EffectFlags() & KHuiFadeEffectFlag);
  3720 
  3453 
  3721         // 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.
  3722         if (visualIsActive && !alreadyFaded && !otherEffectActive && !IsFadedByParent(aVisual) && HasActivePaintedAreas(aVisual, fadesChildren))
  3455         if (visualIsActive && !alreadyFaded && !otherEffectActive && !IsFadedByParent(aVisual) && (HasActivePaintedAreas(aVisual, fadesChildren) || IsAlfOriginatedWindow(aVisual)))
  3723         	{        
  3456         	{        
  3724         	CHuiFxEffect* effect = NULL;
  3457         	CHuiFxEffect* effect = NULL;
  3725         	CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
  3458         	CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
  3726 
  3459 
  3727             if (engine && iFadeEffectFile )
  3460             if (engine && iFadeEffectFile )
  3890         }
  3623         }
  3891     else
  3624     else
  3892         {
  3625         {
  3893         __ALFLOGSTRING1("CAlfBridge::HandleSetCursorDataL - WARNING! Cursor node 0x%x not found!", windowNodeId);
  3626         __ALFLOGSTRING1("CAlfBridge::HandleSetCursorDataL - WARNING! Cursor node 0x%x not found!", windowNodeId);
  3894         }
  3627         }
       
  3628     
       
  3629     AMT_INC_COUNTER_IF(viz, iTotalVisualAttributeChangedCount);   
  3895     }
  3630     }
  3896 
  3631 
  3897 // ---------------------------------------------------------------------------
  3632 // ---------------------------------------------------------------------------
  3898 // HandleSetNodeTracking
  3633 // HandleSetNodeTracking
  3899 // ---------------------------------------------------------------------------
  3634 // ---------------------------------------------------------------------------
  3973             {
  3708             {
  3974             case MAlfGfxEffectPlugin::EBeginFullscreen:
  3709             case MAlfGfxEffectPlugin::EBeginFullscreen:
  3975                 {
  3710                 {
  3976                 aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  3711                 aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  3977                 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);
  3978                 if (needStoredBuffers)
  3714                 if (needStoredBuffers)
  3979                     {
  3715                     {
  3980                     TRAP(err,StoreRenderBufferStartL(aToLayout));
  3716                     TRAP(err,StoreRenderBufferStartL(aToLayout));
       
  3717                     __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - EBeginFullScreen: Screenshot result: KErrNone == %d", err);
  3981                     if (err == KErrNone)
  3718                     if (err == KErrNone)
  3982                         {
  3719                         {
  3983                         aToLayout->SetFreezeState(ETrue);
  3720                         aToLayout->SetFreezeState(ETrue);
  3984                         }
  3721                         }
  3985                     else
  3722                     else
  3993                     case AknTransEffect::EApplicationStart:
  3730                     case AknTransEffect::EApplicationStart:
  3994                     case AknTransEffect::EApplicationStartRect:
  3731                     case AknTransEffect::EApplicationStartRect:
  3995                         {
  3732                         {
  3996                         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
  3997                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  3734                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
       
  3735                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  3998                         break;
  3736                         break;
  3999                         }
  3737                         }
  4000                     case AknTransEffect::EApplicationStartSwitch:
  3738                     case AknTransEffect::EApplicationStartSwitch:
  4001                     case AknTransEffect::EApplicationStartSwitchRect:
  3739                     case AknTransEffect::EApplicationStartSwitchRect:
  4002                         {
  3740                         {
  4003                         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.
  4004                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  3742                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
       
  3743                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4005                         break;
  3744                         break;
  4006                         }
  3745                         }
  4007 
  3746 
  4008                     case AknTransEffect::EApplicationExit:
  3747                     case AknTransEffect::EApplicationExit:
  4009                         {
  3748                         {
       
  3749                         aEvent.iEffectType = CFullScreenEffectState::EExitEffect;
  4010                         // The effect should start when the new view is ready,
  3750                         // The effect should start when the new view is ready,
  4011                         // 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
  4012 
  3752 
  4013                         // Effect end observer is given to engine in LoadEffectL
  3753                         // Effect end observer is given to engine in LoadEffectL
  4014                         // 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
  4020                             // effect on a layout must be an application start effect. 
  3760                             // effect on a layout must be an application start effect. 
  4021                             // External content visual is not used for that.
  3761                             // External content visual is not used for that.
  4022                             __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());
  4023                             aToLayout->SetEffect(NULL);
  3763                             aToLayout->SetEffect(NULL);
  4024                             }
  3764                             }
  4025                         if (!(aToLayout->Flags() & EHuiVisualFlagInactive))
  3765                         if ( aEvent.iAction == AknTransEffect::EApplicationExit && !(aToLayout->Flags() & EHuiVisualFlagInactive)) 
  4026                             {
  3766                             {
  4027                             // 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
  4028                             // Initialize layout for the exit effect  
  3768                             // Initialize layout for the exit effect  
  4029                             iLayoutInitializedForExitEffect = SetupEffectLayoutContainerL(aEvent.iHandle, aToLayout, ETrue);
  3769                             iLayoutInitializedForExitEffect = SetupEffectLayoutContainerL(aEvent.iHandle, aToLayout, ETrue);
       
  3770                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - EBeginFullscreen - iLayoutInitializedForExitEffect: %d", iLayoutInitializedForExitEffect);
  4030                             aEvent.iSetupDone = iLayoutInitializedForExitEffect; 
  3771                             aEvent.iSetupDone = iLayoutInitializedForExitEffect; 
  4031                             }
  3772                             }
  4032                         else
  3773                         else
  4033                             {
  3774                             {
  4034                             iLayoutInitializedForExitEffect = EFalse;
  3775                             iLayoutInitializedForExitEffect = EFalse;
       
  3776                             aEvent.iSetupDone = EFalse;
  4035                             }
  3777                             }
  4036                          return failed;
  3778                          return failed;
  4037                          }
  3779                          }
  4038                     default:
  3780                     default:
  4039                         break;
  3781                         break;
  4051                         }
  3793                         }
  4052                         
  3794                         
  4053                     if (aToLayout)
  3795                     if (aToLayout)
  4054                         {
  3796                         {
  4055                         aToLayout->iOpacity.Set(1.0f);
  3797                         aToLayout->iOpacity.Set(1.0f);
  4056                         __ALFFXLOGSTRING1("HandleGfxEventL - loading effect, handle %d", aEvent.iHandle );
  3798                         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - loading effect, handle %d", aEvent.iHandle );
  4057                         if (aEvent.iAction == AknTransEffect::EApplicationExit)
  3799                         if (aEvent.iAction == AknTransEffect::EApplicationExit)
  4058                             {
  3800                             {
  4059                         	// Exit effect was initialized earlier with EBeginFullscreen event
  3801                             // Exit effect was initialized earlier with EBeginFullscreen event
  4060 						    layoutEffectable = iLayoutInitializedForExitEffect;
  3802 						    layoutEffectable = aEvent.iSetupDone;
       
  3803 						    __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - EEndFullScreen: %d", layoutEffectable);
  4061                             }
  3804                             }
  4062                         else
  3805                         else
  4063                         	{
  3806                         	{
  4064                             // add visuals to visual cleanupstack
  3807                             // add visuals to visual cleanupstack
  4065                             aToLayout->SetStoredRenderBufferModificationsEnabled(EFalse);
  3808                             aToLayout->SetStoredRenderBufferModificationsEnabled(EFalse);
  4067                             aEvent.iSetupDone = layoutEffectable; 
  3810                             aEvent.iSetupDone = layoutEffectable; 
  4068                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  3811                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  4069                             }
  3812                             }
  4070 
  3813 
  4071                         if (layoutEffectable)
  3814                         if (layoutEffectable)
  4072                             {
  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                             
  4073                             if (aEvent.iRect != TRect())
  3823                             if (aEvent.iRect != TRect())
  4074                                 {
  3824                                 {
  4075                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), &aEvent.iRect, this, aEvent.iHandle, KHuiFxDelayRunUntilFirstFrameHasBeenDrawn ));
  3825                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), &aEvent.iRect, this, aEvent.iHandle, effectFlags ));
  4076                                 }
  3826                                 }
  4077                             else
  3827                             else
  4078                                 {
  3828                                 {
  4079                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle, KHuiFxDelayRunUntilFirstFrameHasBeenDrawn ) );
  3829                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle, effectFlags ) );
  4080                                 }
  3830                                 }
  4081                             effect = NULL;
  3831                             effect = NULL;
  4082                             // only use the effect if the effect file was correctly parsed
  3832                             // only use the effect if the effect file was correctly parsed
  4083                             if (err != KErrNone)
  3833                             if (err != KErrNone)
  4084                                 {
  3834                                 {
  4111 void CAlfBridge::FreezeLayoutUntilEffectDestroyedL(CHuiLayout* aLayout, TInt aHandle)
  3861 void CAlfBridge::FreezeLayoutUntilEffectDestroyedL(CHuiLayout* aLayout, TInt aHandle)
  4112     {
  3862     {
  4113     if (aLayout)
  3863     if (aLayout)
  4114         {
  3864         {
  4115 		TRAPD(err, StoreRenderBufferStartL(aLayout));
  3865 		TRAPD(err, StoreRenderBufferStartL(aLayout));
       
  3866 		__ALFFXLOGSTRING2("CAlfBridge::FreezeLayoutUntilEffectDestroyed - StoreRenderBufferStartL call returned: %d for layout 0x%x", err, aLayout);
  4116 		if (err == KErrNone)
  3867 		if (err == KErrNone)
  4117 			{
  3868 			{
  4118             // Freeze only, if buffer was reserved succesfully 
  3869             // Freeze only, if buffer was reserved succesfully 
  4119             aLayout->SetFreezeState(ETrue);
  3870             aLayout->SetFreezeState(ETrue);
  4120         	TBool itemsDestroyed;
  3871         	TBool itemsDestroyed;
  4184             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - layout visual: 0x%x ; handle: %d ", layout, handle);
  3935             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - layout visual: 0x%x ; handle: %d ", layout, handle);
  4185             RemoveTemporaryPresenterVisual(NULL, handle);
  3936             RemoveTemporaryPresenterVisual(NULL, handle);
  4186             }
  3937             }
  4187         layout->iOpacity.Set(1.0f); 
  3938         layout->iOpacity.Set(1.0f); 
  4188         }
  3939         }
  4189     }
       
  4190 
       
  4191 CAlfBridge::CEffectState::CEffectState()
       
  4192     {
       
  4193     // CBase clears all variables
       
  4194     }
       
  4195 
       
  4196 CAlfBridge::CEffectState::~CEffectState()
       
  4197     {
       
  4198     delete iEffectName;
       
  4199     }
       
  4200 
       
  4201 void CAlfBridge::CEffectState::ResolveFileNameL(RMemReadStream& aStream)
       
  4202     {
       
  4203     HBufC* effectDirectory = HBufC::NewLC(aStream, 256);
       
  4204     HBufC* effectFile = HBufC::NewLC(aStream, 256);
       
  4205 
       
  4206     // Add one extra because we want to be able to append a number to the filename
       
  4207     HBufC* effectFullName = HBufC::NewL(effectDirectory->Des().Length()
       
  4208             + effectFile->Des().Length() + 1);
       
  4209     CleanupStack::PushL(effectFullName);
       
  4210 
       
  4211     effectFullName->Des().Copy(*(effectDirectory));
       
  4212     effectFullName->Des().Append(*(effectFile));
       
  4213     delete iEffectName;
       
  4214     iEffectName = effectFullName; // ownership transferred
       
  4215     CleanupStack::Pop(effectFullName);
       
  4216     CleanupStack::PopAndDestroy(2, effectDirectory);
       
  4217     }
       
  4218 
       
  4219 void CAlfBridge::CFullScreenEffectState::ConstructL(
       
  4220         TInt aAction,
       
  4221         RMemReadStream& aStream)
       
  4222     {
       
  4223     iAction = aAction;
       
  4224 
       
  4225     iHandle = aStream.ReadInt32L();
       
  4226 
       
  4227     iType = aStream.ReadInt32L();
       
  4228     iWg1 = aStream.ReadInt32L();
       
  4229     iWg2 = aStream.ReadInt32L();
       
  4230     iToAppId = aStream.ReadInt32L();
       
  4231     iFromAppId = aStream.ReadInt32L();
       
  4232 
       
  4233     if (iType == AknTransEffect::EParameterType)
       
  4234         {
       
  4235         /*screen1 =*/aStream.ReadInt32L();
       
  4236         /*screen2 =*/aStream.ReadInt32L();
       
  4237         }
       
  4238     /*TInt flags =*/
       
  4239     aStream.ReadInt32L();
       
  4240     iRect.iTl.iX = aStream.ReadInt32L();
       
  4241     iRect.iTl.iY = aStream.ReadInt32L();
       
  4242     iRect.iBr.iX = aStream.ReadInt32L();
       
  4243     iRect.iBr.iY = aStream.ReadInt32L();
       
  4244 
       
  4245     ResolveFileNameL(aStream);
       
  4246 
       
  4247     iCompletionHandle = iHandle;
       
  4248     }
       
  4249 
       
  4250 void CAlfBridge::CControlEffectState::ConstructL(TInt aAction,
       
  4251         RMemReadStream& aStream)
       
  4252     {
       
  4253     iAction = aAction;
       
  4254     TInt operation = aStream.ReadInt32L();
       
  4255     iHandle = aStream.ReadInt32L();
       
  4256     iClientHandle = aStream.ReadInt32L();
       
  4257     iClientGroupHandle = aStream.ReadInt32L();
       
  4258     TInt screenNumber = aStream.ReadInt32L(); // this has always value 0 
       
  4259     // Are Symbian full filename+directory combinations still max 256 characters long?
       
  4260     ResolveFileNameL(aStream);
       
  4261     }
  3940     }
  4262 
  3941 
  4263 // ---------------------------------------------------------------------------
  3942 // ---------------------------------------------------------------------------
  4264 // HandleGfxEffectsL
  3943 // HandleGfxEffectsL
  4265 // ---------------------------------------------------------------------------
  3944 // ---------------------------------------------------------------------------
  4352             return;
  4031             return;
  4353             }
  4032             }
  4354 
  4033 
  4355         __ALFFXLOGSTRING("HandleGfxEffectsL - process end");
  4034         __ALFFXLOGSTRING("HandleGfxEffectsL - process end");
  4356         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			
  4357         }
  4043         }
  4358 
  4044 
  4359     CFullScreenEffectState* fxData = iFullScreenEffectData;
  4045     CFullScreenEffectState* fxData = iFullScreenEffectData;
  4360     fxData->iOperation = operation;
  4046     fxData->iOperation = operation;
  4361     fxData->iWaitingWindowGroup = EFalse;
  4047     fxData->iWaitingWindowGroup = EFalse;
  4646     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
  4332     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
  4647     }
  4333     }
  4648 
  4334 
  4649 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect)
  4335 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect)
  4650     {
  4336     {
       
  4337     __ALFFXLOGSTRING3("CAlfBridge::SetupEffectLayoutContainerL - aHandle: %d, aSourceLayout: 0x%x, aIsExitEffect: % d >>", aHandle, aSourceLayout, aIsExitEffect );
       
  4338     
  4651     if (aSourceLayout->Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)
  4339     if (aSourceLayout->Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)
  4652         {
  4340         {
  4653         // the requested visual is already having an effect. 
  4341         // the requested visual is already having an effect. 
  4654         __ALFFXLOGSTRING("CAlfBridge::SetupEffectLayoutContainerL - WE ARE ALREADY HAVING EFFECT! WHAT TO DO??");
  4342         __ALFFXLOGSTRING("CAlfBridge::SetupEffectLayoutContainerL - WE ARE ALREADY HAVING EFFECT! WHAT TO DO??");
  4655         // 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. 
  5203             {
  4891             {
  5204             if (aRoster.ControlGroup(i).ResourceId() == iAlfWindowGroupNodeId)
  4892             if (aRoster.ControlGroup(i).ResourceId() == iAlfWindowGroupNodeId)
  5205                 {
  4893                 {
  5206 #ifdef  HUI_DEBUG_TRACK_DRAWING
  4894 #ifdef  HUI_DEBUG_TRACK_DRAWING
  5207                 __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);                                                    
  5208 #endif         
  4898 #endif         
  5209                 }
  4899                 }
  5210             else
  4900             else
  5211                 {
  4901                 {
  5212 #ifdef  HUI_DEBUG_TRACK_DRAWING
  4902 #ifdef  HUI_DEBUG_TRACK_DRAWING
  5218             }
  4908             }
  5219         else if (indexedGroup.Control(0).Role() == EAlfSessionContainer)
  4909         else if (indexedGroup.Control(0).Role() == EAlfSessionContainer)
  5220             {
  4910             {
  5221 #ifdef  HUI_DEBUG_TRACK_DRAWING
  4911 #ifdef  HUI_DEBUG_TRACK_DRAWING
  5222             __ALFLOGSTRING2(">> %d ALF GROUP, %d", i, clientWindowGroupId);                        
  4912             __ALFLOGSTRING2(">> %d ALF GROUP, %d", i, clientWindowGroupId);                        
       
  4913 #else
       
  4914             __ALFLOGSTRING1(">> %d ALF GROUP", i);                                    
  5223 #endif
  4915 #endif
  5224             }
  4916             }
  5225         else if (indexedGroup.Control(0).Role() == EAlfWindowFloatingSpriteContainer)
  4917         else if (indexedGroup.Control(0).Role() == EAlfWindowFloatingSpriteContainer)
  5226             {
  4918             {
  5227 #ifdef  HUI_DEBUG_TRACK_DRAWING			
  4919 #ifdef  HUI_DEBUG_TRACK_DRAWING			
  5248             }
  4940             }
  5249         else 
  4941         else 
  5250             {
  4942             {
  5251 #ifdef  HUI_DEBUG_TRACK_DRAWING
  4943 #ifdef  HUI_DEBUG_TRACK_DRAWING
  5252             __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);                                                                            
  5253 #endif
  4947 #endif
  5254             }                                                
  4948             }                                                
  5255 
  4949 
  5256         if (&indexedGroup == &aGroup)
  4950         if (&indexedGroup == &aGroup)
  5257             {
  4951             {
  5484             CHuiTexture* texture = CHuiTexture::NewL();
  5178             CHuiTexture* texture = CHuiTexture::NewL();
  5485             CleanupStack::PushL(texture);
  5179             CleanupStack::PushL(texture);
  5486             iAlfScreens[i]->iDisplay->SetForegroundBitmapL( iAlfScreens[i]->iSwRenderingTarget );
  5180             iAlfScreens[i]->iDisplay->SetForegroundBitmapL( iAlfScreens[i]->iSwRenderingTarget );
  5487             CleanupStack::Pop(texture);
  5181             CleanupStack::Pop(texture);
  5488             iAlfScreens[i]->iDisplay->SetForegroundTexture(texture);
  5182             iAlfScreens[i]->iDisplay->SetForegroundTexture(texture);
  5489             iAlfScreens[i]->iDisplay->iRosterObservers.AppendL(*this);
       
  5490             }
  5183             }
  5491         else
  5184         else
  5492             {
  5185             {
  5493             iAlfScreens[i]->iDisplay->SetForegroundBitmapL(NULL);            
  5186             iAlfScreens[i]->iDisplay->SetForegroundBitmapL(NULL);            
  5494             iAlfScreens[i]->iDisplay->SetForegroundTexture(NULL);
  5187             iAlfScreens[i]->iDisplay->SetForegroundTexture(NULL);
  5495             iAlfScreens[i]->iDisplay->iRosterObservers.Remove(*this);            
       
  5496             }
  5188             }
  5497             
  5189             
  5498         // SetCapturingBufferL is called from HandleVisualVisibility.
  5190         // SetCapturingBufferL is called from HandleVisualVisibility.
  5499         iAlfScreens[i]->SetVisualTreeVisibilityChanged(ETrue);
  5191         iAlfScreens[i]->SetVisualTreeVisibilityChanged(ETrue);
  5500         }
       
  5501     }
       
  5502 
       
  5503 // ---------------------------------------------------------------------------
       
  5504 // ---------------------------------------------------------------------------
       
  5505 // 
       
  5506 void CAlfBridge::UploadSwRenderingTargetL(CAlfScreen* aScreen)
       
  5507     {
       
  5508     if (iSwRenderingEnabled)
       
  5509         {
       
  5510         CHuiTexture* texture = aScreen->iDisplay->ForegroundTexture();                        
       
  5511         if (texture && aScreen->iSwRenderingTarget)
       
  5512             {
       
  5513             texture->UploadL(*aScreen->iSwRenderingTarget, NULL);                
       
  5514             }           
       
  5515         }
  5192         }
  5516     }
  5193     }
  5517 
  5194 
  5518 // ---------------------------------------------------------------------------
  5195 // ---------------------------------------------------------------------------
  5519 // ---------------------------------------------------------------------------
  5196 // ---------------------------------------------------------------------------
  5636 	}
  5313 	}
  5637 
  5314 
  5638 // ---------------------------------------------------------------------------
  5315 // ---------------------------------------------------------------------------
  5639 // ---------------------------------------------------------------------------
  5316 // ---------------------------------------------------------------------------
  5640 // 
  5317 // 
  5641 void CAlfBridge::NotifyRosterDrawStart(CHuiDisplay& /*aDisplay*/)
       
  5642     {
       
  5643     // Do nothing
       
  5644     }
       
  5645 
       
  5646 // ---------------------------------------------------------------------------
       
  5647 // ---------------------------------------------------------------------------
       
  5648 // 
       
  5649 void CAlfBridge::NotifyRosterDrawEnd(CHuiDisplay& aDisplay)
       
  5650     {
       
  5651     TInt screenNumber = ResolveScreenNumber(aDisplay);    
       
  5652     TRAP_IGNORE(UploadSwRenderingTargetL(iAlfScreens[screenNumber]));
       
  5653     }
       
  5654 
       
  5655 // ---------------------------------------------------------------------------
       
  5656 // ---------------------------------------------------------------------------
       
  5657 // 
       
  5658 void CAlfBridge::Synchronized(TInt aId)
  5318 void CAlfBridge::Synchronized(TInt aId)
  5659     {
  5319     {
  5660     // Use P&S for now.
  5320     // Use P&S for now.
  5661     RProperty::Set( KAlfPSUidSynchronizer, KAlfPSKeySynchronizer, aId );
  5321     RProperty::Set( KAlfPSUidSynchronizer, KAlfPSKeySynchronizer, aId );
  5662     }
  5322     }
  5663 
  5323 
       
  5324 void CAlfBridge::SetWindowGroupAsAlfApp(TInt aId)
       
  5325     {
       
  5326    TBool lBreak = EFalse;
       
  5327     
       
  5328     for ( TInt j = 0; j < iAlfScreens.Count(); j++ )
       
  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);
       
  5351     }
       
  5352 
  5664 // end of file
  5353 // end of file