Revision: 201026 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 15 Jul 2010 19:40:07 +0300
branchRCL_3
changeset 17 c9d868f1e20c
parent 15 cd0ae4656946
child 18 1801340c26a2
Revision: 201026 Kit: 2010127
rom/alfred.iby
uiaccelerator_plat/alf_client_server_api/inc/alf/alfappsrvsessionbase.h
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiCanvasVisual.h
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiVisual.h
uiacceltk/hitchcock/CommonInc/alfmoduletestconf.h
uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h
uiacceltk/hitchcock/ServerCore/Inc/alfeffectutils.h
uiacceltk/hitchcock/ServerCore/Src/alfappsrvsession.cpp
uiacceltk/hitchcock/ServerCore/Src/alfappsrvsessionBase.cpp
uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp
uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF
uiacceltk/hitchcock/coretoolkit/eabi/hitchcocku.DEF
uiacceltk/hitchcock/coretoolkit/inc/HuiCmdBufferBrush.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffect.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxLayer.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxVisualLayer.h
uiacceltk/hitchcock/coretoolkit/inc/HuiRosterImpl.h
uiacceltk/hitchcock/coretoolkit/inc/huieffectable.h
uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiCmdBufferBrush.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxEffectParser.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxGroupLayer.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxLayer.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxVisualLayer.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiLayout.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiRosterImpl.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiTextVisual.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiTextureManager.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiVisual.cpp
uiacceltk/hitchcock/goommonitor/data/goomconfig.xml
uiacceltk/hitchcock/goommonitor/inc/goomactionlist.h
uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h
uiacceltk/hitchcock/goommonitor/inc/goommemorymonitorsession.h
uiacceltk/hitchcock/goommonitor/inc/goomwindowgrouplist.h
uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp
uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp
uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp
uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp
uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp
uiacceltk/hitchcock/group/core_exports.inc
uiacceltk/hitchcock/plugins/alfoogmplugin/src/alfoogmplugin.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftfxserverplugin/src/alftransitionserver.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/states.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/wsserverdrawercontroller.cpp
--- a/rom/alfred.iby	Mon Jun 21 16:41:52 2010 +0300
+++ b/rom/alfred.iby	Thu Jul 15 19:40:07 2010 +0300
@@ -140,6 +140,8 @@
 data=DATAZ_/RESOURCE_FILES_DIR/effects/optionsmenu_cascade_appear.fxml RESOURCE_FILES_DIR/effects/optionsmenu_cascade_appear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/optionsmenu_cascade_disappear.fxml RESOURCE_FILES_DIR/effects/optionsmenu_cascade_disappear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/optionsmenu_disappear.fxml RESOURCE_FILES_DIR/effects/optionsmenu_disappear.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/phone_callui_appear.fxml RESOURCE_FILES_DIR/effects/phone_callui_appear.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/phone_callui_disappear.fxml RESOURCE_FILES_DIR/effects/phone_callui_disappear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/photos_fullscreen_close.fxml RESOURCE_FILES_DIR/effects/photos_fullscreen_close.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/photos_fullscreen_open.fxml RESOURCE_FILES_DIR/effects/photos_fullscreen_open.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/photos_gridview_appear.fxml RESOURCE_FILES_DIR/effects/photos_gridview_appear.fxml
--- a/uiaccelerator_plat/alf_client_server_api/inc/alf/alfappsrvsessionbase.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiaccelerator_plat/alf_client_server_api/inc/alf/alfappsrvsessionbase.h	Thu Jul 15 19:40:07 2010 +0300
@@ -289,6 +289,8 @@
     // creates subsession
     CAlfSrvSubSessionBase* CreateSubSessionLC(const RMessage2& aMessage);
 
+    TUint SecureId();
+
 protected: // from baseclasses
 
     IMPORT_C void ServiceError(const RMessage2& aMessage,TInt aError);
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiCanvasVisual.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiCanvasVisual.h	Thu Jul 15 19:40:07 2010 +0300
@@ -454,6 +454,7 @@
     
     TBool CanSkipDrawing() const;
     TBool KeepNoCache() const;
+    TBool EffectReadyToDrawNextFrame() const; 
 
 private: 
 
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiVisual.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiVisual.h	Thu Jul 15 19:40:07 2010 +0300
@@ -1406,6 +1406,8 @@
     IMPORT_C void SetFreezeState(TBool aEnabled);
     IMPORT_C TBool Freezed() const;
 
+    IMPORT_C virtual TBool EffectReadyToDrawNextFrame() const;
+    
     /**
      *  Assign an effect for the visual. The ownership of the
      *  effect is transferred to the visual.
@@ -1625,6 +1627,8 @@
      * A value of 0 is fully transparent, a value of 1 is fully opaque.
      */
     THuiTimedValue iOpacity;
+    
+    TReal32 iEffectOpacity;
 
 private:
 
--- a/uiacceltk/hitchcock/CommonInc/alfmoduletestconf.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletestconf.h	Thu Jul 15 19:40:07 2010 +0300
@@ -4,6 +4,9 @@
 // Define this to build module testing enchanced version of ALF
 //#define USE_MODULE_TEST_HOOKS_FOR_ALF
 
+// Define this to override the effects on ROM with effects on MMC
+// #define USE_ALTERNATIVE_EFFECTS_FROM_MMC
+
 #endif // ALF_MODULETEST_CONF_H
 
 // End of File
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h	Thu Jul 15 19:40:07 2010 +0300
@@ -159,7 +159,7 @@
             CHuiRoster& aRoster, 
             CHuiControlGroup& aGroup, 
             TInt aWhere, 
-            TInt aScreenNumber );
+            TInt aScreenNumber = 0);
 
     /**
      * This method sets the windowgroup id for the alf window.
@@ -202,8 +202,8 @@
   	 */
     void AlfGfxEffectEndCallBack( TInt aHandle );
    
-    TInt FindClientWindowGroupId( TInt aScreenNumber, CHuiControlGroup& aControlGroup );
-    TInt FindWindowGroupNodeId( TInt aScreenNumber, CHuiControlGroup& aControlGroup ) const;
+    TInt FindClientWindowGroupId(CHuiControlGroup& aControlGroup );
+    TInt FindWindowGroupNodeId(CHuiControlGroup& aControlGroup ) const;
     
     void CleanAllFxVisuals();
 
@@ -406,6 +406,7 @@
 	*/    
     TBool StoreLayoutIfRequiredByEffectL(CHuiLayout* aLayout, CFullScreenEffectState& aEvent, TBool& aNeededStoredLayout);
 
+    void HandleGfxRedirection(CFullScreenEffectState& aEvent, CHuiLayout*& aLayout);
     /**
      * Handles begin and end fullscreen events
      */
@@ -617,6 +618,10 @@
 	
 	void HandleSetFadeEffectL( TAlfBridgerData& aData );
 	
+	void HandleGroupChained( TAlfBridgerData& aData);
+	
+	void HandleGroupChainBroken( TAlfBridgerData& aData);
+	
 	void HandleMoveWindowToNewGroupL( TAlfBridgerData& aData );
 
     void HandleSetLayoutSwitchEffectL();
@@ -711,12 +716,26 @@
     CHuiCanvasVisual* FindVisualByClientSideIds(TUint32 aClientSideId, TUint32 aClientSideGroupId );
 
     /**
+	 * FindChainedGroup
+	 * 
+	 * Find chained windowgroup from iWindowChainsArray. Return 0, if not found.
+	 */
+    TUint32 FindChainedGroup(TUint32 aTreeNodeId);
+
+    /**
+	 * IsChainedGroup
+	 * 
+	 * @return ETrue if group is chained.
+	 */    
+    TBool IsChainedGroup(TUint32 aTreeNodeId);
+    
+    /**
      * This method finds controlgroup which has been assosiated with given window group id. 
      * Control group may or may not be active in roster.
      *
      * @param aWindowGroupNodeId Node id of the window group, internal.
      */
-    CHuiControlGroup* FindControlGroup(TInt aWindowGroupNodeId, TInt aScreenNumber );
+    CHuiControlGroup* FindControlGroup(TInt aWindowGroupNodeId, TInt aScreenNumber = 0);
 
     /**
      * This method finds controlgroup which has been assosiated with window server window group id. 
@@ -740,6 +759,12 @@
      * @return Pointer to found control gruop. NULL if not found.
      */
     CHuiControlGroup* FindControlGroupBySecureId( TInt aSecureId, TInt aWgId = -1 ) const;
+	 /**
+	  *	FindControlGroupBySecureId
+	  *
+	  *	Returns a list of window groups belonging to aSecureId.
+	  */
+    void FindControlGroupBySecureId( TInt aSecureId, RPointerArray<CHuiControlGroup>& aGroupList);
     
     /**
      * Finds control gruop which matches the full screen effect end state.
@@ -761,7 +786,7 @@
      *
      * @param aWindowGroupNodeId Node id of the window group, internal.
      */
-    void DeleteControlGroupL(TInt aWindowGroupNodeId, TInt aScreenNumber );
+    void DeleteControlGroupL(TInt aWindowGroupNodeId, TInt aScreenNumber = 0);
 
     /**
      * Creates a control group
@@ -787,7 +812,7 @@
      * 
      */
 
-    void ReorderAlfControlGroupsL( TInt aScreenNumber );
+    void ReorderAlfControlGroupsL( TInt aScreenNumber = 0);
         
     /**
      * Called to notify the observer that a display refresh is about to begin.
@@ -1009,6 +1034,18 @@
         };
     
     RHashMap<TUint32,THashVisualStruct> iWindowHashArray;
+    
+    class TChainData
+        {
+    public:
+        TChainData(TUint32 aParent, TUint32 aChainee) : iParent(aParent), iChainee(aChainee)
+            {
+            }
+        TUint32 iParent;
+        TUint32 iChainee;
+        };
+    RHashMap<TUint32,TChainData> iWindowChainsArray;
+    
     CHuiControl* iOrphanStorage; // owned. holds the visuals which are orphaned from their control group
     class TRegisteredEffectsStruct
         {
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfeffectutils.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfeffectutils.h	Thu Jul 15 19:40:07 2010 +0300
@@ -257,7 +257,7 @@
         TRect iRect;
         TBool iLongAppStartTimeout;
         TBool iTimeout;
-        
+        TBool iIsRedirected;
          
         void SetState(TEffectState aState);
        
--- a/uiacceltk/hitchcock/ServerCore/Src/alfappsrvsession.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappsrvsession.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -32,6 +32,10 @@
 #include "alfclientserver.h"
 #include "alfsrvtexturemanager.h"
 #include "alfsrvscreenbuffermanager.h"
+#include "alfstreamerconsts.h"
+#include "alfdecoderserverclient.h"
+
+
 
 #include <coemain.h>
 
@@ -2737,6 +2741,14 @@
         {
         iTextureInfo.Remove( pos );
         }
+
+    if (!iTextureInfo.Count())
+        {
+        if (AlfAppUi()->BridgerClient())
+            {
+            AlfAppUi()->BridgerClient()->SendBlind(EAlfExcludeFromGoomTargets, TIpcArgs(SecureId(),ClientWindowGroup()));
+            }
+        }
     }
 
 TInt CAlfAppSrvSession::GetTextureSize( 
@@ -2765,6 +2777,15 @@
     aPriority = Max( 0, aPriority );
     aPriority = Min( 1, aPriority );
 
+    if (!iTextureInfo.Count())
+        {
+        if (AlfAppUi()->BridgerClient())
+            {
+            AlfAppUi()->BridgerClient()->SendBlind(EAlfVolunteerForGoomTarget, TIpcArgs(SecureId(), ClientWindowGroup()));
+            }
+        }
+
+
     TInt pos = FindTextureInfoById( aTextureId );
     if ( pos != KErrNotFound )
         {
--- a/uiacceltk/hitchcock/ServerCore/Src/alfappsrvsessionBase.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappsrvsessionBase.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -406,10 +406,6 @@
     {
     __ASSERT_DEBUG(iData, USER_INVARIANT());
     iData->iClientWindowGroupId = aId;
-    if (AlfAppUi()->BridgerClient())
-        {
-        AlfAppUi()->BridgerClient()->SendBlind(EAlfVolunteerForGoomTarget, TIpcArgs(iData->iSecureId, iData->iClientWindowGroupId));
-        }
     }
 
 // ---------------------------------------------------------------------------
@@ -1140,6 +1136,15 @@
         CleanupStack::PopAndDestroy();
         }
     }
+    
+TUint CAlfAppSrvSessionBase::SecureId()
+    {
+    if (iData)
+        {
+        return iData->iSecureId;
+        }
+    return 0;
+    }            
    
 // End of file    
 
--- a/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -196,6 +196,7 @@
     delete iEffectEndTimer;
     iDeadControlGroups.Close();
     iEffectWindowGroups.Close();
+    iWindowChainsArray.Close();
     delete iFSFxData;
     delete iFSFXDataPart2;
 
@@ -269,7 +270,11 @@
 void CAlfBridge::RegisterFadeEffectL()
     {
     // TODO: RND, REMOVE MMC DRIVE-F, WHEN NOT REQUIRED FOR TESTING
+#ifdef USE_ALTERNATIVE_EFFECTS_FROM_MMC
     _LIT(KDrivePrefence,"FZC"); 
+#else
+    _LIT(KDrivePrefence,"Z");
+#endif
     // Force register fade effect. Try first MMC, then ROM.
     CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
     RFs& fs = CHuiStatic::FsSession();
@@ -460,7 +465,57 @@
     while(node);
 	return NULL;
     }
-	
+
+// ---------------------------------------------------------------------------
+// FindChainedGroup
+// ---------------------------------------------------------------------------
+// 
+TUint32 CAlfBridge::FindChainedGroup(
+    TUint32 aTreeNodeId)
+    {
+    THashMapIter<TUint32, TChainData> iter(iWindowChainsArray);
+    TChainData const * data = 0;
+    do
+        {
+        data = iter.NextValue();
+        if (data && data->iParent == aTreeNodeId)
+            {
+            TUint32 chainedTo = FindChainedGroup(data->iChainee);
+            if (!chainedTo)
+                {
+                return data->iChainee; 
+                }
+            else
+                {
+                return chainedTo;
+                }
+            }
+        }
+    while(data);
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// IsChainedGroup
+// ---------------------------------------------------------------------------
+// 
+TBool CAlfBridge::IsChainedGroup(
+    TUint32 aTreeNodeId)
+    {
+    THashMapIter<TUint32, TChainData> iter(iWindowChainsArray);
+    TChainData const * data = 0;
+    do
+        {
+        data = iter.NextValue();
+        if (data && data->iChainee == aTreeNodeId)
+            {
+            return ETrue;
+            }
+        }
+    while(data);
+    return EFalse;
+    }
+
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // 
@@ -480,13 +535,13 @@
 // FindClientWindowGroupId
 // ---------------------------------------------------------------------------
 //
-TInt CAlfBridge::FindClientWindowGroupId( TInt aScreenNumber, CHuiControlGroup& aControlGroup  )
-    {
-    for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++)
-        {
-        if( iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup == &aControlGroup )
-            {
-            return iAlfScreens[aScreenNumber]->iControlGroups[i].iClientWindowGroupId;
+TInt CAlfBridge::FindClientWindowGroupId(CHuiControlGroup& aControlGroup  )
+    {
+    for (TInt i=0; i<iAlfScreens[0]->iControlGroups.Count();i++)
+        {
+        if( iAlfScreens[0]->iControlGroups[i].iControlGroup == &aControlGroup )
+            {
+            return iAlfScreens[0]->iControlGroups[i].iClientWindowGroupId;
             }
         }
     return KErrNotFound;
@@ -496,13 +551,13 @@
 // FindWindowGroupNodeId
 // ---------------------------------------------------------------------------
 //
-TInt CAlfBridge::FindWindowGroupNodeId( TInt aScreenNumber, CHuiControlGroup& aControlGroup ) const
-    {
-    for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++)
-        {
-        if( iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup == &aControlGroup )
-            {
-            return iAlfScreens[aScreenNumber]->iControlGroups[i].iWindowGroupNodeId;
+TInt CAlfBridge::FindWindowGroupNodeId(CHuiControlGroup& aControlGroup ) const
+    {
+    for (TInt i=0; i<iAlfScreens[0]->iControlGroups.Count();i++)
+        {
+        if( iAlfScreens[0]->iControlGroups[i].iControlGroup == &aControlGroup )
+            {
+            return iAlfScreens[0]->iControlGroups[i].iWindowGroupNodeId;
             }
         }
     return KErrNotFound;
@@ -576,6 +631,28 @@
     }
 
 // ---------------------------------------------------------------------------
+// FindControlGroupBySecureId
+// May return multiple groups
+// ---------------------------------------------------------------------------
+//
+void CAlfBridge::FindControlGroupBySecureId( TInt aSecureId, RPointerArray<CHuiControlGroup>& aGroupList)
+    {
+    if ( aSecureId == 0 )
+        {
+        return;
+        }
+    
+    for ( TInt i = 0; i < iAlfScreens[0]->iControlGroups.Count(); i++ )
+        {
+        TAlfControlGroupEntry& groupEntry = iAlfScreens[0]->iControlGroups[i];
+        if ( groupEntry.iSecureId == aSecureId )
+            {
+            aGroupList.Append(groupEntry.iControlGroup);
+            }
+        }        
+    }
+
+// ---------------------------------------------------------------------------
 // FindControlGroupByFullScreenToEffect
 // ---------------------------------------------------------------------------
 //
@@ -794,7 +871,7 @@
             TInt aSecureId,
             TInt aScreenNumber )
     {
-    CHuiControlGroup* group = FindControlGroup(aWindowGroupNodeId,aScreenNumber);
+    CHuiControlGroup* group = FindControlGroup(aWindowGroupNodeId);
     if (!group)
         {
         group = &iHuiEnv->NewControlGroupL(aWindowGroupNodeId); 
@@ -1089,14 +1166,14 @@
                        {
                        lSyncDone = ETrue;
                        CHuiControlGroup &lGroup = aRoster.ControlGroup(i+1);
-                       TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
+                       TInt clientWindowGroupId = FindClientWindowGroupId(lGroup );
                        iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
                        }
                        if(!lSyncDone && aGroup.iAlfApp && aRoster.ControlGroup(i-1).ResourceId() != iAlfWindowGroupNodeId )
                            {
                           
                           CHuiControlGroup &lGroup = aRoster.ControlGroup(i);
-                          TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
+                          TInt clientWindowGroupId = FindClientWindowGroupId(lGroup );
                           iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
                            }
                        break;
@@ -1145,7 +1222,7 @@
                 {
                 iAlfWindowGroupNodeId = iAlfScreens[0]->iControlGroups[i].iWindowGroupNodeId;
                 
-                CHuiControlGroup* controlGroup = FindControlGroup(iAlfWindowGroupNodeId, 0);
+                CHuiControlGroup* controlGroup = FindControlGroup(iAlfWindowGroupNodeId);
                 CHuiControl& control = controlGroup->Control(0);
                 CHuiVisual* layout = &control.Visual(0);
                 iAlfScreens[0]->iDisplay->Roster().SetAlfEventWindow(layout);
@@ -1279,7 +1356,7 @@
                 numBuf.AppendNum(fps, TRealFormat(5,1));
                 TRAP_IGNORE(
                         {
-                        iAlfScreens[screenNumber]->iFPSText->SetTextL( numBuf );
+                        iAlfScreens[0]->iFPSText->SetTextL( numBuf );
                         })
                 }
             }
@@ -1290,10 +1367,10 @@
             iActivated = (err == KErrNone);            
             }
                     
-        if (iAlfScreens[screenNumber]->IsVisualTreeVisibilityChanged())
+        if (iAlfScreens[0]->IsVisualTreeVisibilityChanged())
             {
             HandleVisualVisibility( screenNumber );    
-            iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(EFalse);
+            iAlfScreens[0]->SetVisualTreeVisibilityChanged(EFalse);
             }
         }
     }
@@ -1356,7 +1433,10 @@
     transparent |= (!((aVisual.Flags() & EHuiVisualFlagOpaqueHint) == EHuiVisualFlagOpaqueHint));
     transparent |= (aVisual.iOpacity.Now() < KAlfVisualDefaultOpacity);
     transparent |= (aVisual.iOpacity.Target() < KAlfVisualDefaultOpacity);
-    
+    if(aVisual.Effect())
+        {
+        transparent |= (aVisual.iEffectOpacity < KAlfVisualDefaultOpacity);
+        }
     return  !transparent;            
     }
 
@@ -1487,6 +1567,7 @@
 	
 	TBool alfWindowGroupFoundVisible = EFalse;
 	TBool alfClientWindowGroupVisible = EFalse;
+	TBool firstAlfControlGroupFound = EFalse;
 	
     AMT_SET_VALUE( iVisibleVisualCount, 0 );
 	
@@ -1539,7 +1620,7 @@
                 }
             // !fullscreenCovered need to be checked because for fullscreen
             // alf applications alf event window group could be on top of alf client windowgroup
-            if ( (alfClientWindowGroupVisible || !fullscreenCovered)  && activeSession)
+            if ( (!firstAlfControlGroupFound || !fullscreenCovered)  && activeSession)
                 {
                 // clear inactive flag if client has not made this controlgroup hidden
                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
@@ -1560,7 +1641,7 @@
                             iTempRegion.AddRect(fullscreen);
                             iTempRegion.Tidy();
                             fullscreenCovered = ETrue;
-                            alfClientWindowGroupVisible = EFalse;  // change flag so that we don't go in this branch again
+                            firstAlfControlGroupFound = ETrue;  // change flag so that we don't go in this branch again
                             }
                         }
                     }
@@ -1630,9 +1711,56 @@
                    subTreeCovered, hasLayers, IsVisualOpaque(*layout) );
             }
         
-
-        TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
-
+        if ( hasLayers && iActivated )
+            {
+            HandleLayerVisibility( layout, controlgroup, control, hasActiveVisualsInVisualTree );
+            }
+        
+        TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
+        
+        // we need to set /clear inactive flags before we evaluate the fade effect,
+        // otherwise the fade effect will be removed without a reason in
+        // some use cases
+        if (isLayoutActive && (fullscreenCovered || (!hasActiveVisualsInVisualTree && !IsOpaqueEffect(layout->Effect()))))
+            {
+            // don't inactivate alf event wg if alf client is visible
+            if( !( alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId)) )
+                // Setting also the root visual (layout) as inactive, if it had none
+                // active children. This is because otherwise the Inactive checks won't
+                // work correctly within RosterImpl ScanDirty & ClearChanged phases.
+                // If root visual is having an opaque effect, it must remain active
+                {
+                layout->SetFlag(EHuiVisualFlagInactive);
+                }
+            }
+        else if(!isLayoutActive && !fullscreenCovered && (hasActiveVisualsInVisualTree || IsOpaqueEffect(layout->Effect())) ||
+                (alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId)) )
+            {
+            layout->ClearFlag(EHuiVisualFlagInactive);
+            layout->SetPos(fullscreen.iTl);
+            layout->SetSize(fullscreen.Size());
+            
+		    // New visible window group may have received effect just before appearing to the screen.
+			// start the effect if this is the case.
+            if(iFSFxData && iFSFxData->iToSecureId == controlgroup.SecureId() )
+                {
+                TInt windowGroupId = FindClientWindowGroupId(controlgroup);
+
+                if (iFSFxData->iToWg == windowGroupId && iFSFxData->State() == EWaitEndFullScreen &&
+                        iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::ESecondPartActive)
+                    {
+                    GfxTriggerEffectWhenFullScreenDrawn(&controlgroup);
+                    }
+                }
+            }
+
+        // If root visuals effect is marked as opaque, then add whole screen area as covered.
+        if (!fullscreenCovered)
+            {
+            fullscreenCovered = IsOpaqueEffect(layout->Effect());
+            }    
+
+        
         // if native alf app is found visible and the client it self is not covering whole screen, we can assume that alf content
         // fills the rest. 
         // this is for embedded native alf application cases. Otherwise chained window groups tend to
@@ -1649,39 +1777,9 @@
                 alfClientWindowGroupVisible = ETrue;
                 }
             }
-        
-        // If root visuals effect is marked as opaque, then add whole screen area as covered.
-        if (!fullscreenCovered)
-            {
-            fullscreenCovered = IsOpaqueEffect(layout->Effect());
-            }                    
-        
-        if ( hasLayers && iActivated )
-            {
-            HandleLayerVisibility( layout, controlgroup, control, hasActiveVisualsInVisualTree );
-            }
-        
-        TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
-        
-        // we need to set /clear inactive flags before we evaluate the fade effect,
-        // otherwise the fade effect will be removed without a reason in
-        // some use cases
-        if (isLayoutActive && !hasActiveVisualsInVisualTree && !IsOpaqueEffect(layout->Effect()))
-            {
-            // Setting also the root visual (layout) as inactive, if it had none
-			// active children. This is because otherwise the Inactive checks won't
-			// work correctly within RosterImpl ScanDirty & ClearChanged phases.
-			// If root visual is having an opaque effect, it must remain active
-            layout->SetFlag(EHuiVisualFlagInactive);
-            }
-        else if(!isLayoutActive && (hasActiveVisualsInVisualTree || IsOpaqueEffect(layout->Effect())))
-            {
-            layout->ClearFlag(EHuiVisualFlagInactive);
-            layout->SetPos(fullscreen.iTl);
-            layout->SetSize(fullscreen.Size());
-            }
- 
             
+        TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
+
 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
 		// flagged as containing fade effect, then run the setup as well so that effects which
 		// are no more needed get removed.
@@ -2452,14 +2550,12 @@
                 }
             case EAlfDSGroupChained:
             	{
-            	__ALFLOGSTRING("CAlfBridge::DoDispatchL, EAlfDSGroupChained");    
-            	// TODO, link groups 
+            	HandleGroupChained(data);
             	break;
             	}
             case EAlfDSGroupChainBroken:
             	{
-            	__ALFLOGSTRING("CAlfBridge::DoDispatchL, EAlfDSGroupChainBroken");    
-            	// TODO, break link
+            	HandleGroupChainBroken(data);
             	break;
             	}
             case EAlfDSMoveWindowToNewGroup:
@@ -2668,7 +2764,6 @@
 	TInt windowGroupNodeId = aData.iInt1;
 	TInt windowNodeId = aData.iInt2;
 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
-	TInt screenNumber = windowAttributes->iScreenNumber; 
 	__ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: new window %d!",windowNodeId);    
 	                
 	switch (windowAttributes->iWindowNodeType)
@@ -2679,7 +2774,8 @@
 			        windowGroupNodeId, 
 			        windowAttributes->iClientHandle, 
 			        windowAttributes->iSecureId,
-			        screenNumber);                            
+			        0 // Only one screen for avkon content supported 
+					);                            
 
 			// We just received notification for our own window group creation, store its node id for doing
 			// faster lookups later...
@@ -2695,11 +2791,11 @@
 		case EAlfWinTreeNodeSprite:
 		case EAlfWinTreeNodeTextCursor:
 			{
-			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
+			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
 			// Floating sprites only require own group. Normal sprites should behave as normal visuals.
 			if (!controlGroup && windowAttributes->iWindowNodeType == EAlfWinTreeNodeSprite )
 				{                            
-				controlGroup = iAlfScreens[screenNumber]->iFloatingSpriteControlGroup;
+				controlGroup = iAlfScreens[0]->iFloatingSpriteControlGroup;
 				}
 
 			if (controlGroup)
@@ -2718,7 +2814,7 @@
                     viz = CHuiCanvasVisual::AddNewL(control, layout);
 				    }
 
-				__ALFFXLOGSTRING2("CAlfBridge::HandleNewWindowL visual: 0x%x, id 0x%x", viz, windowNodeId);
+				__ALFFXLOGSTRING3("CAlfBridge::HandleNewWindowL visual: 0x%x, id 0x%x, Owner group Uid: 0x%x", viz, windowNodeId, viz->Owner().ControlGroup()->SecureId());
 				AddVisual( 
 				    windowNodeId, 
 					windowAttributes->iClientHandle, 
@@ -2777,7 +2873,7 @@
 			__ALFLOGSTRING("CAlfBridge::HandleNewWindowL: Unknown window node type received !");
 			}
 		}
-	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
+	iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
 	}
 
 // ---------------------------------------------------------------------------
@@ -2860,14 +2956,13 @@
 	TInt windowNodeId = aData.iInt2;
 
 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
-	TInt screenNumber = windowAttributes->iScreenNumber;
-
+	
 	switch (windowAttributes->iWindowNodeType)
 		{
 		case EAlfWinTreeNodeGroup:
 			{
 			HandleVisualVisibility(0);
-			DeleteControlGroupL(windowGroupNodeId, screenNumber);                            
+			DeleteControlGroupL(windowGroupNodeId);                            
 			break;    
 			}
 		case EAlfWinTreeNodeClient:
@@ -2887,7 +2982,7 @@
 			CHuiCanvasVisual* viz;
 			
 			viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
-			CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
+			CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId);
 		     // Sprite is in its own group, and can be deleted normally.
 			if ( !controlGroup  && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite )
 			    {
@@ -2927,7 +3022,7 @@
 		}
 	// TODO: Toolkit does not support recycling (of visuals),
 	// this is not in line with Nokia environmental policy...
-	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
+	iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
 	}
 
 // ---------------------------------------------------------------------------
@@ -2938,7 +3033,6 @@
 	{
 	TInt windowNodeId = aData.iInt2;
 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
-	TInt screenNumber = windowAttributes->iScreenNumber;
 	// fetch visual
 	CHuiVisual* viz = FindVisual(windowNodeId);
 	if (viz)
@@ -2950,8 +3044,8 @@
 		    }
 #endif
 
-		viz->SetPos(windowAttributes->iPosition, windowAttributes->iTransitionTime);
-		  iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
+        viz->SetPos(windowAttributes->iPosition, windowAttributes->iTransitionTime);
+        iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
 		}
 	else
 		{
@@ -2973,7 +3067,6 @@
 	{
 	TInt windowNodeId = aData.iInt2;
 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
-	TInt screenNumber = windowAttributes->iScreenNumber;
 	// fetch visual
 	CHuiVisual* viz = FindVisual(windowNodeId);
 	if (viz)
@@ -2990,7 +3083,7 @@
 		{
 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!");    
 		}   
-    iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
+    iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
     
     AMT_INC_COUNTER_IF(viz, iVisualSizeChangedCount );
     AMT_SET_VALUE_IF(viz, iLatestVisualExtentRect, TRect( windowAttributes->iPosition, windowAttributes->iSize ) );
@@ -3036,7 +3129,6 @@
 	{
 	TInt windowNodeId = aData.iInt2;
 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
-	TInt screenNumber = windowAttributes->iScreenNumber;
 	// fetch visual
 	CHuiVisual* viz = FindVisual(windowNodeId);
 	if (viz)
@@ -3047,9 +3139,9 @@
             RDebug::Print(_L("CAlfBridge::HandleSetWindowOpacityL - Tracked visual"));
             }
 #endif
-		viz->iOpacity.Set(windowAttributes->iOpacity, windowAttributes->iTransitionTime);
-		  iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
-		}
+        viz->iOpacity.Set(windowAttributes->iOpacity, windowAttributes->iTransitionTime);
+        iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
+        }
 	else
 		{
 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowOpacityL, EAlfDSSetWindowOpacity: Visual not found!");                                                
@@ -3064,7 +3156,6 @@
     {
 	TInt windowNodeId = aData.iInt2;
 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
-	TInt screenNumber = windowAttributes->iScreenNumber;
 	// fetch visual
 	CHuiVisual* viz = FindVisual(windowNodeId);
 	if (viz)
@@ -3084,7 +3175,7 @@
 		    viz->SetFlag( EHuiVisualFlagOpaqueHint );
 		    }
 		
-	    iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
+	    iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
 		}
 	else
 		{
@@ -3100,7 +3191,6 @@
     {
     TInt windowNodeId = aData.iInt2;
     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
-    TInt screenNumber = windowAttributes->iScreenNumber;
     // fetch visual
     CHuiVisual* viz = FindVisual(windowNodeId);
     if (viz)
@@ -3125,7 +3215,7 @@
                 }
             }
         
-        iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
+        iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
         }
     else
         {
@@ -3142,7 +3232,6 @@
 	TInt windowNodeId = aData.iInt2;
 	TAny* ptr = (TAny*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
 	
-	TInt screenNumber = 0;
 	TPoint origin;
 	TInt count = 0;
 	RRegion region;
@@ -3150,7 +3239,7 @@
 	
 	    {
 	    RMemReadStream str(ptr, 4*sizeof(TInt32));	
-	    screenNumber = str.ReadInt32L(); 
+	    str.ReadInt32L(); // screen number, obsolete 
     	origin.iX = str.ReadInt32L();
 	    origin.iY = str.ReadInt32L();
 	    count = str.ReadInt32L();
@@ -3188,7 +3277,7 @@
 		CHuiCanvasVisual* canvas = static_cast<CHuiCanvasVisual*>(viz);
 		canvas->SetShape( origin, region );
 		
-		iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
+		iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
 		}
 	else
 		{
@@ -3207,7 +3296,6 @@
 	TInt windowGroupNodeId = aData.iInt1;
 	TInt windowNodeId = aData.iInt2;
 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
-	TInt screenNumber = windowAttributes->iScreenNumber;
 	TInt ordinalPosition = windowAttributes->iOrdinalPosition;
 
 	switch (windowAttributes->iWindowNodeType)
@@ -3227,7 +3315,7 @@
 				}    
 			#endif
 
-			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
+			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
 			
             if (!controlGroup)
                 {
@@ -3235,11 +3323,11 @@
                 }
             ResolveAfterEffectAppearingApplicationL(controlGroup); // does nothing, if effect is not active on this control group
 			// Window server nodes are in inverted Z-order, we switch it here.
-			iAlfScreens[screenNumber]->iDisplay->Roster().Hide(*controlGroup);                            
+			iAlfScreens[0]->iDisplay->Roster().Hide(*controlGroup);                            
 			TInt wsWindowGroupCount = 0;
-			for (TInt i=0; i<iAlfScreens[screenNumber]->iDisplay->Roster().Count();i++)
+			for (TInt i=0; i<iAlfScreens[0]->iDisplay->Roster().Count();i++)
 				{
-                if (iAlfScreens[screenNumber]->iDisplay->Roster().ControlGroup(i).Control(0).Role()==EHuiWindowGroupContainer)
+                if (iAlfScreens[0]->iDisplay->Roster().ControlGroup(i).Control(0).Role()==EHuiWindowGroupContainer)
 					{
 					wsWindowGroupCount++;    
 					}
@@ -3257,16 +3345,16 @@
 				ordinalPosition = -1; // show at top ?    
 				}
 			
-			if (iAlfScreens[screenNumber]->iDisplay && controlGroup)
+			if (iAlfScreens[0]->iDisplay && controlGroup)
 				{
-				ShowControlGroupL(iAlfScreens[screenNumber]->iDisplay->Roster(), *controlGroup, ordinalPosition, screenNumber); 
+				ShowControlGroupL(iAlfScreens[0]->iDisplay->Roster(), *controlGroup, ordinalPosition); 
 				}
 			else
 				{
-				__ALFLOGSTRING2("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Control group not found! Screen: %d, Id: %d ", screenNumber, windowNodeId );        
+				__ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Control group not found! Id: %d ", windowNodeId );        
 				}
 			
-			ReorderAlfControlGroupsL(screenNumber);                                        
+			ReorderAlfControlGroupsL();                                        
 			break;    
 			}
 		case EAlfWinTreeNodeClient:
@@ -3304,7 +3392,7 @@
 				}
 			else
 				{
-				__ALFLOGSTRING2("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Visual not found! Screen: %d, Id: %d ", screenNumber, windowNodeId );    
+				__ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Visual not found! Id: %d ", windowNodeId );    
 				}                       
 			break;
 			}
@@ -3315,7 +3403,7 @@
 			}
 		}
   
-	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed
+	iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed
 
 	AMT_MAP_BRIDGE_SET_ORDINAL_POSITION();
 	}
@@ -3329,7 +3417,6 @@
 	TInt windowGroupNodeId = aData.iInt1;
 	TInt windowNodeId = aData.iInt2;
 	TAlfWindowCommandBufferAttributes* bufferAttributes = (TAlfWindowCommandBufferAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
-	TInt screenNumber = bufferAttributes->iScreenNumber;
 
 	CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
 	
@@ -3341,7 +3428,7 @@
 #ifdef HUI_DEBUG_TRACK_DRAWING
         TBool tracking( EFalse );
 	CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
-	CAlfScreen* screen = iAlfScreens[screenNumber];
+	CAlfScreen* screen = iAlfScreens[0];
 	
 	//TInt clientWindowGroupId = FindClientWindowGroupId( screenNumber, *controlGroup );
 	// NOTE, THE FOLLOWING WServClientFileName MAY CAUSE DEADLOCK. 
@@ -3364,7 +3451,7 @@
 	        {
             // For performance resons, only set visual tree changed if this 
             // was the first buffer for the window. 
-	        iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
+	        iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
 	        }
 
 		TPtrC8 commands((TUint8*)bufferAttributes->iBuffer, bufferAttributes->iBufferLength);
@@ -3425,12 +3512,14 @@
 		}
 	else
 		{
-		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
+		__ALFLOGSTRING2("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Id: %d, GroupId: %d ",  windowNodeId, windowGroupNodeId );                                 
 		}    
+	    // Uncomment the following for tracking which application is doing drawing
+        //__ALFFXLOGSTRING1("CAlfBridge::HandlePostCanvasBufferL 0x%x", viz->Owner().ControlGroup()->SecureId());
 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
 	    if (iFSFxData
 	            && iFSFxData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
-	            && ((iFSFxData->State() == EWaitEndFullScreen && iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::EFirstPartRunning)))
+	            && ((iFSFxData->State() == EWaitEndFullScreen && iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::ESecondPartActive)))
 	        {
 	        CHuiControlGroup *to_group = NULL;
             if (iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect)
@@ -3505,6 +3594,7 @@
     TInt effectIndex;
     if (!HasActiveEffect(aVisual, effectIndex))
         {
+        __ALFFXLOGSTRING2("CAlfBridge::SetWindowActiveL 0x%x - New state: %d", aVisual, aActive);
         // Does not have effect
         if (aActive)
             {
@@ -3570,7 +3660,6 @@
 	TInt windowGroupNodeId = aData.iInt1;
 	TInt windowNodeId = aData.iInt2;
 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
-	TInt screenNumber = windowAttributes->iScreenNumber;
 
     if (windowAttributes->iWindowNodeType == EAlfWinTreeNodeTextCursor && iCursorTimer)
 	    {
@@ -3589,7 +3678,7 @@
 		{
 		case EAlfWinTreeNodeGroup:
 			{
-			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
+			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
 			if (controlGroup)
 				{
 				CHuiControl& control = controlGroup->Control(0);
@@ -3635,7 +3724,7 @@
 			break;                       	        
 			}
 		}
-    iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);	// TODO: Check if really changed                       
+    iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);	// TODO: Check if really changed                       
 
     AMT_INC_COUNTER( iTotalVisualFlagChangedCount );
     AMT_INC_COUNTER_IF( windowAttributes->iActive, iActiveVisualCount );
@@ -3657,7 +3746,6 @@
     TInt windowGroupNodeId = aData.iInt1;
     TInt windowNodeId = aData.iInt2;
     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
-    TInt screenNumber = windowAttributes->iScreenNumber;
     TInt windowFlag = windowAttributes->iActive;
     THuiVisualFlags visualFlag = (THuiVisualFlags)0;
     switch(windowFlag)
@@ -3679,7 +3767,7 @@
         {
         case EAlfWinTreeNodeGroup:
             {
-            CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
+            CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
             if (controlGroup)
                 {
                 CHuiControl& control = controlGroup->Control(0);
@@ -3740,7 +3828,7 @@
             break;                                  
             }
         }
-    iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed                       
+    iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed                       
     }
 
 // ---------------------------------------------------------------------------
@@ -3824,7 +3912,6 @@
 	TInt windowGroupNodeId = aData.iInt1;
 	TInt windowNodeId = aData.iInt2;
 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
-	TInt screenNumber = windowAttributes->iScreenNumber;
 	// fetch visual
 	CHuiCanvasVisual* viz = FindVisual(windowNodeId);
 
@@ -3860,7 +3947,7 @@
 		if (iAlfWindowGroupNodeId != windowGroupNodeId)
 		    __ALFLOGSTRING("CAlfBridge::HandleSetSurfaceExtentL, EAlfDSSetSurfaceExtent: Visual not found!");    
 		}                            
-    iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
+    iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
 	}
 
 // ---------------------------------------------------------------------------
@@ -3872,7 +3959,6 @@
     TInt windowGroupNodeId = aData.iInt1;
     TInt windowNodeId = aData.iInt2;
     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
-    TInt screenNumber = windowAttributes->iScreenNumber;
     
     // fetch visual
     CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
@@ -3889,7 +3975,7 @@
         if (iAlfWindowGroupNodeId != windowGroupNodeId)
             __ALFLOGSTRING("CAlfBridge::HandleLayerUsesAlphaFlagChanged: Visual not found!");    
         }                            
-    iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
+    iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
     }
 
 
@@ -4334,6 +4420,45 @@
     return (didFadeEffectLoad || alreadyFaded);
     }
 
+// ---------------------------------------------------------------------------
+//	HandleGroupChained
+//
+// 	Chain information is used for redirecting effects to correct windowgroup
+// ---------------------------------------------------------------------------
+//
+void CAlfBridge::HandleGroupChained( TAlfBridgerData& aData)
+    {
+    TInt parentId = aData.iInt1;
+    TInt chainedId = aData.iInt2;
+       
+    TChainData data(parentId, chainedId);
+    iWindowChainsArray.Insert(parentId,data);
+    __ALFFXLOGSTRING3("CAlfBridge::DoDispatchL, EAlfDSGroupChained %d chained to %d (host), iWindowChainsArray.Count() = %d", chainedId, parentId, iWindowChainsArray.Count());
+#ifdef _ALF_FXLOGGING
+    CHuiControlGroup* parent = FindControlGroup(parentId);
+    CHuiControlGroup* chained = FindControlGroup(chainedId);
+
+    if (parent)
+        {
+        RDebug::Printf("CAlfBridge::DoDispatch - parent: 0x%x", parent->SecureId());
+        }
+    if (chained)
+        {
+        RDebug::Printf("CAlfBridge::DoDispatch - chained: 0x%x", chained->SecureId());
+        }
+#endif
+    } 
+
+// ---------------------------------------------------------------------------
+// HandleGroupChainBroken
+// ---------------------------------------------------------------------------
+//
+void CAlfBridge::HandleGroupChainBroken( TAlfBridgerData& aData)
+    {
+    TInt parentId = aData.iInt2;
+    iWindowChainsArray.Remove(parentId);
+    __ALFFXLOGSTRING2("CAlfBridge::DoDispatchL, EAlfDSGroupChainBroken - parent: %d, iWindowChainsArray.Count() = %d", parentId, iWindowChainsArray.Count());
+    }
 
 // ---------------------------------------------------------------------------
 // HandleMoveWindowToNewGroupL
@@ -4342,7 +4467,6 @@
 void CAlfBridge::HandleMoveWindowToNewGroupL( TAlfBridgerData& aData )
     {
     TInt windowNodeId = aData.iInt1;
-    TInt screenNumber = aData.iInt2;
     TInt newWindowGroupNodeId = (TInt)aData.iPtr;
    
     CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
@@ -4352,7 +4476,7 @@
     TInt oldWindowGroupId = 0; 
     if ( oldControlGroup  )
         {
-        oldWindowGroupId = FindWindowGroupNodeId(screenNumber, *oldControlGroup );
+        oldWindowGroupId = FindWindowGroupNodeId(*oldControlGroup );
         }   
     __ALFLOGSTRING3("CAlfBridge::HandleMoveWindowToNewGroupL moving nodeId 0x%x from group 0x%x to 0x%x ",windowNodeId, oldWindowGroupId, newWindowGroupNodeId );
 #endif
@@ -4386,7 +4510,7 @@
         viz->Owner().Remove(viz);
         
         // #2 insert visual to the beginning of the new group
-        CHuiControlGroup* newControlGroup = FindControlGroup(newWindowGroupNodeId,screenNumber);
+        CHuiControlGroup* newControlGroup = FindControlGroup(newWindowGroupNodeId);
         if (newControlGroup)
             {
             CHuiControl& newControl = newControlGroup->Control(0);
@@ -4432,7 +4556,7 @@
         }
     else
         {
-        CHuiControlGroup* cg = FindControlGroup(windowNodeId, 0); // TODO: Screen            
+        CHuiControlGroup* cg = FindControlGroup(windowNodeId); // TODO: Screen            
         if (cg) 
             {
             CHuiControl& control = cg->Control(0);
@@ -4624,11 +4748,101 @@
         }
     }
 
-TBool CAlfBridge::HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout *aFromLayout)
+// ---------------------------------------------------------------------------
+// HandleGfxRedirection
+//
+// This effect might have been request for the host application, while the intent was to show it on the application started embedded.
+// Embedded application has its _own_ windowgroup separate from the host application. Fullscreen effect are shown on a windowgroup level.
+// e.g. Messaging -> New Message (editor), or Settings -> Themes (application)
+// Wserv notifies us the window group chaining of applications. See HandleGroupChained and HandleGroupChainBroken for more details. This code
+// will redirect the requested effect on correct windowgroup.
+//
+// NOTE! If embedded application effects are implemented, this will need revision
+// ---------------------------------------------------------------------------
+    
+void CAlfBridge::HandleGfxRedirection(CFullScreenEffectState& aEvent, CHuiLayout*& aToLayout)
+    {
+    TInt windowGroupNodeId = FindWindowGroupNodeId(*((*aToLayout).Owner().ControlGroup()));
+    CHuiControlGroup* chainedGroup = NULL;
+    
+    // check, if the effect is being asked for chained application. This propably indicates that there are two or more instances of it and 
+    // effect was supposed to go to the single standalone instance
+    if (IsChainedGroup(windowGroupNodeId))
+        { 
+        RPointerArray<CHuiControlGroup> groupList;
+        FindControlGroupBySecureId(aEvent.iToSecureId, groupList);
+        TInt i = groupList.Count();
+        TInt standaloneGroups = 0;
+        while(--i >= 0)
+            {
+            windowGroupNodeId = FindWindowGroupNodeId(*groupList[i]);
+            
+            if (!IsChainedGroup(windowGroupNodeId))
+                {
+                // This is an educated guess, which will make the standalone version to have effect. 
+                // Currently (tm) standard appstart effect is never requested for embbedded instances. 
+                chainedGroup = groupList[i];
+                standaloneGroups++;
+                __ALFFXLOGSTRING2("CAlfBridge::HandleGfxRedirection - Wg id: %d is NOT chained. Index: %d",windowGroupNodeId, i);
+                }
+            else
+                {
+                __ALFFXLOGSTRING2("CAlfBridge::HandleGfxRedirection - Wg id: %d IS chained. Index: %d", windowGroupNodeId, i);
+                }
+            }
+        groupList.Close();
+        // If there are multiple standalone app groups (e.g. single application having multiple groups), effecting anything would be a guess.
+        if (standaloneGroups>1)
+            {
+            chainedGroup = NULL;
+            aEvent.iIsRedirected = ETrue;
+            if (iFSFXDataPart2)
+                {
+                iFSFXDataPart2->iIsRedirected = ETrue;
+                }
+            }
+        }
+    else
+        {
+        // Which group is chained to this group?
+        TUint32 chainedId = FindChainedGroup(windowGroupNodeId); 
+        chainedGroup = FindControlGroup(chainedId);
+        }
+    
+    if (chainedGroup)
+        {
+        __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffects - Chained app found for this application. Transferring effect from 0x%x to 0x%x.", aToLayout->Owner().ControlGroup()->SecureId(), chainedGroup->SecureId());
+        aToLayout = (CHuiLayout*)&chainedGroup->Control(0).Visual(0);
+        // we'll change the original effect request to point to this new group. Thus, if effect is 
+        // canceled, it will be removed from the right place.
+        aEvent.iIsRedirected = ETrue;
+        aEvent.iToSecureId = chainedGroup->SecureId(); // Update the effect
+        aEvent.iToWg = FindClientWindowGroupId(*chainedGroup);
+        
+        if (iFSFXDataPart2)
+            {
+            iFSFXDataPart2->iIsRedirected = ETrue;
+            iFSFXDataPart2->iToSecureId = aEvent.iToSecureId;
+            iFSFXDataPart2->iToWg = aEvent.iToWg;
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// HandleGfxEventL
+//
+// ---------------------------------------------------------------------------
+//
+TBool CAlfBridge::HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout* /*aFromLayout */)
     {
     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEventL - To SecureUid: 0x%x, From SecureUid: 0x%x, effect %S", aEvent.iToSecureId, aEvent.iFromSecureId, aEvent.iEffectName);
-    __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEventL - To layout: 0x%x, From layout: 0x%x, Effect handle: %d, Action: %d", aToLayout, aFromLayout, aEvent.iHandle, aEvent.iAction);
-    
+    __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEventL - To layout: 0x%x Effect handle: %d, Action: %d", aToLayout, aEvent.iHandle, aEvent.iAction);
+    
+    if (!aEvent.iIsRedirected)
+        {
+        HandleGfxRedirection(aEvent, aToLayout);
+        }
+        
     TInt err = KErrNone;
     TBool failed = EFalse;
     
@@ -4680,8 +4894,6 @@
                     case AknTransEffect::EApplicationStartSwitchRect:
                     case KAlfFSTaskSwapperAppStart:
                         {
-                        aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that are not yet ready to be drawn, but possible already on the foreground
-                        FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
                         if (iFSFXDataPart2)
                             {
@@ -4764,10 +4976,12 @@
                         
                     if (aToLayout)
                         {
-                        // if this was timeout appstart effect, we need to take screenshot at this point. 
-                        // It was not taken in the beginfullscreen
-                        
-                        if (aEvent.iLongAppStartTimeout)
+                         
+                        // However, if this is timeout, then we should be having update to date screenshot for the long app start effect usage
+                        // For the second part of the effect, screenshot must be update. Thus the transition may continue smoothly, where app_start_long.fxml finished.
+                        if ((aEvent.iLongAppStartTimeout && !aToLayout->StoredRenderBuffer()) 
+                                || aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive // update the screenshot, that the app_start effect can use the end result of app_start_long.fxml as input
+								)
                             {
                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL  - taking screenshot for the timeout appstart effect. Handle: %d",  aEvent.iHandle );
                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
@@ -4824,8 +5038,7 @@
                                 }
                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Active effect group: %d", activeEffectGroup);
                             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
-                            if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName) ||
-                                    aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive)
+                            if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName))
                                 {
                                 effectFlags |= KHuiFxOpaqueHint;
                                 }
@@ -4892,13 +5105,16 @@
     if (aLayout)
         {
 		TRAPD(err, StoreRenderBufferStartL(aLayout));
-		__ALFFXLOGSTRING2("CAlfBridge::FreezeLayoutUntilEffectDestroyed - StoreRenderBufferStartL call returned: %d for layout 0x%x", err, aLayout);
+		__ALFFXLOGSTRING3("CAlfBridge::FreezeLayoutUntilEffectDestroyed - Storing SecureId x%x, StoreRenderBufferStartL call returned: %d for layout 0x%x", aLayout->Owner().ControlGroup()->SecureId(), err, aLayout);
 		if (err == KErrNone)
 			{
             // Freeze only, if buffer was reserved succesfully 
             aLayout->SetFreezeState(ETrue);
-        	TBool itemsDestroyed;
-    	    AddFxItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
+        	if (!HasActiveEffect(aLayout))
+        	    {
+        	    TBool itemsDestroyed;
+        	    AddFxItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
+        	    }
 	        iFSFxData->iAppStartScreenshotItemHandle = aHandle;
 			}
         }
@@ -5009,7 +5225,7 @@
     // If we are in low memory state, we don't want to do any effects
     if(iHuiEnv->MemoryLevel() < EHuiMemoryLevelReduced)
         {
-        __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Returning because memory level below NORMAL");
+        __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - WARNING! - Returning because memory level below NORMAL - EFFECT IS NOT SHOWN!");
 		stream.Release();
         return;
         }
@@ -5247,6 +5463,7 @@
                 && fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen 
                 && fxData->iEffectType == CFullScreenEffectState::EStartEffect)
             {
+            __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Try triggering effect immediately");
             GfxTriggerEffectWhenFullScreenDrawn(toGroup);
             }
         }
@@ -5296,9 +5513,10 @@
     
     CHuiControl& control = aToGroup->Control(0);
     CHuiLayout* toLayout = control.VisualCount() > 0 ? (CHuiLayout*)&control.Visual(0) : NULL;
-    if (!toLayout)
+    if (!toLayout || (toLayout->Flags() & EHuiVisualFlagInactive ))
         {
         // no point starting effect, if the layout is still inactive.
+		__ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - Do not trigger. Layout 0x%x inactive or not found.", toLayout);
         return EFalse;
         }
     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
@@ -5307,7 +5525,7 @@
     // alf content check is relavant only for alf apps
     if (!fullscreenCovered && aToGroup->iAlfApp) 
         {
-        TInt clientGroupId = FindClientWindowGroupId(0, *aToGroup);
+        TInt clientGroupId = FindClientWindowGroupId(*aToGroup);
         if (clientGroupId != KErrNotFound)
             {
             fullscreenCovered = HasActiveAlfContent(clientGroupId);
--- a/uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -1949,8 +1949,8 @@
     if (iModel)
         {
         iModel->Server().Bridge()->AddData( EAlfDSGroupChained, 
-                iId, 
-                aChainedGroup, 
+                iGroupId, 
+                iChainedTo->iGroupId, 
                 (TAny*)iScreenNumber
                 );                
         }
@@ -1962,16 +1962,18 @@
 //
 void CAlfNodeGroup::GroupChainBrokenAfter(  )
 	{
+    TUint32 oldChainedTo = 0; 
 	if ( iChainedTo )
 		{
 		iChainedTo->iChainedFrom = NULL;
+		oldChainedTo = iChainedTo->iId;
 		iChainedTo = NULL;
 		}
 	if (iModel)
 		{
 		iModel->Server().Bridge()->AddData( EAlfDSGroupChainBroken, 
+		        oldChainedTo, 
 				iId, 
-				0, 
 				(TAny*)iScreenNumber );                
 		}
 
@@ -1990,7 +1992,13 @@
     	}
     if ( iChainedFrom )
     	{
-    	iChainedFrom->iChainedTo = NULL;
+        if (iModel)
+            {
+            iModel->Server().Bridge()->AddData( EAlfDSGroupChainBroken, 
+                    iChainedFrom->iId, 
+                    iId, 
+                    (TAny*)iScreenNumber );                
+            }
     	}
     
     if (iModel)
--- a/uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF	Thu Jul 15 19:40:07 2010 +0300
@@ -1603,4 +1603,5 @@
 	?AppIconCache@CHuiEnv@@QBEAAVCAppIconCache@@XZ @ 1602 NONAME ; class CAppIconCache & CHuiEnv::AppIconCache(void) const
 	?Find@CAppIconCache@@QAEPAVCFbsBitmap@@_JVTSize@@@Z @ 1603 NONAME ; class CFbsBitmap * CAppIconCache::Find(long long)
 	?SetSkinSizeChangePending@CHuiDisplay@@QAEXXZ @ 1604 NONAME ; void CHuiDisplay::SetSkinSizeChangePending(void)	
+	?EffectReadyToDrawNextFrame@CHuiVisual@@UBEHXZ @ 1605 NONAME ; int CHuiVisual::EffectReadyToDrawNextFrame(void) const
 
--- a/uiacceltk/hitchcock/coretoolkit/eabi/hitchcocku.DEF	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/eabi/hitchcocku.DEF	Thu Jul 15 19:40:07 2010 +0300
@@ -2004,4 +2004,5 @@
 	_ZN13CAppIconCache6InsertER17TRasterizedBitmap @ 2003 NONAME
 	_ZNK7CHuiEnv12AppIconCacheEv @ 2004 NONAME
 	_ZN11CHuiDisplay24SetSkinSizeChangePendingEv @ 2005 NONAME
+	_ZNK10CHuiVisual26EffectReadyToDrawNextFrameEv @ 2006 NONAME
 
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiCmdBufferBrush.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiCmdBufferBrush.h	Thu Jul 15 19:40:07 2010 +0300
@@ -84,14 +84,14 @@
 public: // from MHuiEffectable
    //void SetEffect(CHuiFxEffect* aEffect);
    void EffectSetEffect(CHuiFxEffect* aEffect);
-   TReal32 EffectOpacityTarget() const;
-   void EffectSetOpacity(TReal32 aOpacity);
+   TReal32 EffectOpacity() const;
+   void EffectSetOpacityAdditive(TReal32 aOpacity, TBool aReplace);
    void EffectDrawSelf( CHuiGc &aGc, const TRect & aDisplayRect) const;
    THuiRealRect EffectDisplayRect() const __SOFTFP;
    void SetLoadingEffect(TBool aLoading);
    void EffectSetSource( TBool aIsInput1 );
    TBool EffectGetSource() const;
-
+   TBool EffectReadyToDrawNextFrame() const;
    
 public: // from MHuiCmdBufDestroyObserver
     void DestroyBuffer(CHuiCanvasCommandBuffer *aBuffer);
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffect.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffect.h	Thu Jul 15 19:40:07 2010 +0300
@@ -146,6 +146,8 @@
     void PrepareCachedRenderTarget(const TPoint& aPosition, const TSize& aSize, TBool aClear, TBool aEnableBackground);
     void ReleaseCachedRenderTarget();
     
+    TBool PrepareDrawL(CHuiGc& aGc, const TRect& aDisplayRect);
+    
     /*
      * CachedDraw is typically much faster than normal draw as it keeps effect result in pre-rendered format
      * instead of doing it on-the-fly as normal draw. There are however few issues that must be noted:
@@ -210,6 +212,8 @@
 	
     TInt iFramesDrawn;
     TReal32 iElapsedTime;
+    
+    MHuiEffectable* iEffectable; // not own
     };
 
 #endif /*HUIFXEFFECT_H_*/
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h	Thu Jul 15 19:40:07 2010 +0300
@@ -55,6 +55,8 @@
     virtual void EnableMarginApplyChildren(TBool aEnable);
     virtual void SetAlwaysReadSurfacePixels(TBool aAlwaysReadSurfacePixels);
 
+    virtual void SetVisualContentState(TBool aChanged, TBool aOpaque);
+
 protected:
     IMPORT_C CHuiFxGroupLayer();
     IMPORT_C void ConstructL(TBool aIsRoot);
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxLayer.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxLayer.h	Thu Jul 15 19:40:07 2010 +0300
@@ -76,6 +76,9 @@
     virtual void EnableMarginApplyChildren(TBool aEnable);
     TBool IsMarginEnabled() const;
     
+    // Internal
+    virtual void SetVisualContentState(TBool aChanged, TBool aOpaque);
+    
     // Internal flag to tell wheter transparency is enabled
     virtual TBool IsSemitransparent() const;
     
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxVisualLayer.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxVisualLayer.h	Thu Jul 15 19:40:07 2010 +0300
@@ -44,6 +44,8 @@
     void SetExtBitmapFileL( TDesC& aFilename );
     TBool IsSemitransparent() const;
     
+    void SetVisualContentState(TBool aChanged, TBool aOpaque);
+    
 public: // effect cache
     IMPORT_C CHuiFxVisualLayer *CloneL() const;
     IMPORT_C void SetExtRect( TRect *aExtRect );
@@ -97,6 +99,11 @@
     HBufC* iExtBitmapFile;
     TReal32 iOpacity;
     TBool iOpaqueHint;
+    
+    CHuiFxEngine*  iEngine;     // not own 
+    CHuiFxRenderbuffer* iRenderBuffer; // owned
+    TBool iVisualContentChanged;
+    TBool iVisualContentOpaque;
     };
 
 #endif /*HUIFXVISUALLAYER_*/
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiRosterImpl.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiRosterImpl.h	Thu Jul 15 19:40:07 2010 +0300
@@ -325,13 +325,14 @@
 	
 	// From MHuiEffectable
     void EffectSetEffect(CHuiFxEffect* aEffect);
-    TReal32 EffectOpacityTarget() const;
-    void EffectSetOpacity(TReal32 aOpacity);
+    TReal32 EffectOpacity() const;
+    void EffectSetOpacityAdditive(TReal32 aOpacity, TBool aReplace);
     void EffectDrawSelf( CHuiGc &aGc, const TRect & aDisplayRect) const;
     THuiRealRect EffectDisplayRect() const __SOFTFP;
     void SetLoadingEffect(TBool aLoading);
     void EffectSetSource( TBool aIsInput1 );
     TBool EffectGetSource() const;	
+    TBool EffectReadyToDrawNextFrame() const;
     
     // From MHuiMemoryLevelObserver
     void SetMemoryLevel(THuiMemoryLevel aLevel);
--- a/uiacceltk/hitchcock/coretoolkit/inc/huieffectable.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huieffectable.h	Thu Jul 15 19:40:07 2010 +0300
@@ -29,13 +29,17 @@
 public:
     virtual ~MHuiEffectable() { }
     virtual void EffectSetEffect(CHuiFxEffect* aEffect)=0;
-    virtual TReal32 EffectOpacityTarget() const=0;
-    virtual void EffectSetOpacity(TReal32 aOpacity)=0;
+    virtual TReal32 EffectOpacity() const=0;
+    // Sets the effect opacity to be given value if bigger than current. Use aReplace to set any value.
+    // This can be used to evaluate the greatest opacity of all effect layers for this effect, so that
+    // drawing can determine if effect as a whole will hide the effected visual or not
+    virtual void EffectSetOpacityAdditive(TReal32 aOpacity, TBool aReplace)=0;
     virtual void EffectDrawSelf( CHuiGc &aGc, const TRect & aDisplayRect) const=0;
     virtual THuiRealRect EffectDisplayRect() const __SOFTFP=0;
     virtual void SetLoadingEffect(TBool aLoading)=0;
     virtual void EffectSetSource( TBool aIsInput1 )=0;
     virtual TBool EffectGetSource() const=0;
+    virtual TBool EffectReadyToDrawNextFrame() const = 0;
     };
     
 #endif    
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -1387,6 +1387,7 @@
             else
                 aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), size, NULL, NULL);
             }
+#ifndef __WINS__
         // assume 32bpp for the icon, don't cache if it's too large
         TInt bitmapBytes = aDestSize.iWidth*aDestSize.iHeight*4;
         if (bitmapBytes < 128*128*4)
@@ -1416,6 +1417,7 @@
                 delete rasterizedIcon;
                 }
             }
+#endif
         }
 
     // restore the old surface before restoring original modes
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -3138,40 +3138,41 @@
     {
     // TODO: This should handle NVG textures
     
+    // No need to fetch only the unused texture entries to a separate binary
+    // ordered tree (with FindUnusedEntries()), just going the cached
+    // texts & images through once is enough.
     TInt totalUnusedTextureBytes = 0;
+    TSize textureSize(0,0);
     
     // Texts
-    RPointerArray<CHuiCanvasTextImage> textEntries;
-    
-    FindUnusedTextEntries(textEntries);
-
-    for(TInt i=textEntries.Count() - 1; i >= 0; i--)
+    for(TInt i = iCachedTexts.Count() - 1; i >= 0; i--)
         {
-        TSize textureSize = textEntries[i]->iTexture->Size();    
-        totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * KHuiCanvasTextEstimatedBpp/8.f;
-        }            
-    
-    textEntries.Close();        
-
-    // Images
-    RPointerArray<CHuiCanvasGraphicImage> imageEntries;
+        CHuiCanvasTextImage* entry = iCachedTexts[i];
+        // Check if the texture is being used..
+        if (!entry->iActiveUsers.Count())
+            {
+            // ..and if not, add it to the sum.
+            textureSize = entry->iTexture->Size();
+            totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * KHuiCanvasTextEstimatedBpp/8.f;
+            }
+        }
     
-    FindUnusedImageEntries(imageEntries);
-
-    for(TInt i=imageEntries.Count() - 1; i >= 0; i--)
+    // Images, just like texts.
+    for(TInt i = iCachedImages.Count() - 1; i >= 0; i--)
         {
-        TBool is16bit = EFalse;
-        if (imageEntries[i]->iBitmap && !imageEntries[i]->iMask && imageEntries[i]->iBitmap->ExtendedBitmapType() == KNullUid &&imageEntries[i]->iBitmap->DisplayMode() == EColor64K)
+        CHuiCanvasGraphicImage* entry = iCachedImages[i];    
+        if (!entry->iActiveUsers.Count())
             {
-            is16bit = ETrue;
+            TBool is16bit = EFalse;
+            if (entry->iBitmap && !entry->iMask && entry->iBitmap->ExtendedBitmapType() == KNullUid && entry->iBitmap->DisplayMode() == EColor64K)
+                {
+                is16bit = ETrue;
+                }
+            textureSize = entry->iTexture->Size();    
+            totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * (is16bit ? KHuiCanvasImageEstimatedBpp/16.f : KHuiCanvasImageEstimatedBpp/8.f);
             }
-
-        TSize textureSize = imageEntries[i]->iTexture->Size();    
-        totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * (is16bit ? KHuiCanvasImageEstimatedBpp/16.f : KHuiCanvasImageEstimatedBpp/8.f);
-        }            
-    
-    imageEntries.Close();        
-    
+        }
+
     return totalUnusedTextureBytes/1024;
     }
 
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -350,8 +350,7 @@
     if (Effect())
         {
         TBool hasStoredContent = (IsDelayedEffectSource() || Freezed()) && (StoredRenderBuffer() ||  iCanvasVisualData->iStoredRenderBuffer);
-    
-        TBool semiTranparentEffectActive = Effect()->IsSemitransparent();
+        TBool semiTranparentEffectActive = iEffectOpacity < 1.f;
         if ((iOpacity.Now() <= EPSILON && !semiTranparentEffectActive))
             {
             return ETrue;
@@ -396,7 +395,7 @@
     	}
     
     // Optimization
-    if (CanSkipDrawing())
+    if (!EffectActive() && CanSkipDrawing())
         {
         return;
         }
@@ -453,11 +452,6 @@
     
     if (EffectActive())
         {
-        // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing 
-        TBool transparent = EFalse; 
-        transparent |= (!(Flags() & EHuiVisualFlagOpaqueHint)); // Does not have opaque hint -> always transparent
-        transparent |= iOpacity.Now() < 1.0f; // Opacity less than 1.0f -> always transparent
-                
         TBool refreshCache = EFalse;        
         TBool layer =  EFalse;
         if (EffectIsAppliedToChildren())
@@ -479,8 +473,23 @@
             {
             refreshCache |= Display()->RosterImpl().NativeAppsContentChanged();
             }
-        didDrawEffect = Effect()->CachedDraw(aGc, area, refreshCache, !transparent, iCanvasVisualData->iPaintedRegion,layer );
-        
+        Effectable()->EffectSetOpacityAdditive(0.0f, ETrue);
+        // PrepareDraw will update iEffectOpacity to correct opacity for this effect frame        
+        if(Effect()->PrepareDrawL(aGc, area))
+            {
+			// let's still check if effect is making visual fully transparent
+            if(CanSkipDrawing())
+                {
+                return;
+                }
+            // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing 
+            TBool transparent = EFalse; 
+            transparent |= (!(Flags() & EHuiVisualFlagOpaqueHint)); // Does not have opaque hint -> always transparent
+            transparent |= iOpacity.Now() < 1.0f; // Opacity less than 1.0f -> always transparent
+            transparent |= iEffectOpacity < 1.0f; // effect opacity is less than 1.0f
+
+            didDrawEffect = Effect()->CachedDraw(aGc, area, refreshCache, !transparent, iCanvasVisualData->iPaintedRegion, layer );
+            }
         }
     
     if ( !didDrawEffect )
@@ -1338,7 +1347,11 @@
     CHuiCanvasGc& gc = CanvasGc();
     CHuiCanvasVisual* visual = NULL; 
     TBool transparent = EffectiveOpacity() < 1.0f;
-    gc.SetDrawMode((THuiCanvasDrawMode)aCanvasDrawMode);
+	if(EffectActive())
+		{
+	    transparent |= iEffectOpacity < 1.0f;
+    	}
+	gc.SetDrawMode((THuiCanvasDrawMode)aCanvasDrawMode);
     if (transparent)
         {
         gc.EnableEffectiveOpacity(ETrue);  
@@ -1384,6 +1397,10 @@
     THuiRealPoint dest_point = DisplayRect().iTl;
     CHuiCanvasRenderBuffer *stored = StoredRenderBuffer();
     TBool transparent = EffectiveOpacity() < 1.0f;
+	if(EffectActive())
+		{
+	    transparent |= iEffectOpacity < 1.0f;
+    	}
     CHuiCanvasVisual* visual = NULL; 
 	gc.SetDrawMode((THuiCanvasDrawMode)aCanvasDrawMode);
     if (transparent)
@@ -1599,3 +1616,34 @@
     
     return rosterFrozen || inactive;
     }
+
+TBool CHuiCanvasVisual::EffectReadyToDrawNextFrame() const 
+    {
+    // if the visual is drawn ans a external content it is probably already inactive
+    if (Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)
+        {
+        if (Display() && Display()->RosterImpl().IsDrawingExternalContent())
+            {
+            return ETrue;
+            }
+        }
+
+    // other checks to
+    TBool rdyToDraw = EFalse;
+    if(Display()->RosterImpl().AlfEventWindow() == this)
+        {
+        rdyToDraw |= ETrue;
+        }
+    
+    rdyToDraw |= (IsDelayedEffectSource() || Freezed()) &&
+                    (StoredRenderBuffer() ||  iCanvasVisualData->iStoredRenderBuffer);
+    rdyToDraw |= (Effect()->EffectFlags() & KHuiFxEnableBackgroundInAllLayers);
+    rdyToDraw |= EffectIsAppliedToChildren();
+    rdyToDraw |= IsExternalContentDrawingEnabled() || IsExternalContentDrawingEnabled(ETrue);
+    rdyToDraw |= IsBackgroundDrawingEnabled();
+
+    rdyToDraw |= HasCommandBuffers(ETrue);
+
+    // visual must be active (seen) and have content
+    return (!(Flags() & EHuiVisualFlagInactive) && rdyToDraw);
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCmdBufferBrush.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCmdBufferBrush.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -204,11 +204,11 @@
     iEffect = aEffect;
     }
 
-TReal32 CHuiCmdBufferBrush::EffectOpacityTarget() const
+TReal32 CHuiCmdBufferBrush::EffectOpacity() const
     {
     return 1.0;
     }
-void CHuiCmdBufferBrush::EffectSetOpacity(TReal32 aOpacity)
+void CHuiCmdBufferBrush::EffectSetOpacityAdditive(TReal32 /*aOpacity*/, TBool /*aReplace*/)
     {
     // empty
     }
@@ -243,6 +243,10 @@
     {
     return EFalse;
     }
+TBool CHuiCmdBufferBrush::EffectReadyToDrawNextFrame() const
+    {
+    return ETrue;
+    }
 
 void CHuiCmdBufferBrush::DestroyBuffer(CHuiCanvasCommandBuffer *aBuffer)
     {
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -66,6 +66,7 @@
     }
 EXPORT_C void CHuiFxEffect::SetVisual( MHuiEffectable *aEffectable )
     {
+    iEffectable = aEffectable;
     iRoot->SetVisual(aEffectable);
     }
 EXPORT_C void CHuiFxEffect::SetEngine( CHuiFxEngine *aEngine )
@@ -258,6 +259,56 @@
         }
     }
 
+TBool CHuiFxEffect::PrepareDrawL(CHuiGc& aGc, const TRect& aDisplayRect)
+    {
+    if(!iEffectable || iEffectable->EffectReadyToDrawNextFrame() )
+         {
+         iFramesDrawn++;
+         }
+
+    // Prepare all layers
+    TRect displayArea = aGc.DisplayArea();
+    TRect targetArea = aDisplayRect;
+    targetArea.Intersection(displayArea);
+
+    if (targetArea.Width() <= 0 || targetArea.Height() <= 0)
+        {
+        // Not visible
+        return ETrue;
+        }
+    
+    if (!iEngine || !iRoot)
+        {
+        return EFalse;
+        }
+
+    if (iEngine->LowMemoryState())
+        {
+        // No memory, no effects.
+        return EFalse;
+        }
+    
+    // Check if margins are allowed to be used for this effect
+    if (EffectFlags() & KHuiFxEffectDisableMarginsFlag)
+        {
+        iRoot->EnableMargin(EFalse);
+        }
+
+    
+    iRoot->SetTargetRect(targetArea);
+    iRoot->SetSourceRect(targetArea);        
+    iRoot->SetDisplayArea(displayArea);
+    
+    TRAPD(err, iRoot->PrepareDrawL(*iEngine));
+    
+    if (err != KErrNone)
+        {
+        return EFalse;
+        }
+
+    return ETrue;
+    }
+
 TBool CHuiFxEffect::CachedDraw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aRefreshCachedRenderTarget, TBool aOpaque)
     {
     RRegion dummy;
@@ -272,12 +323,11 @@
 #ifdef HUIFX_TRACE    
     RDebug::Print(_L("CHuiFxEffect::CachedDraw - 0x%x"), this);
 #endif    
-    iFramesDrawn++;
+
     if (!CHuiStatic::Renderer().Allows(EHuiRenderPluginAllowVisualPBufferSurfaces))
         {
         return EFalse;
         }
-            
     
     CHuiFxRenderbuffer* target = NULL;
     
@@ -303,29 +353,14 @@
         return EFalse;
         }
     
-    // Check if margins are allowed to be used for this effect
-    if (EffectFlags() & KHuiFxEffectDisableMarginsFlag)
-        {
-        iRoot->EnableMargin(EFalse);
-        }
-
     // Check if surface pixels are to be used for this effect in all layers.
     if (EffectFlags() & KHuiFxEnableBackgroundInAllLayers)
         {
         iRoot->SetAlwaysReadSurfacePixels(ETrue);
-        }
-    
-    iRoot->SetTargetRect(targetArea);
-    iRoot->SetSourceRect(targetArea);        
-    iRoot->SetDisplayArea(displayArea);
+        } 
+
+    iRoot->SetVisualContentState(aRefreshCachedRenderTarget, aOpaque);
     
-    TRAPD(err, iRoot->PrepareDrawL(*iEngine));
-    
-    if (err != KErrNone)
-        {
-        return EFalse;
-        }
-
     if (IsCachedRenderTargetSupported() && IsCachedRenderTargetPreferred())
         {
         // Background needs to be captured from surface if effect uses background AND 
@@ -422,7 +457,6 @@
         // Normal drawing
         iRoot->Draw(*iEngine, aGc, *target, *target, aHasSurface);
         }
-                
     return ETrue;    
     }
 
@@ -432,7 +466,6 @@
 #ifdef HUIFX_TRACE    
     RDebug::Print(_L("CHuiFxEffect::Draw - 0x%x"), this);
 #endif
-    iFramesDrawn++;
     if (!CHuiStatic::Renderer().Allows(EHuiRenderPluginAllowVisualPBufferSurfaces))
         {
         return EFalse;
@@ -484,6 +517,8 @@
         }
 
     iRoot->Draw(*iEngine, aGc, *target, *target, aHasSurface);
+
+
     return ETrue;
     }
 
@@ -565,13 +600,13 @@
     // its whole timeline by starting the time only when first frame has been drawn.
     if (iFlags & KHuiFxDelayRunUntilFirstFrameHasBeenDrawn)
         {
-        // Sometimes the effect does not get any frames. Force the time to start, because
-        // otherwise will jam itself and possible the group, where the effect is.
-        if (iElapsedTime > 0.2 && iFramesDrawn == 0)
+        // This is a backup timer. If effect won't start before this 10sec wait there must be something wrong
+		// Force effect to start after 10seconds
+		if (iElapsedTime > 10.0 && iFramesDrawn == 0)
             {
             iFramesDrawn = 1;
 #ifdef HUIFX_TRACE            
-            RDebug::Printf("CHuiFxEffect::AdvanceTime - Not drawn, but cannot wait. release 0x%x in time %f", this, iElapsedTime);
+            RDebug::Printf("CHuiFxEffect::AdvanceTime - Not drawn in 10sec, FORCE start. There was something wrong. release 0x%x in time %f", this, iElapsedTime);
 #endif
             }
         
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffectParser.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffectParser.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -136,7 +136,7 @@
         iEffect = NULL;
         if (iVisual)
             {
-            iVisual->EffectSetOpacity(1.0f);
+            iVisual->EffectSetOpacityAdditive(1.0f, ETrue);
 #ifndef HUIFX_EFFECTCACHE_ENABLED
             iVisual->SetEffect( tempEffect );
 #endif
@@ -155,7 +155,7 @@
         iEffect = NULL;
         if (iVisual)
             {
-            iVisual->EffectSetOpacity(1.0f);
+            iVisual->EffectSetOpacityAdditive(1.0f, ETrue);
             iVisual->EffectSetEffect( NULL );
             }
         }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxGroupLayer.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxGroupLayer.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -474,3 +474,11 @@
         iLayers[i]->SetAlwaysReadSurfacePixels(aAlwaysReadSurfacePixels);
         }
     }
+
+void CHuiFxGroupLayer::SetVisualContentState(TBool aChanged, TBool aOpaque)
+    {
+    for( TInt i=0 ; i < iLayers.Count() ; i++ )
+        {
+        iLayers[i]->SetVisualContentState(aChanged, aOpaque);
+        }    
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxLayer.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxLayer.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -174,6 +174,11 @@
     }
 
 
+void CHuiFxLayer::SetVisualContentState(TBool /*aChanged*/, TBool /*aOpaque*/)
+    {
+    /* empty in baseclass */
+    }
+
 TBool CHuiFxLayer::IsMarginEnabled() const
     {
     return iMarginEnabled;
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxVisualLayer.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxVisualLayer.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -74,8 +74,7 @@
     // We use the visual's own target opacity if we haven't set something explicitly    
     if (iVisual)
         {
-        //iOpacity = iVisual->iOpacity.Target();
-        iOpacity = iVisual->EffectOpacityTarget();
+        iOpacity = iVisual->EffectOpacity();
         }
     else
         {
@@ -196,8 +195,7 @@
     
     if (Math::IsInfinite(iOpacity))
         {
-        //iOpacity = iVisual->iOpacity.Target();
-        iOpacity = iVisual->EffectOpacityTarget();
+        iOpacity = iVisual->EffectOpacity();
         }    
     }
 
@@ -208,6 +206,11 @@
 #ifdef HUIFX_TRACE    
     RDebug::Print(_L("CHuiFxVisualLayer::~CHuiFxVisualLayer - 0x%x "), this);
 #endif
+    if(iRenderBuffer && iEngine)
+        {
+        iEngine->ReleaseRenderbuffer(iRenderBuffer);
+        }
+    
     delete iExtBitmapFile;
     delete iParameterManager;
     iParameterManager = NULL;
@@ -226,10 +229,14 @@
     {
     iParameterManager->AdvanceTime(aElapsedTime);
     }
-
+ 
 EXPORT_C TBool CHuiFxVisualLayer::PrepareDrawL(CHuiFxEngine& aEngine)
     {
     iParameterManager->Update(aEngine, VisualRect());
+    if(iVisual)
+        {
+        iVisual->EffectSetOpacityAdditive( iOpacity, EFalse );
+        }
     return ETrue;
     }
 
@@ -238,55 +245,112 @@
 #ifdef HUIFX_TRACE    
     RDebug::Print(_L("CHuiFxVisualLayer::Draw - 0x%x "), this);
 #endif
+    TRect backbufferRect = SourceRect();
+    TSize backbufferSize = backbufferRect.Size();
+    THuiFxEngineType engineType = aEngine.EngineType();
+    TBool forceRefresh = EFalse;
+    
+    if (iRenderBuffer && iRenderBuffer->Size() != backbufferSize)
+        {
+        iEngine->ReleaseRenderbuffer(iRenderBuffer);
+        iRenderBuffer = NULL;
+        }
+    
+    if(!iRenderBuffer)
+        {
+        iRenderBuffer = aEngine.AcquireRenderbuffer(backbufferSize, EFalse);
+        if (!iRenderBuffer)
+            {
+            return;
+            }
+        iEngine = &aEngine;
+        forceRefresh = ETrue;
+        }
+    
+    // don't update render buffer if visual is not changed or screenshot is used
+    if(forceRefresh || (iVisualContentChanged && iSrcType!=EVisualSrcInput1))
+        {
+        if(!iVisualContentOpaque)
+            {
+            iRenderBuffer->PrepareForReuse(backbufferRect.Size());
+            }
+        iRenderBuffer->BindAsRenderTarget();
+        
+        // Translate the graphics context so that the content appears in the correct place
+        aGc.Push(EHuiGcMatrixModel);
+        if(engineType == EHuiFxEngineVg10)
+            {
+            aGc.Scale(EHuiGcMatrixModel, 1.0f, -1.0f, 1.0f);
+            aGc.Translate(EHuiGcMatrixModel, 0.0f, -backbufferRect.Size().iHeight, 0.0f);
+            }
+        
+        aGc.Translate(EHuiGcMatrixModel, -backbufferRect.iTl.iX, -backbufferRect.iTl.iY, 0.0f);
+        aGc.SetBlendMode( CHuiGc::EBlendNormal );
+    
+        // Set new clipping region which does not clip anything. 
+        // We want always draw visual fully to the aTarget. 
+        aGc.PushClip();
+        TRect bufferArea = TRect(TPoint(0,0), backbufferSize); 
+        aGc.SetClip(bufferArea); // this does not transform bufferArea which is fine for us    
+        
+        // Draw visual content to aTarget
+        iVisual->EffectSetSource(iSrcType==EVisualSrcInput1);
+        iVisual->EffectDrawSelf( aGc, TargetRect() );
+        iVisual->EffectSetSource(EFalse);
+        
+        // Restore original clipping
+        aGc.PopClip();
+        
+        aGc.Pop(EHuiGcMatrixModel);
+        iRenderBuffer->UnbindAsRenderTarget();
+        }
+    
     aTarget.BindAsRenderTarget();
+
+    // make effect transformations effective
     aGc.Push(EHuiGcMatrixModel);
-    
-    THuiFxEngineType engineType = aEngine.EngineType();
     TRenderBufferType bufferType = aTarget.BufferType();
     if(engineType == EHuiFxEngineGles20)
         {
         if(bufferType == EBufferTypeOffscreen)
-            {
-            aGc.Enable(CHuiGc::EFeatureBlending, ETrue);
-            aGc.SetBlendMode(CHuiGc::EBlendReplace);
-            }
+             {
+             aGc.Enable(CHuiGc::EFeatureBlending, ETrue);
+             aGc.SetBlendMode(CHuiGc::EBlendReplace);
+             }
         TRect viewPort(TPoint(0,0), aTarget.Size());
         aGc.SetProjection(CHuiGc::EProjectionOrthographic, viewPort);
         }
-    
-    aGc.Translate(EHuiGcMatrixModel, VisualRect().iTl.iX, VisualRect().iTl.iY, 0.0f);
-    ApplyTransformations(aGc);
-    aGc.Translate(EHuiGcMatrixModel, -VisualRect().iTl.iX, -VisualRect().iTl.iY, 0.0f);
-    
-    aGc.SetBlendMode( CHuiGc::EBlendNormal );
-    //iVisual->iOpacity.Set( iOpacity );
-    iVisual->EffectSetOpacity( iOpacity );   
+     
+     aGc.Translate(EHuiGcMatrixModel, VisualRect().iTl.iX, VisualRect().iTl.iY, 0.0f);
+     ApplyTransformations(aGc);
+     aGc.Translate(EHuiGcMatrixModel, -VisualRect().iTl.iX, -VisualRect().iTl.iY, 0.0f);
+     
+     aGc.SetBlendMode( CHuiGc::EBlendNormal );
+  
+    // do composition to aTarget
+    TRect compositionTargetRect(TargetRect());        
+    compositionTargetRect.Move(-aTarget.Position());
+
+    aGc.Disable(CHuiGc::EFeatureClipping); 
     
-    // Set new clipping region which does not clip anything. 
-    // We want always draw visual fully to the aTarget. 
-    aGc.PushClip();
-    TRect bufferArea = TRect(TPoint(0,0), aTarget.Size()); 
-    aGc.SetClip(bufferArea); // this does not transform bufferArea which is fine for us    
+    // following must always have aOpaque = Efalse because it is quite common that effected window
+    // has areas which do not have any drawing. Even if iOpacity is 1.f these areas are drawn
+    // incorrectly in this case -> we always blend 
+    aEngine.Composite(aGc, *iRenderBuffer, compositionTargetRect.iTl, EFalse, iOpacity*255);
     
-    // Draw visual content to aTarget
-    //iVisual->DrawSelf(aGc, TargetRect());
-    iVisual->EffectSetSource(iSrcType==EVisualSrcInput1);
-    iVisual->EffectDrawSelf( aGc, TargetRect() );
-    iVisual->EffectSetSource(EFalse);
-    
-    // Restore original clipping
-    aGc.PopClip();
+    aGc.Enable(CHuiGc::EFeatureClipping);
     
     if(engineType == EHuiFxEngineGles20)
-        {
-        if(bufferType == EBufferTypeOffscreen)
-            {
-            aGc.SetBlendMode(CHuiGc::EBlendNormal);
-            }
-        aGc.SetProjection(CHuiGc::EProjectionOrthographic);
-        }
-    
+         {
+         if(bufferType == EBufferTypeOffscreen)
+             {
+             aGc.SetBlendMode(CHuiGc::EBlendNormal);
+             }
+         aGc.SetProjection(CHuiGc::EProjectionOrthographic);
+         }
+     
     aGc.Pop(EHuiGcMatrixModel);
+
     aTarget.UnbindAsRenderTarget();
     }
 
@@ -469,3 +533,12 @@
         return EFalse;        
         }
     }
+
+void CHuiFxVisualLayer::SetVisualContentState(TBool aChanged, TBool aOpaque)
+    {
+    if( iVisualContentOpaque != aOpaque || aChanged)
+        {
+        iVisualContentChanged = aChanged;
+        }
+    iVisualContentOpaque = aOpaque;
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiLayout.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiLayout.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -494,7 +494,7 @@
     		}
     	}
 
-    if(iOpacity.Now() <= EPSILON && (Effect() && !Effect()->IsSemitransparent()))
+    if(iOpacity.Now() <= EPSILON && !Effect())
         {
         // This will not be visible due to being completely transparent.
         return;
@@ -540,12 +540,33 @@
     
     if (canUseEffectDrawing)
         {
-        // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing 
-        TBool transparent = !(Flags() & EHuiVisualFlagOpaqueHint) && iOpacity.Now() < 1.0f;
-        TBool refreshCache = Changed();                
-        didDrawEffect =  Effect()->CachedDraw(aGc, area, refreshCache, !transparent);
+        Effectable()->EffectSetOpacityAdditive(0.0f, ETrue);
+        // PrepareDrawL will update iEffectOpacity for current frame
+        if(Effect()->PrepareDrawL(aGc, area))
+            {
+            if(iEffectOpacity <= 0.f)
+                {
+                if(Clipping())
+                    {
+                    // Restore original clipping rectangle.
+                    aGc.PopClip();
+                    }
+
+                
+                DrawBrushes(aGc, EHuiBrushLayerForeground);
+
+                // Restore original transformation.
+                Transform(aGc, EFalse);
+                EnterLocalProjection(aGc, EFalse);
+                return;
+                }
+        
+            // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing 
+            TBool transparent = !(Flags() & EHuiVisualFlagOpaqueHint) && iOpacity.Now() < 1.0f;
+            TBool refreshCache = Changed();                
+            didDrawEffect =  Effect()->CachedDraw(aGc, area, refreshCache, !transparent);
+            }
         }
-    
     if ( !didDrawEffect )
         {
         // huilayout does not draw itself, only children.
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiRosterImpl.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiRosterImpl.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -500,13 +500,20 @@
         // some other part of the effect, so this workaround won't work correctly in those cases. 
         // To get those working, propably whole opacity effect handling should be re-written 
         // differently.
-        if (iEffect->IsSemitransparent() || iEffectOpacity < 1.f)
+        CHuiRosterImpl* nonconst = const_cast<CHuiRosterImpl*>(this);
+        nonconst->Effectable()->EffectSetOpacityAdditive(0.0f, ETrue);
+        // PrepareDraw will update iEffectOpacity to correct opacity for this effect frame
+        if(iEffect->PrepareDrawL(aGc, displayRect))
             {
-            iEffect->ForceCachedRenderTargetUsage(ETrue);
-            }        
-        RRegion dummy;
-        didDrawEffect = iEffect->CachedDraw(aGc, displayRect, refreshCache, opaque, dummy, EFalse, iEffectOpacity*255);        
-        dummy.Close();
+            if (iEffectOpacity < 1.f)
+                {
+                iEffect->ForceCachedRenderTargetUsage(ETrue);
+                }        
+
+            RRegion dummy;
+            didDrawEffect = iEffect->CachedDraw(aGc, displayRect, refreshCache, opaque, dummy, EFalse, iEffectOpacity*255);        
+            dummy.Close();
+            }
         }
     
     if (!didDrawEffect)
@@ -1831,12 +1838,12 @@
     SetChanged();
     }
 
-TReal32 CHuiRosterImpl::EffectOpacityTarget() const
+TReal32 CHuiRosterImpl::EffectOpacity() const
     {
     return iEffectOpacity; 
     }
 
-void CHuiRosterImpl::EffectSetOpacity(TReal32 aOpacity)
+void CHuiRosterImpl::EffectSetOpacityAdditive(TReal32 aOpacity, TBool /*aReplace*/)
     {
     iEffectOpacity = aOpacity;
     }
@@ -1877,6 +1884,11 @@
     return iIsInput1;
     }
 
+TBool CHuiRosterImpl::EffectReadyToDrawNextFrame() const
+    {
+    return ETrue;
+    }
+
 void CHuiRosterImpl::SetMemoryLevel(THuiMemoryLevel /*aLevel*/)
     {
     if ( IsVisibleContentFrozen() && !UseRenderBufferForFreeze() )
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiTextVisual.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiTextVisual.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -359,7 +359,6 @@
             (color & 0xff000000);
         }
 //#endif    
-    return aColor;
     }
 
     
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiTextureManager.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiTextureManager.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -2449,7 +2449,8 @@
 	{
 	TReal32 totalMemUsage = 0;
 	TReal32 avgBitDepth = 0;
-    for(TInt i = 0; i < iTextures.Count(); ++i)
+	TInt count = iTextures.Count();
+    for(TInt i = 0; i < count; ++i)
         {
         if( iTextures[i]->iTexture )
             {            
@@ -2470,12 +2471,15 @@
     buf.AppendNum( avgBitDepth );
     User::InfoPrint( buf );      
 	}
+
 TInt CHuiTextureManager::EstimatedTextureMemUsage(TInt aAverageBitsPerPixel) const
     {
     TReal32 averageBytesPerPixel =  TReal32(aAverageBitsPerPixel)/8.f;
 	TReal32 totalMemUsage = 0;
     TInt pixels = 0;
-    for(TInt i = 0; i < iTextures.Count(); ++i)
+    TInt count = iTextures.Count();
+    
+    for(TInt i = 0; i < count; ++i)
         {
         // TODO: Exclude NVG textures !
         if( iTextures[i]->iTexture /*&& 
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiVisual.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiVisual.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -82,14 +82,16 @@
 public: // from MHuiEffectable
     CHuiEffectable(CHuiVisual *aVisual) : iVisual(aVisual) { }
     void EffectSetEffect(CHuiFxEffect* aEffect);
-    TReal32 EffectOpacityTarget() const;
-    void EffectSetOpacity(TReal32 aOpacity);
+    TReal32 EffectOpacity() const;
+    void EffectSetOpacityAdditive(TReal32 aOpacity, TBool aReplace);
     void EffectDrawSelf( CHuiGc &aGc, const TRect & aDisplayRect) const;
     THuiRealRect EffectDisplayRect() const __SOFTFP;
     void SetLoadingEffect(TBool aLoading);    
     void EffectSetSource( TBool aIsInput1 );
     TBool EffectGetSource() const;
+    TBool EffectReadyToDrawNextFrame() const;
 
+    
 private:
     CHuiVisual *iVisual;
     TBool iIsInput1;
@@ -107,14 +109,22 @@
     return iIsInput1;
     }
 
-TReal32 CHuiEffectable::EffectOpacityTarget() const
+TBool CHuiEffectable::EffectReadyToDrawNextFrame() const
     {
-    return iVisual->iOpacity.Target();
+    return iVisual->EffectReadyToDrawNextFrame();
     }
 
-void CHuiEffectable::EffectSetOpacity(TReal32 aOpacity)
+TReal32 CHuiEffectable::EffectOpacity() const
     {
-    iVisual->iOpacity.Set( aOpacity );
+    return iVisual->iEffectOpacity;
+    }
+
+void CHuiEffectable::EffectSetOpacityAdditive(TReal32 aOpacity, TBool aReplace)
+    {
+    if( aReplace || aOpacity > iVisual->iEffectOpacity)
+        {
+        iVisual->iEffectOpacity = aOpacity;
+        }
     }
 
 void CHuiEffectable::EffectDrawSelf( CHuiGc &aGc, const TRect & aDisplayRect) const
@@ -184,6 +194,11 @@
     return iVisualData->iFreezed;
 }
 
+EXPORT_C TBool CHuiVisual::EffectReadyToDrawNextFrame() const
+    {
+    return  ETrue;
+    }
+
 EXPORT_C CHuiVisual* CHuiVisual::AddNewL(CHuiControl& aOwnerControl,
                                          CHuiLayout* aParentLayout)
     {
@@ -195,6 +210,7 @@
 
 EXPORT_C CHuiVisual::CHuiVisual(MHuiVisualOwner& aOwner)
         : iOpacity(1.f),
+          iEffectOpacity(1.f),
           iOwner(&aOwner), 
           // Set the maximum size to unlimited.
           iMaxSize(TSize(KMaxTInt, KMaxTInt)),
@@ -917,10 +933,30 @@
         
         if (canUseEffectDrawing)
             {
-            // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing 
-            TBool transparent = !(Flags() & EHuiVisualFlagOpaqueHint);
-            TBool refreshCache = Changed();                
-            didDrawEffect = iVisualData->iEffect->CachedDraw(aGc, displayRect, refreshCache, !transparent);
+            Effectable()->EffectSetOpacityAdditive(0.0f, ETrue);
+            // PrepareDrawL will update iEffectOpacity for current frame
+            if(iVisualData->iEffect->PrepareDrawL(aGc, displayRect))
+                {
+                if(iEffectOpacity <= 0.f)
+                    {
+                    if(Clipping())
+                        {
+                        aGc.PopClip();
+                        }
+                    
+                    // Draw foreground brushes (over the content).
+                    DrawBrushes(aGc, EHuiBrushLayerForeground);
+
+                    // Undo local transformation.
+                    Transform(aGc, EFalse);
+                    EnterLocalProjection(aGc, EFalse);
+                    return;
+                    }
+                // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing 
+                TBool transparent = !(Flags() & EHuiVisualFlagOpaqueHint);
+                TBool refreshCache = Changed();                
+                didDrawEffect = iVisualData->iEffect->CachedDraw(aGc, displayRect, refreshCache, !transparent);
+                }
             }
 
         if (!didDrawEffect) 
--- a/uiacceltk/hitchcock/goommonitor/data/goomconfig.xml	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/data/goomconfig.xml	Thu Jul 15 19:40:07 2010 +0300
@@ -36,8 +36,8 @@
   <app uid="101F857A" low_ram_threshold="1000" good_ram_threshold="30000" skip_plugin="2002B3AE" icon_cache="0" use_sw_rend="Yes"></app> <!-- Camera --> 
   <app uid="200159B2" low_ram_threshold="5000" good_ram_threshold="10000" skip_plugin="2002B3AE"></app> <!-- MPlayer -->
   <app uid="102824CD" low_ram_threshold="5000" good_ram_threshold="10000" skip_plugin="2002B3AE"></app> <!-- Embedded mplayer -->
-  <app uid="200009EE" low_ram_threshold="3637" good_ram_threshold="10000" target_free_on_startup="15000"></app> <!-- Photos -->
-  <app uid="101FD693" low_ram_threshold="5000" good_ram_threshold="10000" target_free_on_startup="26000"></app> <!-- Flashlite -->
+  <app uid="200009EE" low_ram_threshold="3637" good_ram_threshold="10000" target_free_on_startup="10000"></app> <!-- Photos -->
+  <app uid="101FD693" low_ram_threshold="5000" good_ram_threshold="10000" skip_plugin="2002C30A" target_free_on_startup="26000"></app> <!-- Flashlite -->
 
 	</app_specific_thresholds>
 
--- a/uiacceltk/hitchcock/goommonitor/inc/goomactionlist.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomactionlist.h	Thu Jul 15 19:40:07 2010 +0300
@@ -225,6 +225,10 @@
     
     void ConstructL(CGOomConfig& aConfig);
     
+    TBool IsOkToKillApp(TInt aAppId);
+    
+    TBool AppCloseActionAlreadyExists(CGOomWindowGroupList& aWindowGroupList, TInt32 appId);
+    
 private: //data    
     
     RWsSession& iWs;
@@ -263,7 +267,7 @@
     TBool iRunningKillAppActions;
     
     TUint iCurrentPluginRun;
-    RArray<TInt> iLowOnMemWgs;
+//    RArray<TInt> iLowOnMemWgs;
     TBool iUseSwRendering;
     TBool iTryOptional; // we did everything we could but still missing some bits, try again with different app targets
     TBool iOptionalTried; // no need to overperform though
--- a/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h	Thu Jul 15 19:40:07 2010 +0300
@@ -27,6 +27,8 @@
 #include "goomwindowgrouplist.h"
 #include "goomtraces.h"
 
+#define ALWAYS_SW_REND 0	//enable only for testing purpose - will force sw rendering no matter what
+
 // ---------------------------------------------------------
 // CMemoryMonitor
 // ---------------------------------------------------------
@@ -56,6 +58,12 @@
             EGOomTriggerRequestMemory,
             EGOomTriggerThresholdCrossed
             };
+    
+    enum TGOomMemMode
+        {
+        EGOomGoodMemMode = 0,
+        EGOomLowMemMode
+        };
 
 public: // event handlers
     void FreeMemThresholdCrossedL(TInt aAction = 0, TInt aThreshold = 0);
@@ -102,6 +110,11 @@
             }
         else
             {
+            if(aClientId == 0)
+                {
+                iClientsRequestingMemory.Reset();
+                }
+            
             TInt idx = iClientsRequestingMemory.Find(aClientId);
             if(idx != KErrNotFound)
                 {
@@ -127,6 +140,8 @@
     void WaitAndSynchroniseMemoryState();
     void SynchroniseMemoryState();
     
+    void SwitchMemMode(TGOomMemMode aMemMode);
+    
 private:
     CMemoryMonitor();
     void ConstructL();
@@ -201,6 +216,13 @@
     TGOomTrigger iTrigger;
     
     CGOomSynchTimer* iSynchTimer;
+    
+    TBool iMemMode;
+    TBool iForegroundAppHasChanged;
+    
+    TInt iRendswitched;
+    
+    RArray<TInt> iLowOnMemWgs;
     };
 
 
--- a/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitorsession.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitorsession.h	Thu Jul 15 19:40:07 2010 +0300
@@ -42,7 +42,6 @@
     TInt iFunction;
     TInt iMinimumMemoryRequested;
     TBool iUseAbsoluteTargets;
-    TUint iClientId;
     };
 
 #endif /*GOOMMEMORYMONITORSESSION_H*/
--- a/uiacceltk/hitchcock/goommonitor/inc/goomwindowgrouplist.h	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomwindowgrouplist.h	Thu Jul 15 19:40:07 2010 +0300
@@ -78,7 +78,7 @@
     
     // Find all the windowgroups in the list that matches application id for this window group
     void GetAllWgIdsMatchingAppId(TInt aWgId, RArray<TInt> & WgIdList) const;
-
+/*
     TInt LowOnMemWgs(TInt aIndex) 
         {
         if (aIndex >= iLowOnMemWgs.Count() || aIndex < 0)
@@ -90,9 +90,11 @@
             return iLowOnMemWgs[aIndex];
             }
         }
-
+*/
     TInt FindParentIdL(TInt aWgId);    
     
+    void GetListOfWindowGroupsWSurfaces(RArray<TInt>& aLowOnMemWgs);
+    
 private:    
 
     void CollapseWindowGroupTree(RArray<TInt>& aWgsHavingSurfaces);
--- a/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -219,7 +219,7 @@
     iAppIndex = 0;
     
     aWindowGroupList.RefreshL(iTryOptional);
-    
+/*    
     for (TInt i = 0; aWindowGroupList.LowOnMemWgs(i) != KErrNotFound ; i++ )
         {
         if ( iLowOnMemWgs.Find(aWindowGroupList.LowOnMemWgs(i)) == KErrNotFound)
@@ -227,9 +227,11 @@
             iLowOnMemWgs.Append(aWindowGroupList.LowOnMemWgs(i));    
             }
         }
-        
+*/        
     iRunningKillAppActions = ETrue;
     
+    TInt oldcount = iActionRefs.Count();
+    
     if (aWindowGroupList.Count())
             {
             // Go through each item in the wglist, create an app close action for this application
@@ -252,6 +254,12 @@
                 // This sets the window group name
                 TInt32 appId = aWindowGroupList.AppId(wgIndex, ETrue);
                 
+                if(AppCloseActionAlreadyExists(aWindowGroupList, appId))
+                    {
+                    wgIndex--;
+                    continue;
+                    }
+                    
                 CApaWindowGroupName* wgName = aWindowGroupList.WgName();
                 __ASSERT_DEBUG(wgName, GOomMonitorPanic(KInvalidWgName));
 
@@ -314,10 +322,24 @@
                 }
             }
             
-        TRACES1("BuildActionListL: Action list built with %d items",iActionRefs.Count());
+        TRACES1("BuildActionListL: Action list built with %d  new items",iActionRefs.Count()- oldcount);
     }    
 
 
+TBool CGOomActionList::AppCloseActionAlreadyExists(CGOomWindowGroupList& aWindowGroupList, TInt32 appId)
+    {
+    for(TInt i = 0 ; i < iActionRefs.Count() ; i++)
+        {
+        TActionRef ref = iActionRefs[i];
+        if(ref.Type() == TActionRef::EAppClose )
+            {
+            if(aWindowGroupList.AppIdfromWgId(ref.WgId(), ETrue) == appId)
+                return ETrue;
+            }
+        }
+        return EFalse;
+    }
+
 // Execute the OOM actions according to their priority
 // Run batches of OOM actions according to their sync mode
 void CGOomActionList::FreeMemory(TInt aMaxPriority)
@@ -364,48 +386,9 @@
             
             ref.iAppPlugin = action;
             
-            //Double checking again if this app is now in foreground, if yes then we dont kill
-            CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(iWs, iWs.GetFocusWindowGroup());
-            
-            TInt32 fgApp = wgName->AppUid().iUid;
             TInt32 appId = iMonitor.GetWindowGroupList()->AppIdfromWgId(ref.WgId(), ETrue);
-                  
-            if(appId == fgApp)
-                {
-                TRACES1("Foreground App wgid %x, spared by GOOM", appId);
-                
-                iCurrentActionIndex++;
-                CleanupStack::PopAndDestroy();
-                continue;
-                }
             
-            //check if this is not parent of foreground app
-            TBool spared = EFalse;
-            TRACES1("CGOomActionList::FreeMemory - Going to kill Appid %x ",appId);
-            TInt prevWgId = 0;
-            while(prevWgId != KErrNotFound)
-                {
-                wgName->FindByAppUid(wgName->AppUid(), iWs, prevWgId);
-                
-                if(prevWgId == KErrNotFound)
-                    break;
-                
-                TInt parentId = 0;
-                TRAPD(err, parentId = iMonitor.GetWindowGroupList()->FindParentIdL(prevWgId));
-                TRACES2("CGOomActionList::FreeMemory - Foreground App wgid %d, parent wgid %d",prevWgId, parentId);
-                if( err == KErrNone && parentId != 0)
-                    {
-                    TInt32 parentAppId = iMonitor.GetWindowGroupList()->AppIdfromWgId(parentId, ETrue);       
-                    if(parentAppId == appId)
-                        {
-                        TRACES3("Parent App %x (wgId %d), of Foreground App %x, spared by GOOM", parentAppId, parentId, fgApp);
-                        spared = ETrue;
-                        break;
-                        }
-                    }
-                }
-            CleanupStack::PopAndDestroy();
-            if(spared)
+            if(!IsOkToKillApp(appId))
                 {
                 iCurrentActionIndex++;
                 if (iCurrentActionIndex >= iActionRefs.Count())
@@ -427,6 +410,7 @@
 
         iFreeingMemory = ETrue;
         TRACES2("CGOomActionList::FreeMemory: Running action %d which has priority %d", iCurrentActionIndex,ref.Priority());
+        iCurrentActionIndex++;
         action->FreeMemory(iCurrentTarget - memoryEstimate, iUseSwRendering);
         iCurrentPluginRun = 0;
         memoryFreeingActionRun = ETrue;
@@ -449,18 +433,16 @@
         if ((ref.SyncMode() == ECheckRam)
                 || (numberOfRunningActions >= maxBatchSize)
                 || estimatedEnoughMemoryFreed
-                || globalConfig.ForceCheckAtPriority(iActionRefs[iCurrentActionIndex].Priority()))
+                || globalConfig.ForceCheckAtPriority(iActionRefs[iCurrentActionIndex-1].Priority()))
             // If this actions requires a RAM check then wait for it to complete
             // Also force a check if we've reached the maximum number of concurrent operations
             // Also check if we estimate that we have already freed enough memory (assuming that the sync mode is "estimate"
             {
             // Return from the loop - we will be called back (in CGOomActionList::StateChanged()) when the running actions complete
-            iCurrentActionIndex++;
             TRACES("CGOomActionList::FreeMemory: Exiting run action loop");
             return;
             }
         // ... otherwise continue running actions, don't wait for any existing ones to complete
-        iCurrentActionIndex++;
         
         if (iCurrentActionIndex >= iActionRefs.Count())
             {
@@ -486,18 +468,69 @@
             iTryOptional = EFalse;
             iOptionalTried = EFalse;
             TRACES("CGOomActionList::FreeMemory: No usable memory freeing action has been found");
+            iFreeingMemory = EFalse;
             iServer.CloseAppsFinished(freeMemory, EFalse);
             iMonitor.WaitAndSynchroniseMemoryState();
             }
         }
     }
 
+TBool CGOomActionList::IsOkToKillApp(TInt aAppId)
+    {
+    
+    //Double checking again if this app is now in foreground, if yes then we dont kill
+    TUid fgAppuid = TUid::Uid(iMonitor.ForegroundAppUid());
+    TInt32 fgApp = fgAppuid.iUid;
+    TRACES1("Foreground Appuid %x", fgApp);
+        
+    if (aAppId == fgApp)
+        {
+        TRACES1("Foreground App wgid %x, spared by GOOM", aAppId);
+        return EFalse;
+        }
+
+    //check if this is not parent of foreground app
+    TBool spared = EFalse;
+    TRACES2("CGOomActionList::FreeMemory - Going to kill Appid %x, Foreground app %x ", aAppId, fgApp);
+    TInt prevWgId = 0;
+    
+    CApaWindowGroupName::FindByAppUid(fgAppuid, iWs, prevWgId);
+    TInt i = 0;
+    while ((prevWgId == KErrNotFound) && (i++ < 3))   //try 3 times before quiting. It takes time to get the wgid info when app is starting
+            {
+            TRACES1("Cannot find any more parent, trying again %d",i);
+            User::After(200000);
+            prevWgId = 0;
+            CApaWindowGroupName::FindByAppUid(fgAppuid, iWs, prevWgId);
+            }
+   
+    while (prevWgId != KErrNotFound)
+        {
+        TInt parentId = 0;
+        TRAPD(err, parentId = iMonitor.GetWindowGroupList()->FindParentIdL(prevWgId));
+        TRACES3("CGOomActionList::FreeMemory - Foreground App AppId %x, wgid %d, parent wgid %d", fgApp, prevWgId, parentId);
+        if (err == KErrNone && parentId > 0)
+            {
+            TInt32 parentAppId = iMonitor.GetWindowGroupList()->AppIdfromWgId(parentId, ETrue);
+            if (parentAppId == aAppId)
+                {
+                TRACES3("Parent App %x (wgId %d), of Foreground App %x, spared by GOOM", parentAppId, parentId, fgApp);
+                spared = ETrue;
+                break;
+                }
+            }
+        CApaWindowGroupName::FindByAppUid(fgAppuid, iWs, prevWgId);
+        }
+    return !spared;
+    }
+
 // Should be called when the memory situation is good
 // It results in notifications of the good memory state to all plugins with an outstanding FreeMemory request
 void CGOomActionList::MemoryGood()
     {
     FUNC_LOG;
-
+    if(!ALWAYS_SW_REND)
+        {
     TInt actionRefIndex = iActionRefs.Count();
 
     // Go through each of the action references, if it's a plugin action then call MemoryGood on it
@@ -510,7 +543,10 @@
             iActionRefs[actionRefIndex].RunPlugin().MemoryGood();
             }
         }
-    // notify window groups which were triggered to low mem that 
+    // notify window groups which were triggered to low mem that
+    iMonitor.SwitchMemMode(CMemoryMonitor::EGOomGoodMemMode);
+        }
+/*    
     TWsEvent event;
     event.SetType(KGoomMemoryGoodEvent); // naive
 
@@ -520,7 +556,8 @@
         iWs.SendEventToWindowGroup(iLowOnMemWgs[i], event);
 #endif // #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
         iLowOnMemWgs.Remove(i);
-		}    
+		}
+*/		    
     }
 
 TBool CGOomActionList::FreeMemoryAboveTarget(TInt& aFreeMemory)
@@ -672,18 +709,16 @@
             {            
             TRACES2("CGOomActionList::StateChanged: Finished Action %d out of %d",iCurrentActionIndex, iActionRefs.Count());
 
-            if (iCurrentActionIndex < iActionRefs.Count()-1)
+            if (iCurrentActionIndex < iActionRefs.Count())
                 {
-                // launch more actions, potential recursion !!
-                iCurrentActionIndex++;
+                // There are still more actions to try, so we continue
+                TRACES1("CGOomActionList::StateChanged: All current actions complete, running more actions. freeMemory=%d", freeMemory);
                 return FreeMemory(iMaxPriority);
                 } 
                                    
             if(iRunningKillAppActions)
 	            {
                 iRunningKillAppActions = EFalse;
-                // There are no more actions to try, so we give up
-                TRACES1("CGOomActionList::StateChanged: All current actions complete, below good threshold with no more actions available. freeMemory=%d", freeMemory);
 
                 if (!iTryOptional && !iOptionalTried && freeMemory < 25*1024*1024 ) // magic, should read this from config
                     { 
@@ -693,6 +728,8 @@
                     }
                 else
                     {
+                    // There are no more actions to try, so we give up
+                    TRACES1("CGOomActionList::StateChanged: All current actions complete, below good threshold with no more actions available. freeMemory=%d", freeMemory);
                     iTryOptional = EFalse;       
                     iServer.CloseAppsFinished(freeMemory, EFalse);
                     iMonitor.WaitAndSynchroniseMemoryState();
--- a/uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -44,7 +44,7 @@
     {
     FUNC_LOG;
 
-    if ( iAlreadyGaveUp )
+    if ( iAlreadyGaveUp )	//will this ever be true ??? iAlredyGaveup is set true in closeAppEvent, which is called only if app gets notified by goom, which happens only after this
         {
         if (iAppCloseTimer)
         	{
@@ -65,9 +65,17 @@
     
     // Set the TApaTask to the app
     iCurrentTask.SetWgId(iWgId);
-
-    // start the chain
-    ConditionalClose();
+    
+    // Start a timer and the thread watcher 
+    /*
+	iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppClosing);
+    iAppCloseTimer->After(iCloseTimeout * 1000);
+    iAppCloseWatcher->Start(iCurrentTask);
+    // Tell the app to close
+    TRACES2("CGOomCloseApp::FreeMemory: Closing app with window group id %d Timeout = %d",iWgId, iCloseTimeout);
+    iCurrentTask.EndTask();
+	*/
+	ConditionalClose();
     }
 
 CGOomCloseApp::~CGOomCloseApp()
@@ -145,6 +153,7 @@
     // Start a timer and the thread watcher 
     iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppClosing);
     iAppCloseTimer->After(iCloseTimeout * 1000);
+    iAppCloseWatcher->Start(iCurrentTask);
     // Tell the app to close
 	// We are not asking system applications to exit anyway, so we'll send legacy event only
 	// even we have powermgmt capability 
@@ -176,7 +185,8 @@
         }
         
     if(IsConsumingMemory(iWgId))    
-        {    
+        {
+        TRACES1("REST IN PEACE - App wgid %d", iWgId);
         iCurrentTask.KillTask();
         iAppCloserRunning = EFalse; // not sure if intended (?)
         iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppKilled);
@@ -184,9 +194,10 @@
         }
     else
         { // application has released its graphics resources -> we are no more interested about it
-        CloseAppEvent();
+        //CloseAppEvent();
+        iAppCloserRunning = EFalse; 
+        MemoryFreed(KErrNone);
         }    
-    //MemoryFreed(KErrNone);
     }
 
 void CGOomCloseApp::KillTaskWaitDone()
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -102,6 +102,8 @@
 #ifdef _DEBUG
     delete iLogger;
 #endif
+    
+    iClientsRequestingMemory.Close();
     }
 
 // ---------------------------------------------------------
@@ -231,8 +233,12 @@
         TRACES1("FreeMemThresholdCrossedL : crossed low threshold %d", iLowThreshold);
         iMemAllocationsGrowing->Stop();
         iMemAllocationsGoingDown->Continue();
-        if((iTrigger == EGOomTriggerNone) && !NeedToPostponeMemGood() && !iSynchTimer->IsActive() )
+        if((iTrigger == EGOomTriggerNone) && !NeedToPostponeMemGood())
+            {
+            if(iSynchTimer->IsActive())
+                iSynchTimer->Cancel();
             StartFreeSomeRamL(iGoodThreshold, EGOomTriggerThresholdCrossed);
+            }
         }
 #endif
     }
@@ -252,7 +258,7 @@
     // Refresh the low and good memory thresholds as they may have changed due to the new foreground application
     RefreshThresholds(aForegroundAppUid);
     
-    if(iCurrentTarget)
+    if(iCurrentTarget || ALWAYS_SW_REND)
         {
         StartFreeSomeRamL(iCurrentTarget, EGOomTriggerFocusChanged);
         }
@@ -275,6 +281,13 @@
 
     TRACES2("MemoryMonitor::StartFreeSomeRamL freeMemoryAboveTarget = %d, freeMemory = %d", freeMemoryAboveCurrentTarget, freeMemory);
 
+    if(ALWAYS_SW_REND)
+        {
+		if(iMemMode == EGOomLowMemMode)
+		return;
+		}
+	else
+		{
     if (freeMemoryAboveCurrentTarget)
         {
         /*if(freeMemory >= iGoodThreshold && !NeedToPostponeMemGood())
@@ -282,14 +295,17 @@
                 iGOomActionList->MemoryGood();
             }
         */
-        if(!iGOomActionList->UseSwRendering())
+        if(!(iGOomActionList->UseSwRendering() && (iMemMode != EGOomLowMemMode)))
             {
             iServer->CloseAppsFinished(freeMemory, ETrue);
             WaitAndSynchroniseMemoryState();
-            return;
+            if(aTrigger == EGOomTriggerRequestMemory)
+                User::Leave(KErrCompletion);
+            else
+                return;
             }
         }
-
+        }
     // update wg list only when actually about to use it 
     //iGOomWindowGroupList->Refresh();
 
@@ -309,6 +325,35 @@
     // Run the memory freeing actions
     iGOomActionList->FreeMemory(aMaxPriority);
     
+    SwitchMemMode(EGOomLowMemMode);
+    }
+
+void CMemoryMonitor::SwitchMemMode(TGOomMemMode aMemMode)
+    {
+    if(iMemMode == aMemMode)
+        return;
+
+#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS    
+    TWsEvent event;
+ 
+    if(aMemMode == EGOomLowMemMode)
+        {
+        iLowOnMemWgs.Reset();
+        iGOomWindowGroupList->GetListOfWindowGroupsWSurfaces(iLowOnMemWgs);
+        event.SetType(KGoomMemoryLowEvent);
+        }
+    else
+        {
+        event.SetType(KGoomMemoryGoodEvent);
+        }
+    
+    for (TInt i = iLowOnMemWgs.Count()-1; i>=0; i--)
+        {
+        iWs.SendEventToWindowGroup(iLowOnMemWgs[i], event);
+        }
+#endif
+    
+    iMemMode = aMemMode;
     }
 
 void CMemoryMonitor::RunCloseAppActions(TInt aMaxPriority)
@@ -567,6 +612,7 @@
 
 	/* Allocate room for the profiling data */
 	prof_data = (EGLint*)User::Alloc(data_count * sizeof(EGLint));
+	TRACES("eglQueryProfilingData - alloc for data done");
 	if (prof_data == NULL)
 	    {
     	TRACES1("eglQueryProfilingData - could not alloc: %d", data_count * sizeof(EGLint));	
@@ -580,7 +626,9 @@
 							 prof_data,
 							 data_count,
 							 &data_count);
-
+	
+	TRACES("eglQueryProfilingData - profiling data acquired");
+	
 	/* Iterate over the returned data */
 	while (i < data_count)
 		{
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -35,7 +35,7 @@
 CMemoryMonitorSession::~CMemoryMonitorSession()
     {
     FUNC_LOG;
-    Server().Monitor().SessionInCriticalAllocation(0,iClientId);
+    Server().Monitor().SessionInCriticalAllocation(0,0);
     CloseAppsFinished(0, EFalse);
     }
 
@@ -61,32 +61,37 @@
     RThread t;
     aMessage.Client(t);
     
-    iClientId = t.SecureId();
+    TUint clientId = t.SecureId();
     t.Close();
     
-    TRACES1("NEW REQUEST from client %x", iClientId);
+    TRACES1("NEW REQUEST from client %x", clientId);
     switch (aMessage.Function())
         {
         case EGOomMonitorRequestFreeMemory:
 
             //Do not take any more requests from the same client if previous request being served
-            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(iClientId))
+            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId))
                 {
-                TRACES1("CANNOT PROCESS NEW REQUEST from %x", iClientId);
+                TRACES1("CANNOT PROCESS NEW REQUEST from %x", clientId);
                 aMessage.Complete(KErrInUse);
                 return;
                 }
             
-            Server().Monitor().SetActiveClient(iClientId);
+            Server().Monitor().SetActiveClient(clientId);
             // message will be completed when CloseAppsFinished() is called.
             if (aMessage.Int1() == 0)
                 {
                 iRequestFreeRam = aMessage;
 
-                Server().Monitor().SessionInCriticalAllocation(1, iClientId);
+                Server().Monitor().SessionInCriticalAllocation(1, clientId);
                 
                 TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0()));
-                if (err)
+                if(err == KErrCompletion) 
+                    {
+                    TRACES("There is already enough memory - nothing to do");
+                    Server().Monitor().SessionInCriticalAllocation(0, clientId);
+                    }
+                else if (err != KErrNone )
                     {
                     // completes the message if that was left to pending
                     TRACES1("Error in RequestFreeMemory %d", err);
@@ -103,8 +108,8 @@
             break;
             
         case EGOomMonitorMemoryAllocationsComplete:
-            TRACES1("ServiceL : Memory Allocations complete from %x", iClientId);
-            Server().Monitor().SessionInCriticalAllocation(0, iClientId);
+            TRACES1("ServiceL : Memory Allocations complete from %x", clientId);
+            Server().Monitor().SessionInCriticalAllocation(0, clientId);
             aMessage.Complete(KErrNone);
             break;
 
@@ -113,7 +118,7 @@
                 {
                 iRequestFreeRam.Complete(KErrCancel);
                 }
-            Server().Monitor().SessionInCriticalAllocation(0, iClientId);
+            Server().Monitor().SessionInCriticalAllocation(0, clientId);
             aMessage.Complete(KErrNone);
             break;
 
@@ -123,11 +128,11 @@
             break;
 
         case EGOomMonitorRequestOptionalRam:
-            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(iClientId))
+            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId))
                 {
                 aMessage.Complete(KErrInUse);
                 }
-            Server().Monitor().SetActiveClient(iClientId);
+            Server().Monitor().SetActiveClient(clientId);
             // message will be completed when CloseAppsFinished() is called.
             iRequestFreeRam = aMessage;
             iMinimumMemoryRequested = aMessage.Int1();
--- a/uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -42,6 +42,18 @@
     FUNC_LOG;
     }
 
+void CGOomWindowGroupList::GetListOfWindowGroupsWSurfaces(RArray<TInt>& aLowOnMemWgs)
+    {
+    if (!iAlfClient.Handle())
+       {
+       if(iAlfClient.Connect() != KErrNone)
+           return;
+       }
+    
+    iAlfClient.GetListOfWindowGroupsWSurfaces(&aLowOnMemWgs);
+    }
+   
+
 // Update the list of window groups
 void CGOomWindowGroupList::Refresh(TBool aOptionalOnly)
     {
@@ -72,14 +84,14 @@
         {
         User::LeaveIfError(iAlfClient.Connect());
         }
-    iLowOnMemWgs.Reset();
+    //iLowOnMemWgs.Reset();
     RArray<TInt> inactiveSurfaces;
 
     // ignore possible errors, we have information from profiling extension anyway
     if (!aOptionalOnly)
         {
         iAlfClient.GetListOfInactiveWindowGroupsWSurfaces(&inactiveSurfaces);    
-        iAlfClient.GetListOfWindowGroupsWSurfaces(&iLowOnMemWgs);
+        //iAlfClient.GetListOfWindowGroupsWSurfaces(&iLowOnMemWgs);
         }
     else
         { // first iteration: try to cope with window group ID's only
@@ -219,6 +231,7 @@
                     processIds.Close();
                     privMemUsed.Close();
                     TRACES("Only WServ using GFX mem, no need for app actions");
+                    iWgIds.Reset();
                     return;
                     }
                 }
@@ -233,7 +246,7 @@
     
     // Remove all child window groups, promote parents to foremost child position
     CollapseWindowGroupTree(inactiveSurfaces);
-    
+/*    
 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
     TWsEvent event;
     event.SetType(KGoomMemoryLowEvent); // naive
@@ -244,7 +257,7 @@
         }
         
 #endif    
-    
+*/    
     // Note the current foreground window ID (if there is one)
     TBool oldForegroundWindowExists = EFalse;
 
--- a/uiacceltk/hitchcock/group/core_exports.inc	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/group/core_exports.inc	Thu Jul 15 19:40:07 2010 +0300
@@ -3,7 +3,7 @@
 *  Name        : core_exports.inc
 *  Part of     : Alfred UI Toolkit
 *  Description : Exported header files.
-*  Version     : %version: tr1sido#8.1.37 %
+*  Version     : %version: tr1sido#8.1.38 %
 *
 *  Copyright © 2006-2007 Nokia.  All rights reserved.
 *  This material, including documentation and any related computer
@@ -91,6 +91,8 @@
 ../coretoolkit/data/optionsmenu_cascade_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/optionsmenu_cascade_appear.fxml
 ../coretoolkit/data/optionsmenu_cascade_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/optionsmenu_cascade_disappear.fxml
 ../coretoolkit/data/optionsmenu_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/optionsmenu_disappear.fxml
+../coretoolkit/data/phone_callui_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/phone_callui_appear.fxml
+../coretoolkit/data/phone_callui_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/phone_callui_disappear.fxml
 ../coretoolkit/data/photos_fullscreen_close.fxml /epoc32/release/winscw/urel/z/resource/effects/photos_fullscreen_close.fxml
 ../coretoolkit/data/photos_fullscreen_open.fxml /epoc32/release/winscw/urel/z/resource/effects/photos_fullscreen_open.fxml
 ../coretoolkit/data/photos_gridview_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/photos_gridview_appear.fxml
@@ -184,6 +186,8 @@
 ../coretoolkit/data/optionsmenu_cascade_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/optionsmenu_cascade_appear.fxml
 ../coretoolkit/data/optionsmenu_cascade_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/optionsmenu_cascade_disappear.fxml
 ../coretoolkit/data/optionsmenu_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/optionsmenu_disappear.fxml
+../coretoolkit/data/phone_callui_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/phone_callui_appear.fxml
+../coretoolkit/data/phone_callui_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/phone_callui_disappear.fxml
 ../coretoolkit/data/photos_fullscreen_close.fxml /epoc32/release/winscw/udeb/z/resource/effects/photos_fullscreen_close.fxml
 ../coretoolkit/data/photos_fullscreen_open.fxml /epoc32/release/winscw/udeb/z/resource/effects/photos_fullscreen_open.fxml
 ../coretoolkit/data/photos_gridview_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/photos_gridview_appear.fxml
@@ -277,6 +281,8 @@
 ../coretoolkit/data/optionsmenu_cascade_appear.fxml /epoc32/data/z/resource/effects/optionsmenu_cascade_appear.fxml
 ../coretoolkit/data/optionsmenu_cascade_disappear.fxml /epoc32/data/z/resource/effects/optionsmenu_cascade_disappear.fxml
 ../coretoolkit/data/optionsmenu_disappear.fxml /epoc32/data/z/resource/effects/optionsmenu_disappear.fxml
+../coretoolkit/data/phone_callui_appear.fxml /epoc32/data/z/resource/effects/phone_callui_appear.fxml
+../coretoolkit/data/phone_callui_disappear.fxml /epoc32/data/z/resource/effects/phone_callui_disappear.fxml
 ../coretoolkit/data/photos_fullscreen_close.fxml /epoc32/data/z/resource/effects/photos_fullscreen_close.fxml
 ../coretoolkit/data/photos_fullscreen_open.fxml /epoc32/data/z/resource/effects/photos_fullscreen_open.fxml
 ../coretoolkit/data/photos_gridview_appear.fxml /epoc32/data/z/resource/effects/photos_gridview_appear.fxml
--- a/uiacceltk/hitchcock/plugins/alfoogmplugin/src/alfoogmplugin.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alfoogmplugin/src/alfoogmplugin.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -90,10 +90,16 @@
 //
 TAny* CreatePlugin()
     {
-    CAlfOogmMonitorPlugin* plugin = new(ELeave) CAlfOogmMonitorPlugin;
-    CleanupStack::PushL(plugin);
-    plugin->ConstructL();
-    CleanupStack::Pop(plugin);
+    CAlfOogmMonitorPlugin* plugin = new CAlfOogmMonitorPlugin;
+    if ( plugin )
+        {
+        TRAPD( err, plugin->ConstructL() );
+        if ( err != KErrNone )
+            {
+            delete plugin;
+            plugin = NULL;
+            }
+        }
     return plugin;
     }
 
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftfxserverplugin/src/alftransitionserver.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftfxserverplugin/src/alftransitionserver.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -27,7 +27,7 @@
 #include "alftfxserverdef.h"
 #include "alftransitionserver.h"
 #include "alflogger.h"
-
+#include "alfmoduletestconf.h" 
 // ======== MEMBER FUNCTIONS ========
 
 
@@ -1198,7 +1198,11 @@
 #ifdef __WINS__
     _LIT( KOptionalDrive, "C:" );
 #else
-    _LIT( KOptionalDrive, "F:" );
+    #ifdef USE_ALTERNATIVE_EFFECTS_FROM_MMC
+         _LIT( KOptionalDrive, "F:" );
+    #else
+         _LIT( KOptionalDrive, "Z:" );
+    #endif
 #endif
     
     TInt err = KErrNone;
@@ -1215,7 +1219,6 @@
         iFile.Close();
         iParse.Set( KOptionalDrive, &aResourceDir, NULL );  
         }
-    
     // Now iParse contains the alternative path if the file is found in the alternative
     // location, else it contains the original path.
     __ALFFXLOGSTRING1("CAlfTransitionServerClient::FindEffectFile - return: %d <<", err);
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -619,7 +619,7 @@
     if ( err != KErrNone || fileName.Length() == 0 || !FileExistsL( resourceDir, fileName ) )
         {
         // Did not find an effect file - nothing to show
-        __ALFFXLOGSTRING2("CAlfServerDrawer::DoSendBeginFullscreenL -  Could not get full screen kml, error %d %S", err, &fileName)
+        __ALFFXLOGSTRING4("CAlfServerDrawer::DoSendBeginFullscreenL -  Could not get full screen kml (Action: %d, toUid: 0x%x, error %d %S", iAction, iToUid, err, &fileName)
         iFromWg = KErrNotFound;
         iToWg = KErrNotFound;
         iFromScreen = KErrNotFound;
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/states.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/states.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -173,7 +173,8 @@
 		        }
             return CRestingState::NewL(iEngine,iHandler);
 		case EEndFullscreen:
-			TInt triggeredLongStartEffect = iEngine.SendEndFullscreen();
+			TInt triggeredLongStartEffect;
+			triggeredLongStartEffect = iEngine.SendEndFullscreen();
 			__ALFFXLOGSTRING1("CPhase1State::SignalL - Was long app start triggered? Stay in Phase1", triggeredLongStartEffect);
 			if (triggeredLongStartEffect)
 			    {
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/wsserverdrawercontroller.cpp	Mon Jun 21 16:41:52 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/wsserverdrawercontroller.cpp	Thu Jul 15 19:40:07 2010 +0300
@@ -768,10 +768,12 @@
 		{
 		if(fstype == CStateHandler::EExit) //application will exit and avkon flags must be reset (otherwise
 		    {
+		    __ALFFXLOGSTRING1("CWsServerDrawerController::BeginFullscreen - Removing 0x%x Avkon app status", toUid);
 			iAppInfoCache->RemoveAvkonUid(toUid); //repeating calls may allow check pass
 		    }
 		else
 		    {
+		    __ALFFXLOGSTRING1("CWsServerDrawerController::BeginFullscreen - Inserting 0x%x as app status", toUid);
 			iAppInfoCache->SetAvkonUid(toUid);
 		    }
 		}
@@ -822,6 +824,13 @@
 		return;
 		}
 
+	if (aType == AknTransEffect::EParameterAvkonInternal && iEngine->Action() == AknTransEffect::EAppStartupBackground)
+		{
+        // skip the effect, as promised earlier...
+        __ALFFXLOGSTRING("CWsServerDrawerController::BeginFullscreen - EAppStartupBackground -> Skip effect. Return");
+        return;
+		}
+
 
 	//Phone is booting, stop any FS effect.
 	if(!StartCheck(flags))