uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
branchRCL_3
changeset 15 cd0ae4656946
parent 13 3a60ebea00d0
child 17 c9d868f1e20c
equal deleted inserted replaced
13:3a60ebea00d0 15:cd0ae4656946
   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     
  1738             iHomeScreenPSValue = value;
  1773             iHomeScreenPSValue = value;
  1739             }
  1774             }
  1740         }
  1775         }
  1741     if ( iSwRenderingEnabled )
  1776     if ( iSwRenderingEnabled )
  1742         {
  1777         {
  1743         screen->iDisplay->SetForegroundTextureOptions( alfWindowGroupFoundVisible | alfClientWindowGroupVisible );
  1778         screen->iDisplay->SetForegroundTextureOptions( alfWindowGroupFoundVisible || alfClientWindowGroupVisible );
  1744         }
  1779         }
  1745    
  1780    
  1746     // 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
  1747     // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others
  1782     // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others
  1748     // would clear the screen areas where they do not really draw.
  1783     // would clear the screen areas where they do not really draw.
  2218         
  2253         
  2219         CHuiVisual* layout = &control.Visual(0);
  2254         CHuiVisual* layout = &control.Visual(0);
  2220         for (TInt i=layout->Count()-1; i >= 0; i--)
  2255         for (TInt i=layout->Count()-1; i >= 0; i--)
  2221             {
  2256             {
  2222             CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&layout->Visual(i));
  2257             CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&layout->Visual(i));
  2223             if (!aInactiveOnly)
  2258             ClearCanvasVisualCommandSetsRecursive(canvasVisual, aInactiveOnly);            
  2224                 {
  2259             }
  2225                 canvasVisual->ClearCommandSet();
  2260         }
  2226                 }
  2261     }
  2227             else if (aInactiveOnly && (canvasVisual->Flags() & EHuiVisualFlagInactive))
  2262 
  2228                 {
  2263 
  2229                 canvasVisual->ClearCommandSet();                        
  2264 // ---------------------------------------------------------------------------
  2230                 }
  2265 // ---------------------------------------------------------------------------
  2231             else
  2266 // 
  2232                 {
  2267 void CAlfBridge::ClearCanvasVisualCommandSetsRecursive(CHuiCanvasVisual* aVisual, TBool aInactiveOnly)
  2233                 // dont clear
  2268     {
  2234                 }
  2269     if (!aVisual)
  2235             }
  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);            
  2236         }
  2291         }
  2237     }
  2292     }
  2238 
  2293 
  2239 
  2294 
  2240 // ---------------------------------------------------------------------------
  2295 // ---------------------------------------------------------------------------
  2529 	                	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
  2530 	                	}
  2585 	                	}
  2531 	                __ALFLOGSTRING1("AlfScreens[0]->iDisplay->SetOrientation: %d",huiOrientation);  	                
  2586 	                __ALFLOGSTRING1("AlfScreens[0]->iDisplay->SetOrientation: %d",huiOrientation);  	                
  2532 	                }
  2587 	                }
  2533 	            
  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                     }
  2534                 break;         
  2596                 break;         
  2535                 }
  2597                 }
  2536            case EAlfEffectFxBeginSyncronizedGroup:
  2598            case EAlfEffectFxBeginSyncronizedGroup:
  2537         	   {
  2599         	   {
  2538         	   CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
  2600         	   CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
  2759     for (TInt familyIndex = 1; familyIndex < familyTree.Count();familyIndex++)
  2821     for (TInt familyIndex = 1; familyIndex < familyTree.Count();familyIndex++)
  2760         {
  2822         {
  2761         CHuiLayout* lVisual = familyTree[familyIndex];
  2823         CHuiLayout* lVisual = familyTree[familyIndex];
  2762         lVisual->Owner().Remove(lVisual);
  2824         lVisual->Owner().Remove(lVisual);
  2763         iOrphanStorage->AppendL( lVisual );
  2825         iOrphanStorage->AppendL( lVisual );
  2764         RemoveTemporaryPresenterVisual(lVisual);
  2826         CleanFxVisual(lVisual);
  2765         
  2827         
  2766         __ALFLOGSTRING1("CAlfBridge::DestroyWindow - orphons: %d", iOrphanStorage->VisualCount());
  2828         __ALFLOGSTRING1("CAlfBridge::DestroyWindow - orphons: %d", iOrphanStorage->VisualCount());
  2767         }
  2829         }
  2768     familyTree.Close();
  2830     familyTree.Close();
  2769          
  2831          
  2773     // there might be effect on this visual. It is not guaranteen.
  2835     // there might be effect on this visual. It is not guaranteen.
  2774     
  2836     
  2775     if (!aUseForce)
  2837     if (!aUseForce)
  2776         {
  2838         {
  2777         // 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
  2778         // 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
  2779         for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  2841         for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  2780             {
  2842             {
  2781             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  2843             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  2782             if (aVisual == effectItem.iEffectedVisual)
  2844             if (aVisual == effectItem.iEffectedVisual)
  2783                 {
  2845                 {
  3364 	else
  3426 	else
  3365 		{
  3427 		{
  3366 		__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 );                                 
  3367 		}    
  3429 		}    
  3368 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
  3430 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
  3369 	    if (iFullScreenEffectData
  3431 	    if (iFSFxData
  3370 	            && !iSecondaryFullScreenEffectData
  3432 	            && iFSFxData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
  3371 	            && iFullScreenEffectData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
  3433 	            && ((iFSFxData->State() == EWaitEndFullScreen && iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::EFirstPartRunning)))
  3372 	            && iFullScreenEffectData->State() == EWaitEndFullScreen
       
  3373 	            && iFullScreenEffectData->iTwoPhaseEffect != CFullScreenEffectState::ESecondPartActive)
       
  3374 	        {
  3434 	        {
  3375 	        CHuiControlGroup *to_group = NULL;
  3435 	        CHuiControlGroup *to_group = NULL;
  3376             if (iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
  3436             if (iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect)
  3377                 {
  3437                 {
  3378                 to_group = FindControlGroupByFullScreenFromEffect();
  3438                 to_group = FindControlGroupByFullScreenFromEffect();
  3379                 }
  3439                 }
  3380             else
  3440             else
  3381                 {
  3441                 {
  3399 // HandleGfxEndFullScreenTimeout
  3459 // HandleGfxEndFullScreenTimeout
  3400 // ---------------------------------------------------------------------------
  3460 // ---------------------------------------------------------------------------
  3401 // 
  3461 // 
  3402 void CAlfBridge::GfxTriggerEndFullScreen(CFullScreenEffectState* aFullScreenEffectData)
  3462 void CAlfBridge::GfxTriggerEndFullScreen(CFullScreenEffectState* aFullScreenEffectData)
  3403     {
  3463     {
  3404     if (iFullScreenEffectData->State() == EFinalEffectActive)
  3464     if (iFSFxData->State() == EFinalEffectActive)
  3405         {
  3465         {
  3406         return;
  3466         return;
  3407         }
  3467         }
  3408     CHuiControlGroup *to_group = FindControlGroupByFullScreenToEffect();
  3468     CHuiControlGroup *to_group = FindControlGroupByFullScreenToEffect();
  3409     CHuiControlGroup *from_group = FindControlGroupByFullScreenFromEffect();
  3469     CHuiControlGroup *from_group = FindControlGroupByFullScreenFromEffect();
  3426         }
  3486         }
  3427     aFullScreenEffectData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
  3487     aFullScreenEffectData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
  3428     if (to_layout)
  3488     if (to_layout)
  3429         {
  3489         {
  3430         // from layout may be undefined
  3490         // from layout may be undefined
  3431         __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);    
  3432         HandleGfxEventL( *aFullScreenEffectData, to_layout, from_layout );
  3492         HandleGfxEventL( *aFullScreenEffectData, to_layout, from_layout );
  3433         aFullScreenEffectData->SetState(EFinalEffectActive);
  3493         aFullScreenEffectData->SetState(EFinalEffectActive);
  3434         }
  3494         }
  3435 
  3495 
  3436     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  3496     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  3459         }
  3519         }
  3460     else
  3520     else
  3461         {
  3521         {
  3462         __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);
  3463         // Has effect
  3523         // Has effect
  3464 		// these flags are put to action in RemoveTemporaryPresenterItem
  3524 		// these flags are put to action in CleanFxItem
  3465         if (aActive)
  3525         if (aActive)
  3466             {
  3526             {
  3467 			// this prevents windows appearing before their "effected" time
  3527 			// this prevents windows appearing before their "effected" time
  3468             if (!iEffectCleanupStack[effectIndex].iHideWhenFinished)
  3528             if (!iEffectCleanupStack[effectIndex].iHideWhenFinished)
  3469                 {
  3529                 {
  4344             }
  4404             }
  4345         else 
  4405         else 
  4346             {
  4406             {
  4347             __ALFLOGSTRING("CAlfBridge::HandleMoveWindowToNewGroupL cannot find new group! orphaning the visual");
  4407             __ALFLOGSTRING("CAlfBridge::HandleMoveWindowToNewGroupL cannot find new group! orphaning the visual");
  4348             
  4408             
  4349             RemoveTemporaryPresenterVisual(viz);
  4409             CleanFxVisual(viz);
  4350              iOrphanStorage->AppendL( viz );
  4410              iOrphanStorage->AppendL( viz );
  4351             }
  4411             }
  4352         }
  4412         }
  4353     else
  4413     else
  4354         {
  4414         {
  4599                     {
  4659                     {
  4600                     TInt dummy;
  4660                     TInt dummy;
  4601 					if (!HasActiveEffect(aToLayout, dummy))
  4661 					if (!HasActiveEffect(aToLayout, dummy))
  4602 						{
  4662 						{
  4603 						__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);
  4604                     	AddEffectItemL(aEvent.iHandle, aToLayout, NULL, NULL, EFalse, dummy, ETrue, EFalse);
  4664                     	AddFxItemL(aEvent.iHandle, aToLayout, NULL, NULL, EFalse, dummy, ETrue, EFalse);
  4605 						}
  4665 						}
  4606                     }
  4666                     }
  4607 				// 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.	
  4608 				if (!success)
  4668 				if (!success)
  4609 					{
  4669 					{
  4621                     case KAlfFSTaskSwapperAppStart:
  4681                     case KAlfFSTaskSwapperAppStart:
  4622                         {
  4682                         {
  4623                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that are not yet ready to be drawn, but possible already on the foreground
  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
  4624                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  4684                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  4625                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4685                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4626                         if (iSecondaryFullScreenEffectData)
  4686                         if (iFSFXDataPart2)
  4627                             {
  4687                             {
  4628                             iSecondaryFullScreenEffectData->iEffectType = CFullScreenEffectState::EStartEffect; 
  4688                             iFSFXDataPart2->iEffectType = CFullScreenEffectState::EStartEffect; 
  4629                             }
  4689                             }
  4630                                 
  4690                                 
  4631                         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
  4632                         break;
  4692                         break;
  4633                         }
  4693                         }
  4679                             {
  4739                             {
  4680                             iLayoutInitializedForExitEffect = EFalse;
  4740                             iLayoutInitializedForExitEffect = EFalse;
  4681                             aEvent.iSetupDone = EFalse;
  4741                             aEvent.iSetupDone = EFalse;
  4682                             failed = ETrue;
  4742                             failed = ETrue;
  4683                             }
  4743                             }
  4684                         if (iSecondaryFullScreenEffectData)
  4744                         if (iFSFXDataPart2)
  4685                             {
  4745                             {
  4686                             iSecondaryFullScreenEffectData->iSetupDone = aEvent.iSetupDone;
  4746                             iFSFXDataPart2->iSetupDone = aEvent.iSetupDone;
  4687                             }
  4747                             }
  4688                          return failed;
  4748                          return failed;
  4689                          }
  4749                          }
  4690                     default:
  4750                     default:
  4691                         break;
  4751                         break;
  4767                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName) ||
  4827                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName) ||
  4768                                     aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive)
  4828                                     aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive)
  4769                                 {
  4829                                 {
  4770                                 effectFlags |= KHuiFxOpaqueHint;
  4830                                 effectFlags |= KHuiFxOpaqueHint;
  4771                                 }
  4831                                 }
  4772                             if (iSecondaryFullScreenEffectData)
  4832                             if (iFSFXDataPart2)
  4773                                 {
  4833                                 {
  4774                                 iSecondaryFullScreenEffectData->iSetupDone = ETrue;
  4834                                 iFSFXDataPart2->iSetupDone = ETrue;
  4775                                 }
  4835                                 }
  4776                             
  4836                             
  4777                             if (aEvent.iRect != TRect())
  4837                             if (aEvent.iRect != TRect())
  4778                                 {
  4838                                 {
  4779                                 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 ));
  4787                             aToLayout->SetFreezeState(EFalse);
  4847                             aToLayout->SetFreezeState(EFalse);
  4788                                                             
  4848                                                             
  4789                             if (err != KErrNone)
  4849                             if (err != KErrNone)
  4790                                 {
  4850                                 {
  4791                                 // 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.
  4792                                 RemoveTemporaryPresenterVisual(NULL, aEvent.iHandle);
  4852                                 CleanFxVisual(NULL, aEvent.iHandle);
  4793                                 aToLayout->SetEffect(NULL);
  4853                                 aToLayout->SetEffect(NULL);
  4794                                 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                                     }
  4795                                 }
  4867                                 }
  4796                             }
  4868                             }
  4797                         else
  4869                         else
  4798                             {
  4870                             {
  4799                             failed = ETrue;                            
  4871                             failed = ETrue;                            
  4824 		if (err == KErrNone)
  4896 		if (err == KErrNone)
  4825 			{
  4897 			{
  4826             // Freeze only, if buffer was reserved succesfully 
  4898             // Freeze only, if buffer was reserved succesfully 
  4827             aLayout->SetFreezeState(ETrue);
  4899             aLayout->SetFreezeState(ETrue);
  4828         	TBool itemsDestroyed;
  4900         	TBool itemsDestroyed;
  4829     	    AddEffectItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
  4901     	    AddFxItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
  4830 	        iFullScreenEffectData->iAppStartScreenshotItemHandle = aHandle;
  4902 	        iFSFxData->iAppStartScreenshotItemHandle = aHandle;
  4831 			}
  4903 			}
  4832         }
  4904         }
  4833     }
  4905     }
  4834 
  4906 
  4835 void CAlfBridge::HandleGfxStopEvent( TBool aClientRequest )
  4907 void CAlfBridge::HandleGfxStopEvent( TBool aClientRequest )
  4836     {
  4908     {
  4837     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent BEGIN");
  4909     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent BEGIN");
  4838     if (!iFullScreenEffectData)
  4910     if (!iFSFxData)
  4839         {
  4911         {
  4840         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END: none");
  4912         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END: none");
  4841         RemoveAllTemporaryPresenterVisuals();
  4913         CleanAllFxVisuals();
  4842         delete iControlEffectData;
  4914         delete iControlEffectData;
  4843         iControlEffectData = NULL;
  4915         iControlEffectData = NULL;
  4844         return;
  4916         return;
  4845         }
  4917         }
  4846     
  4918     
  4847     CFullScreenEffectState* fxData = iFullScreenEffectData;
  4919     CFullScreenEffectState* fxData = iFSFxData;
  4848     iFullScreenEffectData = NULL;
  4920     iFSFxData = NULL;
  4849     CleanupStack::PushL( fxData );
  4921     CleanupStack::PushL( fxData );
  4850     
  4922     
  4851      __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);
  4852     
  4924     
  4853     // clean effects with this handle       
  4925     // clean effects with this handle       
  4854     RemoveTemporaryPresenterVisual(NULL, fxData->iHandle);
  4926     CleanFxVisual(NULL, fxData->iHandle);
  4855     // 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 
  4856     // back
  4928     // back
  4857     if (fxData->iToAppId && fxData->iToAppId != KErrNotFound)
  4929     if (fxData->iToAppId && fxData->iToAppId != KErrNotFound)
  4858         {
  4930         {
  4859         RemoveEffectFromApp(fxData->iToSecureId, fxData->iToWg );
  4931         RemoveEffectFromApp(fxData->iToSecureId, fxData->iToWg );
  4860         RemoveEffectFromApp(fxData->iFromSecureId, fxData->iFromWg );
  4932         RemoveEffectFromApp(fxData->iFromSecureId, fxData->iFromWg );
  4861         }
  4933         }
  4862     // abort ALL other possible control effects
  4934     // abort ALL other possible control effects
  4863     RemoveAllTemporaryPresenterVisuals();
  4935     CleanAllFxVisuals();
  4864     
  4936     
  4865     delete iControlEffectData;
  4937     delete iControlEffectData;
  4866     iControlEffectData = NULL;
  4938     iControlEffectData = NULL;
  4867     
  4939     
  4868     iHuiEnv->ContinueRefresh();
  4940     iHuiEnv->ContinueRefresh();
  4872         // Aborted errornously, signal client side
  4944         // Aborted errornously, signal client side
  4873         RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, fxData->iCompletionHandle );
  4945         RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, fxData->iCompletionHandle );
  4874         }
  4946         }
  4875     
  4947     
  4876     CleanupStack::PopAndDestroy( fxData );
  4948     CleanupStack::PopAndDestroy( fxData );
  4877     delete iSecondaryFullScreenEffectData;
  4949     delete iFSFXDataPart2;
  4878     iSecondaryFullScreenEffectData = NULL;
  4950     iFSFXDataPart2 = NULL;
  4879     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END");
  4951     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END");
  4880     }
  4952     }
  4881 
  4953 
  4882 void CAlfBridge::RemoveEffectFromApp(TInt aSecureId, TInt aWgId )
  4954 void CAlfBridge::RemoveEffectFromApp(TInt aSecureId, TInt aWgId )
  4883     {
  4955     {
  4904     
  4976     
  4905         TInt handle = FindEffectHandle(layout);
  4977         TInt handle = FindEffectHandle(layout);
  4906         if (handle != KErrNotFound)
  4978         if (handle != KErrNotFound)
  4907             {
  4979             {
  4908             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - layout visual: 0x%x ; handle: %d ", layout, handle);
  4980             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - layout visual: 0x%x ; handle: %d ", layout, handle);
  4909             RemoveTemporaryPresenterVisual(NULL, handle);
  4981             CleanFxVisual(NULL, handle);
  4910             }
  4982             }
  4911         layout->iOpacity.Set(1.0f); 
  4983         layout->iOpacity.Set(1.0f); 
  4912         }
  4984         }
  4913     }
  4985     }
  4914 
  4986 
  4942         return;
  5014         return;
  4943         }
  5015         }
  4944      
  5016      
  4945     if ( operation == MAlfGfxEffectPlugin::EBeginFullscreen )
  5017     if ( operation == MAlfGfxEffectPlugin::EBeginFullscreen )
  4946         {
  5018         {
  4947         if ( !iFullScreenEffectData || !iFullScreenEffectData->iSetupDone )
  5019         if ( !iFSFxData || !iFSFxData->iSetupDone )
  4948             {
  5020             {
  4949             // 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, 
  4950             // so we can initialize iFullScreenEffectData from stream.
  5022             // so we can initialize iFSFxData from stream.
  4951             
  5023             
  4952             __ALFFXLOGSTRING("HandleGfxEffectsL - fresh start");
  5024             __ALFFXLOGSTRING("HandleGfxEffectsL - fresh start");
  4953             
  5025             
  4954             CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
  5026             CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
  4955             CleanupStack::PushL( fxData );
  5027             CleanupStack::PushL( fxData );
  4956             fxData->ConstructL( action, stream );
  5028             fxData->ConstructL( action, stream );
  4957             CleanupStack::Pop( fxData );
  5029             CleanupStack::Pop( fxData );
  4958         	
  5030         	
  4959 			// the effect handle of freezed layout (iAppStartScreenshotItemHandle) must match the actual
  5031 			// the effect handle of freezed layout (iAppStartScreenshotItemHandle) must match the actual
  4960 			// 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
  4961 			if (iFullScreenEffectData)
  5033 			if (iFSFxData)
  4962 			{
  5034 			{
  4963             	for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  5035             	for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  4964             	{
  5036             	{
  4965                	 TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  5037                	 TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  4966                	 if (iFullScreenEffectData->iAppStartScreenshotItemHandle == effectItem.iHandle)
  5038                	 if (iFSFxData->iAppStartScreenshotItemHandle == effectItem.iHandle)
  4967                	     {
  5039                	     {
  4968                	     effectItem.iHandle = fxData->iHandle;
  5040                	     effectItem.iHandle = fxData->iHandle;
  4969                	     }
  5041                	     }
  4970                	}
  5042                	}
  4971 			}
  5043 			}
  4972             
  5044             
  4973             if (iFullScreenEffectData && iFullScreenEffectData->iToAppId != fxData->iToAppId)
  5045             if (iFSFxData && iFSFxData->iToAppId != fxData->iToAppId)
  4974                 {
  5046                 {
  4975 				__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"); 
  4976                 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.
  4977                 RemoveEffectFromApp(iFullScreenEffectData->iFromSecureId, iFullScreenEffectData->iFromWg);
  5049                 RemoveEffectFromApp(iFSFxData->iFromSecureId, iFSFxData->iFromWg);
  4978                 __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);
  4979                 RemoveEffectFromApp(iFullScreenEffectData->iToAppId);
  5051                 RemoveEffectFromApp(iFSFxData->iToAppId);
  4980                 // Fullscreen effect for another 
  5052                 // Fullscreen effect for another 
  4981                 }
  5053                 }
  4982 
  5054 
  4983                delete iFullScreenEffectData;
  5055                delete iFSFxData;
  4984                delete iSecondaryFullScreenEffectData;
  5056                delete iFSFXDataPart2;
  4985                iSecondaryFullScreenEffectData = NULL;
  5057                iFSFXDataPart2 = NULL;
  4986             iFullScreenEffectData = fxData;
  5058             iFSFxData = fxData;
  4987             iFullScreenEffectData->iAppStartScreenshotItemHandle = fxData->iHandle;
  5059             iFSFxData->iAppStartScreenshotItemHandle = fxData->iHandle;
  4988             
  5060             
  4989             stream.Release();
  5061             stream.Release();
  4990             }
  5062             }
  4991         else
  5063         else
  4992             {
  5064             {
  4995             // For now, we continue ongoing.
  5067             // For now, we continue ongoing.
  4996             
  5068             
  4997             __ALFFXLOGSTRING("HandleGfxEffectsL - END: ongoing");
  5069             __ALFFXLOGSTRING("HandleGfxEffectsL - END: ongoing");
  4998             
  5070             
  4999             // Client expects completion to be signalled with this handle.
  5071             // Client expects completion to be signalled with this handle.
  5000             iFullScreenEffectData->iCompletionHandle = stream.ReadInt32L();
  5072             iFSFxData->iCompletionHandle = stream.ReadInt32L();
  5001             if (iSecondaryFullScreenEffectData)
  5073             if (iFSFXDataPart2)
  5002                 {
  5074                 {
  5003                 // 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 
  5004                 // 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 
  5005                 // second effect as soon as the first part finishes.
  5077                 // second effect as soon as the first part finishes.
  5006                 __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Trigger second part. when 1st part done.");
  5078                 __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Trigger second part. when 1st part done.");
  5007                 iSecondaryFullScreenEffectData->iCompletionHandle = iFullScreenEffectData->iCompletionHandle;
  5079                 iFSFXDataPart2->iCompletionHandle = iFSFxData->iCompletionHandle;
  5008                 }
  5080                 }
  5009             
  5081             
  5010             stream.Release();           
  5082             stream.Release();           
  5011             return ; 
  5083             return ; 
  5012             }
  5084             }
  5014     else // MAlfGfxEffectPlugin::EEndFullscreen
  5086     else // MAlfGfxEffectPlugin::EEndFullscreen
  5015         {
  5087         {
  5016         // End fullscreen signal received. We proceed only if there is really
  5088         // End fullscreen signal received. We proceed only if there is really
  5017         // effect ongoing and "end fullscreen" hasn't already been processed.
  5089         // effect ongoing and "end fullscreen" hasn't already been processed.
  5018         
  5090         
  5019         if ( !iFullScreenEffectData 
  5091         if ( !iFSFxData 
  5020                 || iFullScreenEffectData->State() == EFinalEffectActive
  5092                 || iFSFxData->State() == EFinalEffectActive
  5021                 || iFullScreenEffectData->State() == EEndFullscreenReceived)
  5093                 || iFSFxData->State() == EEndFullscreenReceived)
  5022             {
  5094             {
  5023             if (iFullScreenEffectData)
  5095             if (iFSFxData)
  5024             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEffectsL - END: fx ready, state %d ", iFullScreenEffectData->State());
  5096             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEffectsL - END: fx ready, state %d ", iFSFxData->State());
  5025             stream.Release();
  5097             stream.Release();
  5026             return;
  5098             return;
  5027             }
  5099             }
  5028         CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
  5100         CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
  5029         CleanupStack::PushL( fxData );
  5101         CleanupStack::PushL( fxData );
  5032         TBool timeout = fxData->iTimeout;
  5104         TBool timeout = fxData->iTimeout;
  5033         // could the application be ready?
  5105         // could the application be ready?
  5034         TBool applicationExists = FindControlGroupByFullScreenToEffect() != NULL ? ETrue : EFalse;
  5106         TBool applicationExists = FindControlGroupByFullScreenToEffect() != NULL ? ETrue : EFalse;
  5035 
  5107 
  5036         // It may be, that application exited already and it was moved already to effect group
  5108         // It may be, that application exited already and it was moved already to effect group
  5037         if (iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect && !applicationExists )
  5109         if (iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect && !applicationExists )
  5038             {
  5110             {
  5039             applicationExists = FindLayoutByEffectHandle(fxData->iHandle) != NULL ? ETrue : EFalse;
  5111             applicationExists = FindLayoutByEffectHandle(fxData->iHandle) != NULL ? ETrue : EFalse;
  5040             }
  5112             }
  5041                 
  5113                 
  5042         TBool longAppStartTimeout = fxData->iLongAppStartTimeout; 
  5114         TBool longAppStartTimeout = fxData->iLongAppStartTimeout; 
  5043         
  5115         
  5044         if (iFullScreenEffectData &&
  5116         if (iFSFxData &&
  5045                 !iSecondaryFullScreenEffectData && // second part has not been requested yet
  5117                 !iFSFXDataPart2 && // second part has not been requested yet
  5046                 longAppStartTimeout && // this is indeed timeout for app start effect
  5118                 longAppStartTimeout && // this is indeed timeout for app start effect
  5047                 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 
  5048                 (iFullScreenEffectData->State() == EWaitEndFullScreen 
  5120                 (iFSFxData->State() == EWaitEndFullScreen 
  5049                  || iFullScreenEffectData->State() == EWaitingWindowGroup))
  5121                  || iFSFxData->State() == EWaitingWindowGroup))
  5050             {
  5122             {
  5051             // 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
  5052             // updated.
  5124             // updated.
  5053             UpdateSecondaryEffectL(*fxData);
  5125             UpdateSecondaryEffectL(*fxData);
  5054             iFullScreenEffectData->iLongAppStartTimeout = fxData->iLongAppStartTimeout;
  5126             iFSFxData->iLongAppStartTimeout = fxData->iLongAppStartTimeout;
  5055             iFullScreenEffectData->iTwoPhaseEffect = CFullScreenEffectState::EFirstPartActive;
  5127             iFSFxData->iTwoPhaseEffect = CFullScreenEffectState::EFirstPartActive;
  5056             iFullScreenEffectData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
  5128             iFSFxData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
  5057             }
  5129             }
  5058 
  5130 
  5059         __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);
  5060         if (!fxData->iLongAppStartTimeout) // endfullscreen originating from the application
  5132         if (!fxData->iLongAppStartTimeout) // endfullscreen originating from the application
  5061             {
  5133             {
  5062             if (iFullScreenEffectData->State() == EWaitingWindowGroup)
  5134             if (iFSFxData->State() == EWaitingWindowGroup)
  5063                 {
  5135                 {
  5064                 iFullScreenEffectData->SetState(EEndFullScreenReceivedWaitingWindowGroup);
  5136                 iFSFxData->SetState(EEndFullScreenReceivedWaitingWindowGroup);
  5065                 }
  5137                 }
  5066             else
  5138             else
  5067                 {
  5139                 {
  5068                 iFullScreenEffectData->SetState(EEndFullscreenReceived);
  5140                 iFSFxData->SetState(EEndFullscreenReceived);
  5069                 }
  5141                 }
  5070             
  5142             
  5071             if (iSecondaryFullScreenEffectData)
  5143             if (iFSFXDataPart2)
  5072                 {
  5144                 {
  5073                 iSecondaryFullScreenEffectData->SetState(EEndFullscreenReceived);
  5145                 iFSFXDataPart2->SetState(EEndFullscreenReceived);
  5074                 }
  5146                 }
  5075             
  5147             
  5076             }
  5148             }
  5077         CleanupStack::PopAndDestroy( fxData );
  5149         CleanupStack::PopAndDestroy( fxData );
  5078         fxData = NULL;
  5150         fxData = NULL;
  5079         
  5151         
  5080         __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",
  5081                 timeout,
  5153                 timeout,
  5082                 longAppStartTimeout,
  5154                 longAppStartTimeout,
  5083                 iFullScreenEffectData->iSetupDone,
  5155                 iFSFxData->iSetupDone,
  5084                 iFullScreenEffectData->State());
  5156                 iFSFxData->State());
  5085 
  5157 
  5086         stream.Release();// We should respect normal timeouts.
  5158         stream.Release();// We should respect normal timeouts.
  5087         if (iFullScreenEffectData->iTwoPhaseEffect > CFullScreenEffectState::EOnlyOnePart
  5159         if (iFSFxData->iTwoPhaseEffect > CFullScreenEffectState::EOnlyOnePart
  5088                 && 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 = 
  5089             {
  5161             {
  5090             // 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)
  5091             // or screen drawn (triggered from 
  5163             // or screen drawn (triggered from 
  5092             __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.");
  5093             return;
  5165             return;
  5094             }
  5166             }
  5095         
  5167         
  5096         // 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
  5097         // 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.
  5098         if (iFullScreenEffectData->State() == EEndFullscreenReceived && !applicationExists && !timeout)
  5170         if (iFSFxData->State() == EEndFullscreenReceived && !applicationExists && !timeout)
  5099             {
  5171             {
  5100             HandleGfxStopEvent(ETrue);
  5172             HandleGfxStopEvent(ETrue);
  5101             return;
  5173             return;
  5102             }
  5174             }
  5103         }
  5175 	    // If a long two part app start effect is ongoing or about to start, we can skip directly to the 
  5104 
  5176 		// second part when EndFullScreen request arrives.
  5105     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;
  5106     fxData->iOperation = operation;
  5188     fxData->iOperation = operation;
  5107 
  5189 
  5108     __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);
  5109     __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - towg: %d, fromwg: %d", fxData->iToWg, fxData->iFromWg);
  5191     __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - towg: %d, fromwg: %d", fxData->iToWg, fxData->iFromWg);
  5110 
  5192 
  5139             {
  5221             {
  5140             failed = HandleGfxEventL(*fxData, toLayout, fromLayout);
  5222             failed = HandleGfxEventL(*fxData, toLayout, fromLayout);
  5141             // 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
  5142             if (fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen)
  5224             if (fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen)
  5143                 {
  5225                 {
  5144                 iFullScreenEffectData->SetState(EWaitEndFullScreen);
  5226                 iFSFxData->SetState(EWaitEndFullScreen);
  5145                 }
  5227                 }
  5146             }
  5228             }
  5147         else
  5229         else
  5148             {
  5230             {
  5149             __ALFFXLOGSTRING("HandleGfxEffectsL - waiting window group");            
  5231             __ALFFXLOGSTRING("HandleGfxEffectsL - waiting window group");            
  5152         }
  5234         }
  5153 
  5235 
  5154     if ( failed )
  5236     if ( failed )
  5155         {
  5237         {
  5156         // Effect failed, reset state
  5238         // Effect failed, reset state
  5157         HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
  5239         HandleGfxStopEvent( EFalse ); // destroys iFSFxData and iFSFXDataPart2
  5158         }
  5240         }
  5159     else
  5241     else
  5160         {
  5242         {
  5161         // 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. 
  5162 		// If so, then trigger EndFullScreen immediately.
  5244 		// If so, then trigger EndFullScreen immediately.
  5184     
  5266     
  5185     __ALFFXLOGSTRING1("CAlfBridge::UpdateSecondaryEffectL - appstart timeout triggered: %d", aState.iLongAppStartTimeout);
  5267     __ALFFXLOGSTRING1("CAlfBridge::UpdateSecondaryEffectL - appstart timeout triggered: %d", aState.iLongAppStartTimeout);
  5186     if (aState.iLongAppStartTimeout) // only application start effects can trigger this timeout 
  5268     if (aState.iLongAppStartTimeout) // only application start effects can trigger this timeout 
  5187         {
  5269         {
  5188         // clone the primary startup effect for later usage
  5270         // clone the primary startup effect for later usage
  5189         delete iSecondaryFullScreenEffectData;
  5271         delete iFSFXDataPart2;
  5190         iSecondaryFullScreenEffectData = new (ELeave) CFullScreenEffectState;
  5272         iFSFXDataPart2 = new (ELeave) CFullScreenEffectState;
  5191         iSecondaryFullScreenEffectData->ConstructL(*iFullScreenEffectData);
  5273         iFSFXDataPart2->ConstructL(*iFSFxData);
  5192         iSecondaryFullScreenEffectData->iLongAppStartTimeout = EFalse;
  5274         iFSFXDataPart2->iLongAppStartTimeout = EFalse;
  5193         
  5275         
  5194         delete iFullScreenEffectData->iEffectName;
  5276         delete iFSFxData->iEffectName;
  5195         iFullScreenEffectData->iEffectName = NULL;
  5277         iFSFxData->iEffectName = NULL;
  5196         iFullScreenEffectData->iEffectName = aState.iEffectName->AllocL();
  5278         iFSFxData->iEffectName = aState.iEffectName->AllocL();
  5197         }
  5279         }
  5198     __ALFFXLOGSTRING("CAlfBridge::UpdateSecondaryEffectL <<" );
  5280     __ALFFXLOGSTRING("CAlfBridge::UpdateSecondaryEffectL <<" );
  5199     return EFalse;
  5281     return EFalse;
  5200     }    
  5282     }    
  5201 
  5283 
  5230             {
  5312             {
  5231             fullscreenCovered = HasActiveAlfContent(clientGroupId);
  5313             fullscreenCovered = HasActiveAlfContent(clientGroupId);
  5232             }
  5314             }
  5233         }
  5315         }
  5234     
  5316     
  5235     __ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - Covered: %d", fullscreenCovered);
  5317     __ALFFXLOGSTRING2("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - SecureId: 0x%x, Covered: %d", aToGroup->SecureId(), fullscreenCovered);
  5236     if (fullscreenCovered)
  5318     if (fullscreenCovered)
  5237         {
  5319         {
  5238         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             }
  5239         return ETrue;
  5336         return ETrue;
  5240         }
  5337         }
  5241     return EFalse;
  5338     return EFalse;
  5242     }
  5339     }
  5243 
  5340 
  5260     TInt toAppUi = stream.ReadInt32L();
  5357     TInt toAppUi = stream.ReadInt32L();
  5261     stream.Release();
  5358     stream.Release();
  5262 
  5359 
  5263     // operation tells if this is abort full screen or something else
  5360     // operation tells if this is abort full screen or something else
  5264     // 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
  5265     if ( iFullScreenEffectData )
  5362     if ( iFSFxData )
  5266         {
  5363         {
  5267         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill fullscreen");        
  5364         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill fullscreen");        
  5268         HandleGfxStopEvent( ETrue );
  5365         HandleGfxStopEvent( ETrue );
  5269         }
  5366         }
  5270     
  5367     
  5271     if ( !toAppUi )
  5368     if ( !toAppUi )
  5272         {
  5369         {
  5273         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill all");
  5370         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill all");
  5274         RemoveAllTemporaryPresenterVisuals();
  5371         CleanAllFxVisuals();
  5275         iHuiEnv->ContinueRefresh();
  5372         iHuiEnv->ContinueRefresh();
  5276         }
  5373         }
  5277     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - end");
  5374     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - end");
  5278     }
  5375     }
  5279 
  5376 
  5292     iControlEffectData = NULL;
  5389     iControlEffectData = NULL;
  5293         
  5390         
  5294     if (handle != KErrNotFound)
  5391     if (handle != KErrNotFound)
  5295         {
  5392         {
  5296         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxStopControlEffectsL - Remove effect with handle: %d", handle);
  5393         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxStopControlEffectsL - Remove effect with handle: %d", handle);
  5297         RemoveTemporaryPresenterVisual(NULL, handle);
  5394         CleanFxVisual(NULL, handle);
  5298         iHuiEnv->ContinueRefresh();
  5395         iHuiEnv->ContinueRefresh();
  5299         }
  5396         }
  5300     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopControlEffectsL - end");
  5397     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopControlEffectsL - end");
  5301     }
  5398     }
  5302 
  5399 
  5376         {
  5473         {
  5377         engine->RegisterEffectL(aFilename);
  5474         engine->RegisterEffectL(aFilename);
  5378         }
  5475         }
  5379     }
  5476     }
  5380 
  5477 
  5381 CHuiCanvasVisual* CAlfBridge::AddEffectItemL(
  5478 CHuiCanvasVisual* CAlfBridge::AddFxItemL(
  5382         TInt aEffectHandle, 
  5479         TInt aEffectHandle, 
  5383         CHuiVisual* aSourceVisual, 
  5480         CHuiVisual* aSourceVisual, 
  5384         CHuiLayout* aTargetLayout, 
  5481         CHuiLayout* aTargetLayout, 
  5385         CHuiControl* aEffectControl, 
  5482         CHuiControl* aEffectControl, 
  5386         TBool aInsertTemporaryVisual,
  5483         TBool aInsertTemporaryVisual,
  5412     
  5509     
  5413         // 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
  5414         // cleanup stack iEffectCleanupStack
  5511         // cleanup stack iEffectCleanupStack
  5415         enableEffect = aSourceVisual->Flags() & EHuiVisualFlagShouldDestroy ? 0 : 1;
  5512         enableEffect = aSourceVisual->Flags() & EHuiVisualFlagShouldDestroy ? 0 : 1;
  5416         __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 );
  5417         RemoveTemporaryPresenterVisual(aSourceVisual);
  5514         CleanFxVisual(aSourceVisual);
  5418         if (!enableEffect)
  5515         if (!enableEffect)
  5419             {
  5516             {
  5420             aItemDestroyed++;
  5517             aItemDestroyed++;
  5421             }
  5518             }
  5422         }
  5519         }
  5469         TBool aCanDestroyOrHideImmediately)
  5566         TBool aCanDestroyOrHideImmediately)
  5470     {
  5567     {
  5471     __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());
  5472     if (aAddLayout)
  5569     if (aAddLayout)
  5473         {
  5570         {
  5474         AddEffectItemL(aEffectHandle, aSourceLayout, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
  5571         AddFxItemL(aEffectHandle, aSourceLayout, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
  5475         }
  5572         }
  5476         
  5573         
  5477     for (TInt i = 0; i < aSourceLayout->Count(); i++)
  5574     for (TInt i = 0; i < aSourceLayout->Count(); i++)
  5478            {
  5575            {
  5479            CHuiCanvasVisual& sourceVisual = static_cast<CHuiCanvasVisual&> (aSourceLayout->Visual(i));
  5576            CHuiCanvasVisual& sourceVisual = static_cast<CHuiCanvasVisual&> (aSourceLayout->Visual(i));
  5482                {
  5579                {
  5483                CHuiLayout& layout = static_cast<CHuiLayout&> (aSourceLayout->Visual(i));
  5580                CHuiLayout& layout = static_cast<CHuiLayout&> (aSourceLayout->Visual(i));
  5484                AddToEffectLayoutContainerL(aEffectHandle, &layout, NULL, aEffectControl, aItemsDestroyed, aIsFullScreenEffect,  EFalse, aIsExitEffect, aCanDestroyOrHideImmediately );
  5581                AddToEffectLayoutContainerL(aEffectHandle, &layout, NULL, aEffectControl, aItemsDestroyed, aIsFullScreenEffect,  EFalse, aIsExitEffect, aCanDestroyOrHideImmediately );
  5485                }
  5582                }
  5486            TInt oldItemsDestroyed = aItemsDestroyed;
  5583            TInt oldItemsDestroyed = aItemsDestroyed;
  5487            AddEffectItemL(aEffectHandle, &sourceVisual, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
  5584            AddFxItemL(aEffectHandle, &sourceVisual, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
  5488            if (oldItemsDestroyed != aItemsDestroyed)
  5585            if (oldItemsDestroyed != aItemsDestroyed)
  5489                {
  5586                {
  5490                // Visual was destroyed. If so, then we must adjust index.
  5587                // Visual was destroyed. If so, then we must adjust index.
  5491                --i;
  5588                --i;
  5492                }
  5589                }
  5494     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
  5591     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
  5495     }
  5592     }
  5496 
  5593 
  5497 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)
  5498     {
  5595     {
  5499     __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 >>", 
  5500             aHandle, 
  5597             aHandle, 
  5501             aSourceLayout, 
  5598             aSourceLayout, 
  5502             aIsExitEffect,
  5599             aIsExitEffect,
  5503             aCanDestroyOrHideImmediately );
  5600             aCanDestroyOrHideImmediately );
  5504     
  5601     
  5517     TInt itemsDestroyed(0);
  5614     TInt itemsDestroyed(0);
  5518     AddToEffectLayoutContainerL(aHandle, aSourceLayout, NULL, &effectControlGroup, itemsDestroyed, aIsFullScreenEffect, EFalse, aIsExitEffect, aCanDestroyOrHideImmediately);
  5615     AddToEffectLayoutContainerL(aHandle, aSourceLayout, NULL, &effectControlGroup, itemsDestroyed, aIsFullScreenEffect, EFalse, aIsExitEffect, aCanDestroyOrHideImmediately);
  5519 
  5616 
  5520     if (aIsExitEffect)
  5617     if (aIsExitEffect)
  5521         {
  5618         {
  5522         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);
  5523         aSourceLayout->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  5620         aSourceLayout->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  5524         __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);
  5525         }
  5622         }
  5526     else
  5623     else
  5527         {
  5624         {
  5528         AddEffectItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, EFalse, itemsDestroyed, aIsFullScreenEffect, EFalse, EFalse);
  5625         AddFxItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, EFalse, itemsDestroyed, aIsFullScreenEffect, EFalse, EFalse);
  5529         __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);
  5530         }
  5627         }
  5531     iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue;
  5628     iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue;
  5532     iAlfScreens[0]->iDisplay->SetDirty();
  5629     iAlfScreens[0]->iDisplay->SetDirty();
  5533     if (itemsDestroyed)
  5630     if (itemsDestroyed)
  5642         __ALFFXLOGSTRING2("HandleGfxControlEffectsL - loading control effect, handle %d, Action: %d", aEvent.iHandle, aEvent.iAction );
  5739         __ALFFXLOGSTRING2("HandleGfxControlEffectsL - loading control effect, handle %d, Action: %d", aEvent.iHandle, aEvent.iAction );
  5643         if (aCanvasVisual->Effect())
  5740         if (aCanvasVisual->Effect())
  5644             {
  5741             {
  5645             __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x has active effect. Requesting removal.", aCanvasVisual);
  5742             __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x has active effect. Requesting removal.", aCanvasVisual);
  5646             // 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
  5647             RemoveTemporaryPresenterVisual(aCanvasVisual);
  5744             CleanFxVisual(aCanvasVisual);
  5648             }
  5745             }
  5649         TBool layoutEffectable(EFalse);
  5746         TBool layoutEffectable(EFalse);
  5650         if (aEvent.iAction == KGfxControlDisappearAction)
  5747         if (aEvent.iAction == KGfxControlDisappearAction)
  5651             {
  5748             {
  5652             if (aCanvasVisual->Flags() & EHuiVisualFlagInactive)
  5749             if (aCanvasVisual->Flags() & EHuiVisualFlagInactive)
  5696             // destruction in any order
  5793             // destruction in any order
  5697             }
  5794             }
  5698         else
  5795         else
  5699             {
  5796             {
  5700             // 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.
  5701             RemoveTemporaryPresenterVisual(NULL, aEvent.iHandle);
  5798             CleanFxVisual(NULL, aEvent.iHandle);
  5702             }
  5799             }
  5703         effect = NULL; // HuiVisual has taken ownership
  5800         effect = NULL; // HuiVisual has taken ownership
  5704         }
  5801         }
  5705     }
  5802     }
  5706 
  5803 
  5707 TBool CAlfBridge::RemoveTemporaryPresenterItem(TEffectCleanupStruct& aEffectItem)
  5804 TBool CAlfBridge::CleanFxItem(TEffectCleanupStruct& aEffectItem)
  5708     {
  5805     {
  5709     CHuiVisual* sourceViz = aEffectItem.iEffectedVisual;
  5806     CHuiVisual* sourceViz = aEffectItem.iEffectedVisual;
  5710     CHuiCanvasVisual* sourceViz2 = dynamic_cast<CHuiCanvasVisual*> (aEffectItem.iEffectedVisual);
  5807     CHuiCanvasVisual* sourceViz2 = dynamic_cast<CHuiCanvasVisual*> (aEffectItem.iEffectedVisual);
  5711     // 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 
  5712     // 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.
  5717         sourceViz2->FreeRenderBuffer();
  5814         sourceViz2->FreeRenderBuffer();
  5718         }
  5815         }
  5719     sourceViz->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  5816     sourceViz->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
  5720     TBool hideVisual = EFalse;
  5817     TBool hideVisual = EFalse;
  5721     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.
  5722     if(!aEffectItem.iIsFullScreenEffect)
  5837     if(!aEffectItem.iIsFullScreenEffect)
  5723         {
  5838         {
  5724         hideVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeHidden) || aEffectItem.iHideWhenFinished;
  5839         hideVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeHidden) || (aEffectItem.iHideWhenFinished && !(sourceViz->Flags() & EHuiVisualFlagShouldBeShown));
  5725         showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown) && !aEffectItem.iHideWhenFinished;
  5840         showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown) && (!aEffectItem.iHideWhenFinished || !hideVisual);
  5726         }
  5841         }
  5727     else
  5842     else
  5728         {
  5843         {
  5729         hideVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeHidden);
  5844         hideVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeHidden);
  5730         showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown);
  5845         showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown);
  5731         }
  5846         }
       
  5847     __ALFFXLOGSTRING4("CAlfBridge::RemoveTemporaryPresenterItem - iIsFullScreenEffect: %d, iHideWhenFinished: %d, Hide: %d, Show: %d", aEffectItem.iIsFullScreenEffect, aEffectItem.iHideWhenFinished, hideVisual, showVisual);
  5732     TBool destroyVisual = sourceViz->Flags() & EHuiVisualFlagShouldDestroy;
  5848     TBool destroyVisual = sourceViz->Flags() & EHuiVisualFlagShouldDestroy;
  5733     TBool shouldInactivate = sourceViz->Flags() & EHuiVisualFlagShouldBeInactive;
  5849     TBool shouldInactivate = sourceViz->Flags() & EHuiVisualFlagShouldBeInactive;
  5734     TBool shouldBeUnderOpaqueHint = sourceViz->Flags() & EHuiVisualFlagShouldBeUnderOpaqueHint;
  5850     TBool shouldBeUnderOpaqueHint = sourceViz->Flags() & EHuiVisualFlagShouldBeUnderOpaqueHint;
  5735     __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);
  5736     __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));
  5830             }
  5946             }
  5831         }
  5947         }
  5832     return TBool(destroyVisual);
  5948     return TBool(destroyVisual);
  5833     }
  5949     }
  5834 
  5950 
  5835 // 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. 
  5836 TBool CAlfBridge::RemoveTemporaryPresenterVisual(CHuiVisual* aVisual,
  5952 TBool CAlfBridge::CleanFxVisual(CHuiVisual* aVisual,
  5837         TInt aHandle)
  5953         TInt aHandle)
  5838     {
  5954     {
  5839     __ALFFXLOGSTRING2("CAlfBridge::RemoveTemporaryPresenterVisual - cleaning handle: %d, 0x%x", aHandle, aVisual);
  5955     __ALFFXLOGSTRING2("CAlfBridge::RemoveTemporaryPresenterVisual - cleaning handle: %d, 0x%x", aHandle, aVisual);
  5840     TInt visualsRemoved = 0;
  5956     TInt visualsRemoved = 0;
  5841     for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  5957     for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  5842         {
  5958         {
  5843         TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  5959         TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  5844         if (aVisual == effectItem.iEffectedVisual || 
  5960         if (aVisual == effectItem.iEffectedVisual || 
  5845 		    aHandle == effectItem.iHandle)
  5961 		    aHandle == effectItem.iHandle)
  5846             {
  5962             {
  5847             if (RemoveTemporaryPresenterItem(effectItem))
  5963             if (CleanFxItem(effectItem))
  5848                 {
  5964                 {
  5849                 visualsRemoved++;
  5965                 visualsRemoved++;
  5850                 }
  5966                 }
  5851             // must remove from finished effects to keep it in sync
  5967             // must remove from finished effects to keep it in sync
  5852             for(TInt k = 0; k < iFinishedCleanupStackEffects.Count(); k++)
  5968             for(TInt k = 0; k < iFinishedCleanupStackEffects.Count(); k++)
  5921         }
  6037         }
  5922     return NULL;
  6038     return NULL;
  5923     }
  6039     }
  5924 
  6040 
  5925 
  6041 
  5926 TBool CAlfBridge::RemoveTemporaryPresenterVisuals()
  6042 TBool CAlfBridge::CleanFxVisuals()
  5927     {
  6043     {
  5928     if (!iFinishedCleanupStackEffects.Count())
  6044     if (!iFinishedCleanupStackEffects.Count())
  5929         {
  6045         {
  5930         return 0;
  6046         return 0;
  5931         }
  6047         }
  5941             __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 );
  5942             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  6058             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  5943              
  6059              
  5944             if (iFinishedCleanupStackEffects[0] == effectItem.iHandle)
  6060             if (iFinishedCleanupStackEffects[0] == effectItem.iHandle)
  5945                 {
  6061                 {
  5946                 if (RemoveTemporaryPresenterItem(effectItem))
  6062                 if (CleanFxItem(effectItem))
  5947                     {
  6063                     {
  5948                     itemsRemoved++;
  6064                     itemsRemoved++;
  5949                     }
  6065                     }
  5950                 if (iEffectCleanupStack.Count() > i)
  6066                 if (iEffectCleanupStack.Count() > i)
  5951                     {
  6067                     {
  5967     iAlfScreens[0]->iDisplay->SetDirty();
  6083     iAlfScreens[0]->iDisplay->SetDirty();
  5968 	__ALFFXLOGSTRING1("CAlfBridge::RemoveTemporaryPresenterVisuals - END - effects in layout %d", effectControlGroupLayout->Count());
  6084 	__ALFFXLOGSTRING1("CAlfBridge::RemoveTemporaryPresenterVisuals - END - effects in layout %d", effectControlGroupLayout->Count());
  5969     return itemsRemoved;
  6085     return itemsRemoved;
  5970     }
  6086     }
  5971 
  6087 
  5972 void CAlfBridge::RemoveAllTemporaryPresenterVisuals()
  6088 void CAlfBridge::CleanAllFxVisuals()
  5973     {
  6089     {
  5974     CHuiControl& effectControlGroup =  iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0);
  6090     CHuiControl& effectControlGroup =  iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0);
  5975     CHuiLayout* effectControlGroupLayout = (CHuiLayout*) &effectControlGroup.Visual(0);
  6091     CHuiLayout* effectControlGroupLayout = (CHuiLayout*) &effectControlGroup.Visual(0);
  5976     __ALFFXLOGSTRING1("CAlfBridge::RemoveAllTemporaryPresenterVisuals - BEGIN - effects in layout %d", effectControlGroupLayout->Count());
  6092     __ALFFXLOGSTRING1("CAlfBridge::RemoveAllTemporaryPresenterVisuals - BEGIN - effects in layout %d", effectControlGroupLayout->Count());
  5977 
  6093 
  5978     while(iEffectCleanupStack.Count())
  6094     while(iEffectCleanupStack.Count())
  5979         {
  6095         {
  5980         TEffectCleanupStruct& effectItem = iEffectCleanupStack[0];
  6096         TEffectCleanupStruct& effectItem = iEffectCleanupStack[0];
  5981         RemoveTemporaryPresenterItem(effectItem);
  6097         CleanFxItem(effectItem);
  5982         iEffectCleanupStack.Remove(0);
  6098         iEffectCleanupStack.Remove(0);
  5983         }
  6099         }
  5984     
  6100     
  5985     while(iFinishedCleanupStackEffects.Count())
  6101     while(iFinishedCleanupStackEffects.Count())
  5986         {
  6102         {
  6002     // around will be cleared when HandleGfxStopEffectsL is called
  6118     // around will be cleared when HandleGfxStopEffectsL is called
  6003 
  6119 
  6004     // iFinishedCleanupStackEffects.Append(aHandle);
  6120     // iFinishedCleanupStackEffects.Append(aHandle);
  6005     
  6121     
  6006 	// check if the first part of application start effect finished
  6122 	// check if the first part of application start effect finished
  6007     if (iFullScreenEffectData 
  6123     if (iFSFxData 
  6008             && iFullScreenEffectData->iHandle == aHandle
  6124             && iFSFxData->iHandle == aHandle
  6009             && iFullScreenEffectData->iLongAppStartTimeout && iSecondaryFullScreenEffectData)
  6125             && iFSFxData->iLongAppStartTimeout && iFSFXDataPart2)
  6010         {
  6126         {
  6011         delete iFullScreenEffectData;
  6127         delete iFSFxData;
  6012         iFullScreenEffectData = iSecondaryFullScreenEffectData;
  6128         iFSFxData = iFSFXDataPart2;
  6013         iSecondaryFullScreenEffectData = NULL;
  6129         iFSFXDataPart2 = NULL;
  6014         iFullScreenEffectData->iTwoPhaseEffect = CFullScreenEffectState::ESecondPartActive;
  6130         iFSFxData->iTwoPhaseEffect = CFullScreenEffectState::ESecondPartActive;
  6015         if (iFullScreenEffectData->State() == EEndFullscreenReceived)
  6131         if (iFSFxData->State() == EEndFullscreenReceived)
  6016             {
  6132             {
  6017             // 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.
  6018             __ALFFXLOGSTRING("CAlfBridge::AlfGfxEffectEndCallBack - End was received. Trigger second part.");
  6134             __ALFFXLOGSTRING("CAlfBridge::AlfGfxEffectEndCallBack - End was received. Trigger second part.");
  6019             iFullScreenEffectData->SetState(ESecondPhaseSetupActive); // effect setup will be skipped in HandleGfxEvent
  6135             GfxTriggerEndFullScreen(iFSFxData);
  6020             GfxTriggerEndFullScreen(iFullScreenEffectData);
  6136             iFSFxData->SetState(EFinalEffectActive);
  6021             iFullScreenEffectData->SetState(EFinalEffectActive);
       
  6022 			// skip cleanup. It will be run, when this effect finishes
  6137 			// skip cleanup. It will be run, when this effect finishes
  6023             return;
  6138             return;
  6024             }
  6139             }
  6025         else
  6140         else
  6026             {
  6141             {
  6027             iFullScreenEffectData->SetState(EWaitEndFullScreen);
  6142             iFSFxData->SetState(EWaitEndFullScreen);
  6028             }
  6143             }
  6029         
  6144         
  6030         iFullScreenEffectData->iEffectType = CFullScreenEffectState::EStartEffect;
  6145         iFSFxData->iEffectType = CFullScreenEffectState::EStartEffect;
  6031         
  6146         
  6032         CHuiControlGroup* toGroup = FindControlGroupByFullScreenToEffect();
  6147         CHuiControlGroup* toGroup = FindControlGroupByFullScreenToEffect();
  6033         GfxTriggerEffectWhenFullScreenDrawn(toGroup);
  6148         GfxTriggerEffectWhenFullScreenDrawn(toGroup);
  6034         return;
  6149         return;
  6035         }
  6150         }
  6066     if ( aHandle == KErrNotFound )
  6181     if ( aHandle == KErrNotFound )
  6067         {
  6182         {
  6068         __ALFFXLOGSTRING("invalid handle");
  6183         __ALFFXLOGSTRING("invalid handle");
  6069         }
  6184         }
  6070     // alftranstion plugin may cancel end timers connected to this effect
  6185     // alftranstion plugin may cancel end timers connected to this effect
  6071     TBool fsEffectDone = iFullScreenEffectData && aHandle == iFullScreenEffectData->iHandle;
  6186     TBool fsEffectDone = iFSFxData && aHandle == iFSFxData->iHandle;
  6072     if ( fsEffectDone )
  6187     if ( fsEffectDone )
  6073         {
  6188         {
  6074         aHandle = iFullScreenEffectData->iCompletionHandle;
  6189         aHandle = iFSFxData->iCompletionHandle;
  6075         }
  6190         }
  6076     RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, aHandle );
  6191     RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, aHandle );
  6077 
  6192 
  6078     // Effect finished
  6193     // Effect finished
  6079     if ( fsEffectDone )
  6194     if ( fsEffectDone )
  6080         {
  6195         {
  6081         delete iFullScreenEffectData;
  6196         delete iFSFxData;
  6082         iFullScreenEffectData = NULL;
  6197         iFSFxData = NULL;
  6083         
  6198         
  6084         delete iSecondaryFullScreenEffectData;
  6199         delete iFSFXDataPart2;
  6085         iSecondaryFullScreenEffectData = NULL;
  6200         iFSFXDataPart2 = NULL;
  6086         }
  6201         }
  6087     }
  6202     }
  6088     
  6203     
  6089 
  6204 
  6090 void CAlfBridge::PrintAllocMem()
  6205 void CAlfBridge::PrintAllocMem()
  6752 TBool CAlfBridge::IsAlfOriginatedWindow(CHuiCanvasVisual& aVisual)
  6867 TBool CAlfBridge::IsAlfOriginatedWindow(CHuiCanvasVisual& aVisual)
  6753     {
  6868     {
  6754     return (aVisual.Owner().ControlGroup()->ResourceId() == iAlfWindowGroupNodeId);
  6869     return (aVisual.Owner().ControlGroup()->ResourceId() == iAlfWindowGroupNodeId);
  6755     }
  6870     }
  6756 
  6871 
  6757 // experimental
  6872 
  6758 TBool CAlfBridge::IsFullScreenDrawn( TInt aOrientation)
  6873 // ---------------------------------------------------------------------------
  6759     {
  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 
  6760     if (!iAlfScreens.Count())
  6884     if (!iAlfScreens.Count())
  6761         return EFalse;
  6885         return EFalse;
  6762     aOrientation = iAlfScreens[0]->iDisplay->Orientation();            
  6886    
  6763     iTempRegion.Clear();
  6887     iTempRegion.Clear();
       
  6888     iTempRegion2.Clear();
  6764     
  6889     
  6765     CAlfScreen* screen = iAlfScreens[0];
  6890     CAlfScreen* screen = iAlfScreens[0];
  6766     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
  6891     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
  6767     __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     
  6768     TBool fullscreenCovered = EFalse;
  6896     TBool fullscreenCovered = EFalse;
  6769         
  6897 	TBool alfClientWindowGroupVisible = EFalse;
  6770     // Check if effect group has an effect with opaque hint.
  6898 	
  6771     CHuiControlGroup& fxcontrolgroup = *(iAlfScreens[0]->iFullscreenEffectControlGroup);
  6899 	TInt coverageModifiedGroupCount = 0;
  6772     CHuiControl& fxcontrol = fxcontrolgroup.Control(0);
  6900 		
  6773     CHuiCanvasVisual* fxlayout = (CHuiCanvasVisual*)&fxcontrol.Visual(0);
  6901     // Skip the topmost (effect) layer, start from floating sprite group
  6774     CHuiVisual* fxExternalContent = fxlayout->ExternalContent();
       
  6775     
       
  6776     if (fxlayout && IsOpaqueEffect(fxlayout->Effect()))
       
  6777         {
       
  6778         fullscreenCovered = ETrue;    
       
  6779         }
       
  6780     else if (fxExternalContent && IsOpaqueEffect(fxExternalContent->Effect()))
       
  6781         {
       
  6782         fullscreenCovered = ETrue;
       
  6783         }    
       
  6784 
       
  6785     TBool alfClientWindowGroupVisible = EFalse;
       
  6786     
       
  6787     AMT_SET_VALUE( iVisibleVisualCount, 0 );
       
  6788     
       
  6789     // skip the topmost (effect) layer, start from floating sprite group
       
  6790     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--)
  6791         {                
  6903         {                
  6792         CHuiControlGroup& controlgroup = iAlfScreens[0]->iDisplay->Roster().ControlGroup(j);
  6904         CHuiControlGroup& controlgroup = screen->iDisplay->Roster().ControlGroup(j);
  6793         CHuiControl& control = controlgroup.Control(0);
  6905         CHuiControl& control = controlgroup.Control(0);
  6794 		__ALFFXLOGSTRING1("CAlfBridge::IsFullScreenDrawn : Group owner 0x%x", controlgroup.SecureId());
  6906 
  6795                 
       
  6796         
       
  6797         if (control.Role() == EHuiFpsIndicatorContainer)
  6907         if (control.Role() == EHuiFpsIndicatorContainer)
  6798             {
  6908             {
  6799             // FPS container doesn't contain canvas visuals
  6909             // FPS container doesn't contain canvas visuals
  6800             continue;
  6910             continue;
  6801             }
  6911             }
  6802 
  6912 
       
  6913         if (controlgroup.ResourceId() == iAlfWindowGroupNodeId)
       
  6914             {
       
  6915             // ALF window doesn't have drawing and it's meant to be completely semitransparent,
       
  6916             // so skip.
       
  6917             continue;
       
  6918             }
       
  6919 
  6803         CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
  6920         CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
  6804        
  6921         
  6805         // For optimization reasons, check if all visuals below in Z-order are covered    
  6922         // For optimization reasons, check if all visuals below in Z-order are covered    
  6806         if (!fullscreenCovered)
  6923         if (!fullscreenCovered)
  6807             {
  6924             {
  6808             fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
  6925             fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);            
  6809             if(fullscreenCovered)
  6926             }
  6810                 {
  6927     
  6811                 return ETrue;
  6928         if (fullscreenCovered)
  6812                 }
  6929             {
  6813             for(TInt ii=0;ii< iTempRegion.Count(); ii++)
  6930             break;
  6814                 {
  6931             }    
  6815                 __ALFFXLOGSTRING4("CAlfBridge::IsFullScreenDrawn (%d,%d)-(%d,%d)", iTempRegion[ii].iTl.iX, iTempRegion[ii].iTl.iY , iTempRegion[ii].iBr.iX, iTempRegion[ii].iBr.iY );
  6932         
  6816                 }
  6933         // ALF applications are handled by checking if their visuals cover the whole screen.
  6817             }
       
  6818         
       
  6819         // Dont mess with alf control group visuals, alf session handling does it for us
       
  6820         if (control.Role() == EHuiSessionContainer)
  6934         if (control.Role() == EHuiSessionContainer)
  6821             {
  6935             {
  6822             CHuiLayout* hostContainer = control.ContainerLayout( NULL );
  6936             CHuiLayout* hostContainer = control.ContainerLayout( NULL );
  6823             TInt flags = hostContainer->Flags();            
  6937             TInt flags = hostContainer->Flags();            
  6824             if (alfClientWindowGroupVisible)
  6938             if (alfClientWindowGroupVisible)
  6843                     }
  6957                     }
  6844                 }
  6958                 }
  6845             continue;
  6959             continue;
  6846             }
  6960             }
  6847         
  6961         
  6848         __ALFLOGSTRING1("CAlfBridge::IsFullScreenDraw - fullscreen covered %d", fullscreenCovered)
  6962         TBool hasActiveVisualsInVisualTree(EFalse);
  6849         TBool subTreeCovered = EFalse;
  6963         TBool coverageRegionModified(EFalse);
  6850         TBool hasActiveVisualsInVisualTree = 
  6964         
  6851                 IsFullScreenDrawnRecursive( layout, controlgroup, control, fullscreenCovered, fullscreen, screen,subTreeCovered, IsVisualOpaque(*layout), aOrientation );    
  6965         if (alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId))
  6852         // If root visuals effect is marked as opaque, then add whole screen area as covered.
  6966             {
  6853         /*
  6967             visualTreeReady =
  6854         if (!fullscreenCovered)
  6968                IsLayoutSwitchReadyRecursive( layout, controlgroup, control, 
  6855             {
  6969                    hasActiveVisualsInVisualTree, fullscreen, screen, 
  6856             fullscreenCovered = IsOpaqueEffect(layout->Effect());
  6970                    IsVisualOpaque(*layout), alfClientWindowGroupVisible, 
  6857             }                    
  6971                    orientation, aDuration, coverageRegionModified );            
  6858         */    
  6972             }
  6859        
  6973         else
  6860         if(controlgroup.iAlfApp && layout->iOpacity.Now() > 0.0f )
  6974             {
       
  6975             visualTreeReady =
       
  6976                IsLayoutSwitchReadyRecursive( layout, controlgroup, control, 
       
  6977                    fullscreenCovered, fullscreen, screen, 
       
  6978                    IsVisualOpaque(*layout), EFalse, orientation, 
       
  6979                    aDuration, coverageRegionModified );            
       
  6980             }
       
  6981 
       
  6982         if (!visualTreeReady)
       
  6983             {
       
  6984             // Problem found in IsLayoutSwitchReadyRecursive
       
  6985             visualTreeReady = EFalse;
       
  6986             break;
       
  6987             }
       
  6988 
       
  6989         if (coverageRegionModified)
       
  6990             {
       
  6991             coverageModifiedGroupCount++;
       
  6992             }
       
  6993 
       
  6994         // Heuristic: If coverage region is modified by multiple apps, then it's possible that
       
  6995         // foreground application hasn't had time to update its layout. So give little time to do that.
       
  6996         if (aDuration <= KAlfCheckCoverageFromMultipleGroups && coverageRegionModified > 1)
       
  6997             {
       
  6998             __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - multiple groups");
       
  6999             visualTreeReady = EFalse;
       
  7000             break;
       
  7001             }
       
  7002 
       
  7003         if( controlgroup.iAlfApp && layout->iOpacity.Now() > 0.0f )
  6861             {
  7004             {
  6862             alfClientWindowGroupVisible = ETrue;
  7005             alfClientWindowGroupVisible = ETrue;
  6863             }
  7006             }
  6864         
  7007         }
  6865         if (fullscreenCovered)
  7008 
  6866             {
  7009     __ALFLOGSTRING2("CAlfBridge::IsLayoutSwitchReady done %d (groups %d)", visualTreeReady, coverageModifiedGroupCount);
  6867             return ETrue;
  7010     iTempRegion2.Clear();
  6868             }
  7011     
  6869         }
  7012     // Heuristic: Check that visual drawing covers the whole screen.
  6870     return fullscreenCovered;
  7013     if ( visualTreeReady && ( aDuration <= KAlfCheckFullscreenCoveredByVisualDrawing ) )
       
  7014         {
       
  7015         if ( !IsRectCoveredByRegion( fullscreen, iTempRegion ) )
       
  7016             {
       
  7017             __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - screen not covered");
       
  7018             visualTreeReady = EFalse;
       
  7019             }
       
  7020         }
       
  7021     
       
  7022     return visualTreeReady;
       
  7023     }
       
  7024 
       
  7025 
       
  7026 // ---------------------------------------------------------------------------
       
  7027 // Checks if rect is inside fullscreen area.
       
  7028 // ---------------------------------------------------------------------------
       
  7029 // 
       
  7030 static TBool CheckVisualRect(const TRect aRect, const TRect& aFullScreen)
       
  7031     {
       
  7032     if (aRect.IsEmpty())
       
  7033         {
       
  7034         return EFalse;
       
  7035         }
       
  7036          
       
  7037     if (!aFullScreen.Contains(aRect.iTl))
       
  7038         {
       
  7039         return EFalse;
       
  7040         }
       
  7041 
       
  7042     TPoint br = aRect.iBr;
       
  7043     br.iX--;
       
  7044     br.iY--;
       
  7045     if (!aFullScreen.Contains(br))
       
  7046         {
       
  7047         return EFalse;
       
  7048         }
       
  7049     
       
  7050     return ETrue;
       
  7051     }
       
  7052 
       
  7053 
       
  7054 // ---------------------------------------------------------------------------
       
  7055 // ---------------------------------------------------------------------------
       
  7056 // 
       
  7057 TBool CAlfBridge::IsLayoutSwitchReadyRecursive(
       
  7058         CHuiLayout* aLayout,
       
  7059         CHuiControlGroup& aControlGroup,
       
  7060         CHuiControl& aControl,
       
  7061         TBool& aFullscreenCovered, 
       
  7062         const TRect& aFullscreen,
       
  7063         CAlfScreen* aScreen,
       
  7064         TBool aChildCanBeOpaque, 
       
  7065         TBool aOnlyForEmbeddedAlfApp,
       
  7066         TInt aOrientation,
       
  7067         TInt aDuration,
       
  7068         TBool& aCoverageRegionModified )
       
  7069     {
       
  7070     TBool visualTreeReady = ETrue;
       
  7071     TRect visualDisplayRect;
       
  7072     TBool visualRectIsCovered = EFalse;
       
  7073     TBool visualIsOpaque = EFalse;
       
  7074     TBool visualIsActive = EFalse;
       
  7075     CHuiCanvasVisual* canvasVisual = NULL;
       
  7076 
       
  7077     for (TInt i = aLayout->Count() - 1; i >= 0; i--)
       
  7078         {
       
  7079         visualDisplayRect = TRect(0,0,0,0);
       
  7080         visualRectIsCovered = EFalse;
       
  7081         visualIsOpaque = EFalse;
       
  7082         visualIsActive = EFalse;
       
  7083         
       
  7084         canvasVisual = (CHuiCanvasVisual*)(&aLayout->Visual(i));
       
  7085 
       
  7086         // Distraction windows are completely ignored.
       
  7087         TBool distractionWindow = (canvasVisual->CanvasFlags() & EHuiCanvasFlagDistractionWindow);
       
  7088         if ( distractionWindow )
       
  7089             {
       
  7090             continue;
       
  7091             }
       
  7092 
       
  7093         visualIsOpaque = aChildCanBeOpaque && IsVisualOpaque(*canvasVisual);
       
  7094         TBool visualIsVisible = (canvasVisual->iOpacity.Now() > 0.01f);       
       
  7095         
       
  7096         if (canvasVisual->Count() && visualIsVisible)
       
  7097             {
       
  7098             TBool ready = IsLayoutSwitchReadyRecursive( canvasVisual, aControlGroup, aControl, 
       
  7099                 aFullscreenCovered, aFullscreen, aScreen, 
       
  7100                 visualIsOpaque, EFalse, aOrientation, 
       
  7101                 aDuration, aCoverageRegionModified );
       
  7102                 
       
  7103             if (!ready)
       
  7104                 {
       
  7105                 visualTreeReady = EFalse;
       
  7106                 break;
       
  7107                 }
       
  7108             }
       
  7109 
       
  7110         // Calculate visual display rect
       
  7111         visualDisplayRect = canvasVisual->DisplayRect();
       
  7112     
       
  7113         ClipVisualRect(visualDisplayRect, aLayout->DisplayRect());
       
  7114         ClipVisualRect(visualDisplayRect, aFullscreen);
       
  7115         
       
  7116         // Check if covered.
       
  7117         if (aFullscreenCovered)
       
  7118             {
       
  7119             visualRectIsCovered = ETrue;    
       
  7120             }
       
  7121         else
       
  7122             {            
       
  7123             // Check if this visual is covered by other opaque visuals which rects are in "covered" region
       
  7124             // it should not check for alf event window group, when we have embedded alf application,
       
  7125             // because we have assumed that alf app will have full screen covered
       
  7126             if(!aOnlyForEmbeddedAlfApp)
       
  7127                 {
       
  7128                 visualRectIsCovered = IsRectCoveredByRegion(visualDisplayRect, iTempRegion);
       
  7129                 }                                
       
  7130             }
       
  7131 
       
  7132         // Heuristic: Check that visual display rect is ok (not empty, inside screen)
       
  7133         if ( aDuration <= KAlfCheckVisualDisplayRect && !visualRectIsCovered && 
       
  7134              !CheckVisualRect(visualDisplayRect, aFullscreen) )
       
  7135             {
       
  7136             __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - display rect not ok");
       
  7137             visualTreeReady = EFalse;
       
  7138             break;
       
  7139             }
       
  7140     
       
  7141 	    // Determine if visual is active from coverage point of view.
       
  7142         visualIsActive = EFalse;
       
  7143         if (visualRectIsCovered)
       
  7144             {                                        
       
  7145             if (!(canvasVisual->Flags() & EHuiVisualFlagAlwaysDraw)) 
       
  7146                 {
       
  7147                 visualIsActive = EFalse;                
       
  7148                 }
       
  7149             else
       
  7150                 { 
       
  7151                 visualIsActive = ETrue;
       
  7152                 }                
       
  7153             }
       
  7154         else
       
  7155             {
       
  7156 			visualIsActive = ETrue;
       
  7157             }
       
  7158         
       
  7159         // Sprites and effects as we consider them always as transparent and also
       
  7160         // if controlgroup is transformed somehow    
       
  7161         if (aControl.Role() == EHuiFullScreenEffectContainer || 
       
  7162             aControl.Role() == EHuiWindowFloatingSpriteContainer ||
       
  7163             aControlGroup.IsTransformed())
       
  7164             {
       
  7165             visualIsOpaque = EFalse;    
       
  7166             }
       
  7167            
       
  7168         // Check that command buffers are ok.
       
  7169         if ( visualIsActive )
       
  7170             {
       
  7171             TRect displayRect = visualDisplayRect;
       
  7172             visualDisplayRect = canvasVisual->CommandBufferCoverage(aOrientation);
       
  7173 
       
  7174             // Heuristic: Check that visual drawing isn't completely empty.
       
  7175             if ( aDuration <= KAlfCheckVisualDrawingNotEmpty && !visualRectIsCovered &&
       
  7176                  visualIsVisible && visualDisplayRect.IsEmpty() )
       
  7177                 {
       
  7178                 __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - no drawing");
       
  7179                 visualTreeReady = EFalse;
       
  7180                 break;
       
  7181                 }
       
  7182             
       
  7183             // Heuristic: Check that visual drawing isn't outside the screen.
       
  7184             if ( aDuration <= KAlfCheckVisualDrawRect && !visualRectIsCovered &&
       
  7185                  visualIsVisible && !CheckVisualRect(visualDisplayRect, aFullscreen) )
       
  7186                 {
       
  7187                 __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - bad drawing");
       
  7188                 visualTreeReady = EFalse;
       
  7189                 break;
       
  7190                 }
       
  7191 
       
  7192             // Heuristic: Check that visual drawing is complete.
       
  7193             if ( aDuration <= KAlfCheckVisualDrawingComplete && !visualRectIsCovered &&
       
  7194                  visualIsVisible && displayRect != visualDisplayRect )
       
  7195                 {
       
  7196                 __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - incomplete drawing");
       
  7197                 visualTreeReady = EFalse;
       
  7198                 break;
       
  7199                 }
       
  7200 
       
  7201             // Make sure we clip visual rect to visible screen area
       
  7202             ClipVisualRect(visualDisplayRect, aFullscreen);
       
  7203             
       
  7204             // Heuristic: Union of opaque visual drawing regions should cover the whole screen.
       
  7205             // Note - coverage is checked at the end of IsLayoutSwitchReady.
       
  7206             if (visualIsOpaque && visualIsVisible && !visualRectIsCovered)
       
  7207                 {
       
  7208                 iTempRegion2.AddRect( visualDisplayRect );
       
  7209                 iTempRegion2.Tidy();
       
  7210                 }
       
  7211             }
       
  7212 			
       
  7213         if (visualIsActive && visualIsOpaque && !visualRectIsCovered)
       
  7214             { 
       
  7215             // New visibility system takes only window shape into account.
       
  7216             if ( canvasVisual->CanvasFlags() & EHuiCanvasFlagIncludeToVisibilityCalculation )
       
  7217                 {
       
  7218                 if ( !canvasVisual->HasCustomShape() )
       
  7219                     {
       
  7220                     aCoverageRegionModified = ETrue;
       
  7221                     
       
  7222                     TRect displayRect(canvasVisual->DisplayRect());
       
  7223                     ClipVisualRect(displayRect, aLayout->DisplayRect());
       
  7224                     ClipVisualRect(displayRect, aFullscreen);
       
  7225 
       
  7226                     iTempRegion.AddRect(displayRect);
       
  7227                     iTempRegion.Tidy();
       
  7228                     }
       
  7229                 else
       
  7230                     {
       
  7231                     aCoverageRegionModified = ETrue;
       
  7232                     
       
  7233                     TRect displayRect = canvasVisual->DisplayRect();
       
  7234                     const TRegion& region = canvasVisual->ShapeRegion();
       
  7235                     TPoint delta = -canvasVisual->ShapeOrigin() + displayRect.iTl;
       
  7236                 
       
  7237                     for (TInt i = 0; i < region.Count(); ++i)
       
  7238                         {
       
  7239                         TRect coveredRect(region[i]);
       
  7240                         coveredRect.Move(delta);
       
  7241                         ClipVisualRect(coveredRect, aFullscreen);
       
  7242 
       
  7243                         iTempRegion.AddRect(coveredRect);
       
  7244                         }
       
  7245                     iTempRegion.Tidy();
       
  7246                     }
       
  7247                 }
       
  7248             }        
       
  7249         } // for loop end : children checking loop
       
  7250      
       
  7251     return visualTreeReady;
  6871     }
  7252     }
  6872 
  7253 
  6873 TBool CAlfBridge::IsFullScreenDrawnRecursiveAlfContent(CHuiVisual* aVisual, TRect& aFullScreen)
  7254 TBool CAlfBridge::IsFullScreenDrawnRecursiveAlfContent(CHuiVisual* aVisual, TRect& aFullScreen)
  6874     {
  7255     {
  6875     if(aVisual)
  7256     if(aVisual)
  7067     iLayoutSwitchInProgress = EFalse;
  7448     iLayoutSwitchInProgress = EFalse;
  7068     if ( iHuiEnv )
  7449     if ( iHuiEnv )
  7069         {
  7450         {
  7070         iIdForLayoutSwitchFrameSync = iIdForEAlfDSSynchronizeOp - KPreventingCollisionOfIdsInSynchDrawRequests;
  7451         iIdForLayoutSwitchFrameSync = iIdForEAlfDSSynchronizeOp - KPreventingCollisionOfIdsInSynchDrawRequests;
  7071         iHuiEnv->Synchronize( iIdForLayoutSwitchFrameSync, this );
  7452         iHuiEnv->Synchronize( iIdForLayoutSwitchFrameSync, this );
       
  7453         AsynchRefresh(); // In SW mode, device is in manual refresh mode - enforce refresh in order to get synchronize done.
  7072         }
  7454         }
  7073     }
  7455     }
  7074 
  7456 
  7075 TAlfBridgeDrawerWrapper::TAlfBridgeDrawerWrapper(CAlfBridge& aBridge)
  7457 TAlfBridgeDrawerWrapper::TAlfBridgeDrawerWrapper(CAlfBridge& aBridge)
  7076     : iBridge( aBridge )
  7458     : iBridge( aBridge )