uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
changeset 31 1b6909418757
parent 29 ac3859d43844
child 38 69409653e863
equal deleted inserted replaced
30:920e03da86f0 31:1b6909418757
   107 const TUid KPSSysCategory = { KUidSystemCategoryValue };
   107 const TUid KPSSysCategory = { KUidSystemCategoryValue };
   108 const TUint32 KAlfPSKeyHSVisible = 0x2002EA91;
   108 const TUint32 KAlfPSKeyHSVisible = 0x2002EA91;
   109 
   109 
   110 const TInt KFadeAction = 6000;
   110 const TInt KFadeAction = 6000;
   111 
   111 
       
   112 // IsLayoutSwitchReady heuristic constants:
       
   113 
       
   114 // Duration to wait that visual display rects are fully inside fullscreen rect. 
       
   115 // 1 unit = 50ms.
       
   116 const TInt KAlfCheckVisualDisplayRect = 15;
       
   117 
       
   118 // Duration to wait that visual has drawing inside screen area.
       
   119 const TInt KAlfCheckVisualDrawRect = 15;
       
   120 
       
   121 // Duration to wait that visual has drawing that covers the whole display rect.
       
   122 const TInt KAlfCheckVisualDrawingComplete = 20;
       
   123 
       
   124 // Duration to wait that visual has some drawing (not necessarily complete).
       
   125 const TInt KAlfCheckVisualDrawingNotEmpty = 28;
       
   126 
       
   127 // Duration to wait that fullscreen is covered by visual drawing.
       
   128 const TInt KAlfCheckFullscreenCoveredByVisualDrawing = 50;
       
   129 
       
   130 // Duration to wait if coverage is modified by multiple control groups.
       
   131 // This may indicate that topmost application hasn't yet had time to update
       
   132 // its layout properly.
       
   133 const TInt KAlfCheckCoverageFromMultipleGroups = 20;
       
   134 
       
   135 
   112 NONSHARABLE_CLASS( TAlfBridgeDrawerWrapper ) : public MAlfDrawerScreenInterface
   136 NONSHARABLE_CLASS( TAlfBridgeDrawerWrapper ) : public MAlfDrawerScreenInterface
   113     {
   137     {
   114 public:
   138 public:
   115     TAlfBridgeDrawerWrapper(CAlfBridge& aBridge);
   139     TAlfBridgeDrawerWrapper(CAlfBridge& aBridge);
   116     TInt GetSizeAndRotation(TSize& aSize, TInt& aRotation);
   140     TInt GetSizeAndRotation(TSize& aSize, TInt& aRotation);
   156 // ---------------------------------------------------------------------------
   180 // ---------------------------------------------------------------------------
   157 // ---------------------------------------------------------------------------
   181 // ---------------------------------------------------------------------------
   158 // 
   182 // 
   159 CAlfBridge::~CAlfBridge()
   183 CAlfBridge::~CAlfBridge()
   160 	{
   184 	{
       
   185     iTempRegion2.Close();
       
   186     
   161     iAlfNativeClientsWgIds.Close();
   187     iAlfNativeClientsWgIds.Close();
   162 	delete iOrphanStorage;
   188 	delete iOrphanStorage;
   163 	delete iFadeEffectFile;
   189 	delete iFadeEffectFile;
   164 	iWindowHashArray.Close();
   190 	iWindowHashArray.Close();
   165 	for( TInt i = 0; i< iAlfRegisteredEffects.Count(); i++ )
   191 	for( TInt i = 0; i< iAlfRegisteredEffects.Count(); i++ )
   168 	    }
   194 	    }
   169 	iAlfRegisteredEffects.Close();
   195 	iAlfRegisteredEffects.Close();
   170     delete iEffectEndTimer;
   196     delete iEffectEndTimer;
   171     iDeadControlGroups.Close();
   197     iDeadControlGroups.Close();
   172     iEffectWindowGroups.Close();
   198     iEffectWindowGroups.Close();
   173     delete iFullScreenEffectData;
   199     delete iFSFxData;
   174     delete iSecondaryFullScreenEffectData;
   200     delete iFSFXDataPart2;
   175 
   201 
   176     if (iActivated)
   202     if (iActivated)
   177         {
   203         {
   178         iBridgerClient.Close();        
   204         iBridgerClient.Close();        
   179         }
   205         }
   553 // FindControlGroupByFullScreenToEffect
   579 // FindControlGroupByFullScreenToEffect
   554 // ---------------------------------------------------------------------------
   580 // ---------------------------------------------------------------------------
   555 //
   581 //
   556 CHuiControlGroup* CAlfBridge::FindControlGroupByFullScreenToEffect() const
   582 CHuiControlGroup* CAlfBridge::FindControlGroupByFullScreenToEffect() const
   557     {
   583     {
   558     if ( iFullScreenEffectData )
   584     if ( iFSFxData )
   559         {
   585         {
   560         return FindControlGroupBySecureId( iFullScreenEffectData->iToSecureId, iFullScreenEffectData->iToWg ); 
   586         return FindControlGroupBySecureId( iFSFxData->iToSecureId, iFSFxData->iToWg ); 
   561         }
   587         }
   562     return NULL;
   588     return NULL;
   563     }
   589     }
   564 
   590 
   565 // ---------------------------------------------------------------------------
   591 // ---------------------------------------------------------------------------
   566 // FindControlGroupByFullScreenFromEffect
   592 // FindControlGroupByFullScreenFromEffect
   567 // ---------------------------------------------------------------------------
   593 // ---------------------------------------------------------------------------
   568 //
   594 //
   569 CHuiControlGroup* CAlfBridge::FindControlGroupByFullScreenFromEffect() const
   595 CHuiControlGroup* CAlfBridge::FindControlGroupByFullScreenFromEffect() const
   570     {
   596     {
   571     if ( iFullScreenEffectData )
   597     if ( iFSFxData )
   572         {
   598         {
   573         return FindControlGroupBySecureId( iFullScreenEffectData->iFromSecureId, iFullScreenEffectData->iFromWg );
   599         return FindControlGroupBySecureId( iFSFxData->iFromSecureId, iFSFxData->iFromWg );
   574         }
   600         }
   575     return NULL;
   601     return NULL;
   576     }
   602     }
   577 
   603 
   578 // ---------------------------------------------------------------------------
   604 // ---------------------------------------------------------------------------
   601 // ---------------------------------------------------------------------------
   627 // ---------------------------------------------------------------------------
   602 // 
   628 // 
   603 void CAlfBridge::ResolveAfterEffectAppearingApplicationL(CHuiControlGroup* aGroup)
   629 void CAlfBridge::ResolveAfterEffectAppearingApplicationL(CHuiControlGroup* aGroup)
   604     {
   630     {
   605 #ifdef USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
   631 #ifdef USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
   606     if (iFullScreenEffectData && iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
   632     if (iFSFxData && iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect)
   607         {
   633         {
   608         CHuiControlGroup *exitingGroupInEffect = FindControlGroupByFullScreenToEffect();
   634         CHuiControlGroup *exitingGroupInEffect = FindControlGroupByFullScreenToEffect();
   609         if (exitingGroupInEffect == aGroup)
   635         if (exitingGroupInEffect == aGroup)
   610             {
   636             {
   611             CHuiRoster& roster = iAlfScreens[0]->iDisplay->Roster();
   637             CHuiRoster& roster = iAlfScreens[0]->iDisplay->Roster();
   625                 {
   651                 {
   626                 for(TInt j = 0 ; j < iAlfScreens[0]->iControlGroups.Count() - 1 ; j++)
   652                 for(TInt j = 0 ; j < iAlfScreens[0]->iControlGroups.Count() - 1 ; j++)
   627                     {
   653                     {
   628                     if (iAlfScreens[0]->iControlGroups[j].iControlGroup == nextToBecomeVisible)
   654                     if (iAlfScreens[0]->iControlGroups[j].iControlGroup == nextToBecomeVisible)
   629                         {
   655                         {
   630                         iFullScreenEffectData->iFromSecureId = iAlfScreens[0]->iControlGroups[j].iSecureId;
   656                         iFSFxData->iFromSecureId = iAlfScreens[0]->iControlGroups[j].iSecureId;
   631                         iFullScreenEffectData->iFromWg = iAlfScreens[0]->iControlGroups[j].iClientWindowGroupId;
   657                         iFSFxData->iFromWg = iAlfScreens[0]->iControlGroups[j].iClientWindowGroupId;
   632                         __ALFFXLOGSTRING2("CAlfBridge::ResolveAfterEffectAppearingApplicationL - Found underneath application uid: 0x%x, window group: %d -  Start track drawing for exit effect.", iFullScreenEffectData->iFromSecureId, iFullScreenEffectData->iFromWg );
   658                         __ALFFXLOGSTRING2("CAlfBridge::ResolveAfterEffectAppearingApplicationL - Found underneath application uid: 0x%x, window group: %d -  Start track drawing for exit effect.", iFSFxData->iFromSecureId, iFSFxData->iFromWg );
   633                         break;
   659                         break;
   634                         }
   660                         }
   635                     }
   661                     }
   636                 }
   662                 }
   637             }
   663             }
   673                     }
   699                     }
   674                 
   700                 
   675                 if (anyVisualHasEffect)
   701                 if (anyVisualHasEffect)
   676                     {
   702                     {
   677                     TInt activeEffectHandle = iEffectCleanupStack[activeEffectIndex].iHandle;
   703                     TInt activeEffectHandle = iEffectCleanupStack[activeEffectIndex].iHandle;
   678                     if (iSecondaryFullScreenEffectData && iSecondaryFullScreenEffectData->iHandle == activeEffectHandle)
   704                     if (iFSFXDataPart2 && iFSFXDataPart2->iHandle == activeEffectHandle)
   679                         {
   705                         {
   680                         __ALFFXLOGSTRING1("CAlfBridge::DeleteControlGroupL - WARNING! Control group with 2 phase effect is being destroyed. Canceling second phase for handle %d", activeEffectHandle);
   706                         __ALFFXLOGSTRING1("CAlfBridge::DeleteControlGroupL - WARNING! Control group with 2 phase effect is being destroyed. Canceling second phase for handle %d", activeEffectHandle);
   681                         delete iSecondaryFullScreenEffectData;
   707                         delete iFSFXDataPart2;
   682                         iSecondaryFullScreenEffectData = NULL;
   708                         iFSFXDataPart2 = NULL;
   683                         }
   709                         }
   684                     
   710                     
   685                     __ALFFXLOGSTRING1("Layout 0x%x has external content", layout);
   711                     __ALFFXLOGSTRING1("Layout 0x%x has external content", layout);
   686                     // EHuiVisualFlagShouldDestroy destroy flag should have come for the windows in this layout already
   712                     // EHuiVisualFlagShouldDestroy destroy flag should have come for the windows in this layout already
   687                     layout->SetFlags(EHuiVisualFlagShouldDestroy);
   713                     layout->SetFlags(EHuiVisualFlagShouldDestroy);
   708                        familyTree[familyIndex]->SetOwner(effectControlGroup);                      
   734                        familyTree[familyIndex]->SetOwner(effectControlGroup);                      
   709                        
   735                        
   710                        if (!HasActiveEffect(familyTree[familyIndex]))
   736                        if (!HasActiveEffect(familyTree[familyIndex]))
   711                            {
   737                            {
   712                            TInt dummy;
   738                            TInt dummy;
   713                            AddEffectItemL(activeEffectHandle, familyTree[familyIndex], NULL, NULL, EFalse, dummy, ETrue, EFalse);
   739                            AddFxItemL(activeEffectHandle, familyTree[familyIndex], NULL, NULL, EFalse, dummy, ETrue, EFalse);
   714                            }
   740                            }
   715                        }
   741                        }
   716                     }
   742                     }
   717                 else
   743                 else
   718                     {
   744                     {
   720                     // the layout is not have effect, but some child window might.
   746                     // the layout is not have effect, but some child window might.
   721                     // in this case, the child window effects WILL BE REMOVED.
   747                     // in this case, the child window effects WILL BE REMOVED.
   722                      for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++)
   748                      for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++)
   723                          {
   749                          {
   724                          CHuiLayout* removedVisual = familyTree[familyIndex];
   750                          CHuiLayout* removedVisual = familyTree[familyIndex];
   725                          RemoveTemporaryPresenterVisual(removedVisual);
   751                          CleanFxVisual(removedVisual);
   726           
   752           
   727                          if ( removedVisual != layout ) // let control group delete the layout
   753                          if ( removedVisual != layout ) // let control group delete the layout
   728 					         {
   754 					         {
   729 					         control.Remove(removedVisual); // remove ownership from the original control (group)
   755 					         control.Remove(removedVisual); // remove ownership from the original control (group)
   730 					         __ALFFXLOGSTRING1("CAlfBridge::DeleteControlGroupL - adding to orphonage 0x%x", layout);
   756 					         __ALFFXLOGSTRING1("CAlfBridge::DeleteControlGroupL - adding to orphonage 0x%x", layout);
   731 					         RemoveTemporaryPresenterVisual(removedVisual);
   757 					         CleanFxVisual(removedVisual);
   732 					         if ( removedVisual->Layout() == layout ) 
   758 					         if ( removedVisual->Layout() == layout ) 
   733 					             {
   759 					             {
   734 					             iOrphanStorage->AppendL( removedVisual );
   760 					             iOrphanStorage->AppendL( removedVisual );
   735 					             } 
   761 					             } 
   736 					         else 
   762 					         else 
   803         entry.iControlGroup = group;
   829         entry.iControlGroup = group;
   804         entry.iWindowGroupNodeId = aWindowGroupNodeId;
   830         entry.iWindowGroupNodeId = aWindowGroupNodeId;
   805         entry.iClientWindowGroupId = aClientWindowGroupId;  
   831         entry.iClientWindowGroupId = aClientWindowGroupId;  
   806         entry.iSecureId = aSecureId;
   832         entry.iSecureId = aSecureId;
   807         // we have received start effect for this group, but the group did not exist in alf universe at the time. hide the group.
   833         // we have received start effect for this group, but the group did not exist in alf universe at the time. hide the group.
   808         if (iFullScreenEffectData
   834         if (iFSFxData
   809                 && (iFullScreenEffectData->State() == EWaitingWindowGroup || iFullScreenEffectData->State() == EEndFullScreenReceivedWaitingWindowGroup)
   835                 && (iFSFxData->State() == EWaitingWindowGroup || iFSFxData->State() == EEndFullScreenReceivedWaitingWindowGroup)
   810                 && iFullScreenEffectData->iToSecureId == aSecureId)
   836                 && iFSFxData->iToSecureId == aSecureId)
   811             {
   837             {
   812             iFullScreenEffectData->iToWg = aClientWindowGroupId;
   838             iFSFxData->iToWg = aClientWindowGroupId;
   813             if (iSecondaryFullScreenEffectData)
   839             if (iFSFXDataPart2)
   814                 {
   840                 {
   815                 iSecondaryFullScreenEffectData->iToWg = aClientWindowGroupId;
   841                 iFSFXDataPart2->iToWg = aClientWindowGroupId;
   816                 }
   842                 }
   817             CHuiControlGroup* fromGroup = NULL;
   843             CHuiControlGroup* fromGroup = NULL;
   818             CHuiLayout* fromLayout = NULL; 
   844             CHuiLayout* fromLayout = NULL; 
   819             fromGroup = FindControlGroupByFullScreenFromEffect();
   845             fromGroup = FindControlGroupByFullScreenFromEffect();
   820             if (fromGroup)
   846             if (fromGroup)
   824                 }
   850                 }
   825             
   851             
   826             
   852             
   827             // First HandleGfxEvent, then clear iWaitingWindowGroup.
   853             // First HandleGfxEvent, then clear iWaitingWindowGroup.
   828             __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - try triggering effect 0x%x", layout);
   854             __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - try triggering effect 0x%x", layout);
   829             TBool failed = HandleGfxEventL( *iFullScreenEffectData, layout, fromLayout );
   855             TBool failed = HandleGfxEventL( *iFSFxData, layout, fromLayout );
   830             if ( iFullScreenEffectData->State() == EWaitingWindowGroup)
   856             if ( iFSFxData->State() == EWaitingWindowGroup)
   831                 {
   857                 {
   832                 iFullScreenEffectData->SetState(EWaitEndFullScreen);
   858                 iFSFxData->SetState(EWaitEndFullScreen);
   833                 }
   859                 }
   834             else
   860             else
   835                 {  
   861                 {  
   836 				// was CFullScreenEffectState::EEndFullScreenReceivedWaitingWindowGroup           
   862 				// was CFullScreenEffectState::EEndFullScreenReceivedWaitingWindowGroup           
   837                 iFullScreenEffectData->SetState(EEndFullscreenReceived);
   863                 iFSFxData->SetState(EEndFullscreenReceived);
   838                 }
   864                 }
   839             
   865             
   840             if ( failed )
   866             if ( failed )
   841                 {
   867                 {
   842                 // Effect failed, reset state
   868                 // Effect failed, reset state
   843                 __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - effect failed on layout 0x%x", layout);
   869                 __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - effect failed on layout 0x%x", layout);
   844                 HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
   870                 HandleGfxStopEvent( EFalse ); // destroys iFSFxData and iFSFXDataPart2
   845                 }
   871                 }
   846             }     
   872             }     
   847         entry.iScreenNumber = aScreenNumber;
   873         entry.iScreenNumber = aScreenNumber;
   848 //        entry.iRole = EHuiWindowGroupContainer;
   874 //        entry.iRole = EHuiWindowGroupContainer;
   849 
   875 
  1029     else
  1055     else
  1030         {
  1056         {
  1031         TInt index = 0; // Index for Window group control groups
  1057         TInt index = 0; // Index for Window group control groups
  1032         TBool added = EFalse;
  1058         TBool added = EFalse;
  1033         for (TInt i=0; i<aRoster.Count() - screen->FixedControlGroupCount(); i++)
  1059         for (TInt i=0; i<aRoster.Count() - screen->FixedControlGroupCount(); i++)
  1034             {
  1060                    {
  1035             if (index == aWhere)
  1061                    if (index == aWhere)
  1036                 {
  1062                        {
  1037                 TBool lSyncAlfAppAndAlfEventGroup = EFalse;
  1063                        TBool lSyncAlfAppAndAlfEventGroup = EFalse;
  1038                 if ( i>0 &&  aRoster.ControlGroup(i).iAlfApp && aRoster.ControlGroup(i-1).ResourceId() == iAlfWindowGroupNodeId  && &aRoster.ControlGroup(i) != &aGroup)
  1064                        if ( i>0 &&  aRoster.ControlGroup(i).iAlfApp && aRoster.ControlGroup(i-1).ResourceId() == iAlfWindowGroupNodeId  && &aRoster.ControlGroup(i) != &aGroup)
  1039                     {
  1065                            {
  1040                     // we still need to check that there are no other alf client window groups on top.
  1066                            // we still need to check that there are no other alf client window groups on top.
  1041 					// if one native alf application is embedding another native alf application, WServ
  1067                            // if one native alf application is embedding another native alf application, WServ
  1042 					// seems to update wg chains so that the following check must be done  
  1068                            // seems to update wg chains so that the following check must be done  
  1043                     TInt u = i+1;
  1069                            TInt u = i+1;
  1044                     TBool clienWgFoundOntop =EFalse;
  1070                            TBool clienWgFoundOntop =EFalse;
  1045                     for(;u < aRoster.Count() - screen->FixedControlGroupCount(); u++)
  1071                            for(;u < aRoster.Count() - screen->FixedControlGroupCount(); u++)
  1046                         {
  1072                                {
  1047                         if(aRoster.ControlGroup(u).iAlfApp)
  1073                                if(aRoster.ControlGroup(u).iAlfApp)
  1048                             {
  1074                                    {
  1049                             clienWgFoundOntop = ETrue;
  1075                                    clienWgFoundOntop = ETrue;
  1050                             break;
  1076                                    break;
  1051                             }
  1077                                    }
  1052                         }
  1078                                }
  1053                     
  1079                            
  1054                     if(!clienWgFoundOntop)
  1080                            if(!clienWgFoundOntop)
  1055                         {
  1081                                {
  1056                         lSyncAlfAppAndAlfEventGroup = ETrue;
  1082                                lSyncAlfAppAndAlfEventGroup = ETrue;
  1057                         }
  1083                                }
  1058                     }
  1084                            }
  1059                 aRoster.ShowL(aGroup, i);
  1085                        aRoster.ShowL(aGroup, i);
  1060                 added = ETrue;
  1086                        added = ETrue;
  1061                 if (lSyncAlfAppAndAlfEventGroup && i< (aRoster.Count()-1) )
  1087                        TBool lSyncDone(EFalse);
  1062                 {
  1088                        if (lSyncAlfAppAndAlfEventGroup && i< (aRoster.Count()-1) )
  1063                 CHuiControlGroup &lGroup = aRoster.ControlGroup(i+1);
  1089                        {
  1064                 TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
  1090                        lSyncDone = ETrue;
  1065                 iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
  1091                        CHuiControlGroup &lGroup = aRoster.ControlGroup(i+1);
  1066                 }
  1092                        TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
  1067                 
  1093                        iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
  1068                 break;
  1094                        }
  1069                 }
  1095                        if(!lSyncDone && aGroup.iAlfApp && aRoster.ControlGroup(i-1).ResourceId() != iAlfWindowGroupNodeId )
       
  1096                            {
       
  1097                           
       
  1098                           CHuiControlGroup &lGroup = aRoster.ControlGroup(i);
       
  1099                           TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
       
  1100                           iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
       
  1101                            }
       
  1102                        break;
       
  1103                        }
  1070 
  1104 
  1071             if (aRoster.ControlGroup(i).Control(0).Role() == EHuiWindowGroupContainer &&
  1105             if (aRoster.ControlGroup(i).Control(0).Role() == EHuiWindowGroupContainer &&
  1072                 &aRoster.ControlGroup(i) != &aGroup)
  1106                 &aRoster.ControlGroup(i) != &aGroup)
  1073                 {
  1107                 {
  1074                 index++;                                                
  1108                 index++;                                                
  1229 // 
  1263 // 
  1230 void CAlfBridge::NotifyDisplayRefreshStarted(CHuiDisplay& aDisplay)
  1264 void CAlfBridge::NotifyDisplayRefreshStarted(CHuiDisplay& aDisplay)
  1231     {
  1265     {
  1232     // Look for the correct display
  1266     // Look for the correct display
  1233     TInt screenNumber = ResolveScreenNumber(aDisplay);
  1267     TInt screenNumber = ResolveScreenNumber(aDisplay);
  1234     RemoveTemporaryPresenterVisuals();
  1268     CleanFxVisuals();
  1235     if ( screenNumber != KErrNotFound )
  1269     if ( screenNumber != KErrNotFound )
  1236         {
  1270         {
  1237         // FPS Counter with hitchcock drawing
  1271         // FPS Counter with hitchcock drawing
  1238 #ifdef SYMBIAN_BUILD_GCE
  1272 #ifdef SYMBIAN_BUILD_GCE
  1239         if(iPrintFPS)
  1273         if(iPrintFPS)
  1406     {
  1440     {
  1407     if (!iAlfScreens.Count())
  1441     if (!iAlfScreens.Count())
  1408         return;
  1442         return;
  1409             
  1443             
  1410     iTempRegion.Clear();
  1444     iTempRegion.Clear();
       
  1445     iTempRegion2.Clear();
  1411     
  1446     
  1412     CAlfScreen* screen = iAlfScreens[aScreenNumber];
  1447     CAlfScreen* screen = iAlfScreens[aScreenNumber];
  1413     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
  1448     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
  1414     TBool checkFadeEffectInScreen = EFalse;
  1449     TBool checkFadeEffectInScreen = EFalse;
  1415     
  1450     
  1623         
  1658         
  1624         if ( hasLayers && iActivated )
  1659         if ( hasLayers && iActivated )
  1625             {
  1660             {
  1626             HandleLayerVisibility( layout, controlgroup, control, hasActiveVisualsInVisualTree );
  1661             HandleLayerVisibility( layout, controlgroup, control, hasActiveVisualsInVisualTree );
  1627             }
  1662             }
       
  1663         
       
  1664         TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
       
  1665         
       
  1666         // we need to set /clear inactive flags before we evaluate the fade effect,
       
  1667         // otherwise the fade effect will be removed without a reason in
       
  1668         // some use cases
       
  1669         if (isLayoutActive && !hasActiveVisualsInVisualTree && !IsOpaqueEffect(layout->Effect()))
       
  1670             {
       
  1671             // Setting also the root visual (layout) as inactive, if it had none
       
  1672 			// active children. This is because otherwise the Inactive checks won't
       
  1673 			// work correctly within RosterImpl ScanDirty & ClearChanged phases.
       
  1674 			// If root visual is having an opaque effect, it must remain active
       
  1675             layout->SetFlag(EHuiVisualFlagInactive);
       
  1676             }
       
  1677         else if(!isLayoutActive && (hasActiveVisualsInVisualTree || IsOpaqueEffect(layout->Effect())))
       
  1678             {
       
  1679             layout->ClearFlag(EHuiVisualFlagInactive);
       
  1680             layout->SetPos(fullscreen.iTl);
       
  1681             layout->SetSize(fullscreen.Size());
       
  1682             }
       
  1683  
  1628             
  1684             
  1629 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1685 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1630 		// flagged as containing fade effect, then run the setup as well so that effects which
  1686 		// flagged as containing fade effect, then run the setup as well so that effects which
  1631 		// are no more needed get removed.
  1687 		// are no more needed get removed.
  1632         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1688         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1647             else
  1703             else
  1648                 {
  1704                 {
  1649                 layout->ClearCanvasFlags(EHuiCanvasFlagExternalFadeExistsInsideVisualTree);            
  1705                 layout->ClearCanvasFlags(EHuiCanvasFlagExternalFadeExistsInsideVisualTree);            
  1650                 }
  1706                 }
  1651             }
  1707             }
  1652         
  1708                
  1653         TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
       
  1654         
       
  1655         if (isLayoutActive && !hasActiveVisualsInVisualTree && !IsOpaqueEffect(layout->Effect()))
       
  1656             {
       
  1657             // Setting also the root visual (layout) as inactive, if it had none
       
  1658 			// active children. This is because otherwise the Inactive checks won't
       
  1659 			// work correctly within RosterImpl ScanDirty & ClearChanged phases.
       
  1660 			// If root visual is having an opaque effect, it must remain active
       
  1661             layout->SetFlag(EHuiVisualFlagInactive);
       
  1662             }
       
  1663         else if(!isLayoutActive && (hasActiveVisualsInVisualTree || IsOpaqueEffect(layout->Effect())))
       
  1664             {
       
  1665             layout->ClearFlag(EHuiVisualFlagInactive);
       
  1666             layout->SetPos(fullscreen.iTl);
       
  1667             layout->SetSize(fullscreen.Size());
       
  1668             }
       
  1669         
       
  1670 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1709 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
  1671         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Control group index: %d", j );
  1710         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Control group index: %d", j );
  1672         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Active visuals : %d", activevisualcount );
  1711         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Active visuals : %d", activevisualcount );
  1673         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Passive visuals: %d", passivevisualcount );
  1712         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Passive visuals: %d", passivevisualcount );
  1674 #endif
  1713 #endif
  1734             iHomeScreenPSValue = value;
  1773             iHomeScreenPSValue = value;
  1735             }
  1774             }
  1736         }
  1775         }
  1737     if ( iSwRenderingEnabled )
  1776     if ( iSwRenderingEnabled )
  1738         {
  1777         {
  1739         screen->iDisplay->SetForegroundTextureOptions( alfWindowGroupFoundVisible | alfClientWindowGroupVisible );
  1778         screen->iDisplay->SetForegroundTextureOptions( alfWindowGroupFoundVisible || alfClientWindowGroupVisible );
  1740         }
  1779         }
  1741    
  1780    
  1742     // Finally, if there are fadeeffects applied to windowgroups, make sure first one does not
  1781     // Finally, if there are fadeeffects applied to windowgroups, make sure first one does not
  1743     // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others
  1782     // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others
  1744     // would clear the screen areas where they do not really draw.
  1783     // would clear the screen areas where they do not really draw.
  2214         
  2253         
  2215         CHuiVisual* layout = &control.Visual(0);
  2254         CHuiVisual* layout = &control.Visual(0);
  2216         for (TInt i=layout->Count()-1; i >= 0; i--)
  2255         for (TInt i=layout->Count()-1; i >= 0; i--)
  2217             {
  2256             {
  2218             CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&layout->Visual(i));
  2257             CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&layout->Visual(i));
  2219             if (!aInactiveOnly)
  2258             ClearCanvasVisualCommandSetsRecursive(canvasVisual, aInactiveOnly);            
  2220                 {
  2259             }
  2221                 canvasVisual->ClearCommandSet();
  2260         }
  2222                 }
  2261     }
  2223             else if (aInactiveOnly && (canvasVisual->Flags() & EHuiVisualFlagInactive))
  2262 
  2224                 {
  2263 
  2225                 canvasVisual->ClearCommandSet();                        
  2264 // ---------------------------------------------------------------------------
  2226                 }
  2265 // ---------------------------------------------------------------------------
  2227             else
  2266 // 
  2228                 {
  2267 void CAlfBridge::ClearCanvasVisualCommandSetsRecursive(CHuiCanvasVisual* aVisual, TBool aInactiveOnly)
  2229                 // dont clear
  2268     {
  2230                 }
  2269     if (!aVisual)
  2231             }
  2270         {
       
  2271         return;
       
  2272         }
       
  2273 
       
  2274     if (!aInactiveOnly)
       
  2275         {
       
  2276         aVisual->ClearCommandSet();
       
  2277         }
       
  2278     else if (aInactiveOnly && (aVisual->Flags() & EHuiVisualFlagInactive))
       
  2279         {
       
  2280         aVisual->ClearCommandSet();                        
       
  2281         }
       
  2282     else
       
  2283         {
       
  2284         // dont clear
       
  2285         }
       
  2286         
       
  2287     for (TInt i=aVisual->Count()-1; i >= 0; --i)
       
  2288         {
       
  2289         CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&aVisual->Visual(i));
       
  2290         ClearCanvasVisualCommandSetsRecursive(canvasVisual, aInactiveOnly);            
  2232         }
  2291         }
  2233     }
  2292     }
  2234 
  2293 
  2235 
  2294 
  2236 // ---------------------------------------------------------------------------
  2295 // ---------------------------------------------------------------------------
  2525 	                	iAppUi->AdjustWindowGroupPositionL(0,CAlfAppServer::EAlfWindowSize); // hackish, but one way to enforce alf window resizing
  2584 	                	iAppUi->AdjustWindowGroupPositionL(0,CAlfAppServer::EAlfWindowSize); // hackish, but one way to enforce alf window resizing
  2526 	                	}
  2585 	                	}
  2527 	                __ALFLOGSTRING1("AlfScreens[0]->iDisplay->SetOrientation: %d",huiOrientation);  	                
  2586 	                __ALFLOGSTRING1("AlfScreens[0]->iDisplay->SetOrientation: %d",huiOrientation);  	                
  2528 	                }
  2587 	                }
  2529 	            
  2588 	            
       
  2589                 if (!iLayoutSwitchInProgress) // LayoutSwitchStart wasn't called, so inform that all is fine.
       
  2590                     {
       
  2591                     if (iActivated)
       
  2592                         {
       
  2593                         iBridgerClient.SendBlind(KAlfCompositionLayoutSwitchComplete, TIpcArgs());
       
  2594                         }            
       
  2595                     }
  2530                 break;         
  2596                 break;         
  2531                 }
  2597                 }
  2532            case EAlfEffectFxBeginSyncronizedGroup:
  2598            case EAlfEffectFxBeginSyncronizedGroup:
  2533         	   {
  2599         	   {
  2534         	   CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
  2600         	   CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
  2755     for (TInt familyIndex = 1; familyIndex < familyTree.Count();familyIndex++)
  2821     for (TInt familyIndex = 1; familyIndex < familyTree.Count();familyIndex++)
  2756         {
  2822         {
  2757         CHuiLayout* lVisual = familyTree[familyIndex];
  2823         CHuiLayout* lVisual = familyTree[familyIndex];
  2758         lVisual->Owner().Remove(lVisual);
  2824         lVisual->Owner().Remove(lVisual);
  2759         iOrphanStorage->AppendL( lVisual );
  2825         iOrphanStorage->AppendL( lVisual );
  2760         RemoveTemporaryPresenterVisual(lVisual);
  2826         CleanFxVisual(lVisual);
  2761         
  2827         
  2762         __ALFLOGSTRING1("CAlfBridge::DestroyWindow - orphons: %d", iOrphanStorage->VisualCount());
  2828         __ALFLOGSTRING1("CAlfBridge::DestroyWindow - orphons: %d", iOrphanStorage->VisualCount());
  2763         }
  2829         }
  2764     familyTree.Close();
  2830     familyTree.Close();
  2765          
  2831          
  2769     // there might be effect on this visual. It is not guaranteen.
  2835     // there might be effect on this visual. It is not guaranteen.
  2770     
  2836     
  2771     if (!aUseForce)
  2837     if (!aUseForce)
  2772         {
  2838         {
  2773         // we can remove from iEffectCleanupStack only when this method was called from HandleDestroyWindow. Otherwise
  2839         // we can remove from iEffectCleanupStack only when this method was called from HandleDestroyWindow. Otherwise
  2774         // messing iEffectCleanupStack is likely to cause forever loop in some RemoveTemporaryPresenterVisuals method
  2840         // messing iEffectCleanupStack is likely to cause forever loop in some CleanFxVisuals method
  2775         for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  2841         for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  2776             {
  2842             {
  2777             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  2843             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  2778             if (aVisual == effectItem.iEffectedVisual)
  2844             if (aVisual == effectItem.iEffectedVisual)
  2779                 {
  2845                 {
  3360 	else
  3426 	else
  3361 		{
  3427 		{
  3362 		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
  3428 		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
  3363 		}    
  3429 		}    
  3364 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
  3430 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
  3365 	    if (iFullScreenEffectData
  3431 	    if (iFSFxData
  3366 	            && !iSecondaryFullScreenEffectData
  3432 	            && iFSFxData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
  3367 	            && iFullScreenEffectData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
  3433 	            && ((iFSFxData->State() == EWaitEndFullScreen && iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::EFirstPartRunning)))
  3368 	            && iFullScreenEffectData->State() == EWaitEndFullScreen
       
  3369 	            && iFullScreenEffectData->iTwoPhaseEffect != CFullScreenEffectState::ESecondPartActive)
       
  3370 	        {
  3434 	        {
  3371 	        CHuiControlGroup *to_group = NULL;
  3435 	        CHuiControlGroup *to_group = NULL;
  3372             if (iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
  3436             if (iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect)
  3373                 {
  3437                 {
  3374                 to_group = FindControlGroupByFullScreenFromEffect();
  3438                 to_group = FindControlGroupByFullScreenFromEffect();
  3375                 }
  3439                 }
  3376             else
  3440             else
  3377                 {
  3441                 {
  3395 // HandleGfxEndFullScreenTimeout
  3459 // HandleGfxEndFullScreenTimeout
  3396 // ---------------------------------------------------------------------------
  3460 // ---------------------------------------------------------------------------
  3397 // 
  3461 // 
  3398 void CAlfBridge::GfxTriggerEndFullScreen(CFullScreenEffectState* aFullScreenEffectData)
  3462 void CAlfBridge::GfxTriggerEndFullScreen(CFullScreenEffectState* aFullScreenEffectData)
  3399     {
  3463     {
  3400     if (iFullScreenEffectData->State() == EFinalEffectActive)
  3464     if (iFSFxData->State() == EFinalEffectActive)
  3401         {
  3465         {
  3402         return;
  3466         return;
  3403         }
  3467         }
  3404     CHuiControlGroup *to_group = FindControlGroupByFullScreenToEffect();
  3468     CHuiControlGroup *to_group = FindControlGroupByFullScreenToEffect();
  3405     CHuiControlGroup *from_group = FindControlGroupByFullScreenFromEffect();
  3469     CHuiControlGroup *from_group = FindControlGroupByFullScreenFromEffect();
  3422         }
  3486         }
  3423     aFullScreenEffectData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
  3487     aFullScreenEffectData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
  3424     if (to_layout)
  3488     if (to_layout)
  3425         {
  3489         {
  3426         // from layout may be undefined
  3490         // from layout may be undefined
  3427         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEndFullScreenTimeout : Enough app drawing. Trigger EndFullScreen for layout 0x%x", to_layout);    
  3491         __ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEndFullScreen : Enough app drawing. Trigger EndFullScreen for layout 0x%x", to_layout);    
  3428         HandleGfxEventL( *aFullScreenEffectData, to_layout, from_layout );
  3492         HandleGfxEventL( *aFullScreenEffectData, to_layout, from_layout );
  3429         aFullScreenEffectData->SetState(EFinalEffectActive);
  3493         aFullScreenEffectData->SetState(EFinalEffectActive);
  3430         }
  3494         }
  3431 
  3495 
  3432     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  3496     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  3455         }
  3519         }
  3456     else
  3520     else
  3457         {
  3521         {
  3458         __ALFFXLOGSTRING2("CAlfBridge::SetWindowActiveL 0x%x has active effect. New state: %d", aVisual, aActive);
  3522         __ALFFXLOGSTRING2("CAlfBridge::SetWindowActiveL 0x%x has active effect. New state: %d", aVisual, aActive);
  3459         // Has effect
  3523         // Has effect
  3460 		// these flags are put to action in RemoveTemporaryPresenterItem
  3524 		// these flags are put to action in CleanFxItem
  3461         if (aActive)
  3525         if (aActive)
  3462             {
  3526             {
  3463 			// this prevents windows appearing before their "effected" time
  3527 			// this prevents windows appearing before their "effected" time
  3464             if (!iEffectCleanupStack[effectIndex].iHideWhenFinished)
  3528             if (!iEffectCleanupStack[effectIndex].iHideWhenFinished)
  3465                 {
  3529                 {
  4340             }
  4404             }
  4341         else 
  4405         else 
  4342             {
  4406             {
  4343             __ALFLOGSTRING("CAlfBridge::HandleMoveWindowToNewGroupL cannot find new group! orphaning the visual");
  4407             __ALFLOGSTRING("CAlfBridge::HandleMoveWindowToNewGroupL cannot find new group! orphaning the visual");
  4344             
  4408             
  4345             RemoveTemporaryPresenterVisual(viz);
  4409             CleanFxVisual(viz);
  4346              iOrphanStorage->AppendL( viz );
  4410              iOrphanStorage->AppendL( viz );
  4347             }
  4411             }
  4348         }
  4412         }
  4349     else
  4413     else
  4350         {
  4414         {
  4595                     {
  4659                     {
  4596                     TInt dummy;
  4660                     TInt dummy;
  4597 					if (!HasActiveEffect(aToLayout, dummy))
  4661 					if (!HasActiveEffect(aToLayout, dummy))
  4598 						{
  4662 						{
  4599 						__ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Add layout 0x%x with handle %d to cleanupstack", aToLayout, aEvent.iHandle);
  4663 						__ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Add layout 0x%x with handle %d to cleanupstack", aToLayout, aEvent.iHandle);
  4600                     	AddEffectItemL(aEvent.iHandle, aToLayout, NULL, NULL, EFalse, dummy, ETrue, EFalse);
  4664                     	AddFxItemL(aEvent.iHandle, aToLayout, NULL, NULL, EFalse, dummy, ETrue, EFalse);
  4601 						}
  4665 						}
  4602                     }
  4666                     }
  4603 				// Screenshot was requested, but it could not be taken. Lets cancel the effect.	
  4667 				// Screenshot was requested, but it could not be taken. Lets cancel the effect.	
  4604 				if (!success)
  4668 				if (!success)
  4605 					{
  4669 					{
  4617                     case KAlfFSTaskSwapperAppStart:
  4681                     case KAlfFSTaskSwapperAppStart:
  4618                         {
  4682                         {
  4619                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that are not yet ready to be drawn, but possible already on the foreground
  4683                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that are not yet ready to be drawn, but possible already on the foreground
  4620                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  4684                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  4621                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4685                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4622                         if (iSecondaryFullScreenEffectData)
  4686                         if (iFSFXDataPart2)
  4623                             {
  4687                             {
  4624                             iSecondaryFullScreenEffectData->iEffectType = CFullScreenEffectState::EStartEffect; 
  4688                             iFSFXDataPart2->iEffectType = CFullScreenEffectState::EStartEffect; 
  4625                             }
  4689                             }
  4626                                 
  4690                                 
  4627                         aEvent.iCanDestroyOrHideImmediately = ETrue; // enable hiding of windows during application start/activate effects
  4691                         aEvent.iCanDestroyOrHideImmediately = ETrue; // enable hiding of windows during application start/activate effects
  4628                         break;
  4692                         break;
  4629                         }
  4693                         }
  4636                         // Effect end observer is given to engine in LoadEffectL
  4700                         // Effect end observer is given to engine in LoadEffectL
  4637                         // It will be set to effect there and called when the effect ends or is deleted
  4701                         // It will be set to effect there and called when the effect ends or is deleted
  4638 
  4702 
  4639                         // The layout should be visible at this time. if not, then this is assumed
  4703                         // The layout should be visible at this time. if not, then this is assumed
  4640                         // as effect to an background application and ignored.
  4704                         // as effect to an background application and ignored.
  4641                         if (aToLayout->Effect())
  4705 						
  4642                             {
  4706                         if (aToLayout->Effect() 
       
  4707 							&& !(aToLayout->Effect()->EffectFlags() & KHuiFadeEffectFlag ))                         
       
  4708 							{
       
  4709 							// If the exit effect took a screesnhot (above), then the layout is freezed to show the screenshot. 
       
  4710 							// Layout may not be unfrozen before EndFullScreen, or flicker will occur.
  4643                             // effect on a layout must be an application start effect. 
  4711                             // effect on a layout must be an application start effect. 
  4644                             // External content visual is not used for that.
  4712                             // External content visual is not used for that.
  4645                             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Found effect on layout 0x%x. Removing effect 0x%x", aToLayout, aToLayout->Effect());
  4713                             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Found effect on layout 0x%x. Removing effect 0x%x", aToLayout, aToLayout->Effect());
  4646                             aToLayout->SetEffect(NULL);
  4714                             aToLayout->SetEffect(NULL);
       
  4715                             aToLayout->SetFreezeState(EFalse); // Only if a screenshot was taken earlier then freeze state would be ETrue
  4647                             }
  4716                             }
       
  4717 							
  4648                         __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Layout 0x%x is active:  %d", aToLayout, !TBool(aToLayout->Flags() & EHuiVisualFlagInactive) );
  4718                         __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Layout 0x%x is active:  %d", aToLayout, !TBool(aToLayout->Flags() & EHuiVisualFlagInactive) );
  4649                         if (!(aToLayout->Flags() & EHuiVisualFlagInactive)) 
  4719                         if (!(aToLayout->Flags() & EHuiVisualFlagInactive)) 
  4650                             {
  4720                             {
  4651                             TInt index;
  4721                             TInt index;
  4652                             if (aToLayout->StoredRenderBuffer() 
  4722                             if (aToLayout->StoredRenderBuffer() 
  4669                             {
  4739                             {
  4670                             iLayoutInitializedForExitEffect = EFalse;
  4740                             iLayoutInitializedForExitEffect = EFalse;
  4671                             aEvent.iSetupDone = EFalse;
  4741                             aEvent.iSetupDone = EFalse;
  4672                             failed = ETrue;
  4742                             failed = ETrue;
  4673                             }
  4743                             }
  4674                         if (iSecondaryFullScreenEffectData)
  4744                         if (iFSFXDataPart2)
  4675                             {
  4745                             {
  4676                             iSecondaryFullScreenEffectData->iSetupDone = aEvent.iSetupDone;
  4746                             iFSFXDataPart2->iSetupDone = aEvent.iSetupDone;
  4677                             }
  4747                             }
  4678                          return failed;
  4748                          return failed;
  4679                          }
  4749                          }
  4680                     default:
  4750                     default:
  4681                         break;
  4751                         break;
  4757                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName) ||
  4827                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName) ||
  4758                                     aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive)
  4828                                     aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive)
  4759                                 {
  4829                                 {
  4760                                 effectFlags |= KHuiFxOpaqueHint;
  4830                                 effectFlags |= KHuiFxOpaqueHint;
  4761                                 }
  4831                                 }
  4762                             if (iSecondaryFullScreenEffectData)
  4832                             if (iFSFXDataPart2)
  4763                                 {
  4833                                 {
  4764                                 iSecondaryFullScreenEffectData->iSetupDone = ETrue;
  4834                                 iFSFXDataPart2->iSetupDone = ETrue;
  4765                                 }
  4835                                 }
  4766                             
  4836                             
  4767                             if (aEvent.iRect != TRect())
  4837                             if (aEvent.iRect != TRect())
  4768                                 {
  4838                                 {
  4769                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), activeEffectGroup, &aEvent.iRect, this, aEvent.iHandle, effectFlags ));
  4839                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), activeEffectGroup, &aEvent.iRect, this, aEvent.iHandle, effectFlags ));
  4772                                 {
  4842                                 {
  4773                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), activeEffectGroup, NULL, this, aEvent.iHandle, effectFlags ) );
  4843                                 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), activeEffectGroup, NULL, this, aEvent.iHandle, effectFlags ) );
  4774                                 }
  4844                                 }
  4775                             effect = NULL;
  4845                             effect = NULL;
  4776                             // only use the effect if the effect file was correctly parsed
  4846                             // only use the effect if the effect file was correctly parsed
       
  4847                             aToLayout->SetFreezeState(EFalse);
       
  4848                                                             
  4777                             if (err != KErrNone)
  4849                             if (err != KErrNone)
  4778                                 {
  4850                                 {
  4779                                 // visuals added to "active effect visual" stack, but they wont be used, because effect loading has failed. cleanup.
  4851                                 // visuals added to "active effect visual" stack, but they wont be used, because effect loading has failed. cleanup.
  4780                                 RemoveTemporaryPresenterVisual(NULL, aEvent.iHandle);
  4852                                 CleanFxVisual(NULL, aEvent.iHandle);
  4781                                 aToLayout->SetEffect(NULL);
  4853                                 aToLayout->SetEffect(NULL);
  4782                                 failed = ETrue;
  4854                                 failed = ETrue;
       
  4855                                 }
       
  4856                             else
       
  4857                                 {
       
  4858                                 switch(aEvent.iTwoPhaseEffect)
       
  4859                                     {
       
  4860                                     case CFullScreenEffectState::EFirstPartActive:
       
  4861                                         aEvent.iTwoPhaseEffect = CFullScreenEffectState::EFirstPartRunning;
       
  4862                                         break;
       
  4863                                     case CFullScreenEffectState::ESecondPartActive:
       
  4864                                         aEvent.iTwoPhaseEffect = CFullScreenEffectState::ESecondPartRunning;
       
  4865                                         break;
       
  4866                                     }
  4783                                 }
  4867                                 }
  4784                             }
  4868                             }
  4785                         else
  4869                         else
  4786                             {
  4870                             {
  4787                             failed = ETrue;                            
  4871                             failed = ETrue;                            
  4812 		if (err == KErrNone)
  4896 		if (err == KErrNone)
  4813 			{
  4897 			{
  4814             // Freeze only, if buffer was reserved succesfully 
  4898             // Freeze only, if buffer was reserved succesfully 
  4815             aLayout->SetFreezeState(ETrue);
  4899             aLayout->SetFreezeState(ETrue);
  4816         	TBool itemsDestroyed;
  4900         	TBool itemsDestroyed;
  4817     	    AddEffectItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
  4901     	    AddFxItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
  4818 	        iFullScreenEffectData->iAppStartScreenshotItemHandle = aHandle;
  4902 	        iFSFxData->iAppStartScreenshotItemHandle = aHandle;
  4819 			}
  4903 			}
  4820         }
  4904         }
  4821     }
  4905     }
  4822 
  4906 
  4823 void CAlfBridge::HandleGfxStopEvent( TBool aClientRequest )
  4907 void CAlfBridge::HandleGfxStopEvent( TBool aClientRequest )
  4824     {
  4908     {
  4825     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent BEGIN");
  4909     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent BEGIN");
  4826     if (!iFullScreenEffectData)
  4910     if (!iFSFxData)
  4827         {
  4911         {
  4828         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END: none");
  4912         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END: none");
  4829         RemoveAllTemporaryPresenterVisuals();
  4913         CleanAllFxVisuals();
  4830         delete iControlEffectData;
  4914         delete iControlEffectData;
  4831         iControlEffectData = NULL;
  4915         iControlEffectData = NULL;
  4832         return;
  4916         return;
  4833         }
  4917         }
  4834     
  4918     
  4835     CFullScreenEffectState* fxData = iFullScreenEffectData;
  4919     CFullScreenEffectState* fxData = iFSFxData;
  4836     iFullScreenEffectData = NULL;
  4920     iFSFxData = NULL;
  4837     CleanupStack::PushL( fxData );
  4921     CleanupStack::PushL( fxData );
  4838     
  4922     
  4839      __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - handle: %d, toAppUid: 0x%x", fxData->iHandle, fxData->iToAppId);
  4923      __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - handle: %d, toAppUid: 0x%x", fxData->iHandle, fxData->iToAppId);
  4840     
  4924     
  4841     // clean effects with this handle       
  4925     // clean effects with this handle       
  4842     RemoveTemporaryPresenterVisual(NULL, fxData->iHandle);
  4926     CleanFxVisual(NULL, fxData->iHandle);
  4843     // this was abort, so we might have received earlier event hiding this window. Here we'll bring it 
  4927     // this was abort, so we might have received earlier event hiding this window. Here we'll bring it 
  4844     // back
  4928     // back
  4845     if (fxData->iToAppId && fxData->iToAppId != KErrNotFound)
  4929     if (fxData->iToAppId && fxData->iToAppId != KErrNotFound)
  4846         {
  4930         {
  4847         RemoveEffectFromApp(fxData->iToSecureId, fxData->iToWg );
  4931         RemoveEffectFromApp(fxData->iToSecureId, fxData->iToWg );
  4848         RemoveEffectFromApp(fxData->iFromSecureId, fxData->iFromWg );
  4932         RemoveEffectFromApp(fxData->iFromSecureId, fxData->iFromWg );
  4849         }
  4933         }
  4850     // abort ALL other possible control effects
  4934     // abort ALL other possible control effects
  4851     RemoveAllTemporaryPresenterVisuals();
  4935     CleanAllFxVisuals();
  4852     
  4936     
  4853     delete iControlEffectData;
  4937     delete iControlEffectData;
  4854     iControlEffectData = NULL;
  4938     iControlEffectData = NULL;
  4855     
  4939     
  4856     iHuiEnv->ContinueRefresh();
  4940     iHuiEnv->ContinueRefresh();
  4860         // Aborted errornously, signal client side
  4944         // Aborted errornously, signal client side
  4861         RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, fxData->iCompletionHandle );
  4945         RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, fxData->iCompletionHandle );
  4862         }
  4946         }
  4863     
  4947     
  4864     CleanupStack::PopAndDestroy( fxData );
  4948     CleanupStack::PopAndDestroy( fxData );
  4865     delete iSecondaryFullScreenEffectData;
  4949     delete iFSFXDataPart2;
  4866     iSecondaryFullScreenEffectData = NULL;
  4950     iFSFXDataPart2 = NULL;
  4867     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END");
  4951     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END");
  4868     }
  4952     }
  4869 
  4953 
  4870 void CAlfBridge::RemoveEffectFromApp(TInt aSecureId, TInt aWgId )
  4954 void CAlfBridge::RemoveEffectFromApp(TInt aSecureId, TInt aWgId )
  4871     {
  4955     {
  4892     
  4976     
  4893         TInt handle = FindEffectHandle(layout);
  4977         TInt handle = FindEffectHandle(layout);
  4894         if (handle != KErrNotFound)
  4978         if (handle != KErrNotFound)
  4895             {
  4979             {
  4896             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - layout visual: 0x%x ; handle: %d ", layout, handle);
  4980             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - layout visual: 0x%x ; handle: %d ", layout, handle);
  4897             RemoveTemporaryPresenterVisual(NULL, handle);
  4981             CleanFxVisual(NULL, handle);
  4898             }
  4982             }
  4899         layout->iOpacity.Set(1.0f); 
  4983         layout->iOpacity.Set(1.0f); 
  4900         }
  4984         }
  4901     }
  4985     }
  4902 
  4986 
  4930         return;
  5014         return;
  4931         }
  5015         }
  4932      
  5016      
  4933     if ( operation == MAlfGfxEffectPlugin::EBeginFullscreen )
  5017     if ( operation == MAlfGfxEffectPlugin::EBeginFullscreen )
  4934         {
  5018         {
  4935         if ( !iFullScreenEffectData || !iFullScreenEffectData->iSetupDone )
  5019         if ( !iFSFxData || !iFSFxData->iSetupDone )
  4936             {
  5020             {
  4937             // No fullsceen effect ongoing or fullscreen effect hasn't yet been set up, 
  5021             // No fullsceen effect ongoing or fullscreen effect hasn't yet been set up, 
  4938             // so we can initialize iFullScreenEffectData from stream.
  5022             // so we can initialize iFSFxData from stream.
  4939             
  5023             
  4940             __ALFFXLOGSTRING("HandleGfxEffectsL - fresh start");
  5024             __ALFFXLOGSTRING("HandleGfxEffectsL - fresh start");
  4941             
  5025             
  4942             CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
  5026             CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
  4943             CleanupStack::PushL( fxData );
  5027             CleanupStack::PushL( fxData );
  4944             fxData->ConstructL( action, stream );
  5028             fxData->ConstructL( action, stream );
  4945             CleanupStack::Pop( fxData );
  5029             CleanupStack::Pop( fxData );
  4946         	
  5030         	
  4947 			// the effect handle of freezed layout (iAppStartScreenshotItemHandle) must match the actual
  5031 			// the effect handle of freezed layout (iAppStartScreenshotItemHandle) must match the actual
  4948 			// effect handle that is run. Only then frozen application can be freed at the end of the effect
  5032 			// effect handle that is run. Only then frozen application can be freed at the end of the effect
  4949 			if (iFullScreenEffectData)
  5033 			if (iFSFxData)
  4950 			{
  5034 			{
  4951             	for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  5035             	for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  4952             	{
  5036             	{
  4953                	 TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  5037                	 TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  4954                	 if (iFullScreenEffectData->iAppStartScreenshotItemHandle == effectItem.iHandle)
  5038                	 if (iFSFxData->iAppStartScreenshotItemHandle == effectItem.iHandle)
  4955                	     {
  5039                	     {
  4956                	     effectItem.iHandle = fxData->iHandle;
  5040                	     effectItem.iHandle = fxData->iHandle;
  4957                	     }
  5041                	     }
  4958                	}
  5042                	}
  4959 			}
  5043 			}
  4960             
  5044             
  4961             if (iFullScreenEffectData && iFullScreenEffectData->iToAppId != fxData->iToAppId)
  5045             if (iFSFxData && iFSFxData->iToAppId != fxData->iToAppId)
  4962                 {
  5046                 {
  4963 				__ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - WARNING - Another fullscreen effect to different app. Deleting the previous ongoing effect"); 
  5047 				__ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - WARNING - Another fullscreen effect to different app. Deleting the previous ongoing effect"); 
  4964                 RemoveEffectFromApp(iFullScreenEffectData->iToSecureId, iFullScreenEffectData->iToWg);// Fullscreen effect for another app has arrived, and the previous has not finished and abort effect was not called.
  5048                 RemoveEffectFromApp(iFSFxData->iToSecureId, iFSFxData->iToWg);// Fullscreen effect for another app has arrived, and the previous has not finished and abort effect was not called.
  4965                 RemoveEffectFromApp(iFullScreenEffectData->iFromSecureId, iFullScreenEffectData->iFromWg);
  5049                 RemoveEffectFromApp(iFSFxData->iFromSecureId, iFSFxData->iFromWg);
  4966                 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - Effect request has changed from appUid 0x%x to 0x%x. Cancel previous effect.", iFullScreenEffectData->iToAppId, fxData->iToAppId);
  5050                 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - Effect request has changed from appUid 0x%x to 0x%x. Cancel previous effect.", iFSFxData->iToAppId, fxData->iToAppId);
  4967                 RemoveEffectFromApp(iFullScreenEffectData->iToAppId);
  5051                 RemoveEffectFromApp(iFSFxData->iToAppId);
  4968                 // Fullscreen effect for another 
  5052                 // Fullscreen effect for another 
  4969                 }
  5053                 }
  4970 
  5054 
  4971                delete iFullScreenEffectData;
  5055                delete iFSFxData;
  4972                delete iSecondaryFullScreenEffectData;
  5056                delete iFSFXDataPart2;
  4973                iSecondaryFullScreenEffectData = NULL;
  5057                iFSFXDataPart2 = NULL;
  4974             iFullScreenEffectData = fxData;
  5058             iFSFxData = fxData;
  4975             iFullScreenEffectData->iAppStartScreenshotItemHandle = fxData->iHandle;
  5059             iFSFxData->iAppStartScreenshotItemHandle = fxData->iHandle;
  4976             
  5060             
  4977             stream.Release();
  5061             stream.Release();
  4978             }
  5062             }
  4979         else
  5063         else
  4980             {
  5064             {
  4983             // For now, we continue ongoing.
  5067             // For now, we continue ongoing.
  4984             
  5068             
  4985             __ALFFXLOGSTRING("HandleGfxEffectsL - END: ongoing");
  5069             __ALFFXLOGSTRING("HandleGfxEffectsL - END: ongoing");
  4986             
  5070             
  4987             // Client expects completion to be signalled with this handle.
  5071             // Client expects completion to be signalled with this handle.
  4988             iFullScreenEffectData->iCompletionHandle = stream.ReadInt32L();
  5072             iFSFxData->iCompletionHandle = stream.ReadInt32L();
  4989             if (iSecondaryFullScreenEffectData)
  5073             if (iFSFXDataPart2)
  4990                 {
  5074                 {
  4991                 // Two phase effect path has been chosen. First part is now ongoing, and second part will be 
  5075                 // Two phase effect path has been chosen. First part is now ongoing, and second part will be 
  4992                 // triggered after that. Client has now notified, that its screen is ready. We may trigger the 
  5076                 // triggered after that. Client has now notified, that its screen is ready. We may trigger the 
  4993                 // second effect as soon as the first part finishes.
  5077                 // second effect as soon as the first part finishes.
  4994                 __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Trigger second part. when 1st part done.");
  5078                 __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Trigger second part. when 1st part done.");
  4995                 iSecondaryFullScreenEffectData->iCompletionHandle = iFullScreenEffectData->iCompletionHandle;
  5079                 iFSFXDataPart2->iCompletionHandle = iFSFxData->iCompletionHandle;
  4996                 }
  5080                 }
  4997             
  5081             
  4998             stream.Release();           
  5082             stream.Release();           
  4999             return ; 
  5083             return ; 
  5000             }
  5084             }
  5002     else // MAlfGfxEffectPlugin::EEndFullscreen
  5086     else // MAlfGfxEffectPlugin::EEndFullscreen
  5003         {
  5087         {
  5004         // End fullscreen signal received. We proceed only if there is really
  5088         // End fullscreen signal received. We proceed only if there is really
  5005         // effect ongoing and "end fullscreen" hasn't already been processed.
  5089         // effect ongoing and "end fullscreen" hasn't already been processed.
  5006         
  5090         
  5007         if ( !iFullScreenEffectData 
  5091         if ( !iFSFxData 
  5008                 || iFullScreenEffectData->State() == EFinalEffectActive
  5092                 || iFSFxData->State() == EFinalEffectActive
  5009                 || iFullScreenEffectData->State() == EEndFullscreenReceived)
  5093                 || iFSFxData->State() == EEndFullscreenReceived)
  5010             {
  5094             {
  5011             if (iFullScreenEffectData)
  5095             if (iFSFxData)
  5012             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEffectsL - END: fx ready, state %d ", iFullScreenEffectData->State());
  5096             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEffectsL - END: fx ready, state %d ", iFSFxData->State());
  5013             stream.Release();
  5097             stream.Release();
  5014             return;
  5098             return;
  5015             }
  5099             }
  5016         CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
  5100         CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
  5017         CleanupStack::PushL( fxData );
  5101         CleanupStack::PushL( fxData );
  5018         fxData->ConstructL( KErrUnknown, stream );
  5102         fxData->ConstructL( KErrUnknown, stream );
  5019         
  5103         
  5020         TBool timeout = fxData->iTimeout;
  5104         TBool timeout = fxData->iTimeout;
  5021         // could the application be ready?
  5105         // could the application be ready?
  5022         CHuiControlGroup* applicationExists = FindControlGroupByFullScreenToEffect();
  5106         TBool applicationExists = FindControlGroupByFullScreenToEffect() != NULL ? ETrue : EFalse;
       
  5107 
       
  5108         // It may be, that application exited already and it was moved already to effect group
       
  5109         if (iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect && !applicationExists )
       
  5110             {
       
  5111             applicationExists = FindLayoutByEffectHandle(fxData->iHandle) != NULL ? ETrue : EFalse;
       
  5112             }
  5023                 
  5113                 
  5024         TBool longAppStartTimeout = fxData->iLongAppStartTimeout; 
  5114         TBool longAppStartTimeout = fxData->iLongAppStartTimeout; 
  5025         
  5115         
  5026         if (iFullScreenEffectData &&
  5116         if (iFSFxData &&
  5027                 !iSecondaryFullScreenEffectData && // second part has not been requested yet
  5117                 !iFSFXDataPart2 && // second part has not been requested yet
  5028                 longAppStartTimeout && // this is indeed timeout for app start effect
  5118                 longAppStartTimeout && // this is indeed timeout for app start effect
  5029                 iFullScreenEffectData->iTwoPhaseEffect == CFullScreenEffectState::EOnlyOnePart && // second part has not been activated. note, that iSecondaryFullScreenEffectData would be NULL in this case 
  5119                 iFSFxData->iTwoPhaseEffect == CFullScreenEffectState::EOnlyOnePart && // second part has not been activated. note, that iFSFXDataPart2 would be NULL in this case 
  5030                 (iFullScreenEffectData->State() == EWaitEndFullScreen 
  5120                 (iFSFxData->State() == EWaitEndFullScreen 
  5031                  || iFullScreenEffectData->State() == EWaitingWindowGroup))
  5121                  || iFSFxData->State() == EWaitingWindowGroup))
  5032             {
  5122             {
  5033             // Load the whole structure. If timeout was triggered then request effect name to be
  5123             // Load the whole structure. If timeout was triggered then request effect name to be
  5034             // updated.
  5124             // updated.
  5035             UpdateSecondaryEffectL(*fxData);
  5125             UpdateSecondaryEffectL(*fxData);
  5036             iFullScreenEffectData->iLongAppStartTimeout = fxData->iLongAppStartTimeout;
  5126             iFSFxData->iLongAppStartTimeout = fxData->iLongAppStartTimeout;
  5037             iFullScreenEffectData->iTwoPhaseEffect = CFullScreenEffectState::EFirstPartActive;
  5127             iFSFxData->iTwoPhaseEffect = CFullScreenEffectState::EFirstPartActive;
  5038             iFullScreenEffectData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
  5128             iFSFxData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
  5039             }
  5129             }
  5040 
  5130 
  5041         __ALFFXLOGSTRING4("HandleGfxEffectsL - iTwoPhaseEffect %d, Setup done: %d, Timeout: %d, long app start timeout: %d", iFullScreenEffectData->iTwoPhaseEffect,iFullScreenEffectData->iSetupDone, timeout,longAppStartTimeout);
  5131         __ALFFXLOGSTRING4("HandleGfxEffectsL - iTwoPhaseEffect %d, Setup done: %d, Timeout: %d, long app start timeout: %d", iFSFxData->iTwoPhaseEffect,iFSFxData->iSetupDone, timeout,longAppStartTimeout);
  5042         if (!fxData->iLongAppStartTimeout) // endfullscreen originating from the application
  5132         if (!fxData->iLongAppStartTimeout) // endfullscreen originating from the application
  5043             {
  5133             {
  5044             if (iFullScreenEffectData->State() == EWaitingWindowGroup)
  5134             if (iFSFxData->State() == EWaitingWindowGroup)
  5045                 {
  5135                 {
  5046                 iFullScreenEffectData->SetState(EEndFullScreenReceivedWaitingWindowGroup);
  5136                 iFSFxData->SetState(EEndFullScreenReceivedWaitingWindowGroup);
  5047                 }
  5137                 }
  5048             else
  5138             else
  5049                 {
  5139                 {
  5050                 iFullScreenEffectData->SetState(EEndFullscreenReceived);
  5140                 iFSFxData->SetState(EEndFullscreenReceived);
  5051                 }
  5141                 }
  5052             
  5142             
  5053             if (iSecondaryFullScreenEffectData)
  5143             if (iFSFXDataPart2)
  5054                 {
  5144                 {
  5055                 iSecondaryFullScreenEffectData->SetState(EEndFullscreenReceived);
  5145                 iFSFXDataPart2->SetState(EEndFullscreenReceived);
  5056                 }
  5146                 }
  5057             
  5147             
  5058             }
  5148             }
  5059         CleanupStack::PopAndDestroy( fxData );
  5149         CleanupStack::PopAndDestroy( fxData );
  5060         fxData = NULL;
  5150         fxData = NULL;
  5061         
  5151         
  5062         __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEffectsL - Regular timeout: %d, Slow start timeout: %d, Effect setup: %d, State: %d",
  5152         __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEffectsL - Regular timeout: %d, Slow start timeout: %d, Effect setup: %d, State: %d",
  5063                 timeout,
  5153                 timeout,
  5064                 longAppStartTimeout,
  5154                 longAppStartTimeout,
  5065                 iFullScreenEffectData->iSetupDone,
  5155                 iFSFxData->iSetupDone,
  5066                 iFullScreenEffectData->State());
  5156                 iFSFxData->State());
  5067 
  5157 
  5068         stream.Release();// We should respect normal timeouts.
  5158         stream.Release();// We should respect normal timeouts.
  5069         if (iFullScreenEffectData->iTwoPhaseEffect > CFullScreenEffectState::EOnlyOnePart
  5159         if (iFSFxData->iTwoPhaseEffect > CFullScreenEffectState::EOnlyOnePart
  5070                 && iFullScreenEffectData->iSetupDone && timeout && longAppStartTimeout) // timeout = endfullscreen was requested or it was normal endfullscreen timeout, longAppStartTime = 
  5160                 && iFSFxData->iSetupDone && timeout && longAppStartTimeout) // timeout = endfullscreen was requested or it was normal endfullscreen timeout, longAppStartTime = 
  5071             {
  5161             {
  5072             // If this is two phased effect, it can be started only by application request of endfullscreen (!timeout)
  5162             // If this is two phased effect, it can be started only by application request of endfullscreen (!timeout)
  5073             // or screen drawn (triggered from 
  5163             // or screen drawn (triggered from 
  5074             __ALFFXLOGSTRING("HandleGfxEffectsL - Two phase effect. Waiting second part to start. Skip this event.");
  5164             __ALFFXLOGSTRING("HandleGfxEffectsL - Two phase effect. Waiting second part to start. Skip this event.");
  5075             return;
  5165             return;
  5076             }
  5166             }
  5077         
  5167         
  5078         // If client triggered EndFullScreen has been received, and still we haven't seen sign of the application, we know
  5168         // If client triggered EndFullScreen has been received, and still we haven't seen sign of the application, we know
  5079         // things have gone wrong and will not go right. Clean up the mess.
  5169         // things have gone wrong and will not go right. Clean up the mess.
  5080         if (iFullScreenEffectData->State() == EEndFullscreenReceived && !applicationExists && !timeout)
  5170         if (iFSFxData->State() == EEndFullscreenReceived && !applicationExists && !timeout)
  5081             {
  5171             {
  5082             HandleGfxStopEvent(ETrue);
  5172             HandleGfxStopEvent(ETrue);
  5083             return;
  5173             return;
  5084             }
  5174             }
  5085         }
  5175 	    // If a long two part app start effect is ongoing or about to start, we can skip directly to the 
  5086 
  5176 		// second part when EndFullScreen request arrives.
  5087     CFullScreenEffectState* fxData = iFullScreenEffectData;
  5177         if (iFSFXDataPart2 && iFSFxData 
       
  5178 				&& applicationExists
       
  5179                 && iFSFXDataPart2->State() == EEndFullscreenReceived 
       
  5180                 && iFSFxData->iHandle == iFSFXDataPart2->iHandle )
       
  5181             {
       
  5182             AlfGfxEffectEndCallBack(iFSFxData->iHandle);
       
  5183             return;
       
  5184             }
       
  5185         }
       
  5186 
       
  5187     CFullScreenEffectState* fxData = iFSFxData;
  5088     fxData->iOperation = operation;
  5188     fxData->iOperation = operation;
  5089 
  5189 
  5090     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEffectsL - Operation: %d, handle: %d, type: %d", operation, fxData->iHandle, fxData->iType);
  5190     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEffectsL - Operation: %d, handle: %d, type: %d", operation, fxData->iHandle, fxData->iType);
  5091     __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - towg: %d, fromwg: %d", fxData->iToWg, fxData->iFromWg);
  5191     __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - towg: %d, fromwg: %d", fxData->iToWg, fxData->iFromWg);
  5092 
  5192 
  5121             {
  5221             {
  5122             failed = HandleGfxEventL(*fxData, toLayout, fromLayout);
  5222             failed = HandleGfxEventL(*fxData, toLayout, fromLayout);
  5123             // We found layout, and this was beginfullscreen event. Wait for endfullscreen to be triggered
  5223             // We found layout, and this was beginfullscreen event. Wait for endfullscreen to be triggered
  5124             if (fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen)
  5224             if (fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen)
  5125                 {
  5225                 {
  5126                 iFullScreenEffectData->SetState(EWaitEndFullScreen);
  5226                 iFSFxData->SetState(EWaitEndFullScreen);
  5127                 }
  5227                 }
  5128             }
  5228             }
  5129         else
  5229         else
  5130             {
  5230             {
  5131             __ALFFXLOGSTRING("HandleGfxEffectsL - waiting window group");            
  5231             __ALFFXLOGSTRING("HandleGfxEffectsL - waiting window group");            
  5134         }
  5234         }
  5135 
  5235 
  5136     if ( failed )
  5236     if ( failed )
  5137         {
  5237         {
  5138         // Effect failed, reset state
  5238         // Effect failed, reset state
  5139         HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
  5239         HandleGfxStopEvent( EFalse ); // destroys iFSFxData and iFSFXDataPart2
  5140         }
  5240         }
  5141     else
  5241     else
  5142         {
  5242         {
  5143         // it might be that the application is already having drawing for the whole screen. 
  5243         // it might be that the application is already having drawing for the whole screen. 
  5144 		// If so, then trigger EndFullScreen immediately.
  5244 		// If so, then trigger EndFullScreen immediately.
  5166     
  5266     
  5167     __ALFFXLOGSTRING1("CAlfBridge::UpdateSecondaryEffectL - appstart timeout triggered: %d", aState.iLongAppStartTimeout);
  5267     __ALFFXLOGSTRING1("CAlfBridge::UpdateSecondaryEffectL - appstart timeout triggered: %d", aState.iLongAppStartTimeout);
  5168     if (aState.iLongAppStartTimeout) // only application start effects can trigger this timeout 
  5268     if (aState.iLongAppStartTimeout) // only application start effects can trigger this timeout 
  5169         {
  5269         {
  5170         // clone the primary startup effect for later usage
  5270         // clone the primary startup effect for later usage
  5171         delete iSecondaryFullScreenEffectData;
  5271         delete iFSFXDataPart2;
  5172         iSecondaryFullScreenEffectData = new (ELeave) CFullScreenEffectState;
  5272         iFSFXDataPart2 = new (ELeave) CFullScreenEffectState;
  5173         iSecondaryFullScreenEffectData->ConstructL(*iFullScreenEffectData);
  5273         iFSFXDataPart2->ConstructL(*iFSFxData);
  5174         iSecondaryFullScreenEffectData->iLongAppStartTimeout = EFalse;
  5274         iFSFXDataPart2->iLongAppStartTimeout = EFalse;
  5175         
  5275         
  5176         delete iFullScreenEffectData->iEffectName;
  5276         delete iFSFxData->iEffectName;
  5177         iFullScreenEffectData->iEffectName = NULL;
  5277         iFSFxData->iEffectName = NULL;
  5178         iFullScreenEffectData->iEffectName = aState.iEffectName->AllocL();
  5278         iFSFxData->iEffectName = aState.iEffectName->AllocL();
  5179         }
  5279         }
  5180     __ALFFXLOGSTRING("CAlfBridge::UpdateSecondaryEffectL <<" );
  5280     __ALFFXLOGSTRING("CAlfBridge::UpdateSecondaryEffectL <<" );
  5181     return EFalse;
  5281     return EFalse;
  5182     }    
  5282     }    
  5183 
  5283 
  5212             {
  5312             {
  5213             fullscreenCovered = HasActiveAlfContent(clientGroupId);
  5313             fullscreenCovered = HasActiveAlfContent(clientGroupId);
  5214             }
  5314             }
  5215         }
  5315         }
  5216     
  5316     
  5217     __ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - Covered: %d", fullscreenCovered);
  5317     __ALFFXLOGSTRING2("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - SecureId: 0x%x, Covered: %d", aToGroup->SecureId(), fullscreenCovered);
  5218     if (fullscreenCovered)
  5318     if (fullscreenCovered)
  5219         {
  5319         {
  5220         GfxTriggerEndFullScreen(iFullScreenEffectData);
  5320         if (iFSFxData->iTwoPhaseEffect == CFullScreenEffectState::EFirstPartRunning)
       
  5321             {
       
  5322             // effect has two parts, and the first one is ongoing. We'll skip to the second part. 
       
  5323             delete iFSFxData;
       
  5324             iFSFxData = iFSFXDataPart2;
       
  5325             iFSFXDataPart2 = NULL;
       
  5326             iFSFxData->iTwoPhaseEffect = CFullScreenEffectState::ESecondPartActive;
       
  5327              // Client notified of the EndFullScreen during the effect. Trigger the end part immediately.
       
  5328              __ALFFXLOGSTRING("CAlfBridge::AlfGfxEffectEndCallBack - End was received. Trigger second part.");
       
  5329              GfxTriggerEndFullScreen(iFSFxData);
       
  5330              iFSFxData->SetState(EFinalEffectActive);
       
  5331             }
       
  5332         else
       
  5333             {
       
  5334             GfxTriggerEndFullScreen(iFSFxData); // trigger effect
       
  5335             }
  5221         return ETrue;
  5336         return ETrue;
  5222         }
  5337         }
  5223     return EFalse;
  5338     return EFalse;
  5224     }
  5339     }
  5225 
  5340 
  5242     TInt toAppUi = stream.ReadInt32L();
  5357     TInt toAppUi = stream.ReadInt32L();
  5243     stream.Release();
  5358     stream.Release();
  5244 
  5359 
  5245     // operation tells if this is abort full screen or something else
  5360     // operation tells if this is abort full screen or something else
  5246     // When this function is used to abort control transitions, all data is 0s
  5361     // When this function is used to abort control transitions, all data is 0s
  5247     if ( iFullScreenEffectData )
  5362     if ( iFSFxData )
  5248         {
  5363         {
  5249         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill fullscreen");        
  5364         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill fullscreen");        
  5250         HandleGfxStopEvent( ETrue );
  5365         HandleGfxStopEvent( ETrue );
  5251         }
  5366         }
  5252     
  5367     
  5253     if ( !toAppUi )
  5368     if ( !toAppUi )
  5254         {
  5369         {
  5255         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill all");
  5370         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill all");
  5256         RemoveAllTemporaryPresenterVisuals();
  5371         CleanAllFxVisuals();
  5257         iHuiEnv->ContinueRefresh();
  5372         iHuiEnv->ContinueRefresh();
  5258         }
  5373         }
  5259     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - end");
  5374     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - end");
  5260     }
  5375     }
  5261 
  5376 
  5274     iControlEffectData = NULL;
  5389     iControlEffectData = NULL;
  5275         
  5390         
  5276     if (handle != KErrNotFound)
  5391     if (handle != KErrNotFound)
  5277         {
  5392         {
  5278         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxStopControlEffectsL - Remove effect with handle: %d", handle);
  5393         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxStopControlEffectsL - Remove effect with handle: %d", handle);
  5279         RemoveTemporaryPresenterVisual(NULL, handle);
  5394         CleanFxVisual(NULL, handle);
  5280         iHuiEnv->ContinueRefresh();
  5395         iHuiEnv->ContinueRefresh();
  5281         }
  5396         }
  5282     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopControlEffectsL - end");
  5397     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopControlEffectsL - end");
  5283     }
  5398     }
  5284 
  5399 
  5358         {
  5473         {
  5359         engine->RegisterEffectL(aFilename);
  5474         engine->RegisterEffectL(aFilename);
  5360         }
  5475         }
  5361     }
  5476     }
  5362 
  5477 
  5363 CHuiCanvasVisual* CAlfBridge::AddEffectItemL(
  5478 CHuiCanvasVisual* CAlfBridge::AddFxItemL(
  5364         TInt aEffectHandle, 
  5479         TInt aEffectHandle, 
  5365         CHuiVisual* aSourceVisual, 
  5480         CHuiVisual* aSourceVisual, 
  5366         CHuiLayout* aTargetLayout, 
  5481         CHuiLayout* aTargetLayout, 
  5367         CHuiControl* aEffectControl, 
  5482         CHuiControl* aEffectControl, 
  5368         TBool aInsertTemporaryVisual,
  5483         TBool aInsertTemporaryVisual,
  5394     
  5509     
  5395         // removes the effect, and the visual (if EShouldDestroy flag enabled). Removes from effect
  5510         // removes the effect, and the visual (if EShouldDestroy flag enabled). Removes from effect
  5396         // cleanup stack iEffectCleanupStack
  5511         // cleanup stack iEffectCleanupStack
  5397         enableEffect = aSourceVisual->Flags() & EHuiVisualFlagShouldDestroy ? 0 : 1;
  5512         enableEffect = aSourceVisual->Flags() & EHuiVisualFlagShouldDestroy ? 0 : 1;
  5398         __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - visual 0x%x is having effect. EShouldBeDestroyed flag state %d", &aSourceVisual, enableEffect );
  5513         __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - visual 0x%x is having effect. EShouldBeDestroyed flag state %d", &aSourceVisual, enableEffect );
  5399         RemoveTemporaryPresenterVisual(aSourceVisual);
  5514         CleanFxVisual(aSourceVisual);
  5400         if (!enableEffect)
  5515         if (!enableEffect)
  5401             {
  5516             {
  5402             aItemDestroyed++;
  5517             aItemDestroyed++;
  5403             }
  5518             }
  5404         }
  5519         }
  5451         TBool aCanDestroyOrHideImmediately)
  5566         TBool aCanDestroyOrHideImmediately)
  5452     {
  5567     {
  5453     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x is having %d children", aSourceLayout, aSourceLayout->Count());
  5568     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x is having %d children", aSourceLayout, aSourceLayout->Count());
  5454     if (aAddLayout)
  5569     if (aAddLayout)
  5455         {
  5570         {
  5456         AddEffectItemL(aEffectHandle, aSourceLayout, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
  5571         AddFxItemL(aEffectHandle, aSourceLayout, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
  5457         }
  5572         }
  5458         
  5573         
  5459     for (TInt i = 0; i < aSourceLayout->Count(); i++)
  5574     for (TInt i = 0; i < aSourceLayout->Count(); i++)
  5460            {
  5575            {
  5461            CHuiCanvasVisual& sourceVisual = static_cast<CHuiCanvasVisual&> (aSourceLayout->Visual(i));
  5576            CHuiCanvasVisual& sourceVisual = static_cast<CHuiCanvasVisual&> (aSourceLayout->Visual(i));
  5464                {
  5579                {
  5465                CHuiLayout& layout = static_cast<CHuiLayout&> (aSourceLayout->Visual(i));
  5580                CHuiLayout& layout = static_cast<CHuiLayout&> (aSourceLayout->Visual(i));
  5466                AddToEffectLayoutContainerL(aEffectHandle, &layout, NULL, aEffectControl, aItemsDestroyed, aIsFullScreenEffect,  EFalse, aIsExitEffect, aCanDestroyOrHideImmediately );
  5581                AddToEffectLayoutContainerL(aEffectHandle, &layout, NULL, aEffectControl, aItemsDestroyed, aIsFullScreenEffect,  EFalse, aIsExitEffect, aCanDestroyOrHideImmediately );
  5467                }
  5582                }
  5468            TInt oldItemsDestroyed = aItemsDestroyed;
  5583            TInt oldItemsDestroyed = aItemsDestroyed;
  5469            AddEffectItemL(aEffectHandle, &sourceVisual, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
  5584            AddFxItemL(aEffectHandle, &sourceVisual, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
  5470            if (oldItemsDestroyed != aItemsDestroyed)
  5585            if (oldItemsDestroyed != aItemsDestroyed)
  5471                {
  5586                {
  5472                // Visual was destroyed. If so, then we must adjust index.
  5587                // Visual was destroyed. If so, then we must adjust index.
  5473                --i;
  5588                --i;
  5474                }
  5589                }
  5476     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
  5591     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
  5477     }
  5592     }
  5478 
  5593 
  5479 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsFullScreenEffect, TBool aIsExitEffect, TBool aCanDestroyOrHideImmediately)
  5594 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsFullScreenEffect, TBool aIsExitEffect, TBool aCanDestroyOrHideImmediately)
  5480     {
  5595     {
  5481     __ALFFXLOGSTRING4("CAlfBridge::SetupEffectLayoutContainerL - aHandle: %d, aSourceLayout: 0x%x, aIsExitEffect: % d, CanDestroyOrHideImmediately: %d >>", 
  5596     __ALFFXLOGSTRING4("CAlfBridge::SetupEffectLayoutContainerL - aHandle: %d, aSourceLayout: 0x%x, aIsExitEffect: %d, CanDstrOrHideImd.:%d >>", 
  5482             aHandle, 
  5597             aHandle, 
  5483             aSourceLayout, 
  5598             aSourceLayout, 
  5484             aIsExitEffect,
  5599             aIsExitEffect,
  5485             aCanDestroyOrHideImmediately );
  5600             aCanDestroyOrHideImmediately );
  5486     
  5601     
  5499     TInt itemsDestroyed(0);
  5614     TInt itemsDestroyed(0);
  5500     AddToEffectLayoutContainerL(aHandle, aSourceLayout, NULL, &effectControlGroup, itemsDestroyed, aIsFullScreenEffect, EFalse, aIsExitEffect, aCanDestroyOrHideImmediately);
  5615     AddToEffectLayoutContainerL(aHandle, aSourceLayout, NULL, &effectControlGroup, itemsDestroyed, aIsFullScreenEffect, EFalse, aIsExitEffect, aCanDestroyOrHideImmediately);
  5501 
  5616 
  5502     if (aIsExitEffect)
  5617     if (aIsExitEffect)
  5503         {
  5618         {
  5504         CHuiCanvasVisual* temporaryPresenterVisual = AddEffectItemL(aHandle, aSourceLayout, &effectControlGroupLayout, &effectControlGroup, ETrue, itemsDestroyed, aIsFullScreenEffect, aIsExitEffect, EFalse);
  5619         CHuiCanvasVisual* temporaryPresenterVisual = AddFxItemL(aHandle, aSourceLayout, &effectControlGroupLayout, &effectControlGroup, ETrue, itemsDestroyed, aIsFullScreenEffect, aIsExitEffect, EFalse);
  5505         aSourceLayout->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  5620         aSourceLayout->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  5506         __ALFFXLOGSTRING3("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout)-> 0x%x (presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout, temporaryPresenterVisual);
  5621         __ALFFXLOGSTRING3("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout)-> 0x%x (presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout, temporaryPresenterVisual);
  5507         }
  5622         }
  5508     else
  5623     else
  5509         {
  5624         {
  5510         AddEffectItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, EFalse, itemsDestroyed, aIsFullScreenEffect, EFalse, EFalse);
  5625         AddFxItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, EFalse, itemsDestroyed, aIsFullScreenEffect, EFalse, EFalse);
  5511         __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout), NO presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout);
  5626         __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout), NO presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout);
  5512         }
  5627         }
  5513     iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue;
  5628     iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue;
  5514     iAlfScreens[0]->iDisplay->SetDirty();
  5629     iAlfScreens[0]->iDisplay->SetDirty();
  5515     if (itemsDestroyed)
  5630     if (itemsDestroyed)
  5619             RecursiveStoreRenderBufferL(aCanvasVisual);
  5734             RecursiveStoreRenderBufferL(aCanvasVisual);
  5620             }
  5735             }
  5621 
  5736 
  5622         // clear out old effect if this visual has one
  5737         // clear out old effect if this visual has one
  5623         __ALFFXLOGSTRING2("HandleGfxControlEffectsL - loading effect %S on visual 0x%x", aEvent.iEffectName, aCanvasVisual );
  5738         __ALFFXLOGSTRING2("HandleGfxControlEffectsL - loading effect %S on visual 0x%x", aEvent.iEffectName, aCanvasVisual );
  5624         __ALFFXLOGSTRING1("HandleGfxControlEffectsL - loading control effect, handle %d", aEvent.iHandle );
  5739         __ALFFXLOGSTRING2("HandleGfxControlEffectsL - loading control effect, handle %d, Action: %d", aEvent.iHandle, aEvent.iAction );
  5625         if (aCanvasVisual->Effect())
  5740         if (aCanvasVisual->Effect())
  5626             {
  5741             {
  5627             __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x has active effect. Requesting removal.", aCanvasVisual);
  5742             __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x has active effect. Requesting removal.", aCanvasVisual);
  5628             // another effect coming to already effected visual. E.g. close options menu, while opening effect still ongoing
  5743             // another effect coming to already effected visual. E.g. close options menu, while opening effect still ongoing
  5629             RemoveTemporaryPresenterVisual(aCanvasVisual);
  5744             CleanFxVisual(aCanvasVisual);
  5630             }
  5745             }
  5631         TBool layoutEffectable(EFalse);
  5746         TBool layoutEffectable(EFalse);
  5632         if (aEvent.iAction == KGfxControlDisappearAction)
  5747         if (aEvent.iAction == KGfxControlDisappearAction)
  5633             { // TODO: revise
  5748             {
  5634             // The control stays visible because the inactive flag is not set
  5749             if (aCanvasVisual->Flags() & EHuiVisualFlagInactive)
  5635             // if the window is reserved.
  5750                 {
  5636             /*if (aCanvasVisual->iOpacity.Target() == 0.0f)
  5751                 __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x is inactive. Skipping effect.", aCanvasVisual);
  5637                 {
  5752                 return;
  5638                 // this visual was hidden, before the effect arrived. sounds like trouble.
  5753                 }
  5639                 // Lets make it visible again, and ask it to be hidden in the end of the effect
       
  5640                 // this enables at least the notes disappear effects
       
  5641                 aCanvasVisual->iOpacity.Set(KAlfVisualDefaultOpacity);
       
  5642                 // visual->SetFlag(EHuiVisualFlagShouldBeHidden);
       
  5643                 }*/
       
  5644             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, ETrue, EFalse);
  5754             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, ETrue, EFalse);
  5645             }
  5755             }
  5646         else
  5756         else
  5647             {
  5757             {
  5648             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, EFalse, EFalse);
  5758             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, EFalse, EFalse);
  5669             {
  5779             {
  5670             err = KErrNotFound;
  5780             err = KErrNotFound;
  5671             }
  5781             }
  5672         //            RDebug::Print(_L("HandleGfxControlEffectsL - loading effect returned %d"), err );
  5782         //            RDebug::Print(_L("HandleGfxControlEffectsL - loading effect returned %d"), err );
  5673         // only use the effect if the effect file was correctly parsed
  5783         // only use the effect if the effect file was correctly parsed
       
  5784         aCanvasVisual->SetFreezeState(EFalse);
       
  5785                   
  5674         if (err == KErrNone)
  5786         if (err == KErrNone)
  5675             {
  5787             {
  5676 #ifdef HUI_DEBUG_TRACK_DRAWING  
  5788 #ifdef HUI_DEBUG_TRACK_DRAWING  
  5677             visual->SetTracking(ETrue);
  5789             visual->SetTracking(ETrue);
  5678 #endif                
  5790 #endif                
  5681             // destruction in any order
  5793             // destruction in any order
  5682             }
  5794             }
  5683         else
  5795         else
  5684             {
  5796             {
  5685             // visuals added to "active effect visual" stack, but they wont be used, because effect loading has failed. cleanup.
  5797             // visuals added to "active effect visual" stack, but they wont be used, because effect loading has failed. cleanup.
  5686             RemoveTemporaryPresenterVisual(NULL, aEvent.iHandle);
  5798             CleanFxVisual(NULL, aEvent.iHandle);
  5687             }
  5799             }
  5688         effect = NULL; // HuiVisual has taken ownership
  5800         effect = NULL; // HuiVisual has taken ownership
  5689         }
  5801         }
  5690     }
  5802     }
  5691 
  5803 
  5692 TBool CAlfBridge::RemoveTemporaryPresenterItem(TEffectCleanupStruct& aEffectItem)
  5804 TBool CAlfBridge::CleanFxItem(TEffectCleanupStruct& aEffectItem)
  5693     {
  5805     {
  5694     CHuiVisual* sourceViz = aEffectItem.iEffectedVisual;
  5806     CHuiVisual* sourceViz = aEffectItem.iEffectedVisual;
  5695     CHuiCanvasVisual* sourceViz2 = dynamic_cast<CHuiCanvasVisual*> (aEffectItem.iEffectedVisual);
  5807     CHuiCanvasVisual* sourceViz2 = dynamic_cast<CHuiCanvasVisual*> (aEffectItem.iEffectedVisual);
  5696     // wserv has already hidden this window. Effect has finished, so lets do what 
  5808     // wserv has already hidden this window. Effect has finished, so lets do what 
  5697     // was asked. Also hide, if this is supposed to be destroyed by now.
  5809     // was asked. Also hide, if this is supposed to be destroyed by now.
  5702         sourceViz2->FreeRenderBuffer();
  5814         sourceViz2->FreeRenderBuffer();
  5703         }
  5815         }
  5704     sourceViz->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  5816     sourceViz->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  5705     TBool hideVisual = EFalse;
  5817     TBool hideVisual = EFalse;
  5706     TBool showVisual = ETrue;
  5818     TBool showVisual = ETrue;
       
  5819     // Effect request flow:
       
  5820     // 1. Effect request
       
  5821 	// 2. If component is found, effect started immediately.
       
  5822 	// 	   If component is not found, effect request is cached and applied when window is created. 
       
  5823 	//	     NOTE: Only one effect request can be cached at time. Possible TODO, if this causes
       
  5824 	//       issues.
       
  5825     // 3. Possible change of component visibility (hide / show)
       
  5826     // 4. At the end of the effect the requested visiblity is applied to the visual (hidden / shown)
       
  5827     
       
  5828     // Exceptions 1: If it was disappear effect (aEffectItem.iHideWhenFinished is ETrue), the 
       
  5829     //              component is hidden. This is to guaranteen that e.g. options menu would not popup 
       
  5830     //              after disappear effect, if visual destruction / hiding request did not come in time.
       
  5831     //
       
  5832     // Exception 2: If disapper effect was requested, and component was requested to be hidden, 
       
  5833     //              and then component was requested to be visible DURING the effect, the 
       
  5834     //              component will be shown at the end of the effect. Use case: the same component shows 
       
  5835     //              two sequentive notes and each note dismissal has disappear effect and no appear
       
  5836 	//              effect between.
  5707     if(!aEffectItem.iIsFullScreenEffect)
  5837     if(!aEffectItem.iIsFullScreenEffect)
  5708         {
  5838         {
  5709         hideVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeHidden) || aEffectItem.iHideWhenFinished;
  5839         hideVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeHidden) || (aEffectItem.iHideWhenFinished && !(sourceViz->Flags() & EHuiVisualFlagShouldBeShown));
  5710         showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown) && !aEffectItem.iHideWhenFinished;
  5840         showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown) && (!aEffectItem.iHideWhenFinished || !hideVisual);
  5711         }
  5841         }
  5712     else
  5842     else
  5713         {
  5843         {
  5714         hideVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeHidden);
  5844         hideVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeHidden);
  5715         showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown);
  5845         showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown);
  5716         }
  5846         }
       
  5847     __ALFFXLOGSTRING4("CAlfBridge::RemoveTemporaryPresenterItem - iIsFullScreenEffect: %d, iHideWhenFinished: %d, Hide: %d, Show: %d", aEffectItem.iIsFullScreenEffect, aEffectItem.iHideWhenFinished, hideVisual, showVisual);
  5717     TBool destroyVisual = sourceViz->Flags() & EHuiVisualFlagShouldDestroy;
  5848     TBool destroyVisual = sourceViz->Flags() & EHuiVisualFlagShouldDestroy;
  5718     TBool shouldInactivate = sourceViz->Flags() & EHuiVisualFlagShouldBeInactive;
  5849     TBool shouldInactivate = sourceViz->Flags() & EHuiVisualFlagShouldBeInactive;
  5719     TBool shouldBeUnderOpaqueHint = sourceViz->Flags() & EHuiVisualFlagShouldBeUnderOpaqueHint;
  5850     TBool shouldBeUnderOpaqueHint = sourceViz->Flags() & EHuiVisualFlagShouldBeUnderOpaqueHint;
  5720     __ALFFXLOGSTRING3("CAlfBridge::RemoveTemporaryPresenterItem - cleaning handle: %d, 0x%x -> 0x%x", aEffectItem.iHandle, aEffectItem.iEffectedVisual, aEffectItem.iTemporaryPresenterVisual);
  5851     __ALFFXLOGSTRING3("CAlfBridge::RemoveTemporaryPresenterItem - cleaning handle: %d, 0x%x -> 0x%x", aEffectItem.iHandle, aEffectItem.iEffectedVisual, aEffectItem.iTemporaryPresenterVisual);
  5721     __ALFFXLOGSTRING3("CAlfBridge::RemoveTemporaryPresenterItem - hide %d, destroy %d, should inactivate: %d", TBool(hideVisual), TBool(destroyVisual), TBool(shouldInactivate));
  5852     __ALFFXLOGSTRING3("CAlfBridge::RemoveTemporaryPresenterItem - hide %d, destroy %d, should inactivate: %d", TBool(hideVisual), TBool(destroyVisual), TBool(shouldInactivate));
  5815             }
  5946             }
  5816         }
  5947         }
  5817     return TBool(destroyVisual);
  5948     return TBool(destroyVisual);
  5818     }
  5949     }
  5819 
  5950 
  5820 // RemoveTemporaryPresenterVisual removes the temporary presenter visual, and unbinds it from the source. 
  5951 // CleanFxVisual removes the temporary presenter visual, and unbinds it from the source. 
  5821 TBool CAlfBridge::RemoveTemporaryPresenterVisual(CHuiVisual* aVisual,
  5952 TBool CAlfBridge::CleanFxVisual(CHuiVisual* aVisual,
  5822         TInt aHandle)
  5953         TInt aHandle)
  5823     {
  5954     {
  5824     __ALFFXLOGSTRING2("CAlfBridge::RemoveTemporaryPresenterVisual - cleaning handle: %d, 0x%x", aHandle, aVisual);
  5955     __ALFFXLOGSTRING2("CAlfBridge::RemoveTemporaryPresenterVisual - cleaning handle: %d, 0x%x", aHandle, aVisual);
  5825     TInt visualsRemoved = 0;
  5956     TInt visualsRemoved = 0;
  5826     for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  5957     for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  5827         {
  5958         {
  5828         TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  5959         TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  5829         if (aVisual == effectItem.iEffectedVisual || 
  5960         if (aVisual == effectItem.iEffectedVisual || 
  5830 		    aHandle == effectItem.iHandle)
  5961 		    aHandle == effectItem.iHandle)
  5831             {
  5962             {
  5832             if (RemoveTemporaryPresenterItem(effectItem))
  5963             if (CleanFxItem(effectItem))
  5833                 {
  5964                 {
  5834                 visualsRemoved++;
  5965                 visualsRemoved++;
  5835                 }
  5966                 }
  5836             // must remove from finished effects to keep it in sync
  5967             // must remove from finished effects to keep it in sync
  5837             for(TInt k = 0; k < iFinishedCleanupStackEffects.Count(); k++)
  5968             for(TInt k = 0; k < iFinishedCleanupStackEffects.Count(); k++)
  5906         }
  6037         }
  5907     return NULL;
  6038     return NULL;
  5908     }
  6039     }
  5909 
  6040 
  5910 
  6041 
  5911 TBool CAlfBridge::RemoveTemporaryPresenterVisuals()
  6042 TBool CAlfBridge::CleanFxVisuals()
  5912     {
  6043     {
  5913     if (!iFinishedCleanupStackEffects.Count())
  6044     if (!iFinishedCleanupStackEffects.Count())
  5914         {
  6045         {
  5915         return 0;
  6046         return 0;
  5916         }
  6047         }
  5926             __ALFFXLOGSTRING2("CAlfBridge::RemoveTemporaryPresenterVisuals - looping, finished count: %d, index in active effecs: %d", iFinishedCleanupStackEffects.Count(), i );
  6057             __ALFFXLOGSTRING2("CAlfBridge::RemoveTemporaryPresenterVisuals - looping, finished count: %d, index in active effecs: %d", iFinishedCleanupStackEffects.Count(), i );
  5927             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  6058             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  5928              
  6059              
  5929             if (iFinishedCleanupStackEffects[0] == effectItem.iHandle)
  6060             if (iFinishedCleanupStackEffects[0] == effectItem.iHandle)
  5930                 {
  6061                 {
  5931                 if (RemoveTemporaryPresenterItem(effectItem))
  6062                 if (CleanFxItem(effectItem))
  5932                     {
  6063                     {
  5933                     itemsRemoved++;
  6064                     itemsRemoved++;
  5934                     }
  6065                     }
  5935                 if (iEffectCleanupStack.Count() > i)
  6066                 if (iEffectCleanupStack.Count() > i)
  5936                     {
  6067                     {
  5952     iAlfScreens[0]->iDisplay->SetDirty();
  6083     iAlfScreens[0]->iDisplay->SetDirty();
  5953 	__ALFFXLOGSTRING1("CAlfBridge::RemoveTemporaryPresenterVisuals - END - effects in layout %d", effectControlGroupLayout->Count());
  6084 	__ALFFXLOGSTRING1("CAlfBridge::RemoveTemporaryPresenterVisuals - END - effects in layout %d", effectControlGroupLayout->Count());
  5954     return itemsRemoved;
  6085     return itemsRemoved;
  5955     }
  6086     }
  5956 
  6087 
  5957 void CAlfBridge::RemoveAllTemporaryPresenterVisuals()
  6088 void CAlfBridge::CleanAllFxVisuals()
  5958     {
  6089     {
  5959     CHuiControl& effectControlGroup =  iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0);
  6090     CHuiControl& effectControlGroup =  iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0);
  5960     CHuiLayout* effectControlGroupLayout = (CHuiLayout*) &effectControlGroup.Visual(0);
  6091     CHuiLayout* effectControlGroupLayout = (CHuiLayout*) &effectControlGroup.Visual(0);
  5961     __ALFFXLOGSTRING1("CAlfBridge::RemoveAllTemporaryPresenterVisuals - BEGIN - effects in layout %d", effectControlGroupLayout->Count());
  6092     __ALFFXLOGSTRING1("CAlfBridge::RemoveAllTemporaryPresenterVisuals - BEGIN - effects in layout %d", effectControlGroupLayout->Count());
  5962 
  6093 
  5963     while(iEffectCleanupStack.Count())
  6094     while(iEffectCleanupStack.Count())
  5964         {
  6095         {
  5965         TEffectCleanupStruct& effectItem = iEffectCleanupStack[0];
  6096         TEffectCleanupStruct& effectItem = iEffectCleanupStack[0];
  5966         RemoveTemporaryPresenterItem(effectItem);
  6097         CleanFxItem(effectItem);
  5967         iEffectCleanupStack.Remove(0);
  6098         iEffectCleanupStack.Remove(0);
  5968         }
  6099         }
  5969     
  6100     
  5970     while(iFinishedCleanupStackEffects.Count())
  6101     while(iFinishedCleanupStackEffects.Count())
  5971         {
  6102         {
  5987     // around will be cleared when HandleGfxStopEffectsL is called
  6118     // around will be cleared when HandleGfxStopEffectsL is called
  5988 
  6119 
  5989     // iFinishedCleanupStackEffects.Append(aHandle);
  6120     // iFinishedCleanupStackEffects.Append(aHandle);
  5990     
  6121     
  5991 	// check if the first part of application start effect finished
  6122 	// check if the first part of application start effect finished
  5992     if (iFullScreenEffectData 
  6123     if (iFSFxData 
  5993             && iFullScreenEffectData->iHandle == aHandle
  6124             && iFSFxData->iHandle == aHandle
  5994             && iFullScreenEffectData->iLongAppStartTimeout && iSecondaryFullScreenEffectData)
  6125             && iFSFxData->iLongAppStartTimeout && iFSFXDataPart2)
  5995         {
  6126         {
  5996         delete iFullScreenEffectData;
  6127         delete iFSFxData;
  5997         iFullScreenEffectData = iSecondaryFullScreenEffectData;
  6128         iFSFxData = iFSFXDataPart2;
  5998         iSecondaryFullScreenEffectData = NULL;
  6129         iFSFXDataPart2 = NULL;
  5999         iFullScreenEffectData->iTwoPhaseEffect = CFullScreenEffectState::ESecondPartActive;
  6130         iFSFxData->iTwoPhaseEffect = CFullScreenEffectState::ESecondPartActive;
  6000         if (iFullScreenEffectData->State() == EEndFullscreenReceived)
  6131         if (iFSFxData->State() == EEndFullscreenReceived)
  6001             {
  6132             {
  6002             // Client notified of the EndFullScreen during the effect. Trigger the end part immediately.
  6133             // Client notified of the EndFullScreen during the effect. Trigger the end part immediately.
  6003             __ALFFXLOGSTRING("CAlfBridge::AlfGfxEffectEndCallBack - End was received. Trigger second part.");
  6134             __ALFFXLOGSTRING("CAlfBridge::AlfGfxEffectEndCallBack - End was received. Trigger second part.");
  6004             iFullScreenEffectData->SetState(ESecondPhaseSetupActive); // effect setup will be skipped in HandleGfxEvent
  6135             GfxTriggerEndFullScreen(iFSFxData);
  6005             GfxTriggerEndFullScreen(iFullScreenEffectData);
  6136             iFSFxData->SetState(EFinalEffectActive);
  6006             iFullScreenEffectData->SetState(EFinalEffectActive);
       
  6007 			// skip cleanup. It will be run, when this effect finishes
  6137 			// skip cleanup. It will be run, when this effect finishes
  6008             return;
  6138             return;
  6009             }
  6139             }
  6010         else
  6140         else
  6011             {
  6141             {
  6012             iFullScreenEffectData->SetState(EWaitEndFullScreen);
  6142             iFSFxData->SetState(EWaitEndFullScreen);
  6013             }
  6143             }
  6014         
  6144         
  6015         iFullScreenEffectData->iEffectType = CFullScreenEffectState::EStartEffect;
  6145         iFSFxData->iEffectType = CFullScreenEffectState::EStartEffect;
  6016         
  6146         
  6017         CHuiControlGroup* toGroup = FindControlGroupByFullScreenToEffect();
  6147         CHuiControlGroup* toGroup = FindControlGroupByFullScreenToEffect();
  6018         GfxTriggerEffectWhenFullScreenDrawn(toGroup);
  6148         GfxTriggerEffectWhenFullScreenDrawn(toGroup);
  6019         return;
  6149         return;
  6020         }
  6150         }
  6051     if ( aHandle == KErrNotFound )
  6181     if ( aHandle == KErrNotFound )
  6052         {
  6182         {
  6053         __ALFFXLOGSTRING("invalid handle");
  6183         __ALFFXLOGSTRING("invalid handle");
  6054         }
  6184         }
  6055     // alftranstion plugin may cancel end timers connected to this effect
  6185     // alftranstion plugin may cancel end timers connected to this effect
  6056     TBool fsEffectDone = iFullScreenEffectData && aHandle == iFullScreenEffectData->iHandle;
  6186     TBool fsEffectDone = iFSFxData && aHandle == iFSFxData->iHandle;
  6057     if ( fsEffectDone )
  6187     if ( fsEffectDone )
  6058         {
  6188         {
  6059         aHandle = iFullScreenEffectData->iCompletionHandle;
  6189         aHandle = iFSFxData->iCompletionHandle;
  6060         }
  6190         }
  6061     RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, aHandle );
  6191     RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, aHandle );
  6062 
  6192 
  6063     // Effect finished
  6193     // Effect finished
  6064     if ( fsEffectDone )
  6194     if ( fsEffectDone )
  6065         {
  6195         {
  6066         delete iFullScreenEffectData;
  6196         delete iFSFxData;
  6067         iFullScreenEffectData = NULL;
  6197         iFSFxData = NULL;
  6068         
  6198         
  6069         delete iSecondaryFullScreenEffectData;
  6199         delete iFSFXDataPart2;
  6070         iSecondaryFullScreenEffectData = NULL;
  6200         iFSFXDataPart2 = NULL;
  6071         }
  6201         }
  6072     }
  6202     }
  6073     
  6203     
  6074 
  6204 
  6075 void CAlfBridge::PrintAllocMem()
  6205 void CAlfBridge::PrintAllocMem()
  6737 TBool CAlfBridge::IsAlfOriginatedWindow(CHuiCanvasVisual& aVisual)
  6867 TBool CAlfBridge::IsAlfOriginatedWindow(CHuiCanvasVisual& aVisual)
  6738     {
  6868     {
  6739     return (aVisual.Owner().ControlGroup()->ResourceId() == iAlfWindowGroupNodeId);
  6869     return (aVisual.Owner().ControlGroup()->ResourceId() == iAlfWindowGroupNodeId);
  6740     }
  6870     }
  6741 
  6871 
  6742 // experimental
  6872 
  6743 TBool CAlfBridge::IsFullScreenDrawn( TInt aOrientation)
  6873 // ---------------------------------------------------------------------------
  6744     {
  6874 // Checks if layout switch is ready. The aDuration parameter is the duration
       
  6875 // since layout switch started. So this allows heuristics to loosen as there
       
  6876 // may be applications that do not behave as expected. aDuration is meant
       
  6877 // to be given in units of 50ms.
       
  6878 // ---------------------------------------------------------------------------
       
  6879 // 
       
  6880 TBool CAlfBridge::IsLayoutSwitchReady( TInt aDuration )
       
  6881     {
       
  6882     TBool visualTreeReady = ETrue;
       
  6883 
  6745     if (!iAlfScreens.Count())
  6884     if (!iAlfScreens.Count())
  6746         return EFalse;
  6885         return EFalse;
  6747     aOrientation = iAlfScreens[0]->iDisplay->Orientation();            
  6886    
  6748     iTempRegion.Clear();
  6887     iTempRegion.Clear();
       
  6888     iTempRegion2.Clear();
  6749     
  6889     
  6750     CAlfScreen* screen = iAlfScreens[0];
  6890     CAlfScreen* screen = iAlfScreens[0];
  6751     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
  6891     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
  6752     __ALFFXLOGSTRING3("CAlfBridge::IsFullScreenDrawn - new orientation %d, screen size: (%d,%d)", aOrientation, fullscreen.iBr.iX, fullscreen.iBr.iY );
  6892     TInt orientation = screen->iDisplay->Orientation();
       
  6893 
       
  6894     __ALFLOGSTRING2("CAlfBridge::IsLayoutSwitchReady begin o:%d d:%d", orientation, aDuration);
       
  6895     
  6753     TBool fullscreenCovered = EFalse;
  6896     TBool fullscreenCovered = EFalse;
  6754         
  6897 	TBool alfClientWindowGroupVisible = EFalse;
  6755     // Check if effect group has an effect with opaque hint.
  6898 	
  6756     CHuiControlGroup& fxcontrolgroup = *(iAlfScreens[0]->iFullscreenEffectControlGroup);
  6899 	TInt coverageModifiedGroupCount = 0;
  6757     CHuiControl& fxcontrol = fxcontrolgroup.Control(0);
  6900 		
  6758     CHuiCanvasVisual* fxlayout = (CHuiCanvasVisual*)&fxcontrol.Visual(0);
  6901     // Skip the topmost (effect) layer, start from floating sprite group
  6759     CHuiVisual* fxExternalContent = fxlayout->ExternalContent();
       
  6760     
       
  6761     if (fxlayout && IsOpaqueEffect(fxlayout->Effect()))
       
  6762         {
       
  6763         fullscreenCovered = ETrue;    
       
  6764         }
       
  6765     else if (fxExternalContent && IsOpaqueEffect(fxExternalContent->Effect()))
       
  6766         {
       
  6767         fullscreenCovered = ETrue;
       
  6768         }    
       
  6769 
       
  6770     TBool alfClientWindowGroupVisible = EFalse;
       
  6771     
       
  6772     AMT_SET_VALUE( iVisibleVisualCount, 0 );
       
  6773     
       
  6774     // skip the topmost (effect) layer, start from floating sprite group
       
  6775     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
  6902     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
  6776         {                
  6903         {                
  6777         CHuiControlGroup& controlgroup = iAlfScreens[0]->iDisplay->Roster().ControlGroup(j);
  6904         CHuiControlGroup& controlgroup = screen->iDisplay->Roster().ControlGroup(j);
  6778         CHuiControl& control = controlgroup.Control(0);
  6905         CHuiControl& control = controlgroup.Control(0);
  6779 		__ALFFXLOGSTRING1("CAlfBridge::IsFullScreenDrawn : Group owner 0x%x", controlgroup.SecureId());
  6906 
  6780                 
       
  6781         
       
  6782         if (control.Role() == EHuiFpsIndicatorContainer)
  6907         if (control.Role() == EHuiFpsIndicatorContainer)
  6783             {
  6908             {
  6784             // FPS container doesn't contain canvas visuals
  6909             // FPS container doesn't contain canvas visuals
  6785             continue;
  6910             continue;
  6786             }
  6911             }
  6787 
  6912 
  6788         CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
  6913         CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
  6789        
  6914         
  6790         // For optimization reasons, check if all visuals below in Z-order are covered    
  6915         // For optimization reasons, check if all visuals below in Z-order are covered    
  6791         if (!fullscreenCovered)
  6916         if (!fullscreenCovered)
  6792             {
  6917             {
  6793             fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
  6918             fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);            
  6794             if(fullscreenCovered)
  6919             }
  6795                 {
  6920     
  6796                 return ETrue;
  6921         if (fullscreenCovered)
  6797                 }
  6922             {
  6798             for(TInt ii=0;ii< iTempRegion.Count(); ii++)
  6923             break;
  6799                 {
  6924             }    
  6800                 __ALFFXLOGSTRING4("CAlfBridge::IsFullScreenDrawn (%d,%d)-(%d,%d)", iTempRegion[ii].iTl.iX, iTempRegion[ii].iTl.iY , iTempRegion[ii].iBr.iX, iTempRegion[ii].iBr.iY );
  6925         
  6801                 }
  6926         // ALF applications are handled by checking if their visuals cover the whole screen.
  6802             }
       
  6803         
       
  6804         // Dont mess with alf control group visuals, alf session handling does it for us
       
  6805         if (control.Role() == EHuiSessionContainer)
  6927         if (control.Role() == EHuiSessionContainer)
  6806             {
  6928             {
  6807             CHuiLayout* hostContainer = control.ContainerLayout( NULL );
  6929             CHuiLayout* hostContainer = control.ContainerLayout( NULL );
  6808             TInt flags = hostContainer->Flags();            
  6930             TInt flags = hostContainer->Flags();            
  6809             if (alfClientWindowGroupVisible)
  6931             if (alfClientWindowGroupVisible)
  6828                     }
  6950                     }
  6829                 }
  6951                 }
  6830             continue;
  6952             continue;
  6831             }
  6953             }
  6832         
  6954         
  6833         __ALFLOGSTRING1("CAlfBridge::IsFullScreenDraw - fullscreen covered %d", fullscreenCovered)
  6955         TBool hasActiveVisualsInVisualTree(EFalse);
  6834         TBool subTreeCovered = EFalse;
  6956         TBool coverageRegionModified(EFalse);
  6835         TBool hasActiveVisualsInVisualTree = 
  6957         
  6836                 IsFullScreenDrawnRecursive( layout, controlgroup, control, fullscreenCovered, fullscreen, screen,subTreeCovered, IsVisualOpaque(*layout), aOrientation );    
  6958         if (alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId))
  6837         // If root visuals effect is marked as opaque, then add whole screen area as covered.
  6959             {
  6838         /*
  6960             visualTreeReady =
  6839         if (!fullscreenCovered)
  6961                IsLayoutSwitchReadyRecursive( layout, controlgroup, control, 
  6840             {
  6962                    hasActiveVisualsInVisualTree, fullscreen, screen, 
  6841             fullscreenCovered = IsOpaqueEffect(layout->Effect());
  6963                    IsVisualOpaque(*layout), alfClientWindowGroupVisible, 
  6842             }                    
  6964                    orientation, aDuration, coverageRegionModified );            
  6843         */    
  6965             }
  6844        
  6966         else
  6845         if(controlgroup.iAlfApp && layout->iOpacity.Now() > 0.0f )
  6967             {
       
  6968             visualTreeReady =
       
  6969                IsLayoutSwitchReadyRecursive( layout, controlgroup, control, 
       
  6970                    fullscreenCovered, fullscreen, screen, 
       
  6971                    IsVisualOpaque(*layout), EFalse, orientation, 
       
  6972                    aDuration, coverageRegionModified );            
       
  6973             }
       
  6974 
       
  6975         if (!visualTreeReady)
       
  6976             {
       
  6977             // Problem found in IsLayoutSwitchReadyRecursive
       
  6978             visualTreeReady = EFalse;
       
  6979             break;
       
  6980             }
       
  6981 
       
  6982         if (coverageRegionModified)
       
  6983             {
       
  6984             coverageModifiedGroupCount++;
       
  6985             }
       
  6986 
       
  6987         // Heuristic: If coverage region is modified by multiple apps, then it's possible that
       
  6988         // foreground application hasn't had time to update its layout. So give little time to do that.
       
  6989         if (aDuration <= KAlfCheckCoverageFromMultipleGroups && coverageRegionModified > 1)
       
  6990             {
       
  6991             __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - multiple groups");
       
  6992             visualTreeReady = EFalse;
       
  6993             break;
       
  6994             }
       
  6995 
       
  6996         if( controlgroup.iAlfApp && layout->iOpacity.Now() > 0.0f )
  6846             {
  6997             {
  6847             alfClientWindowGroupVisible = ETrue;
  6998             alfClientWindowGroupVisible = ETrue;
  6848             }
  6999             }
  6849         
  7000         }
  6850         if (fullscreenCovered)
  7001 
  6851             {
  7002     __ALFLOGSTRING2("CAlfBridge::IsLayoutSwitchReady done %d (groups %d)", visualTreeReady, coverageModifiedGroupCount);
  6852             return ETrue;
  7003     iTempRegion2.Clear();
  6853             }
  7004     
  6854         }
  7005     // Heuristic: Check that visual drawing covers the whole screen.
  6855     return fullscreenCovered;
  7006     if ( visualTreeReady && ( aDuration <= KAlfCheckFullscreenCoveredByVisualDrawing ) )
       
  7007         {
       
  7008         if ( !IsRectCoveredByRegion( fullscreen, iTempRegion ) )
       
  7009             {
       
  7010             __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - screen not covered");
       
  7011             visualTreeReady = EFalse;
       
  7012             }
       
  7013         }
       
  7014     
       
  7015     return visualTreeReady;
       
  7016     }
       
  7017 
       
  7018 
       
  7019 // ---------------------------------------------------------------------------
       
  7020 // Checks if rect is inside fullscreen area.
       
  7021 // ---------------------------------------------------------------------------
       
  7022 // 
       
  7023 static TBool CheckVisualRect(const TRect aRect, const TRect& aFullScreen)
       
  7024     {
       
  7025     if (aRect.IsEmpty())
       
  7026         {
       
  7027         return EFalse;
       
  7028         }
       
  7029          
       
  7030     if (!aFullScreen.Contains(aRect.iTl))
       
  7031         {
       
  7032         return EFalse;
       
  7033         }
       
  7034 
       
  7035     TPoint br = aRect.iBr;
       
  7036     br.iX--;
       
  7037     br.iY--;
       
  7038     if (!aFullScreen.Contains(br))
       
  7039         {
       
  7040         return EFalse;
       
  7041         }
       
  7042     
       
  7043     return ETrue;
       
  7044     }
       
  7045 
       
  7046 
       
  7047 // ---------------------------------------------------------------------------
       
  7048 // ---------------------------------------------------------------------------
       
  7049 // 
       
  7050 TBool CAlfBridge::IsLayoutSwitchReadyRecursive(
       
  7051         CHuiLayout* aLayout,
       
  7052         CHuiControlGroup& aControlGroup,
       
  7053         CHuiControl& aControl,
       
  7054         TBool& aFullscreenCovered, 
       
  7055         const TRect& aFullscreen,
       
  7056         CAlfScreen* aScreen,
       
  7057         TBool aChildCanBeOpaque, 
       
  7058         TBool aOnlyForEmbeddedAlfApp,
       
  7059         TInt aOrientation,
       
  7060         TInt aDuration,
       
  7061         TBool& aCoverageRegionModified )
       
  7062     {
       
  7063     TBool visualTreeReady = ETrue;
       
  7064     TRect visualDisplayRect;
       
  7065     TBool visualRectIsCovered = EFalse;
       
  7066     TBool visualIsOpaque = EFalse;
       
  7067     TBool visualIsActive = EFalse;
       
  7068     CHuiCanvasVisual* canvasVisual = NULL;
       
  7069 
       
  7070     for (TInt i = aLayout->Count() - 1; i >= 0; i--)
       
  7071         {
       
  7072         visualDisplayRect = TRect(0,0,0,0);
       
  7073         visualRectIsCovered = EFalse;
       
  7074         visualIsOpaque = EFalse;
       
  7075         visualIsActive = EFalse;
       
  7076         
       
  7077         canvasVisual = (CHuiCanvasVisual*)(&aLayout->Visual(i));
       
  7078 
       
  7079         // Distraction windows are completely ignored.
       
  7080         TBool distractionWindow = (canvasVisual->CanvasFlags() & EHuiCanvasFlagDistractionWindow);
       
  7081         if ( distractionWindow )
       
  7082             {
       
  7083             continue;
       
  7084             }
       
  7085 
       
  7086         visualIsOpaque = aChildCanBeOpaque && IsVisualOpaque(*canvasVisual);
       
  7087         TBool visualIsVisible = (canvasVisual->iOpacity.Now() > 0.01f);       
       
  7088         
       
  7089         if (canvasVisual->Count() && visualIsVisible)
       
  7090             {
       
  7091             TBool ready = IsLayoutSwitchReadyRecursive( canvasVisual, aControlGroup, aControl, 
       
  7092                 aFullscreenCovered, aFullscreen, aScreen, 
       
  7093                 visualIsOpaque, EFalse, aOrientation, 
       
  7094                 aDuration, aCoverageRegionModified );
       
  7095                 
       
  7096             if (!ready)
       
  7097                 {
       
  7098                 visualTreeReady = EFalse;
       
  7099                 break;
       
  7100                 }
       
  7101             }
       
  7102 
       
  7103         // Calculate visual display rect
       
  7104         visualDisplayRect = canvasVisual->DisplayRect();
       
  7105     
       
  7106         ClipVisualRect(visualDisplayRect, aLayout->DisplayRect());
       
  7107         ClipVisualRect(visualDisplayRect, aFullscreen);
       
  7108         
       
  7109         // Check if covered.
       
  7110         if (aFullscreenCovered)
       
  7111             {
       
  7112             visualRectIsCovered = ETrue;    
       
  7113             }
       
  7114         else
       
  7115             {            
       
  7116             // Check if this visual is covered by other opaque visuals which rects are in "covered" region
       
  7117             // it should not check for alf event window group, when we have embedded alf application,
       
  7118             // because we have assumed that alf app will have full screen covered
       
  7119             if(!aOnlyForEmbeddedAlfApp)
       
  7120                 {
       
  7121                 visualRectIsCovered = IsRectCoveredByRegion(visualDisplayRect, iTempRegion);
       
  7122                 }                                
       
  7123             }
       
  7124 
       
  7125         // Heuristic: Check that visual display rect is ok (not empty, inside screen)
       
  7126         if ( aDuration <= KAlfCheckVisualDisplayRect && !visualRectIsCovered && 
       
  7127              !CheckVisualRect(visualDisplayRect, aFullscreen) )
       
  7128             {
       
  7129             __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - display rect not ok");
       
  7130             visualTreeReady = EFalse;
       
  7131             break;
       
  7132             }
       
  7133     
       
  7134 	    // Determine if visual is active from coverage point of view.
       
  7135         visualIsActive = EFalse;
       
  7136         if (visualRectIsCovered)
       
  7137             {                                        
       
  7138             if (!(canvasVisual->Flags() & EHuiVisualFlagAlwaysDraw)) 
       
  7139                 {
       
  7140                 visualIsActive = EFalse;                
       
  7141                 }
       
  7142             else
       
  7143                 { 
       
  7144                 visualIsActive = ETrue;
       
  7145                 }                
       
  7146             }
       
  7147         else
       
  7148             {
       
  7149 			visualIsActive = ETrue;
       
  7150             }
       
  7151         
       
  7152         // Sprites and effects as we consider them always as transparent and also
       
  7153         // if controlgroup is transformed somehow    
       
  7154         if (aControl.Role() == EHuiFullScreenEffectContainer || 
       
  7155             aControl.Role() == EHuiWindowFloatingSpriteContainer ||
       
  7156             aControlGroup.IsTransformed())
       
  7157             {
       
  7158             visualIsOpaque = EFalse;    
       
  7159             }
       
  7160            
       
  7161         // Check that command buffers are ok.
       
  7162         if ( visualIsActive )
       
  7163             {
       
  7164             TRect displayRect = visualDisplayRect;
       
  7165             visualDisplayRect = canvasVisual->CommandBufferCoverage(aOrientation);
       
  7166 
       
  7167             // Heuristic: Check that visual drawing isn't completely empty.
       
  7168             if ( aDuration <= KAlfCheckVisualDrawingNotEmpty && !visualRectIsCovered &&
       
  7169                  visualIsVisible && visualDisplayRect.IsEmpty() )
       
  7170                 {
       
  7171                 __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - no drawing");
       
  7172                 visualTreeReady = EFalse;
       
  7173                 break;
       
  7174                 }
       
  7175             
       
  7176             // Heuristic: Check that visual drawing isn't outside the screen.
       
  7177             if ( aDuration <= KAlfCheckVisualDrawRect && !visualRectIsCovered &&
       
  7178                  visualIsVisible && !CheckVisualRect(visualDisplayRect, aFullscreen) )
       
  7179                 {
       
  7180                 __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - bad drawing");
       
  7181                 visualTreeReady = EFalse;
       
  7182                 break;
       
  7183                 }
       
  7184 
       
  7185             // Heuristic: Check that visual drawing is complete.
       
  7186             if ( aDuration <= KAlfCheckVisualDrawingComplete && !visualRectIsCovered &&
       
  7187                  visualIsVisible && displayRect != visualDisplayRect )
       
  7188                 {
       
  7189                 __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - incomplete drawing");
       
  7190                 visualTreeReady = EFalse;
       
  7191                 break;
       
  7192                 }
       
  7193 
       
  7194             // Make sure we clip visual rect to visible screen area
       
  7195             ClipVisualRect(visualDisplayRect, aFullscreen);
       
  7196             
       
  7197             // Heuristic: Union of opaque visual drawing regions should cover the whole screen.
       
  7198             // Note - coverage is checked at the end of IsLayoutSwitchReady.
       
  7199             if (visualIsOpaque && visualIsVisible && !visualRectIsCovered)
       
  7200                 {
       
  7201                 iTempRegion2.AddRect( visualDisplayRect );
       
  7202                 iTempRegion2.Tidy();
       
  7203                 }
       
  7204             }
       
  7205 			
       
  7206         if (visualIsActive && visualIsOpaque && !visualRectIsCovered)
       
  7207             { 
       
  7208             // New visibility system takes only window shape into account.
       
  7209             if ( canvasVisual->CanvasFlags() & EHuiCanvasFlagIncludeToVisibilityCalculation )
       
  7210                 {
       
  7211                 if ( !canvasVisual->HasCustomShape() )
       
  7212                     {
       
  7213                     aCoverageRegionModified = ETrue;
       
  7214                     
       
  7215                     TRect displayRect(canvasVisual->DisplayRect());
       
  7216                     ClipVisualRect(displayRect, aLayout->DisplayRect());
       
  7217                     ClipVisualRect(displayRect, aFullscreen);
       
  7218 
       
  7219                     iTempRegion.AddRect(displayRect);
       
  7220                     iTempRegion.Tidy();
       
  7221                     }
       
  7222                 else
       
  7223                     {
       
  7224                     aCoverageRegionModified = ETrue;
       
  7225                     
       
  7226                     TRect displayRect = canvasVisual->DisplayRect();
       
  7227                     const TRegion& region = canvasVisual->ShapeRegion();
       
  7228                     TPoint delta = -canvasVisual->ShapeOrigin() + displayRect.iTl;
       
  7229                 
       
  7230                     for (TInt i = 0; i < region.Count(); ++i)
       
  7231                         {
       
  7232                         TRect coveredRect(region[i]);
       
  7233                         coveredRect.Move(delta);
       
  7234                         ClipVisualRect(coveredRect, aFullscreen);
       
  7235 
       
  7236                         iTempRegion.AddRect(coveredRect);
       
  7237                         }
       
  7238                     iTempRegion.Tidy();
       
  7239                     }
       
  7240                 }
       
  7241             }        
       
  7242         } // for loop end : children checking loop
       
  7243      
       
  7244     return visualTreeReady;
  6856     }
  7245     }
  6857 
  7246 
  6858 TBool CAlfBridge::IsFullScreenDrawnRecursiveAlfContent(CHuiVisual* aVisual, TRect& aFullScreen)
  7247 TBool CAlfBridge::IsFullScreenDrawnRecursiveAlfContent(CHuiVisual* aVisual, TRect& aFullScreen)
  6859     {
  7248     {
  6860     if(aVisual)
  7249     if(aVisual)
  7052     iLayoutSwitchInProgress = EFalse;
  7441     iLayoutSwitchInProgress = EFalse;
  7053     if ( iHuiEnv )
  7442     if ( iHuiEnv )
  7054         {
  7443         {
  7055         iIdForLayoutSwitchFrameSync = iIdForEAlfDSSynchronizeOp - KPreventingCollisionOfIdsInSynchDrawRequests;
  7444         iIdForLayoutSwitchFrameSync = iIdForEAlfDSSynchronizeOp - KPreventingCollisionOfIdsInSynchDrawRequests;
  7056         iHuiEnv->Synchronize( iIdForLayoutSwitchFrameSync, this );
  7445         iHuiEnv->Synchronize( iIdForLayoutSwitchFrameSync, this );
       
  7446         AsynchRefresh(); // In SW mode, device is in manual refresh mode - enforce refresh in order to get synchronize done.
  7057         }
  7447         }
  7058     }
  7448     }
  7059 
  7449 
  7060 TAlfBridgeDrawerWrapper::TAlfBridgeDrawerWrapper(CAlfBridge& aBridge)
  7450 TAlfBridgeDrawerWrapper::TAlfBridgeDrawerWrapper(CAlfBridge& aBridge)
  7061     : iBridge( aBridge )
  7451     : iBridge( aBridge )