uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
branchRCL_3
changeset 13 3a60ebea00d0
parent 12 f93c875b566e
child 15 cd0ae4656946
equal deleted inserted replaced
12:f93c875b566e 13:3a60ebea00d0
   169 	iAlfRegisteredEffects.Close();
   169 	iAlfRegisteredEffects.Close();
   170     delete iEffectEndTimer;
   170     delete iEffectEndTimer;
   171     iDeadControlGroups.Close();
   171     iDeadControlGroups.Close();
   172     iEffectWindowGroups.Close();
   172     iEffectWindowGroups.Close();
   173     delete iFullScreenEffectData;
   173     delete iFullScreenEffectData;
       
   174     delete iSecondaryFullScreenEffectData;
   174 
   175 
   175     if (iActivated)
   176     if (iActivated)
   176         {
   177         {
   177         iBridgerClient.Close();        
   178         iBridgerClient.Close();        
   178         }
   179         }
   672                     }
   673                     }
   673                 
   674                 
   674                 if (anyVisualHasEffect)
   675                 if (anyVisualHasEffect)
   675                     {
   676                     {
   676                     TInt activeEffectHandle = iEffectCleanupStack[activeEffectIndex].iHandle;
   677                     TInt activeEffectHandle = iEffectCleanupStack[activeEffectIndex].iHandle;
       
   678                     if (iSecondaryFullScreenEffectData && iSecondaryFullScreenEffectData->iHandle == activeEffectHandle)
       
   679                         {
       
   680                         __ALFFXLOGSTRING1("CAlfBridge::DeleteControlGroupL - WARNING! Control group with 2 phase effect is being destroyed. Canceling second phase for handle %d", activeEffectHandle);
       
   681                         delete iSecondaryFullScreenEffectData;
       
   682                         iSecondaryFullScreenEffectData = NULL;
       
   683                         }
       
   684                     
   677                     __ALFFXLOGSTRING1("Layout 0x%x has external content", layout);
   685                     __ALFFXLOGSTRING1("Layout 0x%x has external content", layout);
   678                     // EHuiVisualFlagShouldDestroy destroy flag should have come for the windows in this layout already
   686                     // EHuiVisualFlagShouldDestroy destroy flag should have come for the windows in this layout already
   679                     layout->SetFlags(EHuiVisualFlagShouldDestroy);
   687                     layout->SetFlags(EHuiVisualFlagShouldDestroy);
   680                     // move this layout to effect control group, where it can still be shown. this control group may be deleted.
   688                     // move this layout to effect control group, where it can still be shown. this control group may be deleted.
   681                     CHuiControl& control = iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup->Control(0);
   689                     CHuiControl& control = iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup->Control(0);
   796         entry.iWindowGroupNodeId = aWindowGroupNodeId;
   804         entry.iWindowGroupNodeId = aWindowGroupNodeId;
   797         entry.iClientWindowGroupId = aClientWindowGroupId;  
   805         entry.iClientWindowGroupId = aClientWindowGroupId;  
   798         entry.iSecureId = aSecureId;
   806         entry.iSecureId = aSecureId;
   799         // we have received start effect for this group, but the group did not exist in alf universe at the time. hide the group.
   807         // we have received start effect for this group, but the group did not exist in alf universe at the time. hide the group.
   800         if (iFullScreenEffectData
   808         if (iFullScreenEffectData
   801                 && iFullScreenEffectData->iWaitingWindowGroup
   809                 && (iFullScreenEffectData->State() == EWaitingWindowGroup || iFullScreenEffectData->State() == EEndFullScreenReceivedWaitingWindowGroup)
   802                 && iFullScreenEffectData->iToSecureId == aSecureId)
   810                 && iFullScreenEffectData->iToSecureId == aSecureId)
   803             {
   811             {
   804             iFullScreenEffectData->iToWg = aClientWindowGroupId;
   812             iFullScreenEffectData->iToWg = aClientWindowGroupId;
       
   813             if (iSecondaryFullScreenEffectData)
       
   814                 {
       
   815                 iSecondaryFullScreenEffectData->iToWg = aClientWindowGroupId;
       
   816                 }
   805             CHuiControlGroup* fromGroup = NULL;
   817             CHuiControlGroup* fromGroup = NULL;
   806             CHuiLayout* fromLayout = NULL; 
   818             CHuiLayout* fromLayout = NULL; 
   807             fromGroup = FindControlGroupByFullScreenFromEffect();
   819             fromGroup = FindControlGroupByFullScreenFromEffect();
   808             if (fromGroup)
   820             if (fromGroup)
   809                 {
   821                 {
   813             
   825             
   814             
   826             
   815             // First HandleGfxEvent, then clear iWaitingWindowGroup.
   827             // First HandleGfxEvent, then clear iWaitingWindowGroup.
   816             __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - try triggering effect 0x%x", layout);
   828             __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - try triggering effect 0x%x", layout);
   817             TBool failed = HandleGfxEventL( *iFullScreenEffectData, layout, fromLayout );
   829             TBool failed = HandleGfxEventL( *iFullScreenEffectData, layout, fromLayout );
   818             if ( iFullScreenEffectData )
   830             if ( iFullScreenEffectData->State() == EWaitingWindowGroup)
   819                 {
   831                 {
   820                 iFullScreenEffectData->iWaitingWindowGroup = EFalse;
   832                 iFullScreenEffectData->SetState(EWaitEndFullScreen);
   821                 }
   833                 }
       
   834             else
       
   835                 {  
       
   836 				// was CFullScreenEffectState::EEndFullScreenReceivedWaitingWindowGroup           
       
   837                 iFullScreenEffectData->SetState(EEndFullscreenReceived);
       
   838                 }
       
   839             
   822             if ( failed )
   840             if ( failed )
   823                 {
   841                 {
   824                 // Effect failed, reset state
   842                 // Effect failed, reset state
   825                 __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - effect failed on layout 0x%x", layout);
   843                 __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - effect failed on layout 0x%x", layout);
   826                 HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
   844                 HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
  1284     // as it may not cover the full screen
  1302     // as it may not cover the full screen
  1285     if ( IsNonFadeEffect( aVisual.Effect() ) )
  1303     if ( IsNonFadeEffect( aVisual.Effect() ) )
  1286         {
  1304         {
  1287         return EFalse;
  1305         return EFalse;
  1288         }
  1306         }
  1289     if ( aVisual.Layout() && IsNonFadeEffect( aVisual.Layout()->Effect() ) )
  1307     
       
  1308     // Note: The long startup effect uses opaque effect to hide the background. 
       
  1309     if ( aVisual.Layout() 
       
  1310             && (IsNonFadeEffect( aVisual.Layout()->Effect() ) 
       
  1311 			&& !IsOpaqueEffect(aVisual.Layout()->Effect() ))
       
  1312             )
  1290         {
  1313         {
  1291         return EFalse;
  1314         return EFalse;
  1292         }
  1315         }
  1293 
  1316 
  1294     if (aVisual.Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)
  1317     if (aVisual.Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)
  1600         
  1623         
  1601         if ( hasLayers && iActivated )
  1624         if ( hasLayers && iActivated )
  1602             {
  1625             {
  1603             HandleLayerVisibility( layout, controlgroup, control, hasActiveVisualsInVisualTree );
  1626             HandleLayerVisibility( layout, controlgroup, control, hasActiveVisualsInVisualTree );
  1604             }
  1627             }
       
  1628         
       
  1629         TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
       
  1630         
       
  1631         // we need to set /clear inactive flags before we evaluate the fade effect,
       
  1632         // otherwise the fade effect will be removed without a reason in
       
  1633         // some use cases
       
  1634         if (isLayoutActive && !hasActiveVisualsInVisualTree && !IsOpaqueEffect(layout->Effect()))
       
  1635             {
       
  1636             // Setting also the root visual (layout) as inactive, if it had none
       
  1637 			// active children. This is because otherwise the Inactive checks won't
       
  1638 			// work correctly within RosterImpl ScanDirty & ClearChanged phases.
       
  1639 			// If root visual is having an opaque effect, it must remain active
       
  1640             layout->SetFlag(EHuiVisualFlagInactive);
       
  1641             }
       
  1642         else if(!isLayoutActive && (hasActiveVisualsInVisualTree || IsOpaqueEffect(layout->Effect())))
       
  1643             {
       
  1644             layout->ClearFlag(EHuiVisualFlagInactive);
       
  1645             layout->SetPos(fullscreen.iTl);
       
  1646             layout->SetSize(fullscreen.Size());
       
  1647             }
       
  1648  
  1605             
  1649             
  1606 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1650 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1607 		// flagged as containing fade effect, then run the setup as well so that effects which
  1651 		// flagged as containing fade effect, then run the setup as well so that effects which
  1608 		// are no more needed get removed.
  1652 		// are no more needed get removed.
  1609         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1653         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1624             else
  1668             else
  1625                 {
  1669                 {
  1626                 layout->ClearCanvasFlags(EHuiCanvasFlagExternalFadeExistsInsideVisualTree);            
  1670                 layout->ClearCanvasFlags(EHuiCanvasFlagExternalFadeExistsInsideVisualTree);            
  1627                 }
  1671                 }
  1628             }
  1672             }
  1629         
  1673                
  1630         TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
       
  1631         if (isLayoutActive && !hasActiveVisualsInVisualTree)
       
  1632             {
       
  1633             // Setting also the root visual (layout) as inactive, if it had none
       
  1634 			// active children. This is because otherwise the Inactive checks won't
       
  1635 			// work correctly within RosterImpl ScanDirty & ClearChanged phases.
       
  1636             layout->SetFlag(EHuiVisualFlagInactive);
       
  1637             }
       
  1638         else if(!isLayoutActive && hasActiveVisualsInVisualTree)
       
  1639             {
       
  1640             layout->ClearFlag(EHuiVisualFlagInactive);
       
  1641             layout->SetPos(fullscreen.iTl);
       
  1642             layout->SetSize(fullscreen.Size());
       
  1643             }
       
  1644         
       
  1645 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1674 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1646         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Control group index: %d", j );
  1675         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Control group index: %d", j );
  1647         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Active visuals : %d", activevisualcount );
  1676         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Active visuals : %d", activevisualcount );
  1648         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Passive visuals: %d", passivevisualcount );
  1677         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Passive visuals: %d", passivevisualcount );
  1649 #endif
  1678 #endif
  3335 	else
  3364 	else
  3336 		{
  3365 		{
  3337 		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
  3366 		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
  3338 		}    
  3367 		}    
  3339 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
  3368 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
  3340 	    if (iFullScreenEffectData 
  3369 	    if (iFullScreenEffectData
       
  3370 	            && !iSecondaryFullScreenEffectData
  3341 	            && iFullScreenEffectData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
  3371 	            && iFullScreenEffectData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
  3342 	            && !iFullScreenEffectData->iEndFullScreen)
  3372 	            && iFullScreenEffectData->State() == EWaitEndFullScreen
       
  3373 	            && iFullScreenEffectData->iTwoPhaseEffect != CFullScreenEffectState::ESecondPartActive)
  3343 	        {
  3374 	        {
  3344 	        CHuiControlGroup *to_group = NULL;
  3375 	        CHuiControlGroup *to_group = NULL;
  3345             if (iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
  3376             if (iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
  3346                 {
  3377                 {
  3347                 to_group = FindControlGroupByFullScreenFromEffect();
  3378                 to_group = FindControlGroupByFullScreenFromEffect();
  3368 // HandleGfxEndFullScreenTimeout
  3399 // HandleGfxEndFullScreenTimeout
  3369 // ---------------------------------------------------------------------------
  3400 // ---------------------------------------------------------------------------
  3370 // 
  3401 // 
  3371 void CAlfBridge::GfxTriggerEndFullScreen(CFullScreenEffectState* aFullScreenEffectData)
  3402 void CAlfBridge::GfxTriggerEndFullScreen(CFullScreenEffectState* aFullScreenEffectData)
  3372     {
  3403     {
  3373     if (aFullScreenEffectData->iEndFullScreen)
  3404     if (iFullScreenEffectData->State() == EFinalEffectActive)
  3374         {
  3405         {
  3375         return;
  3406         return;
  3376         }
  3407         }
  3377     CHuiControlGroup *to_group = FindControlGroupByFullScreenToEffect();
  3408     CHuiControlGroup *to_group = FindControlGroupByFullScreenToEffect();
  3378     CHuiControlGroup *from_group = FindControlGroupByFullScreenFromEffect();
  3409     CHuiControlGroup *from_group = FindControlGroupByFullScreenFromEffect();
  3397     if (to_layout)
  3428     if (to_layout)
  3398         {
  3429         {
  3399         // from layout may be undefined
  3430         // from layout may be undefined
  3400         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEndFullScreenTimeout : Enough app drawing. Trigger EndFullScreen for layout 0x%x", to_layout);    
  3431         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEndFullScreenTimeout : Enough app drawing. Trigger EndFullScreen for layout 0x%x", to_layout);    
  3401         HandleGfxEventL( *aFullScreenEffectData, to_layout, from_layout );
  3432         HandleGfxEventL( *aFullScreenEffectData, to_layout, from_layout );
  3402         }
  3433         aFullScreenEffectData->SetState(EFinalEffectActive);
  3403 
  3434         }
  3404     aFullScreenEffectData->iEndFullScreen = ETrue;
  3435 
  3405     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  3436     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  3406     }
  3437     }
  3407 
  3438 
  3408 // ---------------------------------------------------------------------------
  3439 // ---------------------------------------------------------------------------
  3409 // SetWindowActiveL
  3440 // SetWindowActiveL
  4533         }
  4564         }
  4534     }
  4565     }
  4535 
  4566 
  4536 TBool CAlfBridge::HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout *aFromLayout)
  4567 TBool CAlfBridge::HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout *aFromLayout)
  4537     {
  4568     {
  4538     __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - To SecureUid: 0x%x, From SecureUid: 0x%x", aEvent.iToSecureId, aEvent.iFromSecureId);
  4569     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEventL - To SecureUid: 0x%x, From SecureUid: 0x%x, effect %S", aEvent.iToSecureId, aEvent.iFromSecureId, aEvent.iEffectName);
  4539     __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEventL - To layout: 0x%x, From layout: 0x%x, Effect handle: %d, Action: %d", aToLayout, aFromLayout, aEvent.iHandle, aEvent.iAction);
  4570     __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEventL - To layout: 0x%x, From layout: 0x%x, Effect handle: %d, Action: %d", aToLayout, aFromLayout, aEvent.iHandle, aEvent.iAction);
       
  4571     
  4540     TInt err = KErrNone;
  4572     TInt err = KErrNone;
  4541     TBool failed = EFalse;
  4573     TBool failed = EFalse;
  4542     
  4574     
  4543     // Check if there is an effects engine in HuiEnv
  4575     // Check if there is an effects engine in HuiEnv
  4544     CHuiFxEffect* effect = NULL;
  4576     CHuiFxEffect* effect = NULL;
  4589                     case KAlfFSTaskSwapperAppStart:
  4621                     case KAlfFSTaskSwapperAppStart:
  4590                         {
  4622                         {
  4591                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that are not yet ready to be drawn, but possible already on the foreground
  4623                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that are not yet ready to be drawn, but possible already on the foreground
  4592                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  4624                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  4593                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4625                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
       
  4626                         if (iSecondaryFullScreenEffectData)
       
  4627                             {
       
  4628                             iSecondaryFullScreenEffectData->iEffectType = CFullScreenEffectState::EStartEffect; 
       
  4629                             }
       
  4630                                 
  4594                         aEvent.iCanDestroyOrHideImmediately = ETrue; // enable hiding of windows during application start/activate effects
  4631                         aEvent.iCanDestroyOrHideImmediately = ETrue; // enable hiding of windows during application start/activate effects
  4595                         break;
  4632                         break;
  4596                         }
  4633                         }
  4597                     case AknTransEffect::EApplicationExit:
  4634                     case AknTransEffect::EApplicationExit:
  4598                         {
  4635                         {
  4603                         // Effect end observer is given to engine in LoadEffectL
  4640                         // Effect end observer is given to engine in LoadEffectL
  4604                         // It will be set to effect there and called when the effect ends or is deleted
  4641                         // It will be set to effect there and called when the effect ends or is deleted
  4605 
  4642 
  4606                         // The layout should be visible at this time. if not, then this is assumed
  4643                         // The layout should be visible at this time. if not, then this is assumed
  4607                         // as effect to an background application and ignored.
  4644                         // as effect to an background application and ignored.
  4608                         if (aToLayout->Effect())
  4645 						
  4609                             {
  4646                         if (aToLayout->Effect() 
       
  4647 							&& !(aToLayout->Effect()->EffectFlags() & KHuiFadeEffectFlag ))                         
       
  4648 							{
       
  4649 							// If the exit effect took a screesnhot (above), then the layout is freezed to show the screenshot. 
       
  4650 							// Layout may not be unfrozen before EndFullScreen, or flicker will occur.
  4610                             // effect on a layout must be an application start effect. 
  4651                             // effect on a layout must be an application start effect. 
  4611                             // External content visual is not used for that.
  4652                             // External content visual is not used for that.
  4612                             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Found effect on layout 0x%x. Removing effect 0x%x", aToLayout, aToLayout->Effect());
  4653                             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Found effect on layout 0x%x. Removing effect 0x%x", aToLayout, aToLayout->Effect());
  4613                             aToLayout->SetEffect(NULL);
  4654                             aToLayout->SetEffect(NULL);
       
  4655                             aToLayout->SetFreezeState(EFalse); // Only if a screenshot was taken earlier then freeze state would be ETrue
  4614                             }
  4656                             }
       
  4657 							
  4615                         __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Layout 0x%x is active:  %d", aToLayout, !TBool(aToLayout->Flags() & EHuiVisualFlagInactive) );
  4658                         __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Layout 0x%x is active:  %d", aToLayout, !TBool(aToLayout->Flags() & EHuiVisualFlagInactive) );
  4616                         if (!(aToLayout->Flags() & EHuiVisualFlagInactive)) 
  4659                         if (!(aToLayout->Flags() & EHuiVisualFlagInactive)) 
  4617                             {
  4660                             {
  4618                             TInt index;
  4661                             TInt index;
  4619                             if (aToLayout->StoredRenderBuffer() && HasActiveEffect(aToLayout, index) && index != KErrNotFound)
  4662                             if (aToLayout->StoredRenderBuffer() 
       
  4663                                     && HasActiveEffect(aToLayout, index) 
       
  4664                                     && index != KErrNotFound)
  4620                                 {
  4665                                 {
  4621 	                            // a screenshot has been saved into the layout, and the layout was added to cleanupstack
  4666 	                            // a screenshot has been saved into the layout, and the layout was added to cleanupstack
  4622     	                        // for cleaning. SetupEffectLayoutContainerL will add the same layout 
  4667     	                        // for cleaning. SetupEffectLayoutContainerL will add the same layout 
  4623         	                    // to the cleanupstack, but double cleaning is not a good idea. Thus it is removed here. 
  4668         	                    // to the cleanupstack, but double cleaning is not a good idea. Thus it is removed here. 
  4624                                 __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Removing the layout 0x%x with screenshot from iEffectCleanupStack", aToLayout);
  4669                                 __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Removing the layout 0x%x with screenshot from iEffectCleanupStack", aToLayout);
  4632                             }
  4677                             }
  4633                         else
  4678                         else
  4634                             {
  4679                             {
  4635                             iLayoutInitializedForExitEffect = EFalse;
  4680                             iLayoutInitializedForExitEffect = EFalse;
  4636                             aEvent.iSetupDone = EFalse;
  4681                             aEvent.iSetupDone = EFalse;
  4637 							failed = ETrue;
  4682                             failed = ETrue;
       
  4683                             }
       
  4684                         if (iSecondaryFullScreenEffectData)
       
  4685                             {
       
  4686                             iSecondaryFullScreenEffectData->iSetupDone = aEvent.iSetupDone;
  4638                             }
  4687                             }
  4639                          return failed;
  4688                          return failed;
  4640                          }
  4689                          }
  4641                     default:
  4690                     default:
  4642                         break;
  4691                         break;
  4653                         aToLayout->iOpacity.Set(1.0f);
  4702                         aToLayout->iOpacity.Set(1.0f);
  4654                         }
  4703                         }
  4655                         
  4704                         
  4656                     if (aToLayout)
  4705                     if (aToLayout)
  4657                         {
  4706                         {
       
  4707                         // if this was timeout appstart effect, we need to take screenshot at this point. 
       
  4708                         // It was not taken in the beginfullscreen
       
  4709                         
       
  4710                         if (aEvent.iLongAppStartTimeout)
       
  4711                             {
       
  4712                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL  - taking screenshot for the timeout appstart effect. Handle: %d",  aEvent.iHandle );
       
  4713                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
       
  4714                             TBool neededStoredBuffers(EFalse); // dummy 
       
  4715                             StoreLayoutIfRequiredByEffectL(aToLayout, aEvent, neededStoredBuffers);
       
  4716                             }
       
  4717                         
  4658                         aToLayout->iOpacity.Set(1.0f);
  4718                         aToLayout->iOpacity.Set(1.0f);
  4659                         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - loading effect, handle %d", aEvent.iHandle );
  4719                         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - loading effect, handle %d", aEvent.iHandle );
  4660                         if (aEvent.iAction == AknTransEffect::EApplicationExit)
  4720                         if (aEvent.iAction == AknTransEffect::EApplicationExit)
  4661                             {
  4721                             {
  4662                             // Exit effect was initialized earlier with EBeginFullscreen event
  4722                             // Exit effect was initialized earlier with EBeginFullscreen event
  4666                         else
  4726                         else
  4667                         	{
  4727                         	{
  4668                             // add visuals to visual cleanupstack
  4728                             // add visuals to visual cleanupstack
  4669                             aToLayout->SetStoredRenderBufferModificationsEnabled(EFalse);
  4729                             aToLayout->SetStoredRenderBufferModificationsEnabled(EFalse);
  4670                             TInt index;
  4730                             TInt index;
  4671                             if (aToLayout->StoredRenderBuffer() && HasActiveEffect(aToLayout, index) && index != KErrNotFound)
  4731                             if (aToLayout->StoredRenderBuffer() 
       
  4732                                     && HasActiveEffect(aToLayout, index) 
       
  4733                                     && index != KErrNotFound
       
  4734                                     && aEvent.iTwoPhaseEffect != CFullScreenEffectState::ESecondPartActive // effects second phase
       
  4735                                     )
  4672                                 {
  4736                                 {
  4673 	                            // a screenshot has been saved into the layout, and the layout was added to cleanupstack
  4737 	                            // a screenshot has been saved into the layout, and the layout was added to cleanupstack
  4674     	                        // for cleaning. SetupEffectLayoutContainerL will add the same layout 
  4738     	                        // for cleaning. SetupEffectLayoutContainerL will add the same layout 
  4675         	                    // to the cleanupstack, but double cleaning is not a good idea. Thus it is removed here. 
  4739         	                    // to the cleanupstack, but double cleaning is not a good idea. Thus it is removed here. 
  4676                                 __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Removing the layout 0x%x with screenshot from iEffectCleanupStack", aToLayout);
  4740                                 __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Removing the layout 0x%x with screenshot from iEffectCleanupStack", aToLayout);
  4677                                 iEffectCleanupStack.Remove(index);
  4741                                 iEffectCleanupStack.Remove(index);
  4678                                 }
  4742                                 }
  4679                             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle,aToLayout, ETrue, EFalse, aEvent.iCanDestroyOrHideImmediately);
  4743                             if (aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive || aEvent.iSetupDone)
       
  4744                                 {
       
  4745                                 // two phase effect, setup has been made with the first part of the effect. 
       
  4746                                 // Only changing the effect is required.
       
  4747                                 layoutEffectable = ETrue; 
       
  4748                                 }
       
  4749                             else
       
  4750                                 {
       
  4751                                 layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle,aToLayout, ETrue, EFalse, aEvent.iCanDestroyOrHideImmediately);
       
  4752                                 }
  4680                             aEvent.iSetupDone = layoutEffectable; 
  4753                             aEvent.iSetupDone = layoutEffectable; 
  4681                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  4754                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  4682                             }
  4755                             }
  4683 
  4756 
  4684                         if (layoutEffectable)
  4757                         if (layoutEffectable)
  4688                             if (activeEffectGroup != KErrNotFound)
  4761                             if (activeEffectGroup != KErrNotFound)
  4689                                 {
  4762                                 {
  4690                                 engine->AddEffectToGroup(activeEffectGroup);
  4763                                 engine->AddEffectToGroup(activeEffectGroup);
  4691                                 }
  4764                                 }
  4692                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Active effect group: %d", activeEffectGroup);
  4765                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Active effect group: %d", activeEffectGroup);
  4693                             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn; 
  4766                             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
  4694                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName))
  4767                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName) ||
       
  4768                                     aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive)
  4695                                 {
  4769                                 {
  4696                                 // Performance improvement, but this would be better to be a special hint param in the fxml
       
  4697                                 effectFlags |= KHuiFxOpaqueHint;
  4770                                 effectFlags |= KHuiFxOpaqueHint;
       
  4771                                 }
       
  4772                             if (iSecondaryFullScreenEffectData)
       
  4773                                 {
       
  4774                                 iSecondaryFullScreenEffectData->iSetupDone = ETrue;
  4698                                 }
  4775                                 }
  4699                             
  4776                             
  4700                             if (aEvent.iRect != TRect())
  4777                             if (aEvent.iRect != TRect())
  4701                                 {
  4778                                 {
  4702                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), activeEffectGroup, &aEvent.iRect, this, aEvent.iHandle, effectFlags ));
  4779                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), activeEffectGroup, &aEvent.iRect, this, aEvent.iHandle, effectFlags ));
  4705                                 {
  4782                                 {
  4706                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), activeEffectGroup, NULL, this, aEvent.iHandle, effectFlags ) );
  4783                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), activeEffectGroup, NULL, this, aEvent.iHandle, effectFlags ) );
  4707                                 }
  4784                                 }
  4708                             effect = NULL;
  4785                             effect = NULL;
  4709                             // only use the effect if the effect file was correctly parsed
  4786                             // only use the effect if the effect file was correctly parsed
       
  4787                             aToLayout->SetFreezeState(EFalse);
       
  4788                                                             
  4710                             if (err != KErrNone)
  4789                             if (err != KErrNone)
  4711                                 {
  4790                                 {
  4712                                 // visuals added to "active effect visual" stack, but they wont be used, because effect loading has failed. cleanup.
  4791                                 // visuals added to "active effect visual" stack, but they wont be used, because effect loading has failed. cleanup.
  4713                                 RemoveTemporaryPresenterVisual(NULL, aEvent.iHandle);
  4792                                 RemoveTemporaryPresenterVisual(NULL, aEvent.iHandle);
  4714                                 aToLayout->SetEffect(NULL);
  4793                                 aToLayout->SetEffect(NULL);
  4729                 // just in case...
  4808                 // just in case...
  4730                 break;
  4809                 break;
  4731                 }
  4810                 }
  4732             }
  4811             }
  4733         }
  4812         }
  4734     iLastAction = aEvent.iAction; // TODO: useless?
  4813     
       
  4814     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  4735     return failed;
  4815     return failed;
  4736     }
  4816     }
  4737 
  4817 
  4738 void CAlfBridge::FreezeLayoutUntilEffectDestroyedL(CHuiLayout* aLayout, TInt aHandle)
  4818 void CAlfBridge::FreezeLayoutUntilEffectDestroyedL(CHuiLayout* aLayout, TInt aHandle)
  4739     {
  4819     {
  4792         // Aborted errornously, signal client side
  4872         // Aborted errornously, signal client side
  4793         RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, fxData->iCompletionHandle );
  4873         RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, fxData->iCompletionHandle );
  4794         }
  4874         }
  4795     
  4875     
  4796     CleanupStack::PopAndDestroy( fxData );
  4876     CleanupStack::PopAndDestroy( fxData );
       
  4877     delete iSecondaryFullScreenEffectData;
       
  4878     iSecondaryFullScreenEffectData = NULL;
  4797     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END");
  4879     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END");
  4798     }
  4880     }
  4799 
  4881 
  4800 void CAlfBridge::RemoveEffectFromApp(TInt aSecureId, TInt aWgId )
  4882 void CAlfBridge::RemoveEffectFromApp(TInt aSecureId, TInt aWgId )
  4801     {
  4883     {
  4897                 RemoveEffectFromApp(iFullScreenEffectData->iToAppId);
  4979                 RemoveEffectFromApp(iFullScreenEffectData->iToAppId);
  4898                 // Fullscreen effect for another 
  4980                 // Fullscreen effect for another 
  4899                 }
  4981                 }
  4900 
  4982 
  4901                delete iFullScreenEffectData;
  4983                delete iFullScreenEffectData;
       
  4984                delete iSecondaryFullScreenEffectData;
       
  4985                iSecondaryFullScreenEffectData = NULL;
  4902             iFullScreenEffectData = fxData;
  4986             iFullScreenEffectData = fxData;
  4903             iFullScreenEffectData->iAppStartScreenshotItemHandle = fxData->iHandle;
  4987             iFullScreenEffectData->iAppStartScreenshotItemHandle = fxData->iHandle;
  4904             
  4988             
  4905             stream.Release();
  4989             stream.Release();
  4906             }
  4990             }
  4912             
  4996             
  4913             __ALFFXLOGSTRING("HandleGfxEffectsL - END: ongoing");
  4997             __ALFFXLOGSTRING("HandleGfxEffectsL - END: ongoing");
  4914             
  4998             
  4915             // Client expects completion to be signalled with this handle.
  4999             // Client expects completion to be signalled with this handle.
  4916             iFullScreenEffectData->iCompletionHandle = stream.ReadInt32L();
  5000             iFullScreenEffectData->iCompletionHandle = stream.ReadInt32L();
       
  5001             if (iSecondaryFullScreenEffectData)
       
  5002                 {
       
  5003                 // Two phase effect path has been chosen. First part is now ongoing, and second part will be 
       
  5004                 // triggered after that. Client has now notified, that its screen is ready. We may trigger the 
       
  5005                 // second effect as soon as the first part finishes.
       
  5006                 __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Trigger second part. when 1st part done.");
       
  5007                 iSecondaryFullScreenEffectData->iCompletionHandle = iFullScreenEffectData->iCompletionHandle;
       
  5008                 }
  4917             
  5009             
  4918             stream.Release();           
  5010             stream.Release();           
  4919             return ; 
  5011             return ; 
  4920             }
  5012             }
  4921         }
  5013         }
  4922     else // MAlfGfxEffectPlugin::EEndFullscreen
  5014     else // MAlfGfxEffectPlugin::EEndFullscreen
  4923         {
  5015         {
  4924         // End fullscreen signal received. We proceed only if there is really
  5016         // End fullscreen signal received. We proceed only if there is really
  4925         // effect ongoing and "end fullscreen" hasn't already been processed.
  5017         // effect ongoing and "end fullscreen" hasn't already been processed.
  4926         
  5018         
  4927         if ( !iFullScreenEffectData || iFullScreenEffectData->iEndFullScreen )
  5019         if ( !iFullScreenEffectData 
  4928             {
  5020                 || iFullScreenEffectData->State() == EFinalEffectActive
  4929             __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - END: fx ready");
  5021                 || iFullScreenEffectData->State() == EEndFullscreenReceived)
       
  5022             {
       
  5023             if (iFullScreenEffectData)
       
  5024             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEffectsL - END: fx ready, state %d ", iFullScreenEffectData->State());
       
  5025             stream.Release();
  4930             return;
  5026             return;
  4931             }
  5027             }
  4932 			// Load the whole structure. If timeout was triggered then request effect name
  5028         CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
  4933 			// is updated.
  5029         CleanupStack::PushL( fxData );
  4934             CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
  5030         fxData->ConstructL( KErrUnknown, stream );
  4935             CleanupStack::PushL( fxData );
  5031         
  4936             fxData->ConstructL( action, stream );
  5032         TBool timeout = fxData->iTimeout;
  4937             iFullScreenEffectData->iTimeoutTriggered = fxData->iTimeoutTriggered;    
  5033         // could the application be ready?
  4938             if (fxData->iTimeoutTriggered)
  5034         TBool applicationExists = FindControlGroupByFullScreenToEffect() != NULL ? ETrue : EFalse;
  4939                 {
  5035 
  4940                 delete iFullScreenEffectData->iEffectName;
  5036         // It may be, that application exited already and it was moved already to effect group
  4941                 iFullScreenEffectData->iEffectName = NULL;
  5037         if (iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect && !applicationExists )
  4942                 iFullScreenEffectData->iEffectName = fxData->iEffectName->AllocL();
  5038             {
       
  5039             applicationExists = FindLayoutByEffectHandle(fxData->iHandle) != NULL ? ETrue : EFalse;
       
  5040             }
  4943                 
  5041                 
  4944                 }
  5042         TBool longAppStartTimeout = fxData->iLongAppStartTimeout; 
  4945             CleanupStack::PopAndDestroy( fxData );
  5043         
  4946             fxData = NULL;
  5044         if (iFullScreenEffectData &&
  4947         
  5045                 !iSecondaryFullScreenEffectData && // second part has not been requested yet
  4948         __ALFFXLOGSTRING("HandleGfxEffectsL - process end");
  5046                 longAppStartTimeout && // this is indeed timeout for app start effect
  4949         iFullScreenEffectData->iEndFullScreen = ETrue;
  5047                 iFullScreenEffectData->iTwoPhaseEffect == CFullScreenEffectState::EOnlyOnePart && // second part has not been activated. note, that iSecondaryFullScreenEffectData would be NULL in this case 
  4950 
  5048                 (iFullScreenEffectData->State() == EWaitEndFullScreen 
  4951 #ifdef USE_APPLICATION_ENDFULLSCREEN_TIMEOUT		
  5049                  || iFullScreenEffectData->State() == EWaitingWindowGroup))
  4952         if (iFullScreenEffectData->iDrawingCompleteTimer)
  5050             {
  4953             {
  5051             // Load the whole structure. If timeout was triggered then request effect name to be
  4954             iFullScreenEffectData->iDrawingCompleteTimer->Cancel();
  5052             // updated.
  4955             }
  5053             UpdateSecondaryEffectL(*fxData);
  4956 #endif			
  5054             iFullScreenEffectData->iLongAppStartTimeout = fxData->iLongAppStartTimeout;
  4957         stream.Release();
  5055             iFullScreenEffectData->iTwoPhaseEffect = CFullScreenEffectState::EFirstPartActive;
       
  5056             iFullScreenEffectData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
       
  5057             }
       
  5058 
       
  5059         __ALFFXLOGSTRING4("HandleGfxEffectsL - iTwoPhaseEffect %d, Setup done: %d, Timeout: %d, long app start timeout: %d", iFullScreenEffectData->iTwoPhaseEffect,iFullScreenEffectData->iSetupDone, timeout,longAppStartTimeout);
       
  5060         if (!fxData->iLongAppStartTimeout) // endfullscreen originating from the application
       
  5061             {
       
  5062             if (iFullScreenEffectData->State() == EWaitingWindowGroup)
       
  5063                 {
       
  5064                 iFullScreenEffectData->SetState(EEndFullScreenReceivedWaitingWindowGroup);
       
  5065                 }
       
  5066             else
       
  5067                 {
       
  5068                 iFullScreenEffectData->SetState(EEndFullscreenReceived);
       
  5069                 }
       
  5070             
       
  5071             if (iSecondaryFullScreenEffectData)
       
  5072                 {
       
  5073                 iSecondaryFullScreenEffectData->SetState(EEndFullscreenReceived);
       
  5074                 }
       
  5075             
       
  5076             }
       
  5077         CleanupStack::PopAndDestroy( fxData );
       
  5078         fxData = NULL;
       
  5079         
       
  5080         __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEffectsL - Regular timeout: %d, Slow start timeout: %d, Effect setup: %d, State: %d",
       
  5081                 timeout,
       
  5082                 longAppStartTimeout,
       
  5083                 iFullScreenEffectData->iSetupDone,
       
  5084                 iFullScreenEffectData->State());
       
  5085 
       
  5086         stream.Release();// We should respect normal timeouts.
       
  5087         if (iFullScreenEffectData->iTwoPhaseEffect > CFullScreenEffectState::EOnlyOnePart
       
  5088                 && iFullScreenEffectData->iSetupDone && timeout && longAppStartTimeout) // timeout = endfullscreen was requested or it was normal endfullscreen timeout, longAppStartTime = 
       
  5089             {
       
  5090             // If this is two phased effect, it can be started only by application request of endfullscreen (!timeout)
       
  5091             // or screen drawn (triggered from 
       
  5092             __ALFFXLOGSTRING("HandleGfxEffectsL - Two phase effect. Waiting second part to start. Skip this event.");
       
  5093             return;
       
  5094             }
       
  5095         
       
  5096         // If client triggered EndFullScreen has been received, and still we haven't seen sign of the application, we know
       
  5097         // things have gone wrong and will not go right. Clean up the mess.
       
  5098         if (iFullScreenEffectData->State() == EEndFullscreenReceived && !applicationExists && !timeout)
       
  5099             {
       
  5100             HandleGfxStopEvent(ETrue);
       
  5101             return;
       
  5102             }
  4958         }
  5103         }
  4959 
  5104 
  4960     CFullScreenEffectState* fxData = iFullScreenEffectData;
  5105     CFullScreenEffectState* fxData = iFullScreenEffectData;
  4961     fxData->iOperation = operation;
  5106     fxData->iOperation = operation;
  4962     fxData->iWaitingWindowGroup = EFalse;
       
  4963 
  5107 
  4964     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEffectsL - Operation: %d, handle: %d, type: %d", operation, fxData->iHandle, fxData->iType);
  5108     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEffectsL - Operation: %d, handle: %d, type: %d", operation, fxData->iHandle, fxData->iType);
  4965     __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - towg: %d, fromwg: %d", fxData->iToWg, fxData->iFromWg);
  5109     __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - towg: %d, fromwg: %d", fxData->iToWg, fxData->iFromWg);
  4966 
  5110 
  4967     CHuiControlGroup* toGroup = NULL;
  5111     CHuiControlGroup* toGroup = NULL;
  4992             }
  5136             }
  4993         
  5137         
  4994         if (toLayout)
  5138         if (toLayout)
  4995             {
  5139             {
  4996             failed = HandleGfxEventL(*fxData, toLayout, fromLayout);
  5140             failed = HandleGfxEventL(*fxData, toLayout, fromLayout);
       
  5141             // We found layout, and this was beginfullscreen event. Wait for endfullscreen to be triggered
       
  5142             if (fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen)
       
  5143                 {
       
  5144                 iFullScreenEffectData->SetState(EWaitEndFullScreen);
       
  5145                 }
  4997             }
  5146             }
  4998         else
  5147         else
  4999             {
  5148             {
  5000             __ALFFXLOGSTRING("HandleGfxEffectsL - waiting window group");            
  5149             __ALFFXLOGSTRING("HandleGfxEffectsL - waiting window group");            
  5001             fxData->iWaitingWindowGroup = ETrue;
  5150             fxData->SetState(EWaitingWindowGroup);
  5002             }
  5151             }
  5003         }
  5152         }
  5004 
  5153 
  5005     if ( failed )
  5154     if ( failed )
  5006         {
  5155         {
  5028     iHuiEnv->ContinueRefresh();
  5177     iHuiEnv->ContinueRefresh();
  5029 
  5178 
  5030     __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - END");
  5179     __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - END");
  5031     }
  5180     }
  5032 
  5181 
       
  5182 TBool CAlfBridge::UpdateSecondaryEffectL(const CFullScreenEffectState& aState)
       
  5183     {
       
  5184     
       
  5185     __ALFFXLOGSTRING1("CAlfBridge::UpdateSecondaryEffectL - appstart timeout triggered: %d", aState.iLongAppStartTimeout);
       
  5186     if (aState.iLongAppStartTimeout) // only application start effects can trigger this timeout 
       
  5187         {
       
  5188         // clone the primary startup effect for later usage
       
  5189         delete iSecondaryFullScreenEffectData;
       
  5190         iSecondaryFullScreenEffectData = new (ELeave) CFullScreenEffectState;
       
  5191         iSecondaryFullScreenEffectData->ConstructL(*iFullScreenEffectData);
       
  5192         iSecondaryFullScreenEffectData->iLongAppStartTimeout = EFalse;
       
  5193         
       
  5194         delete iFullScreenEffectData->iEffectName;
       
  5195         iFullScreenEffectData->iEffectName = NULL;
       
  5196         iFullScreenEffectData->iEffectName = aState.iEffectName->AllocL();
       
  5197         }
       
  5198     __ALFFXLOGSTRING("CAlfBridge::UpdateSecondaryEffectL <<" );
       
  5199     return EFalse;
       
  5200     }    
       
  5201 
  5033 TBool CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn(CHuiControlGroup* aToGroup)
  5202 TBool CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn(CHuiControlGroup* aToGroup)
  5034     {
  5203     {
  5035     if (!aToGroup || (aToGroup && aToGroup->Count() == 0))
  5204     if (!aToGroup || (aToGroup && aToGroup->Count() == 0))
  5036         {
  5205         {
  5037         return EFalse;
  5206         return EFalse;
  5038         }
  5207         }
  5039       iTempRegion.Clear();
  5208     iTempRegion.Clear();
  5040     
  5209     
  5041     CAlfScreen* screen = iAlfScreens[0];
  5210     CAlfScreen* screen = iAlfScreens[0];
  5042     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
  5211     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
  5043     TBool fullscreenCovered(EFalse);
  5212     TBool fullscreenCovered(EFalse);
  5044     TInt dummy = 0;
  5213     TInt dummy = 0;
  5051         return EFalse;
  5220         return EFalse;
  5052         }
  5221         }
  5053     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
  5222     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
  5054     IsFullScreenDrawnRecursive(toLayout, *aToGroup, control, fullscreenCovered, fullscreen, screen, dummy, opaque, iAlfScreens[0]->iDisplay->Orientation());
  5223     IsFullScreenDrawnRecursive(toLayout, *aToGroup, control, fullscreenCovered, fullscreen, screen, dummy, opaque, iAlfScreens[0]->iDisplay->Orientation());
  5055     fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
  5224     fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
       
  5225     // alf content check is relavant only for alf apps
       
  5226     if (!fullscreenCovered && aToGroup->iAlfApp) 
       
  5227         {
       
  5228         TInt clientGroupId = FindClientWindowGroupId(0, *aToGroup);
       
  5229         if (clientGroupId != KErrNotFound)
       
  5230             {
       
  5231             fullscreenCovered = HasActiveAlfContent(clientGroupId);
       
  5232             }
       
  5233         }
       
  5234     
  5056     __ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - Covered: %d", fullscreenCovered);
  5235     __ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - Covered: %d", fullscreenCovered);
  5057     if (fullscreenCovered)
  5236     if (fullscreenCovered)
  5058         {
  5237         {
  5059         GfxTriggerEndFullScreen(iFullScreenEffectData);
  5238         GfxTriggerEndFullScreen(iFullScreenEffectData);
  5060         return ETrue;
  5239         return ETrue;
  5458             RecursiveStoreRenderBufferL(aCanvasVisual);
  5637             RecursiveStoreRenderBufferL(aCanvasVisual);
  5459             }
  5638             }
  5460 
  5639 
  5461         // clear out old effect if this visual has one
  5640         // clear out old effect if this visual has one
  5462         __ALFFXLOGSTRING2("HandleGfxControlEffectsL - loading effect %S on visual 0x%x", aEvent.iEffectName, aCanvasVisual );
  5641         __ALFFXLOGSTRING2("HandleGfxControlEffectsL - loading effect %S on visual 0x%x", aEvent.iEffectName, aCanvasVisual );
  5463         __ALFFXLOGSTRING1("HandleGfxControlEffectsL - loading control effect, handle %d", aEvent.iHandle );
  5642         __ALFFXLOGSTRING2("HandleGfxControlEffectsL - loading control effect, handle %d, Action: %d", aEvent.iHandle, aEvent.iAction );
  5464         if (aCanvasVisual->Effect())
  5643         if (aCanvasVisual->Effect())
  5465             {
  5644             {
  5466             __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x has active effect. Requesting removal.", aCanvasVisual);
  5645             __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x has active effect. Requesting removal.", aCanvasVisual);
  5467             // another effect coming to already effected visual. E.g. close options menu, while opening effect still ongoing
  5646             // another effect coming to already effected visual. E.g. close options menu, while opening effect still ongoing
  5468             RemoveTemporaryPresenterVisual(aCanvasVisual);
  5647             RemoveTemporaryPresenterVisual(aCanvasVisual);
  5469             }
  5648             }
  5470         TBool layoutEffectable(EFalse);
  5649         TBool layoutEffectable(EFalse);
  5471         if (aEvent.iAction == KGfxControlDisappearAction)
  5650         if (aEvent.iAction == KGfxControlDisappearAction)
  5472             { // TODO: revise
  5651             {
  5473             // The control stays visible because the inactive flag is not set
  5652             if (aCanvasVisual->Flags() & EHuiVisualFlagInactive)
  5474             // if the window is reserved.
  5653                 {
  5475             /*if (aCanvasVisual->iOpacity.Target() == 0.0f)
  5654                 __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x is inactive. Skipping effect.", aCanvasVisual);
  5476                 {
  5655                 return;
  5477                 // this visual was hidden, before the effect arrived. sounds like trouble.
  5656                 }
  5478                 // Lets make it visible again, and ask it to be hidden in the end of the effect
       
  5479                 // this enables at least the notes disappear effects
       
  5480                 aCanvasVisual->iOpacity.Set(KAlfVisualDefaultOpacity);
       
  5481                 // visual->SetFlag(EHuiVisualFlagShouldBeHidden);
       
  5482                 }*/
       
  5483             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, ETrue, EFalse);
  5657             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, ETrue, EFalse);
  5484             }
  5658             }
  5485         else
  5659         else
  5486             {
  5660             {
  5487             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, EFalse, EFalse);
  5661             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, EFalse, EFalse);
  5508             {
  5682             {
  5509             err = KErrNotFound;
  5683             err = KErrNotFound;
  5510             }
  5684             }
  5511         //            RDebug::Print(_L("HandleGfxControlEffectsL - loading effect returned %d"), err );
  5685         //            RDebug::Print(_L("HandleGfxControlEffectsL - loading effect returned %d"), err );
  5512         // only use the effect if the effect file was correctly parsed
  5686         // only use the effect if the effect file was correctly parsed
       
  5687         aCanvasVisual->SetFreezeState(EFalse);
       
  5688                   
  5513         if (err == KErrNone)
  5689         if (err == KErrNone)
  5514             {
  5690             {
  5515             iLastEffectHandle = aEvent.iHandle;
       
  5516 
       
  5517 #ifdef HUI_DEBUG_TRACK_DRAWING  
  5691 #ifdef HUI_DEBUG_TRACK_DRAWING  
  5518             visual->SetTracking(ETrue);
  5692             visual->SetTracking(ETrue);
  5519 #endif                
  5693 #endif                
  5520             // HuiVisual takes ownership of the effect, but we save the value for reference
  5694             // HuiVisual takes ownership of the effect, but we save the value for reference
  5521             // add new visual to iFullscreenEffectControlGroup. This enables multiple effects in the group, and their 
  5695             // add new visual to iFullscreenEffectControlGroup. This enables multiple effects in the group, and their 
  5826     // If there are already other handles in the queue, the handler will not
  6000     // If there are already other handles in the queue, the handler will not
  5827     // be called for this handle, but all handles that have been left hanging
  6001     // be called for this handle, but all handles that have been left hanging
  5828     // around will be cleared when HandleGfxStopEffectsL is called
  6002     // around will be cleared when HandleGfxStopEffectsL is called
  5829 
  6003 
  5830     // iFinishedCleanupStackEffects.Append(aHandle);
  6004     // iFinishedCleanupStackEffects.Append(aHandle);
       
  6005     
       
  6006 	// check if the first part of application start effect finished
       
  6007     if (iFullScreenEffectData 
       
  6008             && iFullScreenEffectData->iHandle == aHandle
       
  6009             && iFullScreenEffectData->iLongAppStartTimeout && iSecondaryFullScreenEffectData)
       
  6010         {
       
  6011         delete iFullScreenEffectData;
       
  6012         iFullScreenEffectData = iSecondaryFullScreenEffectData;
       
  6013         iSecondaryFullScreenEffectData = NULL;
       
  6014         iFullScreenEffectData->iTwoPhaseEffect = CFullScreenEffectState::ESecondPartActive;
       
  6015         if (iFullScreenEffectData->State() == EEndFullscreenReceived)
       
  6016             {
       
  6017             // Client notified of the EndFullScreen during the effect. Trigger the end part immediately.
       
  6018             __ALFFXLOGSTRING("CAlfBridge::AlfGfxEffectEndCallBack - End was received. Trigger second part.");
       
  6019             iFullScreenEffectData->SetState(ESecondPhaseSetupActive); // effect setup will be skipped in HandleGfxEvent
       
  6020             GfxTriggerEndFullScreen(iFullScreenEffectData);
       
  6021             iFullScreenEffectData->SetState(EFinalEffectActive);
       
  6022 			// skip cleanup. It will be run, when this effect finishes
       
  6023             return;
       
  6024             }
       
  6025         else
       
  6026             {
       
  6027             iFullScreenEffectData->SetState(EWaitEndFullScreen);
       
  6028             }
       
  6029         
       
  6030         iFullScreenEffectData->iEffectType = CFullScreenEffectState::EStartEffect;
       
  6031         
       
  6032         CHuiControlGroup* toGroup = FindControlGroupByFullScreenToEffect();
       
  6033         GfxTriggerEffectWhenFullScreenDrawn(toGroup);
       
  6034         return;
       
  6035         }
       
  6036     
  5831     if (!iEffectEndTimer->IsActive())
  6037     if (!iEffectEndTimer->IsActive())
  5832         {
  6038         {
  5833         TRAP_IGNORE(iEffectEndTimer->AddFinishedHandleL(aHandle));
  6039         TRAP_IGNORE(iEffectEndTimer->AddFinishedHandleL(aHandle));
  5834         iEffectEndTimer->Start(KEffectCleanupDelayInMs * 1000);
  6040         iEffectEndTimer->Start(KEffectCleanupDelayInMs * 1000);
  5835         }
  6041         }
  5872     // Effect finished
  6078     // Effect finished
  5873     if ( fsEffectDone )
  6079     if ( fsEffectDone )
  5874         {
  6080         {
  5875         delete iFullScreenEffectData;
  6081         delete iFullScreenEffectData;
  5876         iFullScreenEffectData = NULL;
  6082         iFullScreenEffectData = NULL;
       
  6083         
       
  6084         delete iSecondaryFullScreenEffectData;
       
  6085         iSecondaryFullScreenEffectData = NULL;
  5877         }
  6086         }
  5878     }
  6087     }
  5879     
  6088     
  5880 
  6089 
  5881 void CAlfBridge::PrintAllocMem()
  6090 void CAlfBridge::PrintAllocMem()
  6920         {
  7129         {
  6921         iManualRefreshTimer->Start(KAlfManualRefreshTimeout, KAlfManualRefreshTimeout, TCallBack(DoAlfBridgeRefreshNow, this));
  7130         iManualRefreshTimer->Start(KAlfManualRefreshTimeout, KAlfManualRefreshTimeout, TCallBack(DoAlfBridgeRefreshNow, this));
  6922         }
  7131         }
  6923     }
  7132     }
  6924 
  7133 
       
  7134 TBool CAlfBridge::HasActiveAlfContent( TInt aClientWgId )
       
  7135     {
       
  7136     TBool hasAlfContent = EFalse;
       
  7137     if(iAppUi)
       
  7138         {
       
  7139         CAlfAppSrvSessionBase* activeAlfSession = iAppUi->ActiveSession();
       
  7140         CAlfScreen* screen = iAlfScreens[0];
       
  7141         for(TInt i = 0 ; i < screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount() ; i++)
       
  7142             {
       
  7143             CHuiControlGroup& controlgroup = screen->iDisplay->Roster().ControlGroup(i);
       
  7144             CHuiControl& control = controlgroup.Control(0);
       
  7145             if (control.Role() == EHuiSessionContainer)
       
  7146                 {
       
  7147                 CAlfAppSrvSessionBase* alfSrvSession = iAppUi->SrvSessionForControlGroup(controlgroup);
       
  7148                 if(alfSrvSession && 
       
  7149                    (alfSrvSession->ClientWindowGroup() == aClientWgId))
       
  7150                     {
       
  7151                     hasAlfContent = ETrue;
       
  7152                     break;
       
  7153                     }
       
  7154                 }
       
  7155             }
       
  7156         }
       
  7157     return hasAlfContent;
       
  7158     }
       
  7159 
  6925 // end of file
  7160 // end of file