uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
branchRCL_3
changeset 20 31fccae4f8a7
parent 19 e5af45d51884
equal deleted inserted replaced
19:e5af45d51884 20:31fccae4f8a7
    82 
    82 
    83 #ifdef SYMBIAN_BUILD_GCE
    83 #ifdef SYMBIAN_BUILD_GCE
    84 #include <bautils.h>
    84 #include <bautils.h>
    85 #endif
    85 #endif
    86 
    86 
       
    87 #ifdef ALF_MEMORYLOGGING
       
    88 #include <hal.h>
       
    89 #endif
       
    90 
       
    91 #include <graphics/fbsrasterizer.h>
       
    92 #include <graphics/fbsrasterizerclearcache.h>
       
    93 
    87 const TInt KVisualTransformationStepRotate    = 0;
    94 const TInt KVisualTransformationStepRotate    = 0;
    88 
    95 
    89 const TReal32 KAlfVisualDefaultOpacity = 1.0f;
    96 const TReal32 KAlfVisualDefaultOpacity = 1.0f;
    90 //const TReal32 KAlfVisualDefaultOpacity = 0.5f;
    97 //const TReal32 KAlfVisualDefaultOpacity = 0.5f;
    91 const TInt KEffectCleanupDelayInMs = 10;
    98 const TInt KEffectCleanupDelayInMs = 10;
   130 // Duration to wait if coverage is modified by multiple control groups.
   137 // 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
   138 // This may indicate that topmost application hasn't yet had time to update
   132 // its layout properly.
   139 // its layout properly.
   133 const TInt KAlfCheckCoverageFromMultipleGroups = 20;
   140 const TInt KAlfCheckCoverageFromMultipleGroups = 20;
   134 
   141 
       
   142 // Duration to wait if visual is not ready for current orientation.
       
   143 // 1 unit = 50ms.
       
   144 const TInt KAlfCheckVisualIsNotReady = 15;
   135 
   145 
   136 NONSHARABLE_CLASS( TAlfBridgeDrawerWrapper ) : public MAlfDrawerScreenInterface
   146 NONSHARABLE_CLASS( TAlfBridgeDrawerWrapper ) : public MAlfDrawerScreenInterface
   137     {
   147     {
   138 public:
   148 public:
   139     TAlfBridgeDrawerWrapper(CAlfBridge& aBridge);
   149     TAlfBridgeDrawerWrapper(CAlfBridge& aBridge);
   194 	    }
   204 	    }
   195 	iAlfRegisteredEffects.Close();
   205 	iAlfRegisteredEffects.Close();
   196     delete iEffectEndTimer;
   206     delete iEffectEndTimer;
   197     iDeadControlGroups.Close();
   207     iDeadControlGroups.Close();
   198     iEffectWindowGroups.Close();
   208     iEffectWindowGroups.Close();
       
   209     iWindowChainsArray.Close();
   199     delete iFSFxData;
   210     delete iFSFxData;
   200     delete iFSFXDataPart2;
   211     delete iFSFXDataPart2;
   201 
   212 
   202     if (iActivated)
   213     if (iActivated)
   203         {
   214         {
   267 //  a fade that does not belong to the theme may be in use.
   278 //  a fade that does not belong to the theme may be in use.
   268 // ---------------------------------------------------------------------------
   279 // ---------------------------------------------------------------------------
   269 void CAlfBridge::RegisterFadeEffectL()
   280 void CAlfBridge::RegisterFadeEffectL()
   270     {
   281     {
   271     // TODO: RND, REMOVE MMC DRIVE-F, WHEN NOT REQUIRED FOR TESTING
   282     // TODO: RND, REMOVE MMC DRIVE-F, WHEN NOT REQUIRED FOR TESTING
       
   283 #ifdef USE_ALTERNATIVE_EFFECTS_FROM_MMC
   272     _LIT(KDrivePrefence,"FZC"); 
   284     _LIT(KDrivePrefence,"FZC"); 
       
   285 #else
       
   286     _LIT(KDrivePrefence,"Z");
       
   287 #endif
   273     // Force register fade effect. Try first MMC, then ROM.
   288     // Force register fade effect. Try first MMC, then ROM.
   274     CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
   289     CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
   275     RFs& fs = CHuiStatic::FsSession();
   290     RFs& fs = CHuiStatic::FsSession();
   276     if (fs.Handle() && engine)
   291     if (fs.Handle() && engine)
   277         {
   292         {
   458             }
   473             }
   459         }
   474         }
   460     while(node);
   475     while(node);
   461 	return NULL;
   476 	return NULL;
   462     }
   477     }
   463 	
   478 
       
   479 // ---------------------------------------------------------------------------
       
   480 // FindChainedGroup
       
   481 // ---------------------------------------------------------------------------
       
   482 // 
       
   483 TUint32 CAlfBridge::FindChainedGroup(
       
   484     TUint32 aTreeNodeId)
       
   485     {
       
   486     THashMapIter<TUint32, TChainData> iter(iWindowChainsArray);
       
   487     TChainData const * data = 0;
       
   488     do
       
   489         {
       
   490         data = iter.NextValue();
       
   491         if (data && data->iParent == aTreeNodeId)
       
   492             {
       
   493             TUint32 chainedTo = FindChainedGroup(data->iChainee);
       
   494             if (!chainedTo)
       
   495                 {
       
   496                 return data->iChainee; 
       
   497                 }
       
   498             else
       
   499                 {
       
   500                 return chainedTo;
       
   501                 }
       
   502             }
       
   503         }
       
   504     while(data);
       
   505     return NULL;
       
   506     }
       
   507 
       
   508 // ---------------------------------------------------------------------------
       
   509 // IsChainedGroup
       
   510 // ---------------------------------------------------------------------------
       
   511 // 
       
   512 TBool CAlfBridge::IsChainedGroup(
       
   513     TUint32 aTreeNodeId)
       
   514     {
       
   515     THashMapIter<TUint32, TChainData> iter(iWindowChainsArray);
       
   516     TChainData const * data = 0;
       
   517     do
       
   518         {
       
   519         data = iter.NextValue();
       
   520         if (data && data->iChainee == aTreeNodeId)
       
   521             {
       
   522             return ETrue;
       
   523             }
       
   524         }
       
   525     while(data);
       
   526     return EFalse;
       
   527     }
       
   528 
   464 // ---------------------------------------------------------------------------
   529 // ---------------------------------------------------------------------------
   465 // ---------------------------------------------------------------------------
   530 // ---------------------------------------------------------------------------
   466 // 
   531 // 
   467 CHuiControlGroup* CAlfBridge::FindControlGroup(TInt aWindowGroupNodeId, TInt aScreenNumber )
   532 CHuiControlGroup* CAlfBridge::FindControlGroup(TInt aWindowGroupNodeId, TInt aScreenNumber )
   468     {
   533     {
   478 
   543 
   479 // ---------------------------------------------------------------------------
   544 // ---------------------------------------------------------------------------
   480 // FindClientWindowGroupId
   545 // FindClientWindowGroupId
   481 // ---------------------------------------------------------------------------
   546 // ---------------------------------------------------------------------------
   482 //
   547 //
   483 TInt CAlfBridge::FindClientWindowGroupId( TInt aScreenNumber, CHuiControlGroup& aControlGroup  )
   548 TInt CAlfBridge::FindClientWindowGroupId(CHuiControlGroup& aControlGroup  )
   484     {
   549     {
   485     for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++)
   550     for (TInt i=0; i<iAlfScreens[0]->iControlGroups.Count();i++)
   486         {
   551         {
   487         if( iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup == &aControlGroup )
   552         if( iAlfScreens[0]->iControlGroups[i].iControlGroup == &aControlGroup )
   488             {
   553             {
   489             return iAlfScreens[aScreenNumber]->iControlGroups[i].iClientWindowGroupId;
   554             return iAlfScreens[0]->iControlGroups[i].iClientWindowGroupId;
   490             }
   555             }
   491         }
   556         }
   492     return KErrNotFound;
   557     return KErrNotFound;
   493     }
   558     }
   494 
   559 
   495 // ---------------------------------------------------------------------------
   560 // ---------------------------------------------------------------------------
   496 // FindWindowGroupNodeId
   561 // FindWindowGroupNodeId
   497 // ---------------------------------------------------------------------------
   562 // ---------------------------------------------------------------------------
   498 //
   563 //
   499 TInt CAlfBridge::FindWindowGroupNodeId( TInt aScreenNumber, CHuiControlGroup& aControlGroup ) const
   564 TInt CAlfBridge::FindWindowGroupNodeId(CHuiControlGroup& aControlGroup ) const
   500     {
   565     {
   501     for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++)
   566     for (TInt i=0; i<iAlfScreens[0]->iControlGroups.Count();i++)
   502         {
   567         {
   503         if( iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup == &aControlGroup )
   568         if( iAlfScreens[0]->iControlGroups[i].iControlGroup == &aControlGroup )
   504             {
   569             {
   505             return iAlfScreens[aScreenNumber]->iControlGroups[i].iWindowGroupNodeId;
   570             return iAlfScreens[0]->iControlGroups[i].iWindowGroupNodeId;
   506             }
   571             }
   507         }
   572         }
   508     return KErrNotFound;
   573     return KErrNotFound;
   509     }
   574     }
   510 
   575 
   571                 return groupEntry.iControlGroup;
   636                 return groupEntry.iControlGroup;
   572                 }
   637                 }
   573             }
   638             }
   574         }        
   639         }        
   575     return NULL;       
   640     return NULL;       
       
   641     }
       
   642 
       
   643 // ---------------------------------------------------------------------------
       
   644 // FindControlGroupBySecureId
       
   645 // May return multiple groups
       
   646 // ---------------------------------------------------------------------------
       
   647 //
       
   648 void CAlfBridge::FindControlGroupBySecureId( TInt aSecureId, RPointerArray<CHuiControlGroup>& aGroupList)
       
   649     {
       
   650     if ( aSecureId == 0 )
       
   651         {
       
   652         return;
       
   653         }
       
   654     
       
   655     for ( TInt i = 0; i < iAlfScreens[0]->iControlGroups.Count(); i++ )
       
   656         {
       
   657         TAlfControlGroupEntry& groupEntry = iAlfScreens[0]->iControlGroups[i];
       
   658         if ( groupEntry.iSecureId == aSecureId )
       
   659             {
       
   660             aGroupList.Append(groupEntry.iControlGroup);
       
   661             }
       
   662         }        
   576     }
   663     }
   577 
   664 
   578 // ---------------------------------------------------------------------------
   665 // ---------------------------------------------------------------------------
   579 // FindControlGroupByFullScreenToEffect
   666 // FindControlGroupByFullScreenToEffect
   580 // ---------------------------------------------------------------------------
   667 // ---------------------------------------------------------------------------
   792             TInt aWindowGroupNodeId, 
   879             TInt aWindowGroupNodeId, 
   793             TInt aClientWindowGroupId,
   880             TInt aClientWindowGroupId,
   794             TInt aSecureId,
   881             TInt aSecureId,
   795             TInt aScreenNumber )
   882             TInt aScreenNumber )
   796     {
   883     {
   797     CHuiControlGroup* group = FindControlGroup(aWindowGroupNodeId,aScreenNumber);
   884     CHuiControlGroup* group = FindControlGroup(aWindowGroupNodeId);
   798     if (!group)
   885     if (!group)
   799         {
   886         {
   800         group = &iHuiEnv->NewControlGroupL(aWindowGroupNodeId); 
   887         group = &iHuiEnv->NewControlGroupL(aWindowGroupNodeId); 
   801         group->SetSecureId(aSecureId);
   888         group->SetSecureId(aSecureId);
   802         CleanupStack::PushL(group);
   889         CleanupStack::PushL(group);
   828         TAlfControlGroupEntry entry;
   915         TAlfControlGroupEntry entry;
   829         entry.iControlGroup = group;
   916         entry.iControlGroup = group;
   830         entry.iWindowGroupNodeId = aWindowGroupNodeId;
   917         entry.iWindowGroupNodeId = aWindowGroupNodeId;
   831         entry.iClientWindowGroupId = aClientWindowGroupId;  
   918         entry.iClientWindowGroupId = aClientWindowGroupId;  
   832         entry.iSecureId = aSecureId;
   919         entry.iSecureId = aSecureId;
       
   920         // Add to the control group. HandleGfxEventL effect redirection will need this information
       
   921         entry.iScreenNumber = aScreenNumber;
       
   922         iAlfScreens[aScreenNumber]->iControlGroups.Append(entry);
       
   923         CleanupStack::Pop(group);                
       
   924 
   833         // we have received start effect for this group, but the group did not exist in alf universe at the time. hide the group.
   925         // we have received start effect for this group, but the group did not exist in alf universe at the time. hide the group.
   834         if (iFSFxData
   926         if (iFSFxData
   835                 && (iFSFxData->State() == EWaitingWindowGroup || iFSFxData->State() == EEndFullScreenReceivedWaitingWindowGroup)
   927                 && (iFSFxData->State() == EWaitingWindowGroup || iFSFxData->State() == EEndFullScreenReceivedWaitingWindowGroup)
   836                 && iFSFxData->iToSecureId == aSecureId)
   928                 && iFSFxData->iToSecureId == aSecureId)
   837             {
   929             {
   868                 // Effect failed, reset state
   960                 // Effect failed, reset state
   869                 __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - effect failed on layout 0x%x", layout);
   961                 __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - effect failed on layout 0x%x", layout);
   870                 HandleGfxStopEvent( EFalse ); // destroys iFSFxData and iFSFXDataPart2
   962                 HandleGfxStopEvent( EFalse ); // destroys iFSFxData and iFSFXDataPart2
   871                 }
   963                 }
   872             }     
   964             }     
   873         entry.iScreenNumber = aScreenNumber;
       
   874 //        entry.iRole = EHuiWindowGroupContainer;
       
   875 
       
   876         iAlfScreens[aScreenNumber]->iControlGroups.Append(entry);
       
   877         CleanupStack::Pop(group);                
       
   878 
   965 
   879         if (iAlfScreens[aScreenNumber]->iDisplay)
   966         if (iAlfScreens[aScreenNumber]->iDisplay)
   880             ShowControlGroupL(iAlfScreens[aScreenNumber]->iDisplay->Roster(), *group, KHuiRosterShowAtTop, aScreenNumber); 
   967             ShowControlGroupL(iAlfScreens[aScreenNumber]->iDisplay->Roster(), *group, KHuiRosterShowAtTop, aScreenNumber); 
   881         
   968         
   882         AMT_INC_COUNTER( iTotalControlGroupCount );
   969         AMT_INC_COUNTER( iTotalControlGroupCount );
  1087                        TBool lSyncDone(EFalse);
  1174                        TBool lSyncDone(EFalse);
  1088                        if (lSyncAlfAppAndAlfEventGroup && i< (aRoster.Count()-1) )
  1175                        if (lSyncAlfAppAndAlfEventGroup && i< (aRoster.Count()-1) )
  1089                        {
  1176                        {
  1090                        lSyncDone = ETrue;
  1177                        lSyncDone = ETrue;
  1091                        CHuiControlGroup &lGroup = aRoster.ControlGroup(i+1);
  1178                        CHuiControlGroup &lGroup = aRoster.ControlGroup(i+1);
  1092                        TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
  1179                        TInt clientWindowGroupId = FindClientWindowGroupId(lGroup );
  1093                        iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
  1180                        iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
  1094                        }
  1181                        }
  1095                        if(!lSyncDone && aGroup.iAlfApp && aRoster.ControlGroup(i-1).ResourceId() != iAlfWindowGroupNodeId )
  1182                        if(!lSyncDone && aGroup.iAlfApp && aRoster.ControlGroup(i-1).ResourceId() != iAlfWindowGroupNodeId )
  1096                            {
  1183                            {
  1097                           
  1184                           
  1098                           CHuiControlGroup &lGroup = aRoster.ControlGroup(i);
  1185                           CHuiControlGroup &lGroup = aRoster.ControlGroup(i);
  1099                           TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
  1186                           TInt clientWindowGroupId = FindClientWindowGroupId(lGroup );
  1100                           iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
  1187                           iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
  1101                            }
  1188                            }
  1102                        break;
  1189                        break;
  1103                        }
  1190                        }
  1104 
  1191 
  1143             if ( iAlfScreens[0]->iControlGroups[i].iSecureId == secureId && 
  1230             if ( iAlfScreens[0]->iControlGroups[i].iSecureId == secureId && 
  1144                  iAlfScreens[0]->iControlGroups[i].iClientWindowGroupId != CHuiStatic::RootWin(0)->Identifier())
  1231                  iAlfScreens[0]->iControlGroups[i].iClientWindowGroupId != CHuiStatic::RootWin(0)->Identifier())
  1145                 {
  1232                 {
  1146                 iAlfWindowGroupNodeId = iAlfScreens[0]->iControlGroups[i].iWindowGroupNodeId;
  1233                 iAlfWindowGroupNodeId = iAlfScreens[0]->iControlGroups[i].iWindowGroupNodeId;
  1147                 
  1234                 
  1148                 CHuiControlGroup* controlGroup = FindControlGroup(iAlfWindowGroupNodeId, 0);
  1235                 CHuiControlGroup* controlGroup = FindControlGroup(iAlfWindowGroupNodeId);
  1149                 CHuiControl& control = controlGroup->Control(0);
  1236                 CHuiControl& control = controlGroup->Control(0);
  1150                 CHuiVisual* layout = &control.Visual(0);
  1237                 CHuiVisual* layout = &control.Visual(0);
  1151                 iAlfScreens[0]->iDisplay->Roster().SetAlfEventWindow(layout);
  1238                 iAlfScreens[0]->iDisplay->Roster().SetAlfEventWindow(layout);
  1152                 return;
  1239                 return;
  1153                 }
  1240                 }
  1277                 {
  1364                 {
  1278                 TBuf<8> numBuf;
  1365                 TBuf<8> numBuf;
  1279                 numBuf.AppendNum(fps, TRealFormat(5,1));
  1366                 numBuf.AppendNum(fps, TRealFormat(5,1));
  1280                 TRAP_IGNORE(
  1367                 TRAP_IGNORE(
  1281                         {
  1368                         {
  1282                         iAlfScreens[screenNumber]->iFPSText->SetTextL( numBuf );
  1369                         iAlfScreens[0]->iFPSText->SetTextL( numBuf );
  1283                         })
  1370                         })
  1284                 }
  1371                 }
  1285             }
  1372             }
  1286 #endif
  1373 #endif
  1287         if (!iActivated)            
  1374         if (!iActivated)            
  1288             {
  1375             {
  1289             TInt err = iBridgerClient.Connect();
  1376             TInt err = iBridgerClient.Connect();
  1290             iActivated = (err == KErrNone);            
  1377             iActivated = (err == KErrNone);            
  1291             }
  1378             }
  1292                     
  1379                     
  1293         if (iAlfScreens[screenNumber]->IsVisualTreeVisibilityChanged())
  1380         if (iAlfScreens[0]->IsVisualTreeVisibilityChanged())
  1294             {
  1381             {
  1295             HandleVisualVisibility( screenNumber );    
  1382             HandleVisualVisibility( screenNumber );    
  1296             iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(EFalse);
  1383             iAlfScreens[0]->SetVisualTreeVisibilityChanged(EFalse);
  1297             }
  1384             }
  1298         }
  1385         }
  1299     }
  1386     }
  1300 
  1387 
  1301 // ---------------------------------------------------------------------------
  1388 // ---------------------------------------------------------------------------
  1354         }
  1441         }
  1355 
  1442 
  1356     transparent |= (!((aVisual.Flags() & EHuiVisualFlagOpaqueHint) == EHuiVisualFlagOpaqueHint));
  1443     transparent |= (!((aVisual.Flags() & EHuiVisualFlagOpaqueHint) == EHuiVisualFlagOpaqueHint));
  1357     transparent |= (aVisual.iOpacity.Now() < KAlfVisualDefaultOpacity);
  1444     transparent |= (aVisual.iOpacity.Now() < KAlfVisualDefaultOpacity);
  1358     transparent |= (aVisual.iOpacity.Target() < KAlfVisualDefaultOpacity);
  1445     transparent |= (aVisual.iOpacity.Target() < KAlfVisualDefaultOpacity);
  1359     
  1446     if(aVisual.Effect())
       
  1447         {
       
  1448         transparent |= (aVisual.iEffectOpacity < KAlfVisualDefaultOpacity);
       
  1449         }
  1360     return  !transparent;            
  1450     return  !transparent;            
  1361     }
  1451     }
  1362 
  1452 
  1363 // ---------------------------------------------------------------------------
  1453 // ---------------------------------------------------------------------------
  1364 // ---------------------------------------------------------------------------
  1454 // ---------------------------------------------------------------------------
  1485         }    
  1575         }    
  1486     
  1576     
  1487 	
  1577 	
  1488 	TBool alfWindowGroupFoundVisible = EFalse;
  1578 	TBool alfWindowGroupFoundVisible = EFalse;
  1489 	TBool alfClientWindowGroupVisible = EFalse;
  1579 	TBool alfClientWindowGroupVisible = EFalse;
       
  1580 	TBool firstAlfControlGroupFound = EFalse;
  1490 	
  1581 	
  1491     AMT_SET_VALUE( iVisibleVisualCount, 0 );
  1582     AMT_SET_VALUE( iVisibleVisualCount, 0 );
  1492 	
  1583 	
  1493     // skip the topmost (effect) layer, start from floating sprite group
  1584     // skip the topmost (effect) layer, start from floating sprite group
  1494     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
  1585     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
  1537                 {
  1628                 {
  1538                 activeSession = iAppUi->ActiveSession();
  1629                 activeSession = iAppUi->ActiveSession();
  1539                 }
  1630                 }
  1540             // !fullscreenCovered need to be checked because for fullscreen
  1631             // !fullscreenCovered need to be checked because for fullscreen
  1541             // alf applications alf event window group could be on top of alf client windowgroup
  1632             // alf applications alf event window group could be on top of alf client windowgroup
  1542             if ( (alfClientWindowGroupVisible || !fullscreenCovered)  && activeSession)
  1633             if ( (!firstAlfControlGroupFound || !fullscreenCovered)  && activeSession)
  1543                 {
  1634                 {
  1544                 // clear inactive flag if client has not made this controlgroup hidden
  1635                 // clear inactive flag if client has not made this controlgroup hidden
  1545                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
  1636                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
  1546                     {
  1637                     {
  1547                     if(iAppUi)
  1638                     if(iAppUi)
  1558                             hostContainer->ClearFlags(EHuiVisualFlagInactive);
  1649                             hostContainer->ClearFlags(EHuiVisualFlagInactive);
  1559                             // just add the rect to covered region because alf draws solid background
  1650                             // just add the rect to covered region because alf draws solid background
  1560                             iTempRegion.AddRect(fullscreen);
  1651                             iTempRegion.AddRect(fullscreen);
  1561                             iTempRegion.Tidy();
  1652                             iTempRegion.Tidy();
  1562                             fullscreenCovered = ETrue;
  1653                             fullscreenCovered = ETrue;
  1563                             alfClientWindowGroupVisible = EFalse;  // change flag so that we don't go in this branch again
  1654                             firstAlfControlGroupFound = ETrue;  // change flag so that we don't go in this branch again
       
  1655                             }
       
  1656                         else
       
  1657                             {
       
  1658                             hostContainer->SetFlags(EHuiVisualFlagInactive);
  1564                             }
  1659                             }
  1565                         }
  1660                         }
  1566                     }
  1661                     }
  1567                 else // else put as inactive
  1662                 else // else put as inactive
  1568                     {
  1663                     {
  1628                HandleLayoutVisualVisibility( layout, controlgroup, control, 
  1723                HandleLayoutVisualVisibility( layout, controlgroup, control, 
  1629                    fullscreenCovered, fullscreen, screen, 
  1724                    fullscreenCovered, fullscreen, screen, 
  1630                    subTreeCovered, hasLayers, IsVisualOpaque(*layout) );
  1725                    subTreeCovered, hasLayers, IsVisualOpaque(*layout) );
  1631             }
  1726             }
  1632         
  1727         
  1633 
  1728         if ( hasLayers && iActivated )
  1634         TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
  1729             {
  1635 
  1730             HandleLayerVisibility( layout, controlgroup, control, hasActiveVisualsInVisualTree );
       
  1731             }
       
  1732         
       
  1733         TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
       
  1734         
       
  1735         // we need to set /clear inactive flags before we evaluate the fade effect,
       
  1736         // otherwise the fade effect will be removed without a reason in
       
  1737         // some use cases
       
  1738         if (isLayoutActive && (fullscreenCovered || (!hasActiveVisualsInVisualTree && !IsOpaqueEffect(layout->Effect()))))
       
  1739             {
       
  1740             // don't inactivate alf event wg if alf client is visible
       
  1741             if( !( alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId)) )
       
  1742                 // Setting also the root visual (layout) as inactive, if it had none
       
  1743                 // active children. This is because otherwise the Inactive checks won't
       
  1744                 // work correctly within RosterImpl ScanDirty & ClearChanged phases.
       
  1745                 // If root visual is having an opaque effect, it must remain active
       
  1746                 {
       
  1747                 layout->SetFlag(EHuiVisualFlagInactive);
       
  1748                 }
       
  1749             }
       
  1750         else if(!isLayoutActive && !fullscreenCovered && (hasActiveVisualsInVisualTree || IsOpaqueEffect(layout->Effect())) ||
       
  1751                 (alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId)) )
       
  1752             {
       
  1753             layout->ClearFlag(EHuiVisualFlagInactive);
       
  1754             layout->SetPos(fullscreen.iTl);
       
  1755             layout->SetSize(fullscreen.Size());
       
  1756             
       
  1757 		    // New visible window group may have received effect just before appearing to the screen.
       
  1758 			// start the effect if this is the case.
       
  1759             if(iFSFxData && iFSFxData->iToSecureId == controlgroup.SecureId() )
       
  1760                 {
       
  1761                 TInt windowGroupId = FindClientWindowGroupId(controlgroup);
       
  1762 
       
  1763                 if (iFSFxData->iToWg == windowGroupId && iFSFxData->State() == EWaitEndFullScreen &&
       
  1764                         iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::ESecondPartActive)
       
  1765                     {
       
  1766                     GfxTriggerEffectWhenFullScreenDrawn(&controlgroup);
       
  1767                     }
       
  1768                 }
       
  1769             }
       
  1770 
       
  1771         // If root visuals effect is marked as opaque, then add whole screen area as covered.
       
  1772         if (!fullscreenCovered)
       
  1773             {
       
  1774             fullscreenCovered = IsOpaqueEffect(layout->Effect());
       
  1775             }    
       
  1776 
       
  1777         
  1636         // if native alf app is found visible and the client it self is not covering whole screen, we can assume that alf content
  1778         // if native alf app is found visible and the client it self is not covering whole screen, we can assume that alf content
  1637         // fills the rest. 
  1779         // fills the rest. 
  1638         // this is for embedded native alf application cases. Otherwise chained window groups tend to
  1780         // this is for embedded native alf application cases. Otherwise chained window groups tend to
  1639         // flicker from time to time
  1781         // flicker from time to time
  1640         // also if alfcontent is not hided below avkon content the fading effect would reveal alfconent
  1782         // also if alfcontent is not hided below avkon content the fading effect would reveal alfconent
  1647                 iTempRegion.Tidy();
  1789                 iTempRegion.Tidy();
  1648                 fullscreenCovered = ETrue;
  1790                 fullscreenCovered = ETrue;
  1649                 alfClientWindowGroupVisible = ETrue;
  1791                 alfClientWindowGroupVisible = ETrue;
  1650                 }
  1792                 }
  1651             }
  1793             }
  1652         
       
  1653         // If root visuals effect is marked as opaque, then add whole screen area as covered.
       
  1654         if (!fullscreenCovered)
       
  1655             {
       
  1656             fullscreenCovered = IsOpaqueEffect(layout->Effect());
       
  1657             }                    
       
  1658         
       
  1659         if ( hasLayers && iActivated )
       
  1660             {
       
  1661             HandleLayerVisibility( layout, controlgroup, control, hasActiveVisualsInVisualTree );
       
  1662             }
       
  1663         
       
  1664         TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
       
  1665         
       
  1666         // we need to set /clear inactive flags before we evaluate the fade effect,
       
  1667         // otherwise the fade effect will be removed without a reason in
       
  1668         // some use cases
       
  1669         if (isLayoutActive && !hasActiveVisualsInVisualTree && !IsOpaqueEffect(layout->Effect()))
       
  1670             {
       
  1671             // Setting also the root visual (layout) as inactive, if it had none
       
  1672 			// active children. This is because otherwise the Inactive checks won't
       
  1673 			// work correctly within RosterImpl ScanDirty & ClearChanged phases.
       
  1674 			// If root visual is having an opaque effect, it must remain active
       
  1675             layout->SetFlag(EHuiVisualFlagInactive);
       
  1676             }
       
  1677         else if(!isLayoutActive && (hasActiveVisualsInVisualTree || IsOpaqueEffect(layout->Effect())))
       
  1678             {
       
  1679             layout->ClearFlag(EHuiVisualFlagInactive);
       
  1680             layout->SetPos(fullscreen.iTl);
       
  1681             layout->SetSize(fullscreen.Size());
       
  1682             }
       
  1683  
       
  1684             
  1794             
       
  1795         TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
       
  1796 
  1685 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1797 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1686 		// flagged as containing fade effect, then run the setup as well so that effects which
  1798 		// flagged as containing fade effect, then run the setup as well so that effects which
  1687 		// are no more needed get removed.
  1799 		// are no more needed get removed.
  1688         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1800         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1689             {
  1801             {
  2402             case EAlfDSIncludeToVisibilityCalculation:
  2514             case EAlfDSIncludeToVisibilityCalculation:
  2403                 {
  2515                 {
  2404                 HandleIncludeToVisibilityCalculationL( data );
  2516                 HandleIncludeToVisibilityCalculationL( data );
  2405                 break;
  2517                 break;
  2406                 }
  2518                 }
       
  2519             case EAlfDSSetScreenDeviceValid:
       
  2520                 {
       
  2521                 HandleSetScreenDeviceValidL( data );
       
  2522                 break;
       
  2523                 }
       
  2524                 
  2407             case EAlfDSSetWindowArea:
  2525             case EAlfDSSetWindowArea:
  2408                 {
  2526                 {
  2409                 HandleSetWindowAreaL( data );
  2527                 HandleSetWindowAreaL( data );
  2410                 break;
  2528                 break;
  2411                 }
  2529                 }
  2450 //                HandleGetNativeWindowDataL( data );
  2568 //                HandleGetNativeWindowDataL( data );
  2451                 break;
  2569                 break;
  2452                 }
  2570                 }
  2453             case EAlfDSGroupChained:
  2571             case EAlfDSGroupChained:
  2454             	{
  2572             	{
  2455             	__ALFLOGSTRING("CAlfBridge::DoDispatchL, EAlfDSGroupChained");    
  2573             	HandleGroupChained(data);
  2456             	// TODO, link groups 
       
  2457             	break;
  2574             	break;
  2458             	}
  2575             	}
  2459             case EAlfDSGroupChainBroken:
  2576             case EAlfDSGroupChainBroken:
  2460             	{
  2577             	{
  2461             	__ALFLOGSTRING("CAlfBridge::DoDispatchL, EAlfDSGroupChainBroken");    
  2578             	HandleGroupChainBroken(data);
  2462             	// TODO, break link
       
  2463             	break;
  2579             	break;
  2464             	}
  2580             	}
  2465             case EAlfDSMoveWindowToNewGroup:
  2581             case EAlfDSMoveWindowToNewGroup:
  2466             	{
  2582             	{
  2467             	HandleMoveWindowToNewGroupL( data );
  2583             	HandleMoveWindowToNewGroupL( data );
  2666 void CAlfBridge::HandleNewWindowL( TAlfBridgerData& aData )
  2782 void CAlfBridge::HandleNewWindowL( TAlfBridgerData& aData )
  2667 	{
  2783 	{
  2668 	TInt windowGroupNodeId = aData.iInt1;
  2784 	TInt windowGroupNodeId = aData.iInt1;
  2669 	TInt windowNodeId = aData.iInt2;
  2785 	TInt windowNodeId = aData.iInt2;
  2670 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2786 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2671 	TInt screenNumber = windowAttributes->iScreenNumber; 
       
  2672 	__ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: new window %d!",windowNodeId);    
  2787 	__ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: new window %d!",windowNodeId);    
  2673 	                
  2788 	                
  2674 	switch (windowAttributes->iWindowNodeType)
  2789 	switch (windowAttributes->iWindowNodeType)
  2675 		{
  2790 		{
  2676 		case EAlfWinTreeNodeGroup:
  2791 		case EAlfWinTreeNodeGroup:
  2677 			{
  2792 			{
  2678 			CHuiControlGroup& controlGroup = CreateControlGroupL(
  2793 			CHuiControlGroup& controlGroup = CreateControlGroupL(
  2679 			        windowGroupNodeId, 
  2794 			        windowGroupNodeId, 
  2680 			        windowAttributes->iClientHandle, 
  2795 			        windowAttributes->iClientHandle, 
  2681 			        windowAttributes->iSecureId,
  2796 			        windowAttributes->iSecureId,
  2682 			        screenNumber);                            
  2797 			        0 // Only one screen for avkon content supported 
       
  2798 					);                            
  2683 
  2799 
  2684 			// We just received notification for our own window group creation, store its node id for doing
  2800 			// We just received notification for our own window group creation, store its node id for doing
  2685 			// faster lookups later...
  2801 			// faster lookups later...
  2686 			if (windowAttributes->iClientHandle == iAlfWindowGroupId)
  2802 			if (windowAttributes->iClientHandle == iAlfWindowGroupId)
  2687 				{
  2803 				{
  2693 		case EAlfWinTreeNodeRoot: // TODO: Root window receives drawing commands too
  2809 		case EAlfWinTreeNodeRoot: // TODO: Root window receives drawing commands too
  2694 		case EAlfWinTreeNodeAnim:
  2810 		case EAlfWinTreeNodeAnim:
  2695 		case EAlfWinTreeNodeSprite:
  2811 		case EAlfWinTreeNodeSprite:
  2696 		case EAlfWinTreeNodeTextCursor:
  2812 		case EAlfWinTreeNodeTextCursor:
  2697 			{
  2813 			{
  2698 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  2814 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
  2699 			// Floating sprites only require own group. Normal sprites should behave as normal visuals.
  2815 			// Floating sprites only require own group. Normal sprites should behave as normal visuals.
  2700 			if (!controlGroup && windowAttributes->iWindowNodeType == EAlfWinTreeNodeSprite )
  2816 			if (!controlGroup && windowAttributes->iWindowNodeType == EAlfWinTreeNodeSprite )
  2701 				{                            
  2817 				{                            
  2702 				controlGroup = iAlfScreens[screenNumber]->iFloatingSpriteControlGroup;
  2818 				controlGroup = iAlfScreens[0]->iFloatingSpriteControlGroup;
  2703 				}
  2819 				}
  2704 
  2820 
  2705 			if (controlGroup)
  2821 			if (controlGroup)
  2706 				{
  2822 				{
  2707 				CHuiControl& control = controlGroup->Control(0);
  2823 				CHuiControl& control = controlGroup->Control(0);
  2775 		default:
  2891 		default:
  2776 			{
  2892 			{
  2777 			__ALFLOGSTRING("CAlfBridge::HandleNewWindowL: Unknown window node type received !");
  2893 			__ALFLOGSTRING("CAlfBridge::HandleNewWindowL: Unknown window node type received !");
  2778 			}
  2894 			}
  2779 		}
  2895 		}
  2780 	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  2896 	iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
       
  2897 	
       
  2898 #ifdef ALF_MEMORYLOGGING
       
  2899     ReportMemory();
       
  2900 #endif
  2781 	}
  2901 	}
  2782 
  2902 
  2783 // ---------------------------------------------------------------------------
  2903 // ---------------------------------------------------------------------------
  2784 // HandleDestroyWindow
  2904 // HandleDestroyWindow
  2785 // ---------------------------------------------------------------------------
  2905 // ---------------------------------------------------------------------------
  2858 	{
  2978 	{
  2859 	TInt windowGroupNodeId = aData.iInt1;
  2979 	TInt windowGroupNodeId = aData.iInt1;
  2860 	TInt windowNodeId = aData.iInt2;
  2980 	TInt windowNodeId = aData.iInt2;
  2861 
  2981 
  2862 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2982 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2863 	TInt screenNumber = windowAttributes->iScreenNumber;
  2983 	
  2864 
       
  2865 	switch (windowAttributes->iWindowNodeType)
  2984 	switch (windowAttributes->iWindowNodeType)
  2866 		{
  2985 		{
  2867 		case EAlfWinTreeNodeGroup:
  2986 		case EAlfWinTreeNodeGroup:
  2868 			{
  2987 			{
  2869 			HandleVisualVisibility(0);
  2988 			HandleVisualVisibility(0);
  2870 			DeleteControlGroupL(windowGroupNodeId, screenNumber);                            
  2989 			DeleteControlGroupL(windowGroupNodeId);                            
  2871 			break;    
  2990 			break;    
  2872 			}
  2991 			}
  2873 		case EAlfWinTreeNodeClient:
  2992 		case EAlfWinTreeNodeClient:
  2874 		case EAlfWinTreeNodeRoot:
  2993 		case EAlfWinTreeNodeRoot:
  2875 		case EAlfWinTreeNodeAnim:
  2994 		case EAlfWinTreeNodeAnim:
  2885 
  3004 
  2886 			//just remove the visual
  3005 			//just remove the visual
  2887 			CHuiCanvasVisual* viz;
  3006 			CHuiCanvasVisual* viz;
  2888 			
  3007 			
  2889 			viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  3008 			viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  2890 			CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
  3009 			CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId);
  2891 		     // Sprite is in its own group, and can be deleted normally.
  3010 		     // Sprite is in its own group, and can be deleted normally.
  2892 			if ( !controlGroup  && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite )
  3011 			if ( !controlGroup  && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite )
  2893 			    {
  3012 			    {
  2894 			    __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.");
  3013 			    __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.");
  2895 			    // the group containing this visual has been destroyed. 
  3014 			    // the group containing this visual has been destroyed. 
  2925 			break;
  3044 			break;
  2926 			}
  3045 			}
  2927 		}
  3046 		}
  2928 	// TODO: Toolkit does not support recycling (of visuals),
  3047 	// TODO: Toolkit does not support recycling (of visuals),
  2929 	// this is not in line with Nokia environmental policy...
  3048 	// this is not in line with Nokia environmental policy...
  2930 	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  3049 	iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  2931 	}
  3050 	}
  2932 
  3051 
  2933 // ---------------------------------------------------------------------------
  3052 // ---------------------------------------------------------------------------
  2934 // HandleSetWindowPosL
  3053 // HandleSetWindowPosL
  2935 // ---------------------------------------------------------------------------
  3054 // ---------------------------------------------------------------------------
  2936 // 
  3055 // 
  2937 void CAlfBridge::HandleSetWindowPosL( TAlfBridgerData& aData )
  3056 void CAlfBridge::HandleSetWindowPosL( TAlfBridgerData& aData )
  2938 	{
  3057 	{
  2939 	TInt windowNodeId = aData.iInt2;
  3058 	TInt windowNodeId = aData.iInt2;
  2940 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3059 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2941 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  2942 	// fetch visual
  3060 	// fetch visual
  2943 	CHuiVisual* viz = FindVisual(windowNodeId);
  3061 	CHuiVisual* viz = FindVisual(windowNodeId);
  2944 	if (viz)
  3062 	if (viz)
  2945 		{
  3063 		{
  2946 #ifdef HUI_DEBUG_TRACK_DRAWING
  3064 #ifdef HUI_DEBUG_TRACK_DRAWING
  2948 		    {
  3066 		    {
  2949 		    RDebug::Print(_L("CAlfBridge::HandleSetWindowPosL - Tracked visual"));
  3067 		    RDebug::Print(_L("CAlfBridge::HandleSetWindowPosL - Tracked visual"));
  2950 		    }
  3068 		    }
  2951 #endif
  3069 #endif
  2952 
  3070 
  2953 		viz->SetPos(windowAttributes->iPosition, windowAttributes->iTransitionTime);
  3071         viz->SetPos(windowAttributes->iPosition, windowAttributes->iTransitionTime);
  2954 		  iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  3072         iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  2955 		}
  3073 		}
  2956 	else
  3074 	else
  2957 		{
  3075 		{
  2958 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowPosL, EAlfDSSetWindowPos: Visual not found!");    
  3076 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowPosL, EAlfDSSetWindowPos: Visual not found!");    
  2959 		}   
  3077 		}   
  2971 // 
  3089 // 
  2972 void CAlfBridge::HandleSetWindowSizeL( TAlfBridgerData& aData )
  3090 void CAlfBridge::HandleSetWindowSizeL( TAlfBridgerData& aData )
  2973 	{
  3091 	{
  2974 	TInt windowNodeId = aData.iInt2;
  3092 	TInt windowNodeId = aData.iInt2;
  2975 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3093 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2976 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  2977 	// fetch visual
  3094 	// fetch visual
  2978 	CHuiVisual* viz = FindVisual(windowNodeId);
  3095 	CHuiVisual* viz = FindVisual(windowNodeId);
  2979 	if (viz)
  3096 	if (viz)
  2980 		{
  3097 		{
  2981 #ifdef HUI_DEBUG_TRACK_DRAWING
  3098 #ifdef HUI_DEBUG_TRACK_DRAWING
  2988 		}
  3105 		}
  2989 	else
  3106 	else
  2990 		{
  3107 		{
  2991 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!");    
  3108 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!");    
  2992 		}   
  3109 		}   
  2993     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  3110     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  2994     
  3111     
  2995     AMT_INC_COUNTER_IF(viz, iVisualSizeChangedCount );
  3112     AMT_INC_COUNTER_IF(viz, iVisualSizeChangedCount );
  2996     AMT_SET_VALUE_IF(viz, iLatestVisualExtentRect, TRect( windowAttributes->iPosition, windowAttributes->iSize ) );
  3113     AMT_SET_VALUE_IF(viz, iLatestVisualExtentRect, TRect( windowAttributes->iPosition, windowAttributes->iSize ) );
  2997     
  3114     
  2998     AMT_MAP_SET_VALUE_IF( viz, iSizeMap, windowNodeId, 
  3115     AMT_MAP_SET_VALUE_IF( viz, iSizeMap, windowNodeId, 
  3034 // 
  3151 // 
  3035 void CAlfBridge::HandleSetWindowOpacityL( TAlfBridgerData& aData )
  3152 void CAlfBridge::HandleSetWindowOpacityL( TAlfBridgerData& aData )
  3036 	{
  3153 	{
  3037 	TInt windowNodeId = aData.iInt2;
  3154 	TInt windowNodeId = aData.iInt2;
  3038 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3155 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3039 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  3040 	// fetch visual
  3156 	// fetch visual
  3041 	CHuiVisual* viz = FindVisual(windowNodeId);
  3157 	CHuiVisual* viz = FindVisual(windowNodeId);
  3042 	if (viz)
  3158 	if (viz)
  3043 		{
  3159 		{
  3044 #ifdef HUI_DEBUG_TRACK_DRAWING
  3160 #ifdef HUI_DEBUG_TRACK_DRAWING
  3045         if ( viz->Tracking() )
  3161         if ( viz->Tracking() )
  3046             {
  3162             {
  3047             RDebug::Print(_L("CAlfBridge::HandleSetWindowOpacityL - Tracked visual"));
  3163             RDebug::Print(_L("CAlfBridge::HandleSetWindowOpacityL - Tracked visual"));
  3048             }
  3164             }
  3049 #endif
  3165 #endif
  3050 		viz->iOpacity.Set(windowAttributes->iOpacity, windowAttributes->iTransitionTime);
  3166         viz->iOpacity.Set(windowAttributes->iOpacity, windowAttributes->iTransitionTime);
  3051 		  iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3167         iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3052 		}
  3168         }
  3053 	else
  3169 	else
  3054 		{
  3170 		{
  3055 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowOpacityL, EAlfDSSetWindowOpacity: Visual not found!");                                                
  3171 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowOpacityL, EAlfDSSetWindowOpacity: Visual not found!");                                                
  3056 		}  
  3172 		}  
  3057 	}
  3173 	}
  3062 // 
  3178 // 
  3063 void CAlfBridge::HandleSetTransparencyAlphaChannelL( TAlfBridgerData& aData )
  3179 void CAlfBridge::HandleSetTransparencyAlphaChannelL( TAlfBridgerData& aData )
  3064     {
  3180     {
  3065 	TInt windowNodeId = aData.iInt2;
  3181 	TInt windowNodeId = aData.iInt2;
  3066 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3182 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3067 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  3068 	// fetch visual
  3183 	// fetch visual
  3069 	CHuiVisual* viz = FindVisual(windowNodeId);
  3184 	CHuiVisual* viz = FindVisual(windowNodeId);
  3070 	if (viz)
  3185 	if (viz)
  3071 		{
  3186 		{
  3072 #ifdef HUI_DEBUG_TRACK_DRAWING
  3187 #ifdef HUI_DEBUG_TRACK_DRAWING
  3082 		else
  3197 		else
  3083 		    {
  3198 		    {
  3084 		    viz->SetFlag( EHuiVisualFlagOpaqueHint );
  3199 		    viz->SetFlag( EHuiVisualFlagOpaqueHint );
  3085 		    }
  3200 		    }
  3086 		
  3201 		
  3087 	    iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3202 	    iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3088 		}
  3203 		}
  3089 	else
  3204 	else
  3090 		{
  3205 		{
  3091 		__ALFLOGSTRING("CAlfBridge::HandleSetTransparencyAlphaChannel, EAlfDSSetTransparencyAlphaChannel: Visual not found!");                                                
  3206 		__ALFLOGSTRING("CAlfBridge::HandleSetTransparencyAlphaChannel, EAlfDSSetTransparencyAlphaChannel: Visual not found!");                                                
  3092 		}          
  3207 		}          
  3098 // 
  3213 // 
  3099 void CAlfBridge::HandleIncludeToVisibilityCalculationL( TAlfBridgerData& aData )
  3214 void CAlfBridge::HandleIncludeToVisibilityCalculationL( TAlfBridgerData& aData )
  3100     {
  3215     {
  3101     TInt windowNodeId = aData.iInt2;
  3216     TInt windowNodeId = aData.iInt2;
  3102     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3217     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3103     TInt screenNumber = windowAttributes->iScreenNumber;
       
  3104     // fetch visual
  3218     // fetch visual
  3105     CHuiVisual* viz = FindVisual(windowNodeId);
  3219     CHuiVisual* viz = FindVisual(windowNodeId);
  3106     if (viz)
  3220     if (viz)
  3107         {
  3221         {
  3108 #ifdef HUI_DEBUG_TRACK_DRAWING
  3222 #ifdef HUI_DEBUG_TRACK_DRAWING
  3123                 {
  3237                 {
  3124                 canvasVisual->ClearCanvasFlags( EHuiCanvasFlagIncludeToVisibilityCalculation );
  3238                 canvasVisual->ClearCanvasFlags( EHuiCanvasFlagIncludeToVisibilityCalculation );
  3125                 }
  3239                 }
  3126             }
  3240             }
  3127         
  3241         
  3128         iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3242         iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3129         }
  3243         }
  3130     else
  3244     else
  3131         {
  3245         {
  3132         __ALFLOGSTRING("CAlfBridge::HandleIncludeToVisibilityCalculationL, EAlfDSIncludeToVisibilityCalculation: Visual not found!");                                                
  3246         __ALFLOGSTRING("CAlfBridge::HandleIncludeToVisibilityCalculationL, EAlfDSIncludeToVisibilityCalculation: Visual not found!");                                                
  3133         }              
  3247         }              
       
  3248     }
       
  3249 
       
  3250 // ---------------------------------------------------------------------------
       
  3251 // HandleSetScreenDeviceValidL
       
  3252 // ---------------------------------------------------------------------------
       
  3253 // 
       
  3254 void CAlfBridge::HandleSetScreenDeviceValidL( TAlfBridgerData& aData )
       
  3255     {
       
  3256 	TInt windowNodeId = aData.iInt2;
       
  3257 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
       
  3258 
       
  3259 	// fetch visual
       
  3260 	CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
       
  3261 	if (viz)
       
  3262 		{
       
  3263 #ifdef HUI_DEBUG_TRACK_DRAWING
       
  3264         if ( viz->Tracking() )
       
  3265             {
       
  3266             RDebug::Print(_L("CAlfBridge::HandleSetScreenDeviceValidL - Tracked visual"));
       
  3267             }
       
  3268 #endif
       
  3269 		if ( windowAttributes->iActive )
       
  3270 		    {
       
  3271 		    viz->ClearCanvasFlags( EHuiCanvasVisualFlagNotReady );
       
  3272 		    }
       
  3273 		else
       
  3274 		    {
       
  3275 		    viz->SetCanvasFlags( EHuiCanvasVisualFlagNotReady );
       
  3276 		    }
       
  3277 		
       
  3278 	    iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
       
  3279 		}
       
  3280 	else
       
  3281 		{
       
  3282 		__ALFLOGSTRING("CAlfBridge::HandleSetScreenDeviceValidL, EAlfDSSetScreenDeviceValid: Visual not found!");                                                
       
  3283 		}          
  3134     }
  3284     }
  3135 
  3285 
  3136 // ---------------------------------------------------------------------------
  3286 // ---------------------------------------------------------------------------
  3137 // HandleSetWindowAreaL
  3287 // HandleSetWindowAreaL
  3138 // ---------------------------------------------------------------------------
  3288 // ---------------------------------------------------------------------------
  3140 void CAlfBridge::HandleSetWindowAreaL( TAlfBridgerData& aData )
  3290 void CAlfBridge::HandleSetWindowAreaL( TAlfBridgerData& aData )
  3141 	{
  3291 	{
  3142 	TInt windowNodeId = aData.iInt2;
  3292 	TInt windowNodeId = aData.iInt2;
  3143 	TAny* ptr = (TAny*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3293 	TAny* ptr = (TAny*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3144 	
  3294 	
  3145 	TInt screenNumber = 0;
       
  3146 	TPoint origin;
  3295 	TPoint origin;
  3147 	TInt count = 0;
  3296 	TInt count = 0;
  3148 	RRegion region;
  3297 	RRegion region;
  3149 	CleanupClosePushL( region );
  3298 	CleanupClosePushL( region );
  3150 	
  3299 	
  3151 	    {
  3300 	    {
  3152 	    RMemReadStream str(ptr, 4*sizeof(TInt32));	
  3301 	    RMemReadStream str(ptr, 4*sizeof(TInt32));	
  3153 	    screenNumber = str.ReadInt32L(); 
  3302 	    str.ReadInt32L(); // screen number, obsolete 
  3154     	origin.iX = str.ReadInt32L();
  3303     	origin.iX = str.ReadInt32L();
  3155 	    origin.iY = str.ReadInt32L();
  3304 	    origin.iY = str.ReadInt32L();
  3156 	    count = str.ReadInt32L();
  3305 	    count = str.ReadInt32L();
  3157         str.Release();
  3306         str.Release();
  3158         }
  3307         }
  3186 		
  3335 		
  3187 		
  3336 		
  3188 		CHuiCanvasVisual* canvas = static_cast<CHuiCanvasVisual*>(viz);
  3337 		CHuiCanvasVisual* canvas = static_cast<CHuiCanvasVisual*>(viz);
  3189 		canvas->SetShape( origin, region );
  3338 		canvas->SetShape( origin, region );
  3190 		
  3339 		
  3191 		iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  3340 		iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  3192 		}
  3341 		}
  3193 	else
  3342 	else
  3194 		{
  3343 		{
  3195 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowAreaL, EAlfDSSetWindowArea: Visual not found!");                                                
  3344 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowAreaL, EAlfDSSetWindowArea: Visual not found!");                                                
  3196 		}  
  3345 		}  
  3205 void CAlfBridge::HandleReorderWindowL( TAlfBridgerData& aData )
  3354 void CAlfBridge::HandleReorderWindowL( TAlfBridgerData& aData )
  3206 	{
  3355 	{
  3207 	TInt windowGroupNodeId = aData.iInt1;
  3356 	TInt windowGroupNodeId = aData.iInt1;
  3208 	TInt windowNodeId = aData.iInt2;
  3357 	TInt windowNodeId = aData.iInt2;
  3209 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3358 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3210 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  3211 	TInt ordinalPosition = windowAttributes->iOrdinalPosition;
  3359 	TInt ordinalPosition = windowAttributes->iOrdinalPosition;
  3212 
  3360 
  3213 	switch (windowAttributes->iWindowNodeType)
  3361 	switch (windowAttributes->iWindowNodeType)
  3214 		{
  3362 		{
  3215 		case EAlfWinTreeNodeGroup:
  3363 		case EAlfWinTreeNodeGroup:
  3225 				{
  3373 				{
  3226 				__ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: WS window group going to: %d ",windowAttributes->iOrdinalPosition);                                        
  3374 				__ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: WS window group going to: %d ",windowAttributes->iOrdinalPosition);                                        
  3227 				}    
  3375 				}    
  3228 			#endif
  3376 			#endif
  3229 
  3377 
  3230 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  3378             TBool wasInvalidReachable = IsVisualNotReadyReachable();
       
  3379 
       
  3380 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
  3231 			
  3381 			
  3232             if (!controlGroup)
  3382             if (!controlGroup)
  3233                 {
  3383                 {
  3234                 User::Leave(KErrNotFound);
  3384                 User::Leave(KErrNotFound);
  3235                 }
  3385                 }
  3236             ResolveAfterEffectAppearingApplicationL(controlGroup); // does nothing, if effect is not active on this control group
  3386             ResolveAfterEffectAppearingApplicationL(controlGroup); // does nothing, if effect is not active on this control group
  3237 			// Window server nodes are in inverted Z-order, we switch it here.
  3387 			// Window server nodes are in inverted Z-order, we switch it here.
  3238 			iAlfScreens[screenNumber]->iDisplay->Roster().Hide(*controlGroup);                            
  3388 			iAlfScreens[0]->iDisplay->Roster().Hide(*controlGroup);                            
  3239 			TInt wsWindowGroupCount = 0;
  3389 			TInt wsWindowGroupCount = 0;
  3240 			for (TInt i=0; i<iAlfScreens[screenNumber]->iDisplay->Roster().Count();i++)
  3390 			for (TInt i=0; i<iAlfScreens[0]->iDisplay->Roster().Count();i++)
  3241 				{
  3391 				{
  3242                 if (iAlfScreens[screenNumber]->iDisplay->Roster().ControlGroup(i).Control(0).Role()==EHuiWindowGroupContainer)
  3392                 if (iAlfScreens[0]->iDisplay->Roster().ControlGroup(i).Control(0).Role()==EHuiWindowGroupContainer)
  3243 					{
  3393 					{
  3244 					wsWindowGroupCount++;    
  3394 					wsWindowGroupCount++;    
  3245 					}
  3395 					}
  3246 				}
  3396 				}
  3247 			ordinalPosition = wsWindowGroupCount - windowAttributes->iOrdinalPosition;
  3397 			ordinalPosition = wsWindowGroupCount - windowAttributes->iOrdinalPosition;
  3255 			if (ordinalPosition < -1)
  3405 			if (ordinalPosition < -1)
  3256 				{
  3406 				{
  3257 				ordinalPosition = -1; // show at top ?    
  3407 				ordinalPosition = -1; // show at top ?    
  3258 				}
  3408 				}
  3259 			
  3409 			
  3260 			if (iAlfScreens[screenNumber]->iDisplay && controlGroup)
  3410 			if (iAlfScreens[0]->iDisplay && controlGroup)
  3261 				{
  3411 				{
  3262 				ShowControlGroupL(iAlfScreens[screenNumber]->iDisplay->Roster(), *controlGroup, ordinalPosition, screenNumber); 
  3412 				ShowControlGroupL(iAlfScreens[0]->iDisplay->Roster(), *controlGroup, ordinalPosition); 
  3263 				}
  3413 				}
  3264 			else
  3414 			else
  3265 				{
  3415 				{
  3266 				__ALFLOGSTRING2("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Control group not found! Screen: %d, Id: %d ", screenNumber, windowNodeId );        
  3416 				__ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Control group not found! Id: %d ", windowNodeId );        
  3267 				}
  3417 				}
  3268 			
  3418 			
  3269 			ReorderAlfControlGroupsL(screenNumber);                                        
  3419 			ReorderAlfControlGroupsL();                                        
       
  3420 
       
  3421             // Usually, layout switch is initiated by akncapserver before window group in new orientation 
       
  3422             // becomes visible. However, sometimes either akncapserver isn't fast enough or then applications 
       
  3423             // perform operations in wrong order. To reduce flickering, uiaccelerator provides implicit blanker.
       
  3424 
       
  3425             // We will check if there is a visual that is not ready for current orientation.
       
  3426             // If such visual is found before fullscreen is covered then we will enable
       
  3427             // implicit blanker. That gives akncapserver some time to start layout switch.
       
  3428 	
       
  3429             if (!wasInvalidReachable && IsVisualNotReadyReachable())
       
  3430                 {
       
  3431                 iLayoutSwitchEffectCoordinator->ImplicitBlank();
       
  3432                 }
       
  3433 
  3270 			break;    
  3434 			break;    
  3271 			}
  3435 			}
  3272 		case EAlfWinTreeNodeClient:
  3436 		case EAlfWinTreeNodeClient:
  3273 		case EAlfWinTreeNodeRoot:
  3437 		case EAlfWinTreeNodeRoot:
  3274 		case EAlfWinTreeNodeAnim:
  3438 		case EAlfWinTreeNodeAnim:
  3302 				pos = layoutCount - pos - 1;    
  3466 				pos = layoutCount - pos - 1;    
  3303 				layout->Reorder(*viz, pos);
  3467 				layout->Reorder(*viz, pos);
  3304 				}
  3468 				}
  3305 			else
  3469 			else
  3306 				{
  3470 				{
  3307 				__ALFLOGSTRING2("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Visual not found! Screen: %d, Id: %d ", screenNumber, windowNodeId );    
  3471 				__ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Visual not found! Id: %d ", windowNodeId );    
  3308 				}                       
  3472 				}                       
  3309 			break;
  3473 			break;
  3310 			}
  3474 			}
  3311 		default:
  3475 		default:
  3312 			{
  3476 			{
  3313 			__ALFLOGSTRING("CAlfBridge::HandleReorderWindowL: Unknown window node type received !");    
  3477 			__ALFLOGSTRING("CAlfBridge::HandleReorderWindowL: Unknown window node type received !");    
  3314 			break;
  3478 			break;
  3315 			}
  3479 			}
  3316 		}
  3480 		}
  3317   
  3481   
  3318 	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed
  3482 	iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed
  3319 
  3483 
  3320 	AMT_MAP_BRIDGE_SET_ORDINAL_POSITION();
  3484 	AMT_MAP_BRIDGE_SET_ORDINAL_POSITION();
  3321 	}
  3485 	}
  3322 
  3486 
  3323 // ---------------------------------------------------------------------------
  3487 // ---------------------------------------------------------------------------
  3327 void CAlfBridge::HandlePostCanvasBufferL( TAlfBridgerData& aData )
  3491 void CAlfBridge::HandlePostCanvasBufferL( TAlfBridgerData& aData )
  3328 	{
  3492 	{
  3329 	TInt windowGroupNodeId = aData.iInt1;
  3493 	TInt windowGroupNodeId = aData.iInt1;
  3330 	TInt windowNodeId = aData.iInt2;
  3494 	TInt windowNodeId = aData.iInt2;
  3331 	TAlfWindowCommandBufferAttributes* bufferAttributes = (TAlfWindowCommandBufferAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3495 	TAlfWindowCommandBufferAttributes* bufferAttributes = (TAlfWindowCommandBufferAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3332 	TInt screenNumber = bufferAttributes->iScreenNumber;
       
  3333 
  3496 
  3334 	CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  3497 	CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  3335 	
  3498 	
  3336 	// For now we omit drawing commands to ALF window group because in some configurations it causes issues
  3499 	// For now we omit drawing commands to ALF window group because in some configurations it causes issues
  3337 	// TODO: Possible viz->Flags() & EHuiVisualFlagDrawAf.. is not needed anymore. To be checked. Currently this enables floating sprites on the "root visual"
  3500 	// TODO: Possible viz->Flags() & EHuiVisualFlagDrawAf.. is not needed anymore. To be checked. Currently this enables floating sprites on the "root visual"
  3339 	        ||  ( viz && viz->Flags() & EHuiVisualFlagDrawAfterOthers )/* THIS LINE IS HACK FOR DRAWING FLOATING SPRITES */ )
  3502 	        ||  ( viz && viz->Flags() & EHuiVisualFlagDrawAfterOthers )/* THIS LINE IS HACK FOR DRAWING FLOATING SPRITES */ )
  3340 		{
  3503 		{
  3341 #ifdef HUI_DEBUG_TRACK_DRAWING
  3504 #ifdef HUI_DEBUG_TRACK_DRAWING
  3342         TBool tracking( EFalse );
  3505         TBool tracking( EFalse );
  3343 	CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
  3506 	CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
  3344 	CAlfScreen* screen = iAlfScreens[screenNumber];
  3507 	CAlfScreen* screen = iAlfScreens[0];
  3345 	
  3508 	
  3346 	//TInt clientWindowGroupId = FindClientWindowGroupId( screenNumber, *controlGroup );
  3509 	//TInt clientWindowGroupId = FindClientWindowGroupId( screenNumber, *controlGroup );
  3347 	// NOTE, THE FOLLOWING WServClientFileName MAY CAUSE DEADLOCK. 
  3510 	// NOTE, THE FOLLOWING WServClientFileName MAY CAUSE DEADLOCK. 
  3348 	// THIS DOES NOT HAPPEN IF HUI_DEBUG_TRACK_DRAWING IS NOT ENABLED (DEFAULT)
  3511 	// THIS DOES NOT HAPPEN IF HUI_DEBUG_TRACK_DRAWING IS NOT ENABLED (DEFAULT)
  3349 	TFileName processName;/* = iCommandDebug->WServClientFileName( clientWindowGroupId, CHuiStatic::WsSession() );
  3512 	TFileName processName;/* = iCommandDebug->WServClientFileName( clientWindowGroupId, CHuiStatic::WsSession() );
  3362 	    
  3525 	    
  3363 	    if (!viz->HasCommandBuffers(EFalse))
  3526 	    if (!viz->HasCommandBuffers(EFalse))
  3364 	        {
  3527 	        {
  3365             // For performance resons, only set visual tree changed if this 
  3528             // For performance resons, only set visual tree changed if this 
  3366             // was the first buffer for the window. 
  3529             // was the first buffer for the window. 
  3367 	        iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  3530 	        iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  3368 	        }
  3531 	        }
  3369 
  3532 
  3370 		TPtrC8 commands((TUint8*)bufferAttributes->iBuffer, bufferAttributes->iBufferLength);
  3533 		TPtrC8 commands((TUint8*)bufferAttributes->iBuffer, bufferAttributes->iBufferLength);
  3371 		if ( bufferAttributes->iEmptyThisBuffer )
  3534 		if ( bufferAttributes->iEmptyThisBuffer )
  3372 			{
  3535 			{
  3423 				break;
  3586 				break;
  3424 			}
  3587 			}
  3425 		}
  3588 		}
  3426 	else
  3589 	else
  3427 		{
  3590 		{
  3428 		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
  3591 		__ALFLOGSTRING2("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Id: %d, GroupId: %d ",  windowNodeId, windowGroupNodeId );                                 
  3429 		}    
  3592 		}    
       
  3593 	    // Uncomment the following for tracking which application is doing drawing
       
  3594         //__ALFFXLOGSTRING1("CAlfBridge::HandlePostCanvasBufferL 0x%x", viz->Owner().ControlGroup()->SecureId());
  3430 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
  3595 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
  3431 	    if (iFSFxData
  3596 	    if (iFSFxData
  3432 	            && iFSFxData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
  3597 	            && iFSFxData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
  3433 	            && ((iFSFxData->State() == EWaitEndFullScreen && iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::ESecondPartActive)))
  3598 	            && ((iFSFxData->State() == EWaitEndFullScreen && iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::ESecondPartActive)))
  3434 	        {
  3599 	        {
  3503 void CAlfBridge::SetWindowActiveL(CHuiVisual* aVisual, TBool aActive)
  3668 void CAlfBridge::SetWindowActiveL(CHuiVisual* aVisual, TBool aActive)
  3504     {
  3669     {
  3505     TInt effectIndex;
  3670     TInt effectIndex;
  3506     if (!HasActiveEffect(aVisual, effectIndex))
  3671     if (!HasActiveEffect(aVisual, effectIndex))
  3507         {
  3672         {
       
  3673         __ALFFXLOGSTRING2("CAlfBridge::SetWindowActiveL 0x%x - New state: %d", aVisual, aActive);
  3508         // Does not have effect
  3674         // Does not have effect
  3509         if (aActive)
  3675         if (aActive)
  3510             {
  3676             {
  3511             aVisual->ClearFlags(EHuiVisualFlagShouldBeHidden | EHuiVisualFlagShouldBeShown);
  3677             aVisual->ClearFlags(EHuiVisualFlagShouldBeHidden | EHuiVisualFlagShouldBeShown);
  3512             aVisual->iOpacity.Set(KAlfVisualDefaultOpacity);
  3678             aVisual->iOpacity.Set(KAlfVisualDefaultOpacity);
  3568 void CAlfBridge::HandleSetWindowActiveL( TAlfBridgerData& aData )
  3734 void CAlfBridge::HandleSetWindowActiveL( TAlfBridgerData& aData )
  3569 	{
  3735 	{
  3570 	TInt windowGroupNodeId = aData.iInt1;
  3736 	TInt windowGroupNodeId = aData.iInt1;
  3571 	TInt windowNodeId = aData.iInt2;
  3737 	TInt windowNodeId = aData.iInt2;
  3572 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3738 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3573 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  3574 
  3739 
  3575     if (windowAttributes->iWindowNodeType == EAlfWinTreeNodeTextCursor && iCursorTimer)
  3740     if (windowAttributes->iWindowNodeType == EAlfWinTreeNodeTextCursor && iCursorTimer)
  3576 	    {
  3741 	    {
  3577 		if (!windowAttributes->iActive)
  3742 		if (!windowAttributes->iActive)
  3578 		    {
  3743 		    {
  3587 
  3752 
  3588 	switch (windowAttributes->iWindowNodeType)
  3753 	switch (windowAttributes->iWindowNodeType)
  3589 		{
  3754 		{
  3590 		case EAlfWinTreeNodeGroup:
  3755 		case EAlfWinTreeNodeGroup:
  3591 			{
  3756 			{
  3592 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  3757 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
  3593 			if (controlGroup)
  3758 			if (controlGroup)
  3594 				{
  3759 				{
  3595 				CHuiControl& control = controlGroup->Control(0);
  3760 				CHuiControl& control = controlGroup->Control(0);
  3596 				CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
  3761 				CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
  3597                 // Uses opacity for now
  3762                 // Uses opacity for now
  3633 			__ALFLOGSTRING("CAlfBridge::HandleSetWindowActiveL, EAlfDSSetWindowActive: Unknown iWindowNodeType!");                                                         	
  3798 			__ALFLOGSTRING("CAlfBridge::HandleSetWindowActiveL, EAlfDSSetWindowActive: Unknown iWindowNodeType!");                                                         	
  3634 			USER_INVARIANT();
  3799 			USER_INVARIANT();
  3635 			break;                       	        
  3800 			break;                       	        
  3636 			}
  3801 			}
  3637 		}
  3802 		}
  3638     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);	// TODO: Check if really changed                       
  3803     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);	// TODO: Check if really changed                       
  3639 
  3804 
  3640     AMT_INC_COUNTER( iTotalVisualFlagChangedCount );
  3805     AMT_INC_COUNTER( iTotalVisualFlagChangedCount );
  3641     AMT_INC_COUNTER_IF( windowAttributes->iActive, iActiveVisualCount );
  3806     AMT_INC_COUNTER_IF( windowAttributes->iActive, iActiveVisualCount );
  3642     AMT_INC_COUNTER_IF( !windowAttributes->iActive, iPassiveVisualCount );
  3807     AMT_INC_COUNTER_IF( !windowAttributes->iActive, iPassiveVisualCount );
  3643 
  3808 
  3655 void CAlfBridge::HandleSetWindowFlagL( TAlfBridgerData& aData, TInt aOp )
  3820 void CAlfBridge::HandleSetWindowFlagL( TAlfBridgerData& aData, TInt aOp )
  3656     {
  3821     {
  3657     TInt windowGroupNodeId = aData.iInt1;
  3822     TInt windowGroupNodeId = aData.iInt1;
  3658     TInt windowNodeId = aData.iInt2;
  3823     TInt windowNodeId = aData.iInt2;
  3659     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3824     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3660     TInt screenNumber = windowAttributes->iScreenNumber;
       
  3661     TInt windowFlag = windowAttributes->iActive;
  3825     TInt windowFlag = windowAttributes->iActive;
  3662     THuiVisualFlags visualFlag = (THuiVisualFlags)0;
  3826     THuiVisualFlags visualFlag = (THuiVisualFlags)0;
  3663     switch(windowFlag)
  3827     switch(windowFlag)
  3664         {
  3828         {
  3665         case TAlfWindowData::EShouldInactivate:
  3829         case TAlfWindowData::EShouldInactivate:
  3677     
  3841     
  3678     switch (windowAttributes->iWindowNodeType)
  3842     switch (windowAttributes->iWindowNodeType)
  3679         {
  3843         {
  3680         case EAlfWinTreeNodeGroup:
  3844         case EAlfWinTreeNodeGroup:
  3681             {
  3845             {
  3682             CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  3846             CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
  3683             if (controlGroup)
  3847             if (controlGroup)
  3684                 {
  3848                 {
  3685                 CHuiControl& control = controlGroup->Control(0);
  3849                 CHuiControl& control = controlGroup->Control(0);
  3686                 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
  3850                 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
  3687                 // Uses opacity for now                            
  3851                 // Uses opacity for now                            
  3738             __ALFLOGSTRING("CAlfBridge::HandleSetWindowFlagL, HandleSetWindowFlagL: Unknown iWindowNodeType!");                                                          
  3902             __ALFLOGSTRING("CAlfBridge::HandleSetWindowFlagL, HandleSetWindowFlagL: Unknown iWindowNodeType!");                                                          
  3739             USER_INVARIANT();
  3903             USER_INVARIANT();
  3740             break;                                  
  3904             break;                                  
  3741             }
  3905             }
  3742         }
  3906         }
  3743     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed                       
  3907     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed                       
  3744     }
  3908     }
  3745 
  3909 
  3746 // ---------------------------------------------------------------------------
  3910 // ---------------------------------------------------------------------------
  3747 // InsertImageBrushL
  3911 // InsertImageBrushL
  3748 // ---------------------------------------------------------------------------
  3912 // ---------------------------------------------------------------------------
  3822 void CAlfBridge::HandleSetSurfaceExtentL( TAlfBridgerData& aData )
  3986 void CAlfBridge::HandleSetSurfaceExtentL( TAlfBridgerData& aData )
  3823 	{
  3987 	{
  3824 	TInt windowGroupNodeId = aData.iInt1;
  3988 	TInt windowGroupNodeId = aData.iInt1;
  3825 	TInt windowNodeId = aData.iInt2;
  3989 	TInt windowNodeId = aData.iInt2;
  3826 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3990 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3827 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  3828 	// fetch visual
  3991 	// fetch visual
  3829 	CHuiCanvasVisual* viz = FindVisual(windowNodeId);
  3992 	CHuiCanvasVisual* viz = FindVisual(windowNodeId);
  3830 
  3993 	CHuiControlGroup* controlgroup = FindControlGroup(windowGroupNodeId, 0);
       
  3994 	
  3831     // We should not do this for alf window, but renderstage does not know if it is
  3995     // We should not do this for alf window, but renderstage does not know if it is
  3832     // handling alf window or other window, so we ignore the request here if needed.
  3996     // handling alf window or other window, so we ignore the request here if needed.
  3833     // TODO: When alf apps work in multiple display, check here for every displays alf groups...
  3997     // TODO: When alf apps work in multiple display, check here for every displays alf groups...
  3834 	if (viz && iAlfWindowGroupNodeId != windowGroupNodeId)
  3998 	if (viz && iAlfWindowGroupNodeId != windowGroupNodeId && controlgroup && controlgroup->SecureId() != iAlfSecureId )
  3835 		{
  3999 		{
  3836         viz->SetLayerExtent(windowAttributes->iSurfaceExtent);
  4000         viz->SetLayerExtent(windowAttributes->iSurfaceExtent);
  3837 		// Set surface extend area to be cleared with fully transparent color
  4001 		// Set surface extend area to be cleared with fully transparent color
  3838 		// Note: does not support extend that is bigger that the visual
  4002 		// Note: does not support extend that is bigger that the visual
  3839 		// if surface extent is (0,0,0,0) then the background item array is reseted 
  4003 		// if surface extent is (0,0,0,0) then the background item array is reseted 
  3858 	else
  4022 	else
  3859 		{
  4023 		{
  3860 		if (iAlfWindowGroupNodeId != windowGroupNodeId)
  4024 		if (iAlfWindowGroupNodeId != windowGroupNodeId)
  3861 		    __ALFLOGSTRING("CAlfBridge::HandleSetSurfaceExtentL, EAlfDSSetSurfaceExtent: Visual not found!");    
  4025 		    __ALFLOGSTRING("CAlfBridge::HandleSetSurfaceExtentL, EAlfDSSetSurfaceExtent: Visual not found!");    
  3862 		}                            
  4026 		}                            
  3863     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  4027     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  3864 	}
  4028 	}
  3865 
  4029 
  3866 // ---------------------------------------------------------------------------
  4030 // ---------------------------------------------------------------------------
  3867 // HandleLayerUsesAlphaFlagChanged
  4031 // HandleLayerUsesAlphaFlagChanged
  3868 // ---------------------------------------------------------------------------
  4032 // ---------------------------------------------------------------------------
  3870 void CAlfBridge::HandleLayerUsesAlphaFlagChanged( TAlfBridgerData& aData )
  4034 void CAlfBridge::HandleLayerUsesAlphaFlagChanged( TAlfBridgerData& aData )
  3871     {
  4035     {
  3872     TInt windowGroupNodeId = aData.iInt1;
  4036     TInt windowGroupNodeId = aData.iInt1;
  3873     TInt windowNodeId = aData.iInt2;
  4037     TInt windowNodeId = aData.iInt2;
  3874     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  4038     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3875     TInt screenNumber = windowAttributes->iScreenNumber;
       
  3876     
  4039     
  3877     // fetch visual
  4040     // fetch visual
  3878     CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  4041     CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  3879 
  4042 
  3880     // We should not do this for alf window, but renderstage does not know if it is
  4043     // We should not do this for alf window, but renderstage does not know if it is
  3887     else
  4050     else
  3888         {
  4051         {
  3889         if (iAlfWindowGroupNodeId != windowGroupNodeId)
  4052         if (iAlfWindowGroupNodeId != windowGroupNodeId)
  3890             __ALFLOGSTRING("CAlfBridge::HandleLayerUsesAlphaFlagChanged: Visual not found!");    
  4053             __ALFLOGSTRING("CAlfBridge::HandleLayerUsesAlphaFlagChanged: Visual not found!");    
  3891         }                            
  4054         }                            
  3892     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  4055     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  3893     }
  4056     }
  3894 
  4057 
  3895 
  4058 
  3896 // ---------------------------------------------------------------------------
  4059 // ---------------------------------------------------------------------------
  3897 // HandleGetNativeWindowDataL
  4060 // HandleGetNativeWindowDataL
  4305                     {
  4468                     {
  4306                     // All children in the tree are not faded, do not apply effect on children.
  4469                     // All children in the tree are not faded, do not apply effect on children.
  4307                     effectFlags |= KHuiFxEffectExcludeChildrenFlag;
  4470                     effectFlags |= KHuiFxEffectExcludeChildrenFlag;
  4308                     //RDebug::Print(_L("CAlfBridge::SetupFadeEffectL - no children faded by parent"));
  4471                     //RDebug::Print(_L("CAlfBridge::SetupFadeEffectL - no children faded by parent"));
  4309                     }
  4472                     }
  4310                 __ALFFXLOGSTRING1("CAlfBridge::SetupFadeEffectL - insert fade 0x%x", &aVisual);
  4473                 
  4311                 TRAP( err, engine->LoadEffectL(*iFadeEffectFile, effect, aVisual.Effectable(), NULL, NULL, 0, effectFlags ) );
  4474                 if (iHuiEnv->MemoryLevel() <= EHuiMemoryLevelLowest)
  4312                 didFadeEffectLoad = ETrue;
  4475                     {
       
  4476                     __ALFFXLOGSTRING("CAlfBridge::SetupFadeEffectL - Skipping because in SW rendering mode");
       
  4477                     didFadeEffectLoad = EFalse;
       
  4478                     }
       
  4479                 else
       
  4480                     {
       
  4481                     __ALFFXLOGSTRING1("CAlfBridge::SetupFadeEffectL - insert fade 0x%x", &aVisual);
       
  4482                     TRAP( err, engine->LoadEffectL(*iFadeEffectFile, effect, aVisual.Effectable(), NULL, NULL, 0, effectFlags ) );
       
  4483                     didFadeEffectLoad = ETrue;
       
  4484                     }
  4313         		}
  4485         		}
  4314         	}
  4486         	}
  4315         }
  4487         }
  4316     else
  4488     else
  4317         {
  4489         {
  4332         }
  4504         }
  4333     
  4505     
  4334     return (didFadeEffectLoad || alreadyFaded);
  4506     return (didFadeEffectLoad || alreadyFaded);
  4335     }
  4507     }
  4336 
  4508 
       
  4509 // ---------------------------------------------------------------------------
       
  4510 //	HandleGroupChained
       
  4511 //
       
  4512 // 	Chain information is used for redirecting effects to correct windowgroup
       
  4513 // ---------------------------------------------------------------------------
       
  4514 //
       
  4515 void CAlfBridge::HandleGroupChained( TAlfBridgerData& aData)
       
  4516     {
       
  4517     TInt parentId = aData.iInt1;
       
  4518     TInt chainedId = aData.iInt2;
       
  4519        
       
  4520     TChainData data(parentId, chainedId);
       
  4521     iWindowChainsArray.Insert(parentId,data);
       
  4522     __ALFFXLOGSTRING3("CAlfBridge::DoDispatchL, EAlfDSGroupChained %d chained to %d (host), iWindowChainsArray.Count() = %d", chainedId, parentId, iWindowChainsArray.Count());
       
  4523 #ifdef _ALF_FXLOGGING
       
  4524     CHuiControlGroup* parent = FindControlGroup(parentId);
       
  4525     CHuiControlGroup* chained = FindControlGroup(chainedId);
       
  4526 
       
  4527     if (parent)
       
  4528         {
       
  4529         RDebug::Printf("CAlfBridge::DoDispatch - parent: 0x%x", parent->SecureId());
       
  4530         }
       
  4531     if (chained)
       
  4532         {
       
  4533         RDebug::Printf("CAlfBridge::DoDispatch - chained: 0x%x", chained->SecureId());
       
  4534         }
       
  4535 #endif
       
  4536     } 
       
  4537 
       
  4538 // ---------------------------------------------------------------------------
       
  4539 // HandleGroupChainBroken
       
  4540 // ---------------------------------------------------------------------------
       
  4541 //
       
  4542 void CAlfBridge::HandleGroupChainBroken( TAlfBridgerData& aData)
       
  4543     {
       
  4544     TInt parentId = aData.iInt2;
       
  4545     iWindowChainsArray.Remove(parentId);
       
  4546     __ALFFXLOGSTRING2("CAlfBridge::DoDispatchL, EAlfDSGroupChainBroken - parent: %d, iWindowChainsArray.Count() = %d", parentId, iWindowChainsArray.Count());
       
  4547     }
  4337 
  4548 
  4338 // ---------------------------------------------------------------------------
  4549 // ---------------------------------------------------------------------------
  4339 // HandleMoveWindowToNewGroupL
  4550 // HandleMoveWindowToNewGroupL
  4340 // ---------------------------------------------------------------------------
  4551 // ---------------------------------------------------------------------------
  4341 // 
  4552 // 
  4342 void CAlfBridge::HandleMoveWindowToNewGroupL( TAlfBridgerData& aData )
  4553 void CAlfBridge::HandleMoveWindowToNewGroupL( TAlfBridgerData& aData )
  4343     {
  4554     {
  4344     TInt windowNodeId = aData.iInt1;
  4555     TInt windowNodeId = aData.iInt1;
  4345     TInt screenNumber = aData.iInt2;
       
  4346     TInt newWindowGroupNodeId = (TInt)aData.iPtr;
  4556     TInt newWindowGroupNodeId = (TInt)aData.iPtr;
  4347    
  4557    
  4348     CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  4558     CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  4349     
  4559     
  4350 #ifdef _ALF_LOGGING
  4560 #ifdef _ALF_LOGGING
  4351     CHuiControlGroup* oldControlGroup = viz->Owner().ControlGroup();
  4561     CHuiControlGroup* oldControlGroup = viz->Owner().ControlGroup();
  4352     TInt oldWindowGroupId = 0; 
  4562     TInt oldWindowGroupId = 0; 
  4353     if ( oldControlGroup  )
  4563     if ( oldControlGroup  )
  4354         {
  4564         {
  4355         oldWindowGroupId = FindWindowGroupNodeId(screenNumber, *oldControlGroup );
  4565         oldWindowGroupId = FindWindowGroupNodeId(*oldControlGroup );
  4356         }   
  4566         }   
  4357     __ALFLOGSTRING3("CAlfBridge::HandleMoveWindowToNewGroupL moving nodeId 0x%x from group 0x%x to 0x%x ",windowNodeId, oldWindowGroupId, newWindowGroupNodeId );
  4567     __ALFLOGSTRING3("CAlfBridge::HandleMoveWindowToNewGroupL moving nodeId 0x%x from group 0x%x to 0x%x ",windowNodeId, oldWindowGroupId, newWindowGroupNodeId );
  4358 #endif
  4568 #endif
  4359     
  4569     
  4360     if (viz)
  4570     if (viz)
  4384         
  4594         
  4385         // remove from the old control
  4595         // remove from the old control
  4386         viz->Owner().Remove(viz);
  4596         viz->Owner().Remove(viz);
  4387         
  4597         
  4388         // #2 insert visual to the beginning of the new group
  4598         // #2 insert visual to the beginning of the new group
  4389         CHuiControlGroup* newControlGroup = FindControlGroup(newWindowGroupNodeId,screenNumber);
  4599         CHuiControlGroup* newControlGroup = FindControlGroup(newWindowGroupNodeId);
  4390         if (newControlGroup)
  4600         if (newControlGroup)
  4391             {
  4601             {
  4392             CHuiControl& newControl = newControlGroup->Control(0);
  4602             CHuiControl& newControl = newControlGroup->Control(0);
  4393             if ( isRootOfTheMovingTree )
  4603             if ( isRootOfTheMovingTree )
  4394                 {
  4604                 {
  4430         {
  4640         {
  4431         viz = (CHuiVisual*)FindVisual(windowNodeId);
  4641         viz = (CHuiVisual*)FindVisual(windowNodeId);
  4432         }
  4642         }
  4433     else
  4643     else
  4434         {
  4644         {
  4435         CHuiControlGroup* cg = FindControlGroup(windowNodeId, 0); // TODO: Screen            
  4645         CHuiControlGroup* cg = FindControlGroup(windowNodeId); // TODO: Screen            
  4436         if (cg) 
  4646         if (cg) 
  4437             {
  4647             {
  4438             CHuiControl& control = cg->Control(0);
  4648             CHuiControl& control = cg->Control(0);
  4439             viz = &control.Visual(0);
  4649             viz = &control.Visual(0);
  4440             }        
  4650             }        
  4622         __ALFFXLOGSTRING("CAlfBridge::StoreLayoutIfRequiredByEffectL - Storing not required");
  4832         __ALFFXLOGSTRING("CAlfBridge::StoreLayoutIfRequiredByEffectL - Storing not required");
  4623         return ETrue; // no storing requred, no screenshot required => success
  4833         return ETrue; // no storing requred, no screenshot required => success
  4624         }
  4834         }
  4625     }
  4835     }
  4626 
  4836 
  4627 TBool CAlfBridge::HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout *aFromLayout)
  4837 // ---------------------------------------------------------------------------
  4628     {
  4838 // HandleGfxRedirection
  4629     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEventL - To SecureUid: 0x%x, From SecureUid: 0x%x, effect %S", aEvent.iToSecureId, aEvent.iFromSecureId, aEvent.iEffectName);
  4839 //
  4630     __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEventL - To layout: 0x%x, From layout: 0x%x, Effect handle: %d, Action: %d", aToLayout, aFromLayout, aEvent.iHandle, aEvent.iAction);
  4840 // This effect might have been request for the host application, while the intent was to show it on the application started embedded.
  4631     
  4841 // Embedded application has its _own_ windowgroup separate from the host application. Fullscreen effect are shown on a windowgroup level.
       
  4842 // e.g. Messaging -> New Message (editor), or Settings -> Themes (application)
       
  4843 // Wserv notifies us the window group chaining of applications. See HandleGroupChained and HandleGroupChainBroken for more details. This code
       
  4844 // will redirect the requested effect on correct windowgroup.
       
  4845 //
       
  4846 // NOTE! If embedded application effects are implemented, this will need revision
       
  4847 // ---------------------------------------------------------------------------
       
  4848     
       
  4849 void CAlfBridge::HandleGfxRedirection(CFullScreenEffectState& aEvent, CHuiLayout*& aToLayout)
       
  4850     {
       
  4851     __ALFFXLOGSTRING2("CAlfBridge::HandleGfxRedirection - Redirection check for SecureId 0x%x. Effect setup result: %d.", aEvent.iToSecureId, aEvent.iSetupDone);
       
  4852     TInt windowGroupNodeId = FindWindowGroupNodeId(*((*aToLayout).Owner().ControlGroup()));
       
  4853     CHuiControlGroup* chainedGroup = NULL;
       
  4854     
       
  4855     // check, if the effect is being asked for chained application. This propably indicates that there are two or more instances of it and 
       
  4856     // effect was supposed to go to the single standalone instance
       
  4857     if (IsChainedGroup(windowGroupNodeId))
       
  4858         { 
       
  4859         RPointerArray<CHuiControlGroup> groupList;
       
  4860         FindControlGroupBySecureId(aEvent.iToSecureId, groupList);
       
  4861         TInt i = groupList.Count();
       
  4862         TInt standaloneGroups = 0;
       
  4863         while(--i >= 0)
       
  4864             {
       
  4865             windowGroupNodeId = FindWindowGroupNodeId(*groupList[i]);
       
  4866             
       
  4867             if (!IsChainedGroup(windowGroupNodeId))
       
  4868                 {
       
  4869                 // This is an educated guess, which will make the standalone version to have effect. 
       
  4870                 // Currently (tm) standard appstart effect is never requested for embbedded instances. 
       
  4871                 chainedGroup = groupList[i];
       
  4872                 standaloneGroups++;
       
  4873                 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxRedirection - Wg id: %d is NOT chained. Index: %d",windowGroupNodeId, i);
       
  4874                 }
       
  4875             else
       
  4876                 {
       
  4877                 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxRedirection - Wg id: %d IS chained. Index: %d", windowGroupNodeId, i);
       
  4878                 }
       
  4879             }
       
  4880         groupList.Close();
       
  4881         // Skip effect redirection if the end result is uncertain. This is the case, if
       
  4882         // there are multiple standalone app groups (e.g. single application having multiple groups), 
       
  4883         if (standaloneGroups>1)
       
  4884             {
       
  4885             chainedGroup = NULL;
       
  4886             aEvent.iIsRedirected = ETrue;
       
  4887             if (iFSFXDataPart2)
       
  4888                 {
       
  4889                 iFSFXDataPart2->iIsRedirected = ETrue;
       
  4890                 }
       
  4891             }
       
  4892         }
       
  4893     else
       
  4894         {
       
  4895         // Which group is chained to this group?
       
  4896         TUint32 chainedId = FindChainedGroup(windowGroupNodeId); 
       
  4897         chainedGroup = FindControlGroup(chainedId);
       
  4898         }
       
  4899     
       
  4900 	// Redirection is skipped if the host layout has been already prepared (in practice added 
       
  4901 	// to iEffectCleanupStack) for the effect.
       
  4902     if (chainedGroup && !aEvent.iSetupDone)
       
  4903         {
       
  4904         __ALFFXLOGSTRING2("CAlfBridge::HandleGfxRedirection - Chained app found for this application. Transferring effect from 0x%x to 0x%x.", aToLayout->Owner().ControlGroup()->SecureId(), chainedGroup->SecureId());
       
  4905         aToLayout = (CHuiLayout*)&chainedGroup->Control(0).Visual(0);
       
  4906         // we'll change the original effect request to point to this new group. Thus, if effect is 
       
  4907         // canceled, it will be removed from the right place.
       
  4908         
       
  4909         aEvent.iToSecureId = chainedGroup->SecureId(); // Update the effect
       
  4910         aEvent.iToWg = FindClientWindowGroupId(*chainedGroup);
       
  4911         
       
  4912         if (iFSFXDataPart2)
       
  4913             {
       
  4914             iFSFXDataPart2->iToSecureId = aEvent.iToSecureId;
       
  4915             iFSFXDataPart2->iToWg = aEvent.iToWg;
       
  4916             }
       
  4917         }
       
  4918     else
       
  4919         {
       
  4920         __ALFFXLOGSTRING2("CAlfBridge::HandleGfxRedirection - Skip redirection for SecureId 0x%x. Chained group: 0x%x", aEvent.iToSecureId, chainedGroup);
       
  4921         }
       
  4922     // Redirection attemp is allowed to happen only once, because this redirects effects for 
       
  4923 	// _running_ embedded applications that must exist at the time of the request. 
       
  4924 	// We are not interested in the embedded applications effects. Start effects for embedded applications
       
  4925 	// are not currently supported.
       
  4926     aEvent.iIsRedirected = ETrue;
       
  4927     if (iFSFXDataPart2)
       
  4928         {
       
  4929         iFSFXDataPart2->iIsRedirected = ETrue;
       
  4930         }
       
  4931     }
       
  4932 
       
  4933 // ---------------------------------------------------------------------------
       
  4934 // HandleGfxEventL
       
  4935 //
       
  4936 // ---------------------------------------------------------------------------
       
  4937 //
       
  4938 TBool CAlfBridge::HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout* /*aFromLayout */)
       
  4939     {
       
  4940     __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEventL - Operation: %d, To SecureUid: 0x%x, From SecureUid: 0x%x, effect %S", aEvent.iOperation, aEvent.iToSecureId, aEvent.iFromSecureId, aEvent.iEffectName);
       
  4941     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEventL - To layout: 0x%x Effect handle: %d, Action: %d", aToLayout, aEvent.iHandle, aEvent.iAction);
       
  4942     
       
  4943     if (!aEvent.iIsRedirected)
       
  4944         {
       
  4945         HandleGfxRedirection(aEvent, aToLayout);
       
  4946         }
       
  4947         
  4632     TInt err = KErrNone;
  4948     TInt err = KErrNone;
  4633     TBool failed = EFalse;
  4949     TBool failed = EFalse;
  4634     
  4950     
  4635     // Check if there is an effects engine in HuiEnv
  4951     // Check if there is an effects engine in HuiEnv
  4636     CHuiFxEffect* effect = NULL;
  4952     CHuiFxEffect* effect = NULL;
  4678                     case AknTransEffect::EApplicationStartRect:
  4994                     case AknTransEffect::EApplicationStartRect:
  4679                     case AknTransEffect::EApplicationStartSwitch:
  4995                     case AknTransEffect::EApplicationStartSwitch:
  4680                     case AknTransEffect::EApplicationStartSwitchRect:
  4996                     case AknTransEffect::EApplicationStartSwitchRect:
  4681                     case KAlfFSTaskSwapperAppStart:
  4997                     case KAlfFSTaskSwapperAppStart:
  4682                         {
  4998                         {
  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
       
  4684                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
       
  4685                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4999                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4686                         if (iFSFXDataPart2)
  5000                         if (iFSFXDataPart2)
  4687                             {
  5001                             {
  4688                             iFSFXDataPart2->iEffectType = CFullScreenEffectState::EStartEffect; 
  5002                             iFSFXDataPart2->iEffectType = CFullScreenEffectState::EStartEffect; 
  4689                             }
  5003                             }
  4762                         aToLayout->iOpacity.Set(1.0f);
  5076                         aToLayout->iOpacity.Set(1.0f);
  4763                         }
  5077                         }
  4764                         
  5078                         
  4765                     if (aToLayout)
  5079                     if (aToLayout)
  4766                         {
  5080                         {
  4767                         // if this was timeout appstart effect, we need to take screenshot at this point. 
  5081                         // 1. If this is timeout, then we should be update the 
  4768                         // It was not taken in the beginfullscreen
  5082 						//    screenshot for the long app start effect usage. 
  4769                         
  5083                         // 2. For the second part of the effect, screenshot must be 
  4770                         if (aEvent.iLongAppStartTimeout)
  5084 						//    update. Thus the transition may continue smoothly, where app_start_long.fxml finished.
       
  5085 						// 3. Sometimes BeginFullScreen has not run for the effect. For instance 
       
  5086 						//    when window group is created after EndFullScreen was received. 
       
  5087                         TBool requiresScreenshot = NeedsStoredBuffers(iHuiEnv->EffectsEngine(), *aEvent.iEffectName);
       
  5088                         TBool hasScreenshot = TBool(aToLayout->StoredRenderBuffer());
       
  5089                         if ((aEvent.iLongAppStartTimeout && !hasScreenshot)  // (1)
       
  5090                                 || aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive // (2) 
       
  5091 								|| (requiresScreenshot && !hasScreenshot) // (3)
       
  5092                                 )
  4771                             {
  5093                             {
  4772                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL  - taking screenshot for the timeout appstart effect. Handle: %d",  aEvent.iHandle );
  5094                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL  - taking screenshot for the timeout appstart effect. Handle: %d",  aEvent.iHandle );
  4773                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  5095                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  4774                             TBool neededStoredBuffers(EFalse); // dummy 
  5096                             TBool neededStoredBuffers(EFalse); // dummy 
  4775                             StoreLayoutIfRequiredByEffectL(aToLayout, aEvent, neededStoredBuffers);
  5097                             StoreLayoutIfRequiredByEffectL(aToLayout, aEvent, neededStoredBuffers);
  4806                                 // Only changing the effect is required.
  5128                                 // Only changing the effect is required.
  4807                                 layoutEffectable = ETrue; 
  5129                                 layoutEffectable = ETrue; 
  4808                                 }
  5130                                 }
  4809                             else
  5131                             else
  4810                                 {
  5132                                 {
       
  5133 								// SetupEffectLayoutContainerL always returns ETrue. Code cleanup needed.
  4811                                 layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle,aToLayout, ETrue, EFalse, aEvent.iCanDestroyOrHideImmediately);
  5134                                 layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle,aToLayout, ETrue, EFalse, aEvent.iCanDestroyOrHideImmediately);
  4812                                 }
  5135                                 }
  4813                             aEvent.iSetupDone = layoutEffectable; 
  5136                             aEvent.iSetupDone = ETrue;
       
  5137                             if (iFSFXDataPart2)
       
  5138                                 {
       
  5139                                 iFSFXDataPart2->iSetupDone = aEvent.iSetupDone;
       
  5140                                 }
  4814                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  5141                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  4815                             }
  5142                             }
  4816 
  5143 
  4817                         if (layoutEffectable)
  5144                         if (layoutEffectable) // Note, this is always ETrue
  4818                             {
  5145                             {
  4819                             TInt effectFlags = 0;
  5146                             TInt effectFlags = 0;
  4820                             TInt activeEffectGroup = engine->ActiveGroupEffect();
  5147                             TInt activeEffectGroup = engine->ActiveGroupEffect();
  4821                             if (activeEffectGroup != KErrNotFound)
  5148                             if (activeEffectGroup != KErrNotFound)
  4822                                 {
  5149                                 {
  4823                                 engine->AddEffectToGroup(activeEffectGroup);
  5150                                 engine->AddEffectToGroup(activeEffectGroup);
  4824                                 }
  5151                                 }
  4825                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Active effect group: %d", activeEffectGroup);
  5152                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Active effect group: %d", activeEffectGroup);
  4826                             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
  5153                             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
  4827                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName) ||
  5154                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName))
  4828                                     aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive)
       
  4829                                 {
  5155                                 {
  4830                                 effectFlags |= KHuiFxOpaqueHint;
  5156                                 effectFlags |= KHuiFxOpaqueHint;
  4831                                 }
  5157                                 }
  4832                             if (iFSFXDataPart2)
  5158                             if (iFSFXDataPart2)
  4833                                 {
  5159                                 {
  4895 		__ALFFXLOGSTRING3("CAlfBridge::FreezeLayoutUntilEffectDestroyed - Storing SecureId x%x, StoreRenderBufferStartL call returned: %d for layout 0x%x", aLayout->Owner().ControlGroup()->SecureId(), err, aLayout);
  5221 		__ALFFXLOGSTRING3("CAlfBridge::FreezeLayoutUntilEffectDestroyed - Storing SecureId x%x, StoreRenderBufferStartL call returned: %d for layout 0x%x", aLayout->Owner().ControlGroup()->SecureId(), err, aLayout);
  4896 		if (err == KErrNone)
  5222 		if (err == KErrNone)
  4897 			{
  5223 			{
  4898             // Freeze only, if buffer was reserved succesfully 
  5224             // Freeze only, if buffer was reserved succesfully 
  4899             aLayout->SetFreezeState(ETrue);
  5225             aLayout->SetFreezeState(ETrue);
  4900         	TBool itemsDestroyed;
  5226         	if (!HasActiveEffect(aLayout))
  4901     	    AddFxItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
  5227         	    {
       
  5228         	    TBool itemsDestroyed;
       
  5229         	    AddFxItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
       
  5230         	    }
  4902 	        iFSFxData->iAppStartScreenshotItemHandle = aHandle;
  5231 	        iFSFxData->iAppStartScreenshotItemHandle = aHandle;
  4903 			}
  5232 			}
  4904         }
  5233         }
  4905     }
  5234     }
  4906 
  5235 
  5007     TInt operation = stream.ReadInt32L();
  5336     TInt operation = stream.ReadInt32L();
  5008     
  5337     
  5009     // If we are in low memory state, we don't want to do any effects
  5338     // If we are in low memory state, we don't want to do any effects
  5010     if(iHuiEnv->MemoryLevel() < EHuiMemoryLevelReduced)
  5339     if(iHuiEnv->MemoryLevel() < EHuiMemoryLevelReduced)
  5011         {
  5340         {
  5012         __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Returning because memory level below NORMAL");
  5341         __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - WARNING! - Returning because memory level below NORMAL - EFFECT IS NOT SHOWN!");
  5013 		stream.Release();
  5342 		stream.Release();
  5014         return;
  5343         return;
  5015         }
  5344         }
  5016      
  5345      
  5017     if ( operation == MAlfGfxEffectPlugin::EBeginFullscreen )
  5346     if ( operation == MAlfGfxEffectPlugin::EBeginFullscreen )
  5245         if (fxData && 
  5574         if (fxData && 
  5246                 toGroup 
  5575                 toGroup 
  5247                 && fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen 
  5576                 && fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen 
  5248                 && fxData->iEffectType == CFullScreenEffectState::EStartEffect)
  5577                 && fxData->iEffectType == CFullScreenEffectState::EStartEffect)
  5249             {
  5578             {
       
  5579             __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Try triggering effect immediately");
  5250             GfxTriggerEffectWhenFullScreenDrawn(toGroup);
  5580             GfxTriggerEffectWhenFullScreenDrawn(toGroup);
  5251             }
  5581             }
  5252         }
  5582         }
  5253     
  5583     
  5254     for (TInt i = 0; i < iAlfScreens.Count(); i++)
  5584     for (TInt i = 0; i < iAlfScreens.Count(); i++)
  5294     TBool fullscreenCovered(EFalse);
  5624     TBool fullscreenCovered(EFalse);
  5295     TInt dummy = 0;
  5625     TInt dummy = 0;
  5296     
  5626     
  5297     CHuiControl& control = aToGroup->Control(0);
  5627     CHuiControl& control = aToGroup->Control(0);
  5298     CHuiLayout* toLayout = control.VisualCount() > 0 ? (CHuiLayout*)&control.Visual(0) : NULL;
  5628     CHuiLayout* toLayout = control.VisualCount() > 0 ? (CHuiLayout*)&control.Visual(0) : NULL;
  5299     if (!toLayout)
  5629     if (!toLayout || (toLayout->Flags() & EHuiVisualFlagInactive ))
  5300         {
  5630         {
  5301         // no point starting effect, if the layout is still inactive.
  5631         // no point starting effect, if the layout is still inactive.
       
  5632 		__ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - Do not trigger. Layout 0x%x inactive or not found.", toLayout);
  5302         return EFalse;
  5633         return EFalse;
  5303         }
  5634         }
  5304     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
  5635     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
  5305     IsFullScreenDrawnRecursive(toLayout, *aToGroup, control, fullscreenCovered, fullscreen, screen, dummy, opaque, iAlfScreens[0]->iDisplay->Orientation());
  5636     IsFullScreenDrawnRecursive(toLayout, *aToGroup, control, fullscreenCovered, fullscreen, screen, dummy, opaque, iAlfScreens[0]->iDisplay->Orientation());
  5306     fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
  5637     fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
  5307     // alf content check is relavant only for alf apps
  5638     // alf content check is relavant only for alf apps
  5308     if (!fullscreenCovered && aToGroup->iAlfApp) 
  5639     if (!fullscreenCovered && aToGroup->iAlfApp) 
  5309         {
  5640         {
  5310         TInt clientGroupId = FindClientWindowGroupId(0, *aToGroup);
  5641         TInt clientGroupId = FindClientWindowGroupId(*aToGroup);
  5311         if (clientGroupId != KErrNotFound)
  5642         if (clientGroupId != KErrNotFound)
  5312             {
  5643             {
  5313             fullscreenCovered = HasActiveAlfContent(clientGroupId);
  5644             fullscreenCovered = HasActiveAlfContent(clientGroupId);
  5314             }
  5645             }
  5315         }
  5646         }
  5657         }
  5988         }
  5658     
  5989     
  5659     CControlEffectState* fxData = new (ELeave) CControlEffectState;
  5990     CControlEffectState* fxData = new (ELeave) CControlEffectState;
  5660     CleanupStack::PushL(fxData);
  5991     CleanupStack::PushL(fxData);
  5661     fxData->ConstructL(action, stream);
  5992     fxData->ConstructL(action, stream);
  5662     iControlEffectData = fxData;
  5993     
  5663     CleanupStack::Pop(fxData);
       
  5664 
       
  5665     // We now have all the data sent to us.
  5994     // We now have all the data sent to us.
  5666     stream.Release();
  5995     stream.Release();
  5667 
  5996 
  5668     // We need to pass the filename from the transeffect plugin that handles the controls
  5997     // We need to pass the filename from the transeffect plugin that handles the controls
  5669     // that define which effect is used for the selected skin or the selected application
  5998     // that define which effect is used for the selected skin or the selected application
  5672 
  6001 
  5673     CHuiCanvasVisual* visual = FindVisualByClientSideIds(fxData->iClientHandle, fxData->iClientGroupHandle);
  6002     CHuiCanvasVisual* visual = FindVisualByClientSideIds(fxData->iClientHandle, fxData->iClientGroupHandle);
  5674 
  6003 
  5675     if (visual)
  6004     if (visual)
  5676         {
  6005         {
  5677         HandleGfxControlEventL(*iControlEffectData, visual);
  6006         HandleGfxControlEventL(*fxData, visual);
       
  6007         CleanupStack::PopAndDestroy(fxData);
  5678         }
  6008         }
  5679     else
  6009     else
  5680         {
  6010         {
       
  6011        iControlEffectData = fxData; // move ownership
       
  6012         // Control was not found. Apply effect later when control appears in HandleNewWindow
  5681         __ALFFXLOGSTRING2("CAlfBridge::HandleGfxControlEffectsL - Control not found. iClientHandle %d, iClientGroupHandle %d", 
  6013         __ALFFXLOGSTRING2("CAlfBridge::HandleGfxControlEffectsL - Control not found. iClientHandle %d, iClientGroupHandle %d", 
  5682                 iControlEffectData->iClientHandle, 
  6014                 iControlEffectData->iClientHandle, 
  5683                 iControlEffectData->iClientGroupHandle);
  6015                 iControlEffectData->iClientGroupHandle);
       
  6016        CleanupStack::Pop(fxData);
  5684         return;
  6017         return;
  5685         }
  6018         }
  5686     iAlfScreens[0]->iDisplay->SetDirty();
  6019     iAlfScreens[0]->iDisplay->SetDirty();
  5687     iHuiEnv->ContinueRefresh();
  6020     iHuiEnv->ContinueRefresh();
  5688 
       
  5689     delete iControlEffectData;
       
  5690     iControlEffectData = NULL;
       
  5691 
  6021 
  5692     __ALFFXLOGSTRING("HandleGfxControlEffectsL - end");
  6022     __ALFFXLOGSTRING("HandleGfxControlEffectsL - end");
  5693     }
  6023     }
  5694 
  6024 
  5695 void CAlfBridge::HandleGfxControlEventL(CControlEffectState& aEvent,
  6025 void CAlfBridge::HandleGfxControlEventL(CControlEffectState& aEvent,
  5935                 sourceViz->Layout()->Remove(sourceViz);
  6265                 sourceViz->Layout()->Remove(sourceViz);
  5936                 }
  6266                 }
  5937             sourceViz->Owner().Remove(sourceViz);
  6267             sourceViz->Owner().Remove(sourceViz);
  5938              
  6268              
  5939             delete sourceViz;
  6269             delete sourceViz;
  5940             __ALFFXLOGSTRING1("CAlfBridge::RemoveTemporaryPresenterItem - Destroying sourceViz: 0x%x", sourceViz);
  6270             __ALFFXLOGSTRING1("CAlfBridge::CleanFxItem - Destroying sourceViz: 0x%x", sourceViz);
  5941             aEffectItem.iEffectedVisual = NULL;
  6271             aEffectItem.iEffectedVisual = NULL;
  5942             }
  6272             }
  5943         else
  6273         else
  5944             {
  6274             {
  5945             DestroyWindow(sourceViz, ETrue);
  6275             DestroyWindow(sourceViz, ETrue);
  5950 
  6280 
  5951 // CleanFxVisual removes the temporary presenter visual, and unbinds it from the source. 
  6281 // CleanFxVisual removes the temporary presenter visual, and unbinds it from the source. 
  5952 TBool CAlfBridge::CleanFxVisual(CHuiVisual* aVisual,
  6282 TBool CAlfBridge::CleanFxVisual(CHuiVisual* aVisual,
  5953         TInt aHandle)
  6283         TInt aHandle)
  5954     {
  6284     {
  5955     __ALFFXLOGSTRING2("CAlfBridge::RemoveTemporaryPresenterVisual - cleaning handle: %d, 0x%x", aHandle, aVisual);
  6285     __ALFFXLOGSTRING2("CAlfBridge::CleanFxVisual - cleaning handle: %d, 0x%x", aHandle, aVisual);
  5956     TInt visualsRemoved = 0;
  6286     TInt visualsRemoved = 0;
  5957     for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  6287     for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
  5958         {
  6288         {
  5959         TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  6289         TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
  5960         if (aVisual == effectItem.iEffectedVisual || 
  6290         if (aVisual == effectItem.iEffectedVisual || 
  6560 
  6890 
  6561     if (!iSwRenderingEnabled && iManualRefreshTimer)
  6891     if (!iSwRenderingEnabled && iManualRefreshTimer)
  6562         {
  6892         {
  6563         iManualRefreshTimer->Cancel();
  6893         iManualRefreshTimer->Cancel();
  6564         }
  6894         }
       
  6895     if (!aEnable)
       
  6896         {
       
  6897         ClearRasterizerCache();
       
  6898         }
       
  6899 
       
  6900 #ifdef ALF_MEMORYLOGGING
       
  6901     ReportMemory();
       
  6902 #endif
  6565     }
  6903     }
  6566 
  6904 
  6567 // ---------------------------------------------------------------------------
  6905 // ---------------------------------------------------------------------------
  6568 // ---------------------------------------------------------------------------
  6906 // ---------------------------------------------------------------------------
  6569 // 
  6907 // 
  7169         if ( visualIsActive )
  7507         if ( visualIsActive )
  7170             {
  7508             {
  7171             TRect displayRect = visualDisplayRect;
  7509             TRect displayRect = visualDisplayRect;
  7172             visualDisplayRect = canvasVisual->CommandBufferCoverage(aOrientation);
  7510             visualDisplayRect = canvasVisual->CommandBufferCoverage(aOrientation);
  7173 
  7511 
       
  7512             if (aDuration <= KAlfCheckVisualIsNotReady && !visualRectIsCovered && visualIsVisible && 
       
  7513                 !displayRect.IsEmpty() && (canvasVisual->CanvasFlags() & EHuiCanvasVisualFlagNotReady))
       
  7514                 {
       
  7515                 __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - invalid screen device reachable");                 
       
  7516                 visualTreeReady = EFalse;
       
  7517                 break;
       
  7518                 }
       
  7519 
  7174             // Heuristic: Check that visual drawing isn't completely empty.
  7520             // Heuristic: Check that visual drawing isn't completely empty.
  7175             if ( aDuration <= KAlfCheckVisualDrawingNotEmpty && !visualRectIsCovered &&
  7521             if ( aDuration <= KAlfCheckVisualDrawingNotEmpty && !visualRectIsCovered &&
  7176                  visualIsVisible && visualDisplayRect.IsEmpty() )
  7522                  visualIsVisible && visualDisplayRect.IsEmpty() )
  7177                 {
  7523                 {
  7178                 __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - no drawing");
  7524                 __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - no drawing");
  7249         } // for loop end : children checking loop
  7595         } // for loop end : children checking loop
  7250      
  7596      
  7251     return visualTreeReady;
  7597     return visualTreeReady;
  7252     }
  7598     }
  7253 
  7599 
       
  7600 // ---------------------------------------------------------------------------
       
  7601 // ---------------------------------------------------------------------------
       
  7602 // 
       
  7603 TBool CAlfBridge::IsVisualNotReadyReachable()
       
  7604     {
       
  7605     TBool invalidReachable = ETrue;
       
  7606 
       
  7607     if (!iAlfScreens.Count())
       
  7608         {
       
  7609         return EFalse;
       
  7610         }
       
  7611    
       
  7612     iTempRegion.Clear();
       
  7613     iTempRegion2.Clear();
       
  7614     
       
  7615     CAlfScreen* screen = iAlfScreens[0];
       
  7616     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
       
  7617     TInt orientation = screen->iDisplay->Orientation();
       
  7618     
       
  7619     TBool fullscreenCovered = EFalse;
       
  7620 	TBool alfClientWindowGroupVisible = EFalse;
       
  7621 		
       
  7622     // Skip the topmost (effect) layer, start from floating sprite group
       
  7623     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
       
  7624         {                
       
  7625         CHuiControlGroup& controlgroup = screen->iDisplay->Roster().ControlGroup(j);
       
  7626         CHuiControl& control = controlgroup.Control(0);
       
  7627 
       
  7628         if (control.Role() == EHuiFpsIndicatorContainer)
       
  7629             {
       
  7630             // FPS container doesn't contain canvas visuals
       
  7631             continue;
       
  7632             }
       
  7633 
       
  7634         CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
       
  7635         
       
  7636         // For optimization reasons, check if all visuals below in Z-order are covered    
       
  7637         if (!fullscreenCovered)
       
  7638             {
       
  7639             fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);            
       
  7640             }    
       
  7641     
       
  7642         if (fullscreenCovered)
       
  7643             {
       
  7644             break;
       
  7645             }    
       
  7646         
       
  7647         // ALF applications are handled by checking if their visuals cover the whole screen.
       
  7648         if (control.Role() == EHuiSessionContainer)
       
  7649             {
       
  7650             CHuiLayout* hostContainer = control.ContainerLayout( NULL );
       
  7651             TInt flags = hostContainer->Flags();            
       
  7652             if (alfClientWindowGroupVisible)
       
  7653                 {
       
  7654                 // check visual sizes if client has not made this control group hidden
       
  7655                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
       
  7656                     {
       
  7657                     if(iAppUi)
       
  7658                         {
       
  7659                         CAlfAppSrvSessionBase* alfSrvSession = iAppUi->SrvSessionForControlGroup(controlgroup);
       
  7660                         
       
  7661                         TInt clientWindowGroupId = alfSrvSession->ClientWindowGroup();
       
  7662                         // checking the case if there are multiple alf application openend.
       
  7663                         if (clientWindowGroupId == iAppUi->GetLastActiveClient())
       
  7664                             {
       
  7665                             return EFalse;
       
  7666                             }
       
  7667                         }
       
  7668                     }
       
  7669                 }
       
  7670             continue;
       
  7671             }
       
  7672         
       
  7673         TBool hasActiveVisualsInVisualTree(EFalse);
       
  7674         
       
  7675         if (alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId))
       
  7676             {
       
  7677             invalidReachable =
       
  7678                IsVisualNotReadyReachableRecursive( layout, controlgroup, control, 
       
  7679                    hasActiveVisualsInVisualTree, fullscreen, screen, 
       
  7680                    IsVisualOpaque(*layout), alfClientWindowGroupVisible);            
       
  7681             }
       
  7682         else
       
  7683             {
       
  7684             invalidReachable =
       
  7685                IsVisualNotReadyReachableRecursive( layout, controlgroup, control, 
       
  7686                    fullscreenCovered, fullscreen, screen, 
       
  7687                    IsVisualOpaque(*layout), EFalse);      
       
  7688             }
       
  7689 
       
  7690         if (invalidReachable)
       
  7691             {
       
  7692             // Problem found in IsInvalidScreenDeviceVisualReachableRecursive
       
  7693             break;
       
  7694             }
       
  7695 
       
  7696         if ( controlgroup.iAlfApp && layout->iOpacity.Now() > 0.0f )
       
  7697             {
       
  7698             alfClientWindowGroupVisible = ETrue;
       
  7699             }
       
  7700         }
       
  7701 
       
  7702     iTempRegion2.Clear();
       
  7703     
       
  7704     return invalidReachable;
       
  7705     }
       
  7706 
       
  7707 // ---------------------------------------------------------------------------
       
  7708 // ---------------------------------------------------------------------------
       
  7709 // 
       
  7710 TBool CAlfBridge::IsVisualNotReadyReachableRecursive(
       
  7711         CHuiLayout* aLayout,
       
  7712         CHuiControlGroup& aControlGroup,
       
  7713         CHuiControl& aControl,
       
  7714         TBool& aFullscreenCovered, 
       
  7715         const TRect& aFullscreen,
       
  7716         CAlfScreen* aScreen,
       
  7717         TBool aChildCanBeOpaque, 
       
  7718         TBool aOnlyForEmbeddedAlfApp)
       
  7719     {
       
  7720     TBool invalidReachable = EFalse;
       
  7721     TRect visualDisplayRect;
       
  7722     TBool visualRectIsCovered = EFalse;
       
  7723     TBool visualIsOpaque = EFalse;
       
  7724     TBool visualIsActive = EFalse;
       
  7725     CHuiCanvasVisual* canvasVisual = NULL;
       
  7726 
       
  7727     for (TInt i = aLayout->Count() - 1; i >= 0; i--)
       
  7728         {
       
  7729         visualDisplayRect = TRect(0,0,0,0);
       
  7730         visualRectIsCovered = EFalse;
       
  7731         visualIsOpaque = EFalse;
       
  7732         visualIsActive = EFalse;
       
  7733         
       
  7734         canvasVisual = (CHuiCanvasVisual*)(&aLayout->Visual(i));
       
  7735 
       
  7736         // Distraction windows are completely ignored.
       
  7737         TBool distractionWindow = (canvasVisual->CanvasFlags() & EHuiCanvasFlagDistractionWindow);
       
  7738         if ( distractionWindow )
       
  7739             {
       
  7740             continue;
       
  7741             }
       
  7742 
       
  7743         visualIsOpaque = aChildCanBeOpaque && IsVisualOpaque(*canvasVisual);
       
  7744         TBool visualIsVisible = (canvasVisual->iOpacity.Now() > 0.01f);       
       
  7745         
       
  7746         if (canvasVisual->Count() && visualIsVisible)
       
  7747             {
       
  7748             invalidReachable = IsVisualNotReadyReachableRecursive( canvasVisual, aControlGroup, aControl, 
       
  7749                 aFullscreenCovered, aFullscreen, aScreen, 
       
  7750                 visualIsOpaque, EFalse);
       
  7751                 
       
  7752             if (invalidReachable)
       
  7753                 {
       
  7754                 break;
       
  7755                 }
       
  7756             }
       
  7757 
       
  7758         // Calculate visual display rect
       
  7759         visualDisplayRect = canvasVisual->DisplayRect();
       
  7760     
       
  7761         ClipVisualRect(visualDisplayRect, aLayout->DisplayRect());
       
  7762         ClipVisualRect(visualDisplayRect, aFullscreen);
       
  7763         
       
  7764         // Check if covered.
       
  7765         if (aFullscreenCovered)
       
  7766             {
       
  7767             visualRectIsCovered = ETrue;    
       
  7768             }
       
  7769         else
       
  7770             {            
       
  7771             // Check if this visual is covered by other opaque visuals which rects are in "covered" region
       
  7772             // it should not check for alf event window group, when we have embedded alf application,
       
  7773             // because we have assumed that alf app will have full screen covered
       
  7774             if(!aOnlyForEmbeddedAlfApp)
       
  7775                 {
       
  7776                 visualRectIsCovered = IsRectCoveredByRegion(visualDisplayRect, iTempRegion);
       
  7777                 }                                
       
  7778             }
       
  7779     
       
  7780 	    // Determine if visual is active from coverage point of view.
       
  7781         visualIsActive = EFalse;
       
  7782         if (visualRectIsCovered)
       
  7783             {                                        
       
  7784             if (!(canvasVisual->Flags() & EHuiVisualFlagAlwaysDraw)) 
       
  7785                 {
       
  7786                 visualIsActive = EFalse;                
       
  7787                 }
       
  7788             else
       
  7789                 { 
       
  7790                 visualIsActive = ETrue;
       
  7791                 }                
       
  7792             }
       
  7793         else
       
  7794             {
       
  7795 			visualIsActive = ETrue;
       
  7796             }
       
  7797         
       
  7798         // Sprites and effects as we consider them always as transparent and also
       
  7799         // if controlgroup is transformed somehow    
       
  7800         if (aControl.Role() == EHuiFullScreenEffectContainer || 
       
  7801             aControl.Role() == EHuiWindowFloatingSpriteContainer ||
       
  7802             aControlGroup.IsTransformed())
       
  7803             {
       
  7804             visualIsOpaque = EFalse;    
       
  7805             }
       
  7806            
       
  7807         // Check that command buffers are ok.
       
  7808         if ( visualIsActive )
       
  7809             {
       
  7810             if (!visualRectIsCovered && visualIsVisible && !visualDisplayRect.IsEmpty() && 
       
  7811                 (canvasVisual->CanvasFlags() & EHuiCanvasVisualFlagNotReady))
       
  7812                 {
       
  7813                 __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready reachable");                   
       
  7814                 invalidReachable = ETrue;
       
  7815                 break;
       
  7816                 }
       
  7817             }
       
  7818 			
       
  7819         if (visualIsActive && visualIsOpaque && !visualRectIsCovered)
       
  7820             { 
       
  7821             // New visibility system takes only window shape into account.
       
  7822             if ( canvasVisual->CanvasFlags() & EHuiCanvasFlagIncludeToVisibilityCalculation )
       
  7823                 {
       
  7824                 if ( !canvasVisual->HasCustomShape() )
       
  7825                     {                    
       
  7826                     TRect displayRect(canvasVisual->DisplayRect());
       
  7827                     ClipVisualRect(displayRect, aLayout->DisplayRect());
       
  7828                     ClipVisualRect(displayRect, aFullscreen);
       
  7829 
       
  7830                     iTempRegion.AddRect(displayRect);
       
  7831                     iTempRegion.Tidy();
       
  7832                     }
       
  7833                 else
       
  7834                     {
       
  7835                     TRect displayRect = canvasVisual->DisplayRect();
       
  7836                     const TRegion& region = canvasVisual->ShapeRegion();
       
  7837                     TPoint delta = -canvasVisual->ShapeOrigin() + displayRect.iTl;
       
  7838                 
       
  7839                     for (TInt i = 0; i < region.Count(); ++i)
       
  7840                         {
       
  7841                         TRect coveredRect(region[i]);
       
  7842                         coveredRect.Move(delta);
       
  7843                         ClipVisualRect(coveredRect, aFullscreen);
       
  7844 
       
  7845                         iTempRegion.AddRect(coveredRect);
       
  7846                         }
       
  7847                     iTempRegion.Tidy();
       
  7848                     }
       
  7849                 }
       
  7850             }        
       
  7851         } // for loop end : children checking loop
       
  7852      
       
  7853     return invalidReachable;
       
  7854     }
       
  7855 
  7254 TBool CAlfBridge::IsFullScreenDrawnRecursiveAlfContent(CHuiVisual* aVisual, TRect& aFullScreen)
  7856 TBool CAlfBridge::IsFullScreenDrawnRecursiveAlfContent(CHuiVisual* aVisual, TRect& aFullScreen)
  7255     {
  7857     {
  7256     if(aVisual)
  7858     if(aVisual)
  7257         {
  7859         {
  7258         TInt flags = aVisual->Flags();
  7860         TInt flags = aVisual->Flags();
  7537             }
  8139             }
  7538         }
  8140         }
  7539     return hasAlfContent;
  8141     return hasAlfContent;
  7540     }
  8142     }
  7541 
  8143 
       
  8144 void CAlfBridge::ReportMemory()
       
  8145     {
       
  8146 #ifdef ALF_MEMORYLOGGING
       
  8147     TInt totalSpaceAllocated = 0;
       
  8148     TInt cellsAllocatedInHeap = User::AllocSize(totalSpaceAllocated);
       
  8149     TInt largestFreeBlock = 0;
       
  8150     TInt totalFreeSpaceInHeap = User::Available(largestFreeBlock);
       
  8151     TInt freeRAM = 0;
       
  8152     if ( HAL::Get( HALData::EMemoryRAMFree, freeRAM ) != KErrNone )
       
  8153         {
       
  8154         freeRAM = -1;
       
  8155         }
       
  8156     TInt timestamp = User::NTickCount();
       
  8157         
       
  8158     RDebug::Printf("%x CAlfBridge::ReportMemory - Allocated space: %d, Amount of allocated cells: %d, Largest free block: %d, Free space in heap: %d",
       
  8159             timestamp,
       
  8160             totalSpaceAllocated,
       
  8161             cellsAllocatedInHeap,
       
  8162             largestFreeBlock,
       
  8163             totalFreeSpaceInHeap);
       
  8164     RDebug::Printf("%x CAlfBridge::ReportMemory - Free RAM in system: %d", timestamp, freeRAM);
       
  8165 #endif    
       
  8166     }
       
  8167 
       
  8168 void CAlfBridge::ClearRasterizerCache()
       
  8169     {
       
  8170     CFbsRasterizer* rasterizer = CFbsBitmap::Rasterizer();
       
  8171     MFbsRasterizerClearCache* cacheInterfacePtr = NULL;
       
  8172     rasterizer->GetInterface(TUid::Uid(KUidFbsRasterizerClearCache), (TAny*&)cacheInterfacePtr);
       
  8173     if (cacheInterfacePtr)
       
  8174         {
       
  8175         cacheInterfacePtr->ClearCache();
       
  8176         }
       
  8177     }
       
  8178 
  7542 // end of file
  8179 // end of file