uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
branchRCL_3
changeset 9 3ac8bf5c5014
parent 8 46927d61fef3
child 10 7c5dd702d6d3
equal deleted inserted replaced
8:46927d61fef3 9:3ac8bf5c5014
    89 const TReal32 KAlfVisualDefaultOpacity = 1.0f;
    89 const TReal32 KAlfVisualDefaultOpacity = 1.0f;
    90 //const TReal32 KAlfVisualDefaultOpacity = 0.5f;
    90 //const TReal32 KAlfVisualDefaultOpacity = 0.5f;
    91 const TInt KEffectCleanupDelayInMs = 10;
    91 const TInt KEffectCleanupDelayInMs = 10;
    92 
    92 
    93 const TInt KPreventingCollisionOfIdsInSynchDrawRequests = 35;
    93 const TInt KPreventingCollisionOfIdsInSynchDrawRequests = 35;
    94 
    94 const TInt KRequestFrameSynchForComposition = -1; // bogus
       
    95 
       
    96 const TInt KAlfFSTaskSwapperAppStart = 1507;
    95 _LIT8(KAlfWindowGroupContainerControlTag, "WGROUP");
    97 _LIT8(KAlfWindowGroupContainerControlTag, "WGROUP");
    96 
    98 
    97 #define USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
    99 #define USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
    98 // This debug option shows window groups in a grid
   100 // This debug option shows window groups in a grid
    99 //#define ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
   101 //#define ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
   100 
   102 
       
   103 // Timeout for manual refresh
       
   104 const TInt KAlfManualRefreshTimeout = 35000;
   101 
   105 
   102 const TInt KFadeAction = 6000;
   106 const TInt KFadeAction = 6000;
   103 
   107 
   104 NONSHARABLE_CLASS( TAlfBridgeDrawerWrapper ) : public MAlfDrawerScreenInterface
   108 NONSHARABLE_CLASS( TAlfBridgeDrawerWrapper ) : public MAlfDrawerScreenInterface
   105     {
   109     {
   172 #ifdef HUI_DEBUG_TRACK_DRAWING
   176 #ifdef HUI_DEBUG_TRACK_DRAWING
   173     delete iCommandDebug;
   177     delete iCommandDebug;
   174 #endif
   178 #endif
   175     delete iCursorTimer;
   179     delete iCursorTimer;
   176     delete iLayoutSwitchEffectCoordinator;
   180     delete iLayoutSwitchEffectCoordinator;
       
   181     delete iManualRefreshTimer;
   177 	}
   182 	}
   178     
   183     
   179 
   184 
   180 // ---------------------------------------------------------------------------
   185 // ---------------------------------------------------------------------------
   181 // ---------------------------------------------------------------------------
   186 // ---------------------------------------------------------------------------
   213 	// Create control for the orphaned windows, which control group id deleted before them
   218 	// Create control for the orphaned windows, which control group id deleted before them
   214     iOrphanStorage = new (ELeave) CHuiControl(*iHuiEnv);
   219     iOrphanStorage = new (ELeave) CHuiControl(*iHuiEnv);
   215     iOrphanStorage->ConstructL();
   220     iOrphanStorage->ConstructL();
   216 	
   221 	
   217     RegisterFadeEffectL();
   222     RegisterFadeEffectL();
       
   223     
       
   224     iManualRefreshTimer = CPeriodic::NewL(CActive::EPriorityStandard);
   218     }
   225     }
   219 
   226 
   220 // ---------------------------------------------------------------------------
   227 // ---------------------------------------------------------------------------
   221 //  RegisterFadeEffectL
   228 //  RegisterFadeEffectL
   222 //
   229 //
   785                 fromLayout = (CHuiLayout*)&control2.Visual(0);
   792                 fromLayout = (CHuiLayout*)&control2.Visual(0);
   786                 }
   793                 }
   787             
   794             
   788             
   795             
   789             // First HandleGfxEvent, then clear iWaitingWindowGroup.
   796             // First HandleGfxEvent, then clear iWaitingWindowGroup.
       
   797             __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - try triggering effect 0x%x", layout);
   790             TBool failed = HandleGfxEventL( *iFullScreenEffectData, layout, fromLayout );
   798             TBool failed = HandleGfxEventL( *iFullScreenEffectData, layout, fromLayout );
   791             if ( iFullScreenEffectData )
   799             if ( iFullScreenEffectData )
   792                 {
   800                 {
   793                 iFullScreenEffectData->iWaitingWindowGroup = EFalse;
   801                 iFullScreenEffectData->iWaitingWindowGroup = EFalse;
   794                 }
   802                 }
   795             if ( failed )
   803             if ( failed )
   796                 {
   804                 {
   797                 // Effect failed, reset state
   805                 // Effect failed, reset state
       
   806                 __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - effect failed on layout 0x%x", layout);
   798                 HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
   807                 HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
   799                 }
   808                 }
   800             }     
   809             }     
   801         entry.iScreenNumber = aScreenNumber;
   810         entry.iScreenNumber = aScreenNumber;
   802 //        entry.iRole = EAlfWindowGroupContainer;
   811 //        entry.iRole = EAlfWindowGroupContainer;
  1353             
  1362             
  1354     iTempRegion.Clear();
  1363     iTempRegion.Clear();
  1355     
  1364     
  1356     CAlfScreen* screen = iAlfScreens[aScreenNumber];
  1365     CAlfScreen* screen = iAlfScreens[aScreenNumber];
  1357     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
  1366     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
  1358     TBool fadeEffectInScreen = EFalse;
  1367     TBool checkFadeEffectInScreen = EFalse;
  1359     
  1368     
  1360     
  1369     
  1361     // Prepare SW render target (if needed)
  1370     // Prepare SW render target (if needed)
  1362     if (iSwRenderingEnabled)
  1371     if (iSwRenderingEnabled)
  1363         {
  1372         {
  1443             if (!fullscreenCovered || alfClientWindowGroupVisible)
  1452             if (!fullscreenCovered || alfClientWindowGroupVisible)
  1444                 {
  1453                 {
  1445                 // clear inactive flag if client has not made this controlgroup hidden
  1454                 // clear inactive flag if client has not made this controlgroup hidden
  1446                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
  1455                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
  1447                     {
  1456                     {
  1448                     alfWindowGroupFoundVisible = ETrue;
       
  1449                     if(iAppUi)
  1457                     if(iAppUi)
  1450                         {
  1458                         {
  1451                         topMostAlfSrvSession = iAppUi->SrvSessionForControlGroup(controlgroup);
  1459                         topMostAlfSrvSession = iAppUi->SrvSessionForControlGroup(controlgroup);
       
  1460                         
       
  1461                         TInt clientWindowGroupId = topMostAlfSrvSession->ClientWindowGroup();
       
  1462                         __ALFLOGSTRING1("Alf Application: clientWindowGroupId %d", clientWindowGroupId);
       
  1463                         // checking the case if there are multiple alf application openend.
       
  1464                         if (clientWindowGroupId == iAppUi->GetLastActiveClient())
       
  1465                             {
       
  1466                             __ALFLOGSTRING1("Alf Application: GetLastActiveClient %d", iAppUi->GetLastActiveClient());
       
  1467                             alfWindowGroupFoundVisible = ETrue;
       
  1468                             hostContainer->ClearFlags(EHuiVisualFlagInactive);
       
  1469                             // just add the rect to covered region because alf draws solid background
       
  1470                             iTempRegion.AddRect(fullscreen);
       
  1471                             iTempRegion.Tidy();
       
  1472                             fullscreenCovered = ETrue;
       
  1473                             alfClientWindowGroupVisible = EFalse;  // change flag so that we don't go in this branch again
       
  1474                             }
  1452                         }
  1475                         }
  1453                     hostContainer->ClearFlags(EHuiVisualFlagInactive);
       
  1454 
       
  1455                     // just add the rect to covered region because alf draws solid background
       
  1456                     iTempRegion.AddRect(fullscreen);
       
  1457                     iTempRegion.Tidy();
       
  1458                     fullscreenCovered = ETrue;
       
  1459                     alfClientWindowGroupVisible = EFalse;  // change flag so that we don't go in this branch again
       
  1460                     }
  1476                     }
  1461                 else // else put as inactive
  1477                 else // else put as inactive
  1462                     {
  1478                     {
  1463                     hostContainer->SetFlags(EHuiVisualFlagInactive);
  1479                     hostContainer->SetFlags(EHuiVisualFlagInactive);
  1464                     }
  1480                     }
  1499             if (fullscreenCovered)
  1515             if (fullscreenCovered)
  1500                 __ALFLOGSTRING("Full screen covered because of frozen roster content");                    
  1516                 __ALFLOGSTRING("Full screen covered because of frozen roster content");                    
  1501 #endif
  1517 #endif
  1502             }
  1518             }
  1503         
  1519         
  1504 		// if native alf app is found visible we can assume it should cover whole screen with alfcontent
       
  1505 		// this is for embedded native alf application cases. Otherwise chained window groups tend to
       
  1506 		// flicker from time to time
       
  1507         if(!fullscreenCovered && controlgroup.iAlfApp)
       
  1508             {
       
  1509             alfClientWindowGroupVisible = ETrue;
       
  1510             }
       
  1511         
       
  1512         
       
  1513         TBool subTreeCovered = EFalse;
  1520         TBool subTreeCovered = EFalse;
  1514         TBool hasLayers = EFalse;
  1521         TBool hasLayers = EFalse;
  1515         
  1522         
  1516         TBool hasActiveVisualsInVisualTree(EFalse);
  1523         TBool hasActiveVisualsInVisualTree(EFalse);
  1517         
  1524         
  1518         //embedded native alf application assumes that it should cover whole screen with alfcontent
  1525         // native alf application assumes that it should cover whole screen with alfcontent
  1519         // it makes alfeventwindowgroup as inactive and fading is not done on alf content
  1526         // it makes alfeventwindowgroup as inactive and fading is not done on alf content
  1520         // this call is exculsive for alfeventwindowgroup 
  1527         // this call is exculsive for alfeventwindowgroup 
  1521         if (alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId))
  1528         if (alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId))
  1522             {
  1529             {
  1523             hasActiveVisualsInVisualTree = 
  1530             hasActiveVisualsInVisualTree = 
  1524                HandleLayoutVisualVisibility( layout, controlgroup, control, 
  1531                HandleLayoutVisualVisibility( layout, controlgroup, control, 
  1525                    hasActiveVisualsInVisualTree, fullscreen, screen, 
  1532                    hasActiveVisualsInVisualTree, fullscreen, screen, 
  1526                    subTreeCovered, hasLayers, IsVisualOpaque(*layout),alfClientWindowGroupVisible );
  1533                    subTreeCovered, hasLayers, IsVisualOpaque(*layout),alfClientWindowGroupVisible );
  1527             }
  1534             }
  1528         
       
  1529         else
  1535         else
  1530             {
  1536             {
  1531             hasActiveVisualsInVisualTree = 
  1537             hasActiveVisualsInVisualTree = 
  1532                HandleLayoutVisualVisibility( layout, controlgroup, control, 
  1538                HandleLayoutVisualVisibility( layout, controlgroup, control, 
  1533                    fullscreenCovered, fullscreen, screen, 
  1539                    fullscreenCovered, fullscreen, screen, 
  1535             }
  1541             }
  1536         
  1542         
  1537 
  1543 
  1538         TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
  1544         TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
  1539 
  1545 
  1540         if(!fullscreenCovered && alfClientWindowGroupVisible)
  1546         // if native alf app is found visible and the client it self is not covering whole screen, we can assume that alf content
  1541             {
  1547         // fills the rest. 
  1542             iTempRegion.AddRect(fullscreen);
  1548         // this is for embedded native alf application cases. Otherwise chained window groups tend to
  1543             iTempRegion.Tidy();
  1549         // flicker from time to time
  1544             fullscreenCovered = ETrue;
  1550         // also if alfcontent is not hided below avkon content the fading effect would reveal alfconent
       
  1551         if(controlgroup.iAlfApp)
       
  1552             {
       
  1553             fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion); 
       
  1554             if(!fullscreenCovered )
       
  1555                 {
       
  1556                 iTempRegion.AddRect(fullscreen);
       
  1557                 iTempRegion.Tidy();
       
  1558                 fullscreenCovered = ETrue;
       
  1559                 alfClientWindowGroupVisible = ETrue;
       
  1560                 }
  1545             }
  1561             }
  1546         
  1562         
  1547         // If root visuals effect is marked as opaque, then add whole screen area as covered.
  1563         // If root visuals effect is marked as opaque, then add whole screen area as covered.
  1548         if (!fullscreenCovered)
  1564         if (!fullscreenCovered)
  1549             {
  1565             {
  1558 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1574 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1559 		// flagged as containing fade effect, then run the setup as well so that effects which
  1575 		// flagged as containing fade effect, then run the setup as well so that effects which
  1560 		// are no more needed get removed.
  1576 		// are no more needed get removed.
  1561         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1577         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1562             {
  1578             {
  1563             fadeEffectInScreen = ETrue;
  1579             checkFadeEffectInScreen = ETrue;
  1564             
  1580             
  1565             // Prepare fade effects to whole visual tree  below layout
  1581             // Prepare fade effects to whole visual tree  below layout
  1566             PrepareFadeEffects( *layout );
  1582             PrepareFadeEffects( *layout );
  1567     
  1583     
  1568             // Load needed fade effects (or remove them)
  1584             // Load needed fade effects (or remove them)
  1654         }
  1670         }
  1655 
  1671 
  1656     // Finally, if there are fadeeffects applied to windowgroups, make sure first one does not
  1672     // Finally, if there are fadeeffects applied to windowgroups, make sure first one does not
  1657     // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others
  1673     // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others
  1658     // would clear the screen areas where they do not really draw.
  1674     // would clear the screen areas where they do not really draw.
  1659     if (fadeEffectInScreen)
  1675     if (checkFadeEffectInScreen)
  1660         {
  1676         {
  1661         TBool firstFadedWindowGroupFound = EFalse;
  1677         TBool firstFadedWindowGroupFound = EFalse;
  1662         for (TInt j=0; j<screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j++) // skip the topmost (effect) layer 
  1678         for (TInt j=0; j<screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j++) // skip the topmost (effect) layer 
  1663             {                
  1679             {                
  1664             CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
  1680             CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
  2426                     }
  2442                     }
  2427 	            if (iAlfScreens[0]->iDisplay->Orientation() != huiOrientation)
  2443 	            if (iAlfScreens[0]->iDisplay->Orientation() != huiOrientation)
  2428 	                {
  2444 	                {
  2429                     HandleSetLayoutSwitchEffectL();
  2445                     HandleSetLayoutSwitchEffectL();
  2430 	                iAlfScreens[0]->iDisplay->SetOrientation(huiOrientation);
  2446 	                iAlfScreens[0]->iDisplay->SetOrientation(huiOrientation);
       
  2447 	                UpdateRootVisualsToFullscreen();
  2431 	                if (iAppUi)
  2448 	                if (iAppUi)
  2432 	                	{
  2449 	                	{
  2433 	                	iAppUi->AdjustWindowGroupPositionL(0,CAlfAppServer::EAlfWindowSize); // hackish, but one way to enforce alf window resizing
  2450 	                	iAppUi->AdjustWindowGroupPositionL(0,CAlfAppServer::EAlfWindowSize); // hackish, but one way to enforce alf window resizing
  2434 	                	}
  2451 	                	}
  2435 	                __ALFLOGSTRING1("AlfScreens[0]->iDisplay->SetOrientation: %d",huiOrientation);  	                
  2452 	                __ALFLOGSTRING1("AlfScreens[0]->iDisplay->SetOrientation: %d",huiOrientation);  	                
  2469               {
  2486               {
  2470               // Should not happen
  2487               // Should not happen
  2471               __ALFLOGSTRING1("CAlfBridge::DoDispatchL: Received Unknown op: %d",data.iOp);
  2488               __ALFLOGSTRING1("CAlfBridge::DoDispatchL: Received Unknown op: %d",data.iOp);
  2472               }
  2489               }
  2473             }
  2490             }
       
  2491         
       
  2492         AsynchRefresh();
  2474         }
  2493         }
  2475    }
  2494    }
  2476 
  2495 
  2477 // ---------------------------------------------------------------------------
  2496 // ---------------------------------------------------------------------------
  2478 // HandleDestroyDisplay
  2497 // HandleDestroyDisplay
  4006             }        
  4025             }        
  4007         }    
  4026         }    
  4008     return has;
  4027     return has;
  4009     }
  4028     }
  4010 
  4029 
       
  4030 // ---------------------------------------------------------------------------
       
  4031 //
       
  4032 // ---------------------------------------------------------------------------
       
  4033 //
       
  4034 void CAlfBridge::UpdateRootVisualsToFullscreen()
       
  4035     {
       
  4036     if (!iAlfScreens.Count())
       
  4037         {
       
  4038         return;    
       
  4039         }
       
  4040     
       
  4041     // update all the layouts even inactive ones.
       
  4042     CAlfScreen* screen = iAlfScreens[0];
       
  4043     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
       
  4044     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
       
  4045         {                
       
  4046         CHuiControlGroup& controlgroup = screen->iDisplay->Roster().ControlGroup(j);
       
  4047         CHuiControl& control = controlgroup.Control(0);
       
  4048 
       
  4049         if( control.Role() == EAlfWindowGroupContainer)
       
  4050             {
       
  4051             // Only update layout which are made to correspond window groups. 
       
  4052             // Layouts that fullscreen effects are applied to
       
  4053             CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
       
  4054             layout->SetPos(fullscreen.iTl);
       
  4055             layout->SetSize(fullscreen.Size());
       
  4056             }
       
  4057         }
       
  4058     }
       
  4059 
       
  4060 
  4011 
  4061 
  4012 // ---------------------------------------------------------------------------
  4062 // ---------------------------------------------------------------------------
  4013 // SetupFadeEffectL
  4063 // SetupFadeEffectL
  4014 //
  4064 //
  4015 // NOTE: This method gets called very often, so we should not do anything time
  4065 // NOTE: This method gets called very often, so we should not do anything time
  4351     }
  4401     }
  4352 TBool NeedsStoredBuffers(CHuiFxEngine *aEngine, const TDesC &aFileName)
  4402 TBool NeedsStoredBuffers(CHuiFxEngine *aEngine, const TDesC &aFileName)
  4353     {
  4403     {
  4354     return aEngine->FxmlUsesInput1(aFileName);
  4404     return aEngine->FxmlUsesInput1(aFileName);
  4355     }
  4405     }
       
  4406 TBool FxmlHasOpaqueHint(CHuiFxEngine *aEngine, const TDesC &aFileName)
       
  4407     {
       
  4408     return aEngine->FxmlUsesOpaqueHint(aFileName);
       
  4409     }
  4356 
  4410 
  4357 // ---------------------------------------------------------------------------
  4411 // ---------------------------------------------------------------------------
  4358 // StoreLayoutIfRequiredByEffectL
  4412 // StoreLayoutIfRequiredByEffectL
  4359 //
  4413 //
  4360 // Certains effects require screenshot to be taken when BeginFullScreen event
  4414 // Certains effects require screenshot to be taken when BeginFullScreen event
  4439                     case AknTransEffect::EApplicationActivate:
  4493                     case AknTransEffect::EApplicationActivate:
  4440                     case AknTransEffect::EApplicationStart:
  4494                     case AknTransEffect::EApplicationStart:
  4441                     case AknTransEffect::EApplicationStartRect:
  4495                     case AknTransEffect::EApplicationStartRect:
  4442                     case AknTransEffect::EApplicationStartSwitch:
  4496                     case AknTransEffect::EApplicationStartSwitch:
  4443                     case AknTransEffect::EApplicationStartSwitchRect:
  4497                     case AknTransEffect::EApplicationStartSwitchRect:
       
  4498                     case KAlfFSTaskSwapperAppStart:
  4444                         {
  4499                         {
  4445                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that are not yet ready to be drawn, but possible already on the foreground
  4500                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that are not yet ready to be drawn, but possible already on the foreground
  4446                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  4501                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
  4447                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4502                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4448                         aEvent.iCanDestroyOrHideImmediately = ETrue; // enable hiding of windows during application start/activate effects
  4503                         aEvent.iCanDestroyOrHideImmediately = ETrue; // enable hiding of windows during application start/activate effects
  4543                                 {
  4598                                 {
  4544                                 engine->AddEffectToGroup(activeEffectGroup);
  4599                                 engine->AddEffectToGroup(activeEffectGroup);
  4545                                 }
  4600                                 }
  4546                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Active effect group: %d", activeEffectGroup);
  4601                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Active effect group: %d", activeEffectGroup);
  4547                             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn; 
  4602                             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn; 
  4548                             if (NeedsStoredBuffers(iHuiEnv->EffectsEngine(), *aEvent.iEffectName))
  4603                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName))
  4549                                 {
  4604                                 {
  4550                                 // Performance improvement, but this would be better to be a special hint param in the fxml
  4605                                 // Performance improvement, but this would be better to be a special hint param in the fxml
  4551                                 effectFlags |= KHuiFxOpaqueHint;
  4606                                 effectFlags |= KHuiFxOpaqueHint;
  4552                                 }
  4607                                 }
  4553                             
  4608                             
  4745             if (iFullScreenEffectData && iFullScreenEffectData->iToAppId != fxData->iToAppId)
  4800             if (iFullScreenEffectData && iFullScreenEffectData->iToAppId != fxData->iToAppId)
  4746                 {
  4801                 {
  4747 				__ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - WARNING - Another fullscreen effect to different app. Deleting the previous ongoing effect"); 
  4802 				__ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - WARNING - Another fullscreen effect to different app. Deleting the previous ongoing effect"); 
  4748                 RemoveEffectFromApp(iFullScreenEffectData->iToSecureId, iFullScreenEffectData->iToWg);// Fullscreen effect for another app has arrived, and the previous has not finished and abort effect was not called.
  4803                 RemoveEffectFromApp(iFullScreenEffectData->iToSecureId, iFullScreenEffectData->iToWg);// Fullscreen effect for another app has arrived, and the previous has not finished and abort effect was not called.
  4749                 RemoveEffectFromApp(iFullScreenEffectData->iFromSecureId, iFullScreenEffectData->iFromWg);
  4804                 RemoveEffectFromApp(iFullScreenEffectData->iFromSecureId, iFullScreenEffectData->iFromWg);
  4750                 // Fullscreen effect for another 
       
  4751                 }
       
  4752 
       
  4753             if (iFullScreenEffectData && iFullScreenEffectData->iToAppId != fxData->iToAppId)
       
  4754                 {
       
  4755                 // effected application has changed. Only single begin - end request supported at a time.
       
  4756                 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - Effect request has changed from appUid 0x%x to 0x%x. Cancel previous effect.", iFullScreenEffectData->iToAppId, fxData->iToAppId);
  4805                 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - Effect request has changed from appUid 0x%x to 0x%x. Cancel previous effect.", iFullScreenEffectData->iToAppId, fxData->iToAppId);
  4757                 RemoveEffectFromApp(iFullScreenEffectData->iToAppId);
  4806                 RemoveEffectFromApp(iFullScreenEffectData->iToAppId);
  4758                 }
  4807                 // Fullscreen effect for another 
  4759             delete iFullScreenEffectData;
  4808                 }
       
  4809 
       
  4810                delete iFullScreenEffectData;
  4760             iFullScreenEffectData = fxData;
  4811             iFullScreenEffectData = fxData;
  4761             iFullScreenEffectData->iAppStartScreenshotItemHandle = fxData->iHandle;
  4812             iFullScreenEffectData->iAppStartScreenshotItemHandle = fxData->iHandle;
  4762             
  4813             
  4763             stream.Release();
  4814             stream.Release();
  4764             }
  4815             }
  4889     
  4940     
  4890     CHuiControl& control = aToGroup->Control(0);
  4941     CHuiControl& control = aToGroup->Control(0);
  4891     CHuiLayout* toLayout = control.VisualCount() > 0 ? (CHuiLayout*)&control.Visual(0) : NULL;
  4942     CHuiLayout* toLayout = control.VisualCount() > 0 ? (CHuiLayout*)&control.Visual(0) : NULL;
  4892     if (!toLayout)
  4943     if (!toLayout)
  4893         {
  4944         {
       
  4945         // no point starting effect, if the layout is still inactive.
  4894         return EFalse;
  4946         return EFalse;
  4895         }
  4947         }
  4896     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
  4948     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
  4897     IsFullScreenDrawnRecursive(toLayout, *aToGroup, control, fullscreenCovered, fullscreen, screen, dummy, opaque, iAlfScreens[0]->iDisplay->Orientation());
  4949     IsFullScreenDrawnRecursive(toLayout, *aToGroup, control, fullscreenCovered, fullscreen, screen, dummy, opaque, iAlfScreens[0]->iDisplay->Orientation());
  4898     fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
  4950     fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
  5111            if (sourceVisual.Count())
  5163            if (sourceVisual.Count())
  5112                {
  5164                {
  5113                CHuiLayout& layout = static_cast<CHuiLayout&> (aSourceLayout->Visual(i));
  5165                CHuiLayout& layout = static_cast<CHuiLayout&> (aSourceLayout->Visual(i));
  5114                AddToEffectLayoutContainerL(aEffectHandle, &layout, NULL, aEffectControl, aItemsDestroyed, EFalse,aIsExitEffect, aCanDestroyOrHideImmediately );
  5166                AddToEffectLayoutContainerL(aEffectHandle, &layout, NULL, aEffectControl, aItemsDestroyed, EFalse,aIsExitEffect, aCanDestroyOrHideImmediately );
  5115                }
  5167                }
       
  5168            TInt oldItemsDestroyed = aItemsDestroyed;
  5116            AddEffectItemL(aEffectHandle, &sourceVisual, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsExitEffect, aCanDestroyOrHideImmediately);
  5169            AddEffectItemL(aEffectHandle, &sourceVisual, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsExitEffect, aCanDestroyOrHideImmediately);
       
  5170            if (oldItemsDestroyed != aItemsDestroyed)
       
  5171                {
       
  5172                // Visual was destroyed. If so, then we must adjust index.
       
  5173                --i;
       
  5174                }
  5117            }
  5175            }
  5118     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
  5176     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
  5119     }
  5177     }
  5120 
  5178 
  5121 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect, TBool aCanDestroyOrHideImmediately)
  5179 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect, TBool aCanDestroyOrHideImmediately)
  5267             {
  5325             {
  5268             TInt effectFlags = 0;
  5326             TInt effectFlags = 0;
  5269             
  5327             
  5270             // effect will start delayed anyway when it is syncronized. this flag would break syncronization between effects.
  5328             // effect will start delayed anyway when it is syncronized. this flag would break syncronization between effects.
  5271             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn; 
  5329             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn; 
       
  5330             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName))
       
  5331                 {
       
  5332                 effectFlags |= KHuiFxOpaqueHint;
       
  5333                 }
       
  5334 
  5272             TInt activeEffectGroup = engine->ActiveGroupEffect();
  5335             TInt activeEffectGroup = engine->ActiveGroupEffect();
  5273             if (activeEffectGroup != KErrNotFound)
  5336             if (activeEffectGroup != KErrNotFound)
  5274                 {
  5337                 {
  5275                 engine->AddEffectToGroup(activeEffectGroup);
  5338                 engine->AddEffectToGroup(activeEffectGroup);
  5276                 }
  5339                 }
  5970             CHuiTexture* texture = CHuiTexture::NewL();
  6033             CHuiTexture* texture = CHuiTexture::NewL();
  5971             CleanupStack::PushL(texture);
  6034             CleanupStack::PushL(texture);
  5972             iAlfScreens[i]->iDisplay->SetForegroundBitmapL( iAlfScreens[i]->iSwRenderingTarget );
  6035             iAlfScreens[i]->iDisplay->SetForegroundBitmapL( iAlfScreens[i]->iSwRenderingTarget );
  5973             CleanupStack::Pop(texture);
  6036             CleanupStack::Pop(texture);
  5974             iAlfScreens[i]->iDisplay->SetForegroundTexture(texture);
  6037             iAlfScreens[i]->iDisplay->SetForegroundTexture(texture);
       
  6038 #ifdef ALF_DRAW_FRAME_BEFORE_END_CALLBACK 
       
  6039             iHuiEnv->SetRefreshMode(EHuiRefreshModeManual);
       
  6040 #endif // #ifdef ALF_DRAW_FRAME_BEFORE_END_CALLBACK 
  5975             }
  6041             }
  5976         else
  6042         else
  5977             {
  6043             {
  5978             iAlfScreens[i]->iDisplay->SetForegroundBitmapL(NULL);            
  6044             iAlfScreens[i]->iDisplay->SetForegroundBitmapL(NULL);            
  5979             iAlfScreens[i]->iDisplay->SetForegroundTexture(NULL);
  6045             iAlfScreens[i]->iDisplay->SetForegroundTexture(NULL);
       
  6046 #ifdef ALF_DRAW_FRAME_BEFORE_END_CALLBACK 
       
  6047             iHuiEnv->SetRefreshMode(EHuiRefreshModeAutomatic);
       
  6048 #endif // #ifdef ALF_DRAW_FRAME_BEFORE_END_CALLBACK 
  5980             }
  6049             }
  5981             
  6050             
  5982         // SetCapturingBufferL is called from HandleVisualVisibility.
  6051         // SetCapturingBufferL is called from HandleVisualVisibility.
  5983         iAlfScreens[i]->SetVisualTreeVisibilityChanged(ETrue);
  6052         iAlfScreens[i]->SetVisualTreeVisibilityChanged(ETrue);
       
  6053         }
       
  6054 
       
  6055     if (!iSwRenderingEnabled && iManualRefreshTimer)
       
  6056         {
       
  6057         iManualRefreshTimer->Cancel();
  5984         }
  6058         }
  5985     }
  6059     }
  5986 
  6060 
  5987 // ---------------------------------------------------------------------------
  6061 // ---------------------------------------------------------------------------
  5988 // ---------------------------------------------------------------------------
  6062 // ---------------------------------------------------------------------------
  6193 // ---------------------------------------------------------------------------
  6267 // ---------------------------------------------------------------------------
  6194 // ---------------------------------------------------------------------------
  6268 // ---------------------------------------------------------------------------
  6195 // 
  6269 // 
  6196 void CAlfBridge::Synchronized(TInt aId)
  6270 void CAlfBridge::Synchronized(TInt aId)
  6197     {
  6271     {
  6198     if(aId == iIdForLayoutSwitchFrameSync)
  6272     if (aId == KRequestFrameSynchForComposition)
       
  6273         {
       
  6274         return;    
       
  6275         }    
       
  6276     else if (aId == iIdForLayoutSwitchFrameSync)
  6199         {
  6277         {
  6200         // send notification to alfstreamer server about
  6278         // send notification to alfstreamer server about
  6201         if (iActivated)
  6279         if (iActivated)
  6202             {
  6280             {
  6203             iBridgerClient.SendBlind(KAlfCompositionLayoutSwitchComplete, TIpcArgs());
  6281             iBridgerClient.SendBlind(KAlfCompositionLayoutSwitchComplete, TIpcArgs());
  6332             }
  6410             }
  6333         
  6411         
  6334         // Dont mess with alf control group visuals, alf session handling does it for us
  6412         // Dont mess with alf control group visuals, alf session handling does it for us
  6335         if (control.Role() == EAlfSessionContainer)
  6413         if (control.Role() == EAlfSessionContainer)
  6336             {
  6414             {
  6337             CHuiLayout* hostContainer = control.ContainerLayout( NULL );
  6415             // Skip alf session containers until we have better heuristic implement for them
  6338             TInt flags = hostContainer->Flags();            
       
  6339             if (!fullscreenCovered)
       
  6340                 {
       
  6341                 
       
  6342                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
       
  6343                     {
       
  6344                     alfWindowGroupFoundVisible = ETrue;
       
  6345                     if(iAppUi)
       
  6346                         {
       
  6347                         topMostAlfSrvSession = iAppUi->SrvSessionForControlGroup(controlgroup);
       
  6348                         }
       
  6349 
       
  6350                     // just add the rect to covered region because alf draws solid background
       
  6351                     iTempRegion.AddRect(fullscreen);
       
  6352                     iTempRegion.Tidy();
       
  6353                     fullscreenCovered = ETrue;
       
  6354                     }
       
  6355                 }
       
  6356             else if(!alfWindowGroupFoundVisible || flags&EHuiVisualFlagUnderOpaqueHint)
       
  6357                 {
       
  6358                 // this alf session control group should not be visible anymore because avkon application is on top
       
  6359                 // -> change to inactive
       
  6360                 
       
  6361                 }
       
  6362             else if(!(flags&EHuiVisualFlagUnderOpaqueHint)) // alf app covers full screen
       
  6363                 {
       
  6364                 // check if current controlgroup belongs to same srvsession as the topmost visible alf session container
       
  6365                 CAlfAppSrvSessionBase* alfsrvsession = NULL;
       
  6366                 if(iAppUi)
       
  6367                     {
       
  6368                     alfsrvsession = iAppUi->SrvSessionForControlGroup(controlgroup);
       
  6369                     }
       
  6370                 if(topMostAlfSrvSession!=NULL && topMostAlfSrvSession == alfsrvsession)
       
  6371                     {
       
  6372                 
       
  6373                     }
       
  6374                 else
       
  6375                     {
       
  6376                 
       
  6377                     }
       
  6378                 }
       
  6379             continue;
  6416             continue;
  6380             }
  6417             }
  6381         
  6418         
  6382         __ALFLOGSTRING1("CAlfBridge::IsFullScreenDraw - fullscreen covered %d", fullscreenCovered)
  6419         __ALFLOGSTRING1("CAlfBridge::IsFullScreenDraw - fullscreen covered %d", fullscreenCovered)
  6383         TBool subTreeCovered = EFalse;
  6420         TBool subTreeCovered = EFalse;
  6538                 MarkAllLayersHiddenRecursive(canvasVisual);
  6575                 MarkAllLayersHiddenRecursive(canvasVisual);
  6539                 }            
  6576                 }            
  6540     
  6577     
  6541             if (!canvasVisual->LayerExtent().IsEmpty())
  6578             if (!canvasVisual->LayerExtent().IsEmpty())
  6542                 {
  6579                 {
  6543                 canvasVisual->ClearCanvasFlags(EHuiCanvasFlagSurfaceVisible);
  6580                 // Force update
  6544                 canvasVisual->SetCanvasFlags(EHuiCanvasFlagSurfaceInvisible);
  6581                 canvasVisual->ClearCanvasFlags( EHuiCanvasFlagSurfaceInvisible );
       
  6582                 canvasVisual->ClearCanvasFlags( EHuiCanvasFlagSurfaceVisible );
  6545                 }
  6583                 }
  6546             }
  6584             }
  6547         }
  6585         }
  6548     }
  6586     }
  6549 
  6587 
  6586         return &iBridgerClient;
  6624         return &iBridgerClient;
  6587         }
  6625         }
  6588     return 0;      
  6626     return 0;      
  6589     }
  6627     }
  6590 
  6628 
       
  6629 void CAlfBridge::RefreshNow(TBool aSyncWait)
       
  6630     {
       
  6631     if (!iHuiEnv)
       
  6632         {
       
  6633         return;
       
  6634         }
       
  6635 
       
  6636     if (iSwRenderingEnabled && iManualRefreshTimer)
       
  6637         {
       
  6638         iManualRefreshTimer->Cancel();
       
  6639         }
       
  6640 
       
  6641     if (aSyncWait)
       
  6642         {
       
  6643         iHuiEnv->Synchronize( KRequestFrameSynchForComposition, this );
       
  6644         }
       
  6645         
       
  6646     iHuiEnv->RefreshCallBack((TAny*)iHuiEnv);
       
  6647     }
       
  6648 
       
  6649 static TInt DoAlfBridgeRefreshNow(TAny* aAny)
       
  6650     {
       
  6651     CAlfBridge* bridge = static_cast<CAlfBridge*>(aAny);
       
  6652     bridge->RefreshNow(EFalse);
       
  6653     return KErrNone;
       
  6654     }
       
  6655 
       
  6656 void CAlfBridge::AsynchRefresh()
       
  6657     {
       
  6658     if (iSwRenderingEnabled && iManualRefreshTimer && !iManualRefreshTimer->IsActive())
       
  6659         {
       
  6660         iManualRefreshTimer->Start(KAlfManualRefreshTimeout, KAlfManualRefreshTimeout, TCallBack(DoAlfBridgeRefreshNow, this));
       
  6661         }
       
  6662     }
  6591 
  6663 
  6592 // end of file
  6664 // end of file