Catchup to latest Symbian^4 GCC_SURGE
authorWilliam Roberts <williamr@symbian.org>
Thu, 22 Jul 2010 16:43:39 +0100
branchGCC_SURGE
changeset 45 c1d3b75cab24
parent 37 8651eaddcb0b (current diff)
parent 43 95d73125a086 (diff)
Catchup to latest Symbian^4
--- a/group/bld.inf	Mon Jun 21 22:39:28 2010 +0100
+++ b/group/bld.inf	Thu Jul 22 16:43:39 2010 +0100
@@ -15,9 +15,9 @@
 *
 */
 
-// local
-//#define ALF_USE_OPENWF_COMPOSITION
-
+#ifdef SYMBIAN_GRAPHICS_BUILD_OPENWF_WSERV
+#define ALF_USE_OPENWF_COMPOSITION
+#endif
 
 #include "../uiaccelerator_plat/group/bld.inf"
 
--- a/layers.sysdef.xml	Mon Jun 21 22:39:28 2010 +0100
+++ b/layers.sysdef.xml	Thu Jul 22 16:43:39 2010 +0100
@@ -10,6 +10,7 @@
         <unit unitID="nga.uiaccelerator" mrp="" bldFile="&layer_real_source_path;/group" name="uiaccelerator" />
       </module>
     </layer>
+
     
    <layer name="unit_test_layer">
       <module name="uiaccelerator_test">
--- a/rom/alfred.iby	Mon Jun 21 22:39:28 2010 +0100
+++ b/rom/alfred.iby	Thu Jul 22 16:43:39 2010 +0100
@@ -71,12 +71,13 @@
 // Stub sis file
 data=ABI_DIR\BUILD_DIR\uiaccelerator_stub.sis system\install\uiaccelerator_stub.sis
 
-//#ifdef HUI_FX
 // For testing purposes we put our manifest file into the rom.
 // 101f84b9.sel file should be put to rom by aknskins even if we override the file during build.
 // After aknskins has taken over 101f84b9.sel and manifest.mf, we should no longe export them
 // or put them onto the rom.
 
+#ifndef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#ifndef ALF_USE_OPENWF_COMPOSITION
 data=DATAZ_/RESOURCE_FILES_DIR/effects/manifest.mf RESOURCE_FILES_DIR/effects/manifest.mf
 
 // Effect fxmls. Keep the list in alphabetical order. When updating the list below, REMEMBER TO ALSO UPDATE core_exports.inc!
@@ -101,6 +102,7 @@
 data=DATAZ_/RESOURCE_FILES_DIR/effects/app_activate.fxml RESOURCE_FILES_DIR/effects/app_activate.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/app_exit.fxml RESOURCE_FILES_DIR/effects/app_exit.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/app_start.fxml RESOURCE_FILES_DIR/effects/app_start.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/app_start_long.fxml RESOURCE_FILES_DIR/effects/app_start_long.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/app_start_rect.fxml RESOURCE_FILES_DIR/effects/app_start_rect.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/app_start_switch.fxml RESOURCE_FILES_DIR/effects/app_start_switch.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/app_start_switch_rect.fxml RESOURCE_FILES_DIR/effects/app_start_switch_rect.fxml
@@ -161,7 +163,7 @@
 data=DATAZ_/RESOURCE_FILES_DIR/effects/touchinput_close.fxml RESOURCE_FILES_DIR/effects/touchinput_close.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/touchinput_open.fxml RESOURCE_FILES_DIR/effects/touchinput_open.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/viewswitch_left.fxml RESOURCE_FILES_DIR/effects/viewswitch_left.fxml
-data=DATAZ_/RESOURCE_FILES_DIR/effects/viewswitch_left_appear.fxml RESOURCE_FILES_DIR/effects/viewswitch_left_appear2.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/viewswitch_left_appear.fxml RESOURCE_FILES_DIR/effects/viewswitch_left_appear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/viewswitch_left_disappear.fxml RESOURCE_FILES_DIR/effects/viewswitch_left_disappear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/viewswitch_right.fxml RESOURCE_FILES_DIR/effects/viewswitch_right.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/viewswitch_right_appear.fxml RESOURCE_FILES_DIR/effects/viewswitch_right_appear.fxml
@@ -171,15 +173,8 @@
 data=DATAZ_/RESOURCE_FILES_DIR/effects/warningnote_appear.fxml RESOURCE_FILES_DIR/effects/warningnote_appear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/warningnote_disappear.fxml RESOURCE_FILES_DIR/effects/warningnote_disappear.fxml
 
-
-// No actual effect files are included into the rom by default.
-// For testing the effect files can be put onto a memory card into
-// /resource/effectst/ directory.
-// As long as the testing override is in effect, this directory is used for the effects.
-// Only if an effect file is not found on the memory card will the one in rom be used.
-// see the filenames used in the manifest.mf file or change the manifest.mf before ROM imgage is built
-
-//#endif
+#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#endif // ALF_USE_OPENWF_COMPOSITION
 
 file=ABI_DIR\BUILD_DIR\backgroundanimhost.exe PROGRAMS_DIR\backgroundanimhost.exe
 file=ABI_DIR\BUILD_DIR\bga_reference_plugin.dll SHARED_LIB_DIR\bga_reference_plugin.dll
--- a/uiaccelerator_plat/alf_client_server_api/inc/alf/alfappserver.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiaccelerator_plat/alf_client_server_api/inc/alf/alfappserver.h	Thu Jul 22 16:43:39 2010 +0100
@@ -164,6 +164,12 @@
      * @return Container. Ownership not transferred.
      */
     CObjectCon* NewContainerL();
+
+    /**
+     * Releases container created by NewContainerL back to server.
+     * @param aContainer container to be removed.
+     */
+    void ReleaseContainer(CObjectCon& aContainer);
     
 // from base class CAknAppServer
 
--- a/uiaccelerator_plat/alf_client_server_api/inc/alf/alfappui.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiaccelerator_plat/alf_client_server_api/inc/alf/alfappui.h	Thu Jul 22 16:43:39 2010 +0100
@@ -33,6 +33,7 @@
 class CAlfAppSrvSessionBase;
 class CAlfSrvResourceManager;
 class CAlfSrvSettingsHandler;
+class RAlfBridgerClient;
 
 enum TAlfSrvSetting
     {
@@ -54,7 +55,7 @@
  *
  *  @since S60 v3.2
  */
-NONSHARABLE_CLASS(CAlfAppUi) : public CAknAppUi, public MAlfSrvSettingsObserver
+NONSHARABLE_CLASS(CAlfAppUi) : public CBase, public MAlfSrvSettingsObserver
     {
 
 public: // new methods 
@@ -121,7 +122,7 @@
      * 2nd phase constructor. Called by the framework after 
      * the 1st phase construction.
      */
-    IMPORT_C void ConstructL();
+    IMPORT_C virtual void ConstructL();
     
     /**
      * From CAknAppUi.
@@ -129,7 +130,7 @@
      *
      * @param aEvent Occurred event.
      */
-    IMPORT_C void HandleSystemEventL(const TWsEvent& aEvent);
+    IMPORT_C virtual void HandleSystemEventL(const TWsEvent& aEvent);
 
     /**
      * From CAknAppUi.
@@ -137,7 +138,7 @@
      *
      * @param aEvent Occurred event.
      */    
-    IMPORT_C void HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination);
+    IMPORT_C virtual void HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination);
     
     /**
      * From CAknAppUi.
@@ -145,7 +146,7 @@
      *
      * @return ETrue. Meaning the framework will synchronize the application to the starter
      */
-    IMPORT_C TBool FrameworkCallsRendezvous() const;
+    IMPORT_C virtual TBool FrameworkCallsRendezvous() const;
     
     /**
      * From CAknAppUi.
@@ -153,7 +154,7 @@
      *
      * @param aType Changed resource. 
      */
-    IMPORT_C void HandleResourceChangeL( TInt aType );
+    IMPORT_C virtual void HandleResourceChangeL( TInt aType );
    
    /**
      * From CAknAppUi.
@@ -161,7 +162,7 @@
      *
      * @param aCommand The command
      */
-    IMPORT_C void HandleCommandL(TInt aCommand);
+    IMPORT_C virtual void HandleCommandL(TInt aCommand);
     
     void MAlfSrvUintSettingChangedL( TAlfSrvSetting aSetting, TUint aNewValue );
     
@@ -177,6 +178,8 @@
     void EndPointerEventHandling();
     void UpdateActiveSession(CAlfAppSrvSessionBase* aSession);
     
+    CAlfAppSrvSessionBase* ActiveSession();
+    
     TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
 
     TInt FirstAlfControlGroupIndex( TInt aScreenNumber = 0);    
@@ -205,6 +208,7 @@
     void DoBlankScreen(const RMessage2& aMessage);
     
     TInt GetLastActiveClient();
+    RAlfBridgerClient* BridgerClient();
 
 private:
 
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiCanvasVisual.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiCanvasVisual.h	Thu Jul 22 16:43:39 2010 +0100
@@ -449,8 +449,8 @@
     static TBool RecursiveIsExternalContentDrawingEnabled(CHuiVisual* aVisual);
     static TBool RecursiveHasCommandBuffers(CHuiVisual* aVisual);
     
-    void CollectPaintedRegion(TRegion& aRecursivePaintRegion, TInt aExcludeCanvasFlags) const;
-    void CollectRecursivePaintedRegion(TRegion& aRecursivePaintRegion, TInt aExcludeCanvasFlags) const;
+    TBool CollectPaintedRegion(TRegion& aRecursivePaintRegion, TInt aExcludeCanvasFlags) const;
+    TBool CollectRecursivePaintedRegion(TRegion& aRecursivePaintRegion, TInt aExcludeCanvasFlags) const;
     
     TBool CanSkipDrawing() const;
     TBool KeepNoCache() const;
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiControlGroup.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiControlGroup.h	Thu Jul 22 16:43:39 2010 +0100
@@ -30,6 +30,29 @@
 #include <uiacceltk/HuiSessionObject.h>
 
 
+
+enum THuiControlGroupRole
+    {
+    /** Unknown */
+    EHuiUnknownContainer,
+    
+    /** Alf application control group */
+    EHuiSessionContainer,
+    
+    /** WSERV window group */
+    EHuiWindowGroupContainer,
+    
+    /** WSERV floating sprite group */
+    EHuiWindowFloatingSpriteContainer,
+
+    /** Group for showing effects */
+    EHuiFullScreenEffectContainer,
+    
+    /** Group for FPS indicator */
+    EHuiFpsIndicatorContainer
+    };
+
+
 /* Forward declarations. */
 class CHuiEnv;
 class CHuiControl;
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiDisplay.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiDisplay.h	Thu Jul 22 16:43:39 2010 +0100
@@ -818,6 +818,19 @@
      */
     IMPORT_C void CopyScreenToBitmapL(CFbsBitmap* aBitmap);
     
+    
+    /**
+     * Does background clearing for native alf application
+     */
+    void DoBackgroundClear();
+    
+    void ScanningAlfContent(TBool aScanning);
+    void SetAlfContentChanged(TBool aChanged);
+    TBool AlfContentChanged();
+    IMPORT_C void SetSkinSizeChangePending();
+    TBool QueryAndResetSkinSizeChangePendingStatus();
+    TRect CurrentDirtyRect();
+    
 private:
 
     /**
@@ -1021,6 +1034,19 @@
     CFbsBitGc* iForegroundBitmapGc;
     /** ETrue if foreground texture should be blend, EFalse otherwise */
     TBool iForegroundTextureTransparency;
+    
+    /** dirty region index that is being drawn currently */ 
+    TInt iCurrentDirtyIndx;
+    
+    /** Current dirty region for this refresh instance */
+    RDirtyRegions iTempDirtyRegions;
+    TRect iCurrentDirtyRect;
+
+    
+	/** For handling alf content update */
+    TBool iScanningAlfContent;
+    TBool iDisplayContainsChangedAlfContent;
+    TBool iDisplaySizeChangePending;
     };
 
 #endif  // __HUIDISPLAY_H__
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiEnv.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiEnv.h	Thu Jul 22 16:43:39 2010 +0100
@@ -52,6 +52,7 @@
 class CHuiCanvasTextureCache;
 class CHuiFxEngine;
 class MHuiSynchronizationObserver;
+class CAppIconCache;
 
 class CHighResTimer;
 const TInt KHuiEnvReleasedActionId = 0x200100F8;
@@ -759,6 +760,7 @@
     CHuiDisplay* CurrentDisplay() const;
 
     CHuiCanvasTextureCache& CanvasTextureCache() const;
+    IMPORT_C CAppIconCache& AppIconCache() const;
 
     /**
 	 * Performs drawing synchronization.
@@ -977,6 +979,7 @@
     RThread  iIdleCPUValueThread;
     
     CHuiCanvasTextureCache* iCanvasTextureCache;    
+    CAppIconCache* iAppIconCache;
     
     RPointerArray<MHuiLowMemoryObserver> iLowMemoryObservers;
     RPointerArray<MHuiMemoryLevelObserver> iMemoryLevelObservers;
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiRoster.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiRoster.h	Thu Jul 22 16:43:39 2010 +0100
@@ -234,6 +234,8 @@
     
     virtual TBool IsVisibleContentFrozen() const = 0;
     
+    virtual void SetAlfEventWindow(CHuiVisual* aVisual) = 0;
+    
 protected:
 
     /* Constructors. */
--- a/uiaccelerator_plat/alf_visual_api/inc/alf/alftimedvalue.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiaccelerator_plat/alf_visual_api/inc/alf/alftimedvalue.h	Thu Jul 22 16:43:39 2010 +0100
@@ -159,7 +159,7 @@
      *
      * @param aValueNow  New currentvalue.
      */
-    IMPORT_C void SetValueNow(const TReal32& aValueNow);
+    IMPORT_C void SetValueNow(const TReal32& aValueNow) __SOFTFP;
 
     /**
      * Gets current value.
@@ -175,7 +175,7 @@
      * @param aValue            New target value.
      * @param aTime   Time duration after the target value will be in effect. Transition duration in milliseconds.
      */
-    IMPORT_C void SetTarget(const TReal32& aTarget, TInt aTime); 
+    IMPORT_C void SetTarget(const TReal32& aTarget, TInt aTime) __SOFTFP; 
 
     /**
      * Sets a new target value. The transition time depends on the speed.
--- a/uiacceltk/hitchcock/AlfCommandDebug/group/alfcommanddescriptions.rss	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/AlfCommandDebug/group/alfcommanddescriptions.rss	Thu Jul 22 16:43:39 2010 +0100
@@ -281,11 +281,6 @@
                 },
             ALF_COMMAND_DESCRIPTION
                 {
-                command = EAlfSetBrushColor;
-                description = "EAlfSetBrushColor";
-                },
-            ALF_COMMAND_DESCRIPTION
-                {
                 command = EAlfSetBrushOrigin;
                 description = "EAlfSetBrushOrigin";
                 },
@@ -381,11 +376,6 @@
                 },
             ALF_COMMAND_DESCRIPTION
                 {
-                command = EAlfDrawRoundRect;
-                description = "EAlfDrawRoundRect";
-                },
-            ALF_COMMAND_DESCRIPTION
-                {
                 command = EAlfSetFontNoDuplicate;
                 description = "EAlfSetFontNoDuplicate";
                 },
@@ -734,11 +724,6 @@
                 },
             ALF_COMMAND_DESCRIPTION
                 {
-                command = EAlfDSRequestCommandsStart;
-                description = "EAlfDSRequestCommandsStart";
-                },
-            ALF_COMMAND_DESCRIPTION
-                {
                 command = EAlfDSGetAlfNativeWindowData;
                 description = "EAlfDSGetAlfNativeWindowData";
                 },
--- a/uiacceltk/hitchcock/AlfCommandDebug/src/alfcommanddebug.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/AlfCommandDebug/src/alfcommanddebug.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -28,6 +28,7 @@
 #include "alfcommanddebug.h"
 #include <data_caging_path_literals.hrh>
 #include <alfcommanddescriptions.rsg>    
+#include <alfbridgecommands.h>
 #include <gdi.h>
 #include <uiacceltk/HuiStatic.h>
 
@@ -47,6 +48,66 @@
     }
 
 // ---------------------------------------------------------------------------
+// destructor
+//
+// Note, you can enable iPrintStatistics at run-time in debugger  
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CAlfCommandDebug::~CAlfCommandDebug()
+    {
+    TInt test1 = 0;
+    TInt testCount1 = iCommandDescriptions->Count();
+    
+    THashMapIter <TUint32,TCommand> ptrHashSetIter(*iCommandDescriptions);
+     for ( ; ; )        
+         {        
+         const TCommand* resNext = ptrHashSetIter.NextValue();        
+         if (!resNext)            
+             {             
+             break;            
+             }  
+         //RDebug::Print(_L("!!HV: ~CAlfCommandDebug. DELETE: command.iDescription=%S (0x%x)"), 
+         //        resNext->iDescription, resNext->iDescription);
+         delete resNext->iDescription;
+         test1++;
+         }
+
+    if (test1 != testCount1)
+        {
+        RDebug::Print(_L("CAlfCommandDebug::~CAlfCommandDebug(). Mismatch in iCommandDescriptions delete: deleted=%d, array count=%d"), test1, testCount1);
+        }
+
+    TInt test2 = 0;
+    TInt testCount2 = iBridgeCommandDescriptions->Count();
+    
+    THashMapIter <TUint32,TCommand> ptrHashSetIter2(*iBridgeCommandDescriptions);
+     for ( ; ; )        
+         {        
+         const TCommand* resNext = ptrHashSetIter2.NextValue();        
+         if (!resNext)            
+             {             
+             break;            
+             }  
+         //RDebug::Print(_L("!!HV: ~CAlfCommandDebug. DELETE2: command.iDescription=%S (0x%x)"), 
+         //        resNext->iDescription, resNext->iDescription);
+         delete resNext->iDescription;
+         test2++;
+         }
+  
+    if (test2 != testCount2)
+        {
+        RDebug::Print(_L("CAlfCommandDebug::~CAlfCommandDebug(). Mismatch in iBridgeCommandDescriptions delete: deleted=%d, array count=%d"), test2, testCount2);
+        }
+    
+    iCommandDescriptions->Close();
+    iBridgeCommandDescriptions->Close();
+    
+    delete iCommandDescriptions;
+    delete iBridgeCommandDescriptions;
+    }
+
+
+// ---------------------------------------------------------------------------
 // ConstructL
 // ---------------------------------------------------------------------------
 //
@@ -158,7 +219,20 @@
             TCommand command;
             command.iDescription = reader.ReadHBufC16L();
 
-            aDescriptionArray->Insert(commandId, command);
+            TCommand* commandPtr = NULL;
+            commandPtr = aDescriptionArray->Find(commandId);
+            if (commandPtr==NULL)
+                {
+                aDescriptionArray->Insert(commandId, command);
+                //RDebug::Print(_L("!!HV: CAlfCommandDebug::ReadCommandDescriptionsL. INSERT: commandId=%d, command.iDescription=%S (0x%x)"), 
+                //        commandId, command.iDescription, command.iDescription);
+                }
+            else
+                {
+                RDebug::Print(_L("!!HV: CAlfCommandDebug::ReadCommandDescriptionsL. ERROR. Duplicate command descriptions in the resource file! Skip the latter description. commandId=%d, command.iDescription=%S"),
+                        commandId, command.iDescription); 
+                delete command.iDescription;
+                }
             }
         CleanupStack::PopAndDestroy(readData);
         }
@@ -443,17 +517,6 @@
     }
 
 // ---------------------------------------------------------------------------
-// destructor
-//
-// Note, you can enable iPrintStatistics at run-time in debugger  
-// ---------------------------------------------------------------------------
-//
-EXPORT_C CAlfCommandDebug::~CAlfCommandDebug()
-    {
-    delete iCommandDescriptions;
-    }
-
-// ---------------------------------------------------------------------------
 // DebugPrintControlGroupOrder
 // Can be used only from CAlfBridge
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/AlfDecoderServerClient/bwins/alfdecoderserverclientu.def	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/AlfDecoderServerClient/bwins/alfdecoderserverclientu.def	Thu Jul 22 16:43:39 2010 +0100
@@ -50,4 +50,5 @@
 	?SubscribeCallbackL@CAlfEffectObserver@@QAEXPAVMAlfEffectObserver@1@HH@Z @ 49 NONAME ; void CAlfEffectObserver::SubscribeCallbackL(class CAlfEffectObserver::MAlfEffectObserver *, int, int)
 	?GetListOfWindowGroupsWSurfaces@RAlfBridgerClient@@QAEHPAV?$RArray@H@@@Z @ 50 NONAME ; int RAlfBridgerClient::GetListOfWindowGroupsWSurfaces(class RArray<int> *)
 	?SetDistractionWindow@CAlfEffectObserver@@QAEXABVRWindowTreeNode@@H@Z @ 51 NONAME ; void CAlfEffectObserver::SetDistractionWindow(class RWindowTreeNode const &, int)
+	?GetOptionalGraphicsMemUsers@RAlfBridgerClient@@QAEXPAV?$RArray@H@@@Z @ 52 NONAME ; void RAlfBridgerClient::GetOptionalGraphicsMemUsers(class RArray<int> *)
 
--- a/uiacceltk/hitchcock/AlfDecoderServerClient/eabi/alfdecoderserverclientu.def	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/AlfDecoderServerClient/eabi/alfdecoderserverclientu.def	Thu Jul 22 16:43:39 2010 +0100
@@ -73,4 +73,5 @@
 	_ZN18CAlfEffectObserver18SubscribeCallbackLEPNS_18MAlfEffectObserverEii @ 72 NONAME
 	_ZN17RAlfBridgerClient30GetListOfWindowGroupsWSurfacesEP6RArrayIiE @ 73 NONAME
 	_ZN18CAlfEffectObserver20SetDistractionWindowERK15RWindowTreeNodei @ 74 NONAME
+	_ZN17RAlfBridgerClient27GetOptionalGraphicsMemUsersEP6RArrayIiE @ 75 NONAME
 
--- a/uiacceltk/hitchcock/AlfDecoderServerClient/src/alfcompositionclient.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/AlfDecoderServerClient/src/alfcompositionclient.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -832,6 +832,8 @@
     TRect iSurfaceRect;
     
     TInt iWaiterAoPriority;
+    
+    TTimeStamp iTimeStamp; // not used but is required parameter for NotifyWhenDisplayed
     };
 
 
@@ -1198,7 +1200,7 @@
     TBool draw = iData->iProvider.ProduceNewFrameL(region, buffer);
     if(draw)
         {
-        iData->iSurfaceUpdateSession.NotifyWhenAvailable(aStatus);        
+        iData->iSurfaceUpdateSession.NotifyWhenDisplayed(aStatus, iData->iTimeStamp);        
     
         iData->iSurfaceUpdateSession.SubmitUpdate(KAllScreens, iData->iSurfaceId, aBufferNumber);
         }
--- a/uiacceltk/hitchcock/AlfDecoderServerClient/src/alfdecoderserverclient.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/AlfDecoderServerClient/src/alfdecoderserverclient.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -22,9 +22,18 @@
 #include "alfuids.h"
 
 _LIT(KAlfServerThreadName, "alfredserver");
+
+
+// Implements just Error() to avoid panic
+NONSHARABLE_CLASS(CSimpleScheduler) : public CActiveScheduler
+    {
+    void Error( TInt ) const{} // From CActiveScheduler
+    };
+
+
 static void RunServerL()
     {
-    CActiveScheduler* s=new(ELeave) CActiveScheduler;
+    CActiveScheduler* s=new(ELeave) CSimpleScheduler;
     CleanupStack::PushL(s);
     CActiveScheduler::Install(s);
 
@@ -147,12 +156,14 @@
     SendReceive(aOp, aIPCArgs, aStatus );
     }
 
-TInt RAlfBridgerClient::GetListOfWindowGroups(RArray<TInt>* aWindowGroups, TBool aListAll)
+TInt RAlfBridgerClient::GetListOfWindowGroups(RArray<TInt>* aWindowGroups, TInt aType)
     {
     TInt err = KErrNone;
     TInt array[10];
     TPtr8 ptr((TUint8*)array,0,40);
-    err = SendReceive(EAlfGetListOfWGsHavingInactiveSurfaces, TIpcArgs(&ptr, aListAll));
+
+    err = SendReceive(EAlfGetListOfWGsHavingInactiveSurfaces, TIpcArgs(&ptr, aType));
+
     if (!err)
         {
         for(TInt i = 0; i < 10; i++)
@@ -172,14 +183,18 @@
 
 EXPORT_C TInt RAlfBridgerClient::GetListOfInactiveWindowGroupsWSurfaces(RArray<TInt>* aWindowGroups)
     {
-    return GetListOfWindowGroups(aWindowGroups, EFalse);
+    return GetListOfWindowGroups(aWindowGroups, EAlfInactiveWgs);
     }
 
 EXPORT_C TInt RAlfBridgerClient::GetListOfWindowGroupsWSurfaces(RArray<TInt>* aWindowGroups)
     {
-    return GetListOfWindowGroups(aWindowGroups, ETrue);
+    return GetListOfWindowGroups(aWindowGroups, EAlfAllWgsWithSurface);
     }
 
+EXPORT_C void RAlfBridgerClient::GetOptionalGraphicsMemUsers(RArray<TInt>* aOptionalCandidates)
+    {
+    GetListOfWindowGroups(aOptionalCandidates, EAlfVolunteersForCommonGood);
+    }    
 
 
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstage.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstage.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -71,13 +71,7 @@
 	delete iWsGraphicsContext;
 	delete iGoomSession;
 	
-    #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
-    if (Dll::Tls()!=NULL) 
-        {
-        delete AMT_CONTROL();
-        Dll::FreeTls();
-        }
-    #endif
+	AMT_FREE_TLS();
 
     // Used just as a temporary holding place, do not delete!
 	iWindowDrawingNode = NULL;	
@@ -117,14 +111,7 @@
       compcntrl->AlfBridgeCallback(MAlfBridge::ESetWindowTreeObserver,(MAlfCompositionAgnosticWindowTreeObserver*)this);  
       }
 
-    #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF    
-    // Setup TLS and open global module testing chunk and mutex
-    if (Dll::Tls()==NULL) // create only for the first render stage!
-        {
-        User::LeaveIfError(Dll::SetTls(new(ELeave) CAlfModuleTestDataControl()));
-        User::LeaveIfError(AMT_CONTROL()->OpenGlobalObjects());
-        }
-    #endif         
+    AMT_SET_TLS();
     
     __ALFLOGSTRING("CAlfRenderStage: ready to rock");
     }
@@ -597,10 +584,6 @@
 #endif    
 	iAlfSendBuffer->CommitL();
 	
-    AMT_INC_COUNTER_IF(nodeType==MWsWindowTreeNode::EWinTreeNodeClient, iRsWindowNodeCount ); 
-    AMT_INC_COUNTER_IF(nodeType==MWsWindowTreeNode::EWinTreeNodeGroup,  iRsWindowGroupNodeCount ); 
-    AMT_INC_COUNTER(iRsTotalNodeCount );
-    
     AMT_MAP_RENDER_STAGE_NODE_CREATED();
     }
 
@@ -642,16 +625,7 @@
 	    __ALFLOGSTRING("CAlfRenderStage::NodeReleased - WARNING: Node not found!!");
 	    }
 
-    AMT_DEC_COUNTER_IF(nodeType==MWsWindowTreeNode::EWinTreeNodeClient, iRsWindowNodeCount ); 
-    AMT_DEC_COUNTER_IF(nodeType==MWsWindowTreeNode::EWinTreeNodeGroup,  iRsWindowGroupNodeCount ); 
-    AMT_DEC_COUNTER(iRsTotalNodeCount );
-    
-    AMT_MAP_INC_VALUE_IF( ( MWsWindowTreeNode::EWinTreeNodeClient == nodeType && aWindowTreeNode.Window() ),
-                          iIntMap, aWindowTreeNode.Window()->Handle(),
-                          EAlfModuleTestTypeRenderStageReleaseWindow );
-    AMT_MAP_INC_VALUE_IF( ( MWsWindowTreeNode::EWinTreeNodeGroup == nodeType && aWindowTreeNode.WindowGroup() ),
-                          iIntMap, aWindowTreeNode.WindowGroup()->Identifier(),
-                          EAlfModuleTestTypeRenderStageReleaseWindowGroup );    
+	AMT_MAP_RENDER_STAGE_NODE_RELEASED();
     }
 
 // ---------------------------------------------------------------------------
@@ -670,11 +644,7 @@
 	iAlfSendBuffer->CommitL();
     __ALFLOGSTRING("CAlfRenderStage::NodeActivated <<");
    
-    AMT_INC_COUNTER_IF(nodeType==MWsWindowTreeNode::EWinTreeNodeClient, iRsWindowNodeActivatedCount );
-    
-    AMT_MAP_SET_VALUE_IF( nodeType == MWsWindowTreeNode::EWinTreeNodeClient, 
-                          iBoolMap, aWindowTreeNode.Window()->Handle(), ETrue, 
-                          EAlfModuleTestTypeRenderStageActiveWindow );
+    AMT_MAP_RENDER_STAGE_NODE_ACTIVATED();
     }
 
 // ---------------------------------------------------------------------------
@@ -712,15 +682,7 @@
         }
 	iAlfSendBuffer->CommitL();
 
-    AMT_INC_COUNTER( iRsNodeExtentChangedCount );
-    AMT_SET_VALUE( iRsLatestNodeExtentRect, aRect );
-    
-    AMT_MAP_SET_VALUE_IF( ( aWindowTreeNode.Window() ),
-                          iSizeMap, aWindowTreeNode.Window()->Handle(),
-                          aRect.Size(), EAlfModuleTestTypeRenderStageChangeWindowSize );
-    AMT_MAP_SET_VALUE_IF( ( aWindowTreeNode.Window() ),
-                          iPositionMap, aWindowTreeNode.Window()->Handle(),
-                          aRect.iTl, EAlfModuleTestTypeRenderStageChangeWindowPosition );
+	AMT_MAP_RENDER_STAGE_NODE_EXTENT_CHANGED();
     }
 
 // ---------------------------------------------------------------------------
@@ -754,13 +716,7 @@
             &aWindowTreeNode   );
 	iAlfSendBuffer->CommitL();
 
-    AMT_INC_COUNTER( iRsTotalNodeFlagChangedCount );
-    
-    AMT_MAP_SET_VALUE_IF( ( aWindowTreeNode.Window() && MWsWindowTreeObserver::EVisible == aFlag ),
-                          iBoolMap, 
-                          aWindowTreeNode.Window()->Handle(),
-                          aNewValue,
-                          EAlfModuleTestTypeRenderStageChangeWindowVisibility );
+	AMT_MAP_RENDER_STAGE_FLAG_CHANGED();
     }
 
 // ---------------------------------------------------------------------------
@@ -858,8 +814,6 @@
                 }
             }
         iAlfSendBuffer->CommitL();
-        
-        AMT_INC_COUNTER( iRsTotalNodeAttributeChangedCount );
         }
     
     AMT_MAP_RENDER_STAGE_TEXT_CURSOR_CHANGE();
--- a/uiacceltk/hitchcock/Client/src/alftimedvalue.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/Client/src/alftimedvalue.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -53,13 +53,13 @@
     }
     
     
-EXPORT_C void TAlfTimedValue::SetValueNow(const TReal32& aValueNow)
+EXPORT_C void TAlfTimedValue::SetValueNow(const TReal32& aValueNow) __SOFTFP
     {
     iFlags |= EAlfValueNowChanged;    
     iValueNow = aValueNow;
     }
     
-EXPORT_C void TAlfTimedValue::SetTarget(const TReal32& aTarget, TInt aTime)
+EXPORT_C void TAlfTimedValue::SetTarget(const TReal32& aTarget, TInt aTime) __SOFTFP
     {
     iFlags |= EAlfValueTargetChanged;    
     iValueTarget = aTarget;
--- a/uiacceltk/hitchcock/CommonInc/alfbridgecommands.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/CommonInc/alfbridgecommands.h	Thu Jul 22 16:43:39 2010 +0100
@@ -85,7 +85,7 @@
     EAlfDSIncludeToVisibilityCalculation,
     EAlfDSSetDistractionWindow,
 
-    KUnInitialized
+    KUnInitialized // This must be kept as last command!
     };
 
 #endif /* ALFBRIDGECOMMANDS_H_ */
--- a/uiacceltk/hitchcock/CommonInc/alfdecoderserverclient.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/CommonInc/alfdecoderserverclient.h	Thu Jul 22 16:43:39 2010 +0100
@@ -66,16 +66,23 @@
      */    
     IMPORT_C TInt GetListOfWindowGroupsWSurfaces(RArray<TInt>* aWindowGroups);
 
-
      /**
      * Asks the number of active effects
      * @return error code or number of active effects (>= 0).
      */    
      IMPORT_C TInt EffectsCount();
+
+     /**
+     * Asks list of window groups that potentially use graohics memory even no direct EGL nor surface access on main display
+     * @param aArray array to be populated
+     * @return error code.
+     */   
+    IMPORT_C void RAlfBridgerClient::GetOptionalGraphicsMemUsers(RArray<TInt>* aOptionalCandidates);
+
      
 private:
     
-    TInt GetListOfWindowGroups(RArray<TInt>* aWindowGroups, TBool aListAll);
+    TInt GetListOfWindowGroups(RArray<TInt>* aWindowGroups, TInt aType);
     TInt iSpare1;
     TInt iSpare2;
     };
--- a/uiacceltk/hitchcock/CommonInc/alfmoduletest.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletest.h	Thu Jul 22 16:43:39 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 #ifndef ALFMODULETEST_H
 #define ALFMODULETEST_H
 
@@ -41,7 +25,7 @@
 _LIT(KAlfModuleTestChunkName, "ALF_MODULE_TEST_CHUNK");
 _LIT(KAlfModuleTestMutexName, "ALF_MODULE_TEST_MUTEX");
 
-
+const TInt KMaxSimultMeasurementCount = 10;
 /*
  *  Class CAlfModuleTestData
  */
@@ -240,6 +224,18 @@
     TInt iASE_Temp3;
     TInt iASE_Temp4;
 
+    class TSpeedTest
+    {
+    public:
+        TInt64 iHandle;
+        TInt iCounter;
+        TBool iEffects;
+        TInt64 iTimeStamp[5];
+    };
+    
+    TSpeedTest iTimeMap[10];
+    TInt iNextFreeMap;
+        
     // Map that contains boolean items for certain test cases.
     TAlfModuleTestMap< TBool > iBoolMap;        
     // Map that contains integer items for certain test cases.
--- a/uiacceltk/hitchcock/CommonInc/alfmoduletestconf.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletestconf.h	Thu Jul 22 16:43:39 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 #ifndef ALF_MODULETEST_CONF_H
 #define ALF_MODULETEST_CONF_H
 
--- a/uiacceltk/hitchcock/CommonInc/alfmoduletestconsts.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletestconsts.h	Thu Jul 22 16:43:39 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 /**
  * Provides general constants for test cases.
  */
--- a/uiacceltk/hitchcock/CommonInc/alfmoduletestdefines.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletestdefines.h	Thu Jul 22 16:43:39 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 /**
  * @see alfmoduletest.h for class implementations that these defines use.
  */
@@ -35,35 +19,11 @@
     #define AMT_FUNC_EXC_RET(ret, func)
     #define AMT_FUNC_EXC_IF(cond, func)
     #define AMT_FUNC_EXC_IF_RET(cond, ret, func)
-    #define AMT_INC_COUNTER(member)
-    #define AMT_DEC_COUNTER(member)
-    #define AMT_SET_VALUE(member, val)
-    #define AMT_GET_VALUE(x, member)
-    #define AMT_INC_COUNTER_IF(cond, member)
-    #define AMT_DEC_COUNTER_IF(cond, member)
-    #define AMT_SET_VALUE_IF(cond, member, val)
-    #define AMT_GET_VALUE_IF(cond, x, member)
-    
-    #define AMT_MAP_PTR_TO_KEY_CAST( keyPtr )
-    #define AMT_MAP_CPTR_TO_KEY_CAST( keyCPtr )
-    #define AMT_MAP_APPEND_IF(cond, memberMap, key, defaultValue, type)
-    #define AMT_MAP_APPEND(memberMap, key, defaultValue, type)
-    #define AMT_MAP_APPEND_LINK_IF(cond, memberMap, linkKey, targetKey, type)
-    #define AMT_MAP_APPEND_LINK(memberMap, linkKey, targetKey, type)
-    #define AMT_MAP_APPEND_AND_LINK_IF(cond, memberMap, linkKey, actualKey, defaultValue, type)
-    #define AMT_MAP_APPEND_AND_LINK(memberMap, linkKey, actualKey, defaultValue, type)
-    #define AMT_MAP_SET_VALUE_IF(cond, memberMap, key, value, type)
-    #define AMT_MAP_INC_VALUE_IF(cond, memberMap, key, type)
-    #define AMT_MAP_DEC_VALUE_IF(cond, memberMap, key, type)
-    #define AMT_MAP_SET_VALUE(memberMap, key, value, type)
-    #define AMT_MAP_INC_VALUE(memberMap, key, type)
-    #define AMT_MAP_DEC_VALUE(memberMap, key, type)
-    #define AMT_MAP_APPEND_ACCEPT_IF(cond, memberMap, testType)
-    #define AMT_MAP_APPEND_ACCEPT(memberMap, testType)
-    #define AMT_MAP_RESET_ITEMS(memberMap, defaultValue, type)
-    #define AMT_MAP_RESET(memberMap)
-    
-    #define AMT_PRINT_STATE()
+    #define AMT_MAP_PTR_TO_KEY_CAST(keyPtr)
+    #define AMT_MAP_CANVAS_WS_PAINTER_SELECT_GC()
+    #define AMT_MAP_GCE_SET_LAYER_POSITIONS()
+    #define AMT_SET_TLS()
+    #define AMT_FREE_TLS()
 
 #else
     // Module test hook has been set.
@@ -78,6 +38,23 @@
     #endif // AMT_CONTROL
 
 
+    // *** General test variable defines
+    
+    // Text cursor handle is defined as constant because correct handle is not provided
+    // from the window server for render stage.
+    #define AMT_MAP_TEXT_CURSOR_HANDLE 0
+    
+    #define AMT_MAP_FORCE_SW_HANDLE 0
+    #define AMT_MAP_SW_ENABLED_HANDLE 1
+    #define AMT_MAP_LOW_MEMORY_MODE_HANDLE 2
+    
+    #define AMT_MAP_CANVAS_WS_GC_TYPE 0
+    #define AMT_MAP_TEXTURE_CACHE_MEMORY_LEVEL 1
+    #define AMT_MAP_CACHED_IMAGES_COUNT 2
+    #define AMT_MAP_CACHED_TEXTS_COUNT 3
+    #define AMT_MAP_CACHED_RENDER_BUFFERS_COUNT 4
+
+
     //  *** Use these macros to access global memory chunk
     
     
@@ -87,62 +64,113 @@
     
     // Note: Be careful not to lock the the mutex for a long time as it will halt other processes if they are using the lock during that time!
     
-    // Generic macros
+    // *** Generic macros
+
     #define AMT_DATA()                              AMT_CONTROL()->iModuleTestData
     #define AMT_FUNC(func)                          if (AMT_DATA()->iIsEnabled) {func;}                                         
     #define AMT_FUNC_EXC(func)                      {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled) {func;} AMT_CONTROL()->Unlock();}
     #define AMT_FUNC_EXC_RET(ret, func)             {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled) {ret = func;} AMT_CONTROL()->Unlock();}
     #define AMT_FUNC_EXC_IF(cond, func)             {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled && (cond)) {func;} AMT_CONTROL()->Unlock();}        
     #define AMT_FUNC_EXC_IF_RET(cond, ret, func)    {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled && (cond)) {ret = func;} AMT_CONTROL()->Unlock();}
-    
-    // Single operation macros, that will do lock/unlock.
-    #define AMT_INC_COUNTER(member)                 AMT_FUNC_EXC(AMT_DATA()->member++)
-    #define AMT_DEC_COUNTER(member)                 AMT_FUNC_EXC(AMT_DATA()->member--)
-    #define AMT_SET_VALUE(member, val)              AMT_FUNC_EXC(AMT_DATA()->member=(val))
-    #define AMT_GET_VALUE(x, member)                AMT_FUNC_EXC((x) = AMT_DATA()->member)
-    
-    // Conditional single operation macros, that will do lock/unlock.
-    #define AMT_INC_COUNTER_IF(cond, member)        AMT_FUNC_EXC_IF((cond), AMT_DATA()->member++)
-    #define AMT_DEC_COUNTER_IF(cond, member)        AMT_FUNC_EXC_IF((cond), AMT_DATA()->member--)
-    #define AMT_SET_VALUE_IF(cond, member, val)     AMT_FUNC_EXC_IF((cond), AMT_DATA()->member=(val))
-    #define AMT_GET_VALUE_IF(cond, x, member)       AMT_FUNC_EXC_IF((cond), (x) = AMT_DATA()->member)
-    
-    // Map operation macros, that will do lock/unlock
-    #define AMT_MAP_PTR_TO_KEY_CAST( keyPtr )                                                   reinterpret_cast< TInt >( keyPtr )
-    #define AMT_MAP_CPTR_TO_KEY_CAST( keyCPtr )                                                 AMT_MAP_PTR_TO_KEY_CAST( static_cast< const CBase* >( keyCPtr ) )
-    #define AMT_MAP_APPEND_IF(cond, memberMap, key, defaultValue, type)                         AMT_FUNC_EXC_IF((cond), AMT_DATA()->memberMap.Append(type, key, defaultValue))
-    #define AMT_MAP_APPEND(memberMap, key, defaultValue, type)                                  AMT_MAP_APPEND_IF(ETrue, memberMap, key, defaultValue, type)
-    #define AMT_MAP_APPEND_LINK_IF(cond, memberMap, linkKey, targetKey, type)                   AMT_FUNC_EXC_IF((cond), AMT_DATA()->memberMap.AppendLink(type, linkKey, targetKey))
-    #define AMT_MAP_APPEND_LINK(memberMap, linkKey, targetKey, type)                            AMT_MAP_APPEND_LINK_IF(ETrue, memberMap, linkKey, targetKey, type)
-    #define AMT_MAP_APPEND_AND_LINK_IF(cond, memberMap, linkKey, actualKey, defaultValue, type) AMT_MAP_APPEND_IF(cond, memberMap, actualKey, defaultValue, type ); AMT_MAP_APPEND_LINK_IF(cond, memberMap, linkKey, actualKey, type)
-    #define AMT_MAP_APPEND_AND_LINK(memberMap, linkKey, actualKey, defaultValue, type)          AMT_MAP_APPEND_AND_LINK_IF(ETrue, memberMap, linkKey, actualKey, defaultValue, type)
-    #define AMT_MAP_SET_VALUE_IF(cond, memberMap, key, value, type)                             AMT_FUNC_EXC_IF((cond), AMT_DATA()->memberMap.SetActualValue(type, key, value))
-    #define AMT_MAP_INC_VALUE_IF(cond, memberMap, key, type)                                    AMT_FUNC_EXC_IF((cond && AMT_DATA()->memberMap.FindActual(type, key)), AMT_DATA()->memberMap.SetActualValue(type, key, AMT_DATA()->memberMap.FindActual(type, key)->Value() + 1))
-    #define AMT_MAP_DEC_VALUE_IF(cond, memberMap, key, type)                                    AMT_FUNC_EXC_IF((cond && AMT_DATA()->memberMap.FindActual(type, key)), AMT_DATA()->memberMap.SetActualValue(type, key, AMT_DATA()->memberMap.FindActual(type, key)->Value() - 1))
-    #define AMT_MAP_SET_VALUE(memberMap, key, value, type)                                      AMT_FUNC_EXC_IF(ETrue, AMT_DATA()->memberMap.SetActualValue(type, key, value))
-    #define AMT_MAP_INC_VALUE(memberMap, key, type)                                             AMT_MAP_INC_VALUE_IF(ETrue, memberMap, key, type)              
-    #define AMT_MAP_DEC_VALUE(memberMap, key, type)                                             AMT_MAP_DEC_VALUE_IF(ETrue, memberMap, key, type)
-    #define AMT_MAP_APPEND_ACCEPT_IF(cond, memberMap, testType)                                 AMT_FUNC_EXC_IF((cond), AMT_DATA()->memberMap.AppendAccept(testType))
-    #define AMT_MAP_APPEND_ACCEPT(memberMap, testType)                                          AMT_MAP_APPEND_ACCEPT_IF(ETrue, memberMap, testType)
-    #define AMT_MAP_RESET_ITEMS(memberMap, defaultValue, type)                                  AMT_FUNC_EXC(AMT_DATA()->memberMap.ResetItems(type, defaultValue))
-    #define AMT_MAP_RESET(memberMap)                                                            AMT_FUNC_EXC(AMT_DATA()->memberMap.Reset())
-    
-    #define AMT_PRINT_STATE()   AMT_FUNC_EXC(AMT_DATA()->PrintState())
+    #define AMT_MAP_PTR_TO_KEY_CAST(keyPtr)         reinterpret_cast< TInt >( keyPtr )
+
+
+    // *** Macros to define function content
+
+    #define AMT_MAP_CANVAS_WS_PAINTER_SELECT_GC() \
+            if ( iCanvasWsGc ) \
+                { \
+                AMT_MAP_SET_VALUE( \
+                        iIntMap, \
+                        AMT_MAP_CANVAS_WS_GC_TYPE, \
+                        iCanvasWsGc->Type(), \
+                        EAlfModuleTestTypeCoreToolkitGoom ); \
+                } \
+            else \
+                { \
+                AMT_MAP_SET_VALUE( \
+                        iIntMap, \
+                        AMT_MAP_CANVAS_WS_GC_TYPE, \
+                        KErrNotFound, \
+                        EAlfModuleTestTypeCoreToolkitGoom ); \
+                }
+
+    // Sets the position of the layer into the map. 
+    // Zero means the bottom and the top layer has the greates position value.
+    #define AMT_MAP_GCE_SET_LAYER_POSITIONS() \
+            TInt gceLayerPosition( -1 ); \
+            const MWsLayer* gceLayer( iBottomLayer ); \
+            while( gceLayer ) \
+                { \
+                ++gceLayerPosition; \
+                AMT_MAP_SET_VALUE( \
+                    iIntMap, AMT_MAP_PTR_TO_KEY_CAST( gceLayer ), \
+                    gceLayerPosition, EAlfModuleTestTypeGceLayerPosition ); \
+                gceLayer = gceLayer->Above(); \
+                }
+
+    // Setup TLS and open global module testing chunk and mutex.
+    // Create only for the first object!
+    #define AMT_SET_TLS() \
+            if (!Dll::Tls()) \
+                { \
+                User::LeaveIfError(Dll::SetTls(new(ELeave) CAlfModuleTestDataControl())); \
+                User::LeaveIfError(AMT_CONTROL()->OpenGlobalObjects()); \
+                }
+
+    #define AMT_FREE_TLS() \
+            if (Dll::Tls()) \
+                { \
+                delete AMT_CONTROL(); \
+                Dll::FreeTls(); \
+                }
 
 #endif // USE_MODULE_TEST_HOOKS_FOR_ALF
 
 
-// General defines
-// Text cursor handle is defined as constant because correct handle is not provided
-// from the window server for render stage.
-#define AMT_MAP_TEXT_CURSOR_HANDLE 0
-
-
 // Notice: 
 // Defines below will be empty if module test hook is not set.
 // If module test hook is set on, then these defines also use functionality defined above.  
 
 
+// Single operation macros, that will do lock/unlock.
+#define AMT_PRINT_STATE()                       AMT_FUNC_EXC(AMT_DATA()->PrintState())
+#define AMT_INC_COUNTER(member)                 AMT_FUNC_EXC(AMT_DATA()->member++)
+#define AMT_DEC_COUNTER(member)                 AMT_FUNC_EXC(AMT_DATA()->member--)
+#define AMT_SET_VALUE(member, val)              AMT_FUNC_EXC(AMT_DATA()->member=(val))
+#define AMT_GET_VALUE(x, member)                AMT_FUNC_EXC((x) = AMT_DATA()->member)
+
+// Conditional single operation macros, that will do lock/unlock.
+#define AMT_INC_COUNTER_IF(cond, member)        AMT_FUNC_EXC_IF((cond), AMT_DATA()->member++)
+#define AMT_DEC_COUNTER_IF(cond, member)        AMT_FUNC_EXC_IF((cond), AMT_DATA()->member--)
+#define AMT_SET_VALUE_IF(cond, member, val)     AMT_FUNC_EXC_IF((cond), AMT_DATA()->member=(val))
+#define AMT_GET_VALUE_IF(cond, x, member)       AMT_FUNC_EXC_IF((cond), (x) = AMT_DATA()->member)
+
+#define AMT_ADD_TIME(handle, member, effects)   AMT_FUNC_EXC(TInt timemapIndex = 0; while(timemapIndex < 10){ if (AMT_DATA()->iTimeMap[timemapIndex].iHandle == handle){ TInt nextFreeIndex = AMT_DATA()->iTimeMap[timemapIndex].iCounter; AMT_DATA()->iTimeMap[timemapIndex].iTimeStamp[nextFreeIndex] = member; AMT_DATA()->iTimeMap[timemapIndex].iCounter++; timemapIndex = 100; break;} timemapIndex++; } if (timemapIndex == 10) { if (AMT_DATA()->iNextFreeMap == 10) { AMT_DATA()->iNextFreeMap = 0;} TInt nextFreeMap = AMT_DATA()->iNextFreeMap; AMT_DATA()->iTimeMap[nextFreeMap].iCounter = 1; AMT_DATA()->iTimeMap[nextFreeMap].iHandle = handle; AMT_DATA()->iTimeMap[nextFreeMap].iTimeStamp[0] = member; AMT_DATA()->iTimeMap[nextFreeMap].iEffects = effects; AMT_DATA()->iNextFreeMap++; /*RDebug::Printf("Handle: %d, %d %d %d", handle, timemapIndex, AMT_DATA()->iNextFreeMap, member)*/;})
+#define AMT_GET_TIME(x, handle, index, effects) AMT_FUNC_EXC(TInt timemapIndex = 0; while(timemapIndex < 10){ if (AMT_DATA()->iTimeMap[timemapIndex].iHandle == handle){ (x) = AMT_DATA()->iTimeMap[timemapIndex].iTimeStamp[index];(effects) = AMT_DATA()->iTimeMap[timemapIndex].iEffects;break;}timemapIndex++;}if(timemapIndex == 10){(x) = KErrNotFound;(effects) = EFalse;})
+#define AMT_GET_TIME_POINT_COUNT(handle, x)     AMT_FUNC_EXC(TInt timemapIndex = 0; while(timemapIndex < 10){ if (AMT_DATA()->iTimeMap[timemapIndex].iHandle == handle){ (x) = AMT_DATA()->iTimeMap[timemapIndex].iCounter;timemapIndex = 100;}timemapIndex++;}if(timemapIndex == 10){(x) = KErrNotFound;})
+#define AMT_RESET_TIME(handle)                  AMT_FUNC_EXC(TInt timemapIndex = 0; while(timemapIndex < 10){ if (AMT_DATA()->iTimeMap[timemapIndex].iHandle == handle){ AMT_DATA()->iTimeMap[timemapIndex].iHandle = 0; AMT_DATA()->iTimeMap[timemapIndex].iCounter = 0;AMT_DATA()->iTimeMap[timemapIndex].iEffects = 0;break;}timemapIndex++;})
+
+// Map operation macros, that will do lock/unlock
+#define AMT_MAP_CPTR_TO_KEY_CAST(keyCPtr)                                                   AMT_MAP_PTR_TO_KEY_CAST( static_cast< const CBase* >( keyCPtr ) )
+#define AMT_MAP_APPEND_IF(cond, memberMap, key, defaultValue, type)                         AMT_FUNC_EXC_IF((cond), AMT_DATA()->memberMap.Append(type, key, defaultValue))
+#define AMT_MAP_APPEND(memberMap, key, defaultValue, type)                                  AMT_MAP_APPEND_IF(ETrue, memberMap, key, defaultValue, type)
+#define AMT_MAP_APPEND_LINK_IF(cond, memberMap, linkKey, targetKey, type)                   AMT_FUNC_EXC_IF((cond), AMT_DATA()->memberMap.AppendLink(type, linkKey, targetKey))
+#define AMT_MAP_APPEND_LINK(memberMap, linkKey, targetKey, type)                            AMT_MAP_APPEND_LINK_IF(ETrue, memberMap, linkKey, targetKey, type)
+#define AMT_MAP_APPEND_AND_LINK_IF(cond, memberMap, linkKey, actualKey, defaultValue, type) AMT_MAP_APPEND_IF(cond, memberMap, actualKey, defaultValue, type ); AMT_MAP_APPEND_LINK_IF(cond, memberMap, linkKey, actualKey, type)
+#define AMT_MAP_APPEND_AND_LINK(memberMap, linkKey, actualKey, defaultValue, type)          AMT_MAP_APPEND_AND_LINK_IF(ETrue, memberMap, linkKey, actualKey, defaultValue, type)
+#define AMT_MAP_SET_VALUE_IF(cond, memberMap, key, value, type)                             AMT_FUNC_EXC_IF((cond), AMT_DATA()->memberMap.SetActualValue(type, key, value))
+#define AMT_MAP_INC_VALUE_IF(cond, memberMap, key, type)                                    AMT_FUNC_EXC_IF((cond && AMT_DATA()->memberMap.FindActual(type, key)), AMT_DATA()->memberMap.SetActualValue(type, key, AMT_DATA()->memberMap.FindActual(type, key)->Value() + 1))
+#define AMT_MAP_DEC_VALUE_IF(cond, memberMap, key, type)                                    AMT_FUNC_EXC_IF((cond && AMT_DATA()->memberMap.FindActual(type, key)), AMT_DATA()->memberMap.SetActualValue(type, key, AMT_DATA()->memberMap.FindActual(type, key)->Value() - 1))
+#define AMT_MAP_SET_VALUE(memberMap, key, value, type)                                      AMT_FUNC_EXC_IF(ETrue, AMT_DATA()->memberMap.SetActualValue(type, key, value))
+#define AMT_MAP_INC_VALUE(memberMap, key, type)                                             AMT_MAP_INC_VALUE_IF(ETrue, memberMap, key, type)              
+#define AMT_MAP_DEC_VALUE(memberMap, key, type)                                             AMT_MAP_DEC_VALUE_IF(ETrue, memberMap, key, type)
+#define AMT_MAP_APPEND_ACCEPT_IF(cond, memberMap, testType)                                 AMT_FUNC_EXC_IF((cond), AMT_DATA()->memberMap.AppendAccept(testType))
+#define AMT_MAP_APPEND_ACCEPT(memberMap, testType)                                          AMT_MAP_APPEND_ACCEPT_IF(ETrue, memberMap, testType)
+#define AMT_MAP_RESET_ITEMS(memberMap, defaultValue, type)                                  AMT_FUNC_EXC(AMT_DATA()->memberMap.ResetItems(type, defaultValue))
+#define AMT_MAP_RESET(memberMap)                                                            AMT_FUNC_EXC(AMT_DATA()->memberMap.Reset())
+
+
 // Render stage defines
 
 #define AMT_MAP_RENDER_STAGE_NODE_CREATED() \
@@ -159,24 +187,49 @@
         AMT_MAP_APPEND_IF( ( MWsWindowTreeNode::EWinTreeNodeStandardTextCursor == nodeType ), iIntMap, AMT_MAP_TEXT_CURSOR_HANDLE, 0, EAlfModuleTestTypeRenderStageChangeTextCursorFlag ); \
         AMT_MAP_APPEND_IF( ( MWsWindowTreeNode::EWinTreeNodeStandardTextCursor == nodeType ), iIntMap, AMT_MAP_TEXT_CURSOR_HANDLE, 0, EAlfModuleTestTypeRenderStageChangeTextCursorColor ); \
         \
+        AMT_MAP_APPEND_AND_LINK_IF( ( MWsWindowTreeNode::EWinTreeNodeClient == nodeType && aWindowTreeNode.Window() ), iSurfaceMap, aWindowTreeNode.Window()->Handle(), AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), TSurfaceId::CreateNullId(), EAlfModuleTestTypeCreateLayer ); \
+        AMT_MAP_APPEND_AND_LINK_IF( ( MWsWindowTreeNode::EWinTreeNodeClient == nodeType && aWindowTreeNode.Window() ), iSurfaceMap, aWindowTreeNode.Window()->Handle(), AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), TSurfaceId::CreateNullId(), EAlfModuleTestTypeReleaseLayer ); \
+        AMT_MAP_APPEND_AND_LINK_IF( ( MWsWindowTreeNode::EWinTreeNodeClient == nodeType && aWindowTreeNode.Window() ), iIntMap, aWindowTreeNode.Window()->Handle(), AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), 0, EAlfModuleTestTypeLayerOrdinalPosition ); \
+        AMT_MAP_APPEND_AND_LINK_IF( ( MWsWindowTreeNode::EWinTreeNodeClient == nodeType && aWindowTreeNode.Window() ), iIntMap, aWindowTreeNode.Window()->Handle(), AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), 0, EAlfModuleTestTypeLayerNodeOrdinalPosition ); \
+        \
         AMT_MAP_INC_VALUE_IF( ( MWsWindowTreeNode::EWinTreeNodeClient == nodeType && aWindowTreeNode.Window() ), iIntMap, aWindowTreeNode.Window()->Handle(), EAlfModuleTestTypeRenderStageCreateWindow ); \
         AMT_MAP_INC_VALUE_IF( ( MWsWindowTreeNode::EWinTreeNodeGroup == nodeType && aWindowTreeNode.WindowGroup() ), iIntMap, aWindowTreeNode.WindowGroup()->Identifier(), EAlfModuleTestTypeRenderStageCreateWindowGroup )
 
+#define AMT_MAP_RENDER_STAGE_NODE_RELEASED() \
+        AMT_MAP_INC_VALUE_IF( ( MWsWindowTreeNode::EWinTreeNodeClient == nodeType && aWindowTreeNode.Window() ), iIntMap, aWindowTreeNode.Window()->Handle(), EAlfModuleTestTypeRenderStageReleaseWindow ); \
+        AMT_MAP_INC_VALUE_IF( ( MWsWindowTreeNode::EWinTreeNodeGroup == nodeType && aWindowTreeNode.WindowGroup() ), iIntMap, aWindowTreeNode.WindowGroup()->Identifier(), EAlfModuleTestTypeRenderStageReleaseWindowGroup )
+
+#define AMT_MAP_RENDER_STAGE_NODE_ACTIVATED() \
+        AMT_MAP_SET_VALUE_IF( nodeType == MWsWindowTreeNode::EWinTreeNodeClient, iBoolMap, aWindowTreeNode.Window()->Handle(), ETrue, EAlfModuleTestTypeRenderStageActiveWindow )
+
+#define AMT_MAP_RENDER_STAGE_NODE_EXTENT_CHANGED() \
+        AMT_MAP_SET_VALUE_IF( ( aWindowTreeNode.Window() ), iSizeMap, aWindowTreeNode.Window()->Handle(), aRect.Size(), EAlfModuleTestTypeRenderStageChangeWindowSize ); \
+        AMT_MAP_SET_VALUE_IF( ( aWindowTreeNode.Window() ), iPositionMap, aWindowTreeNode.Window()->Handle(), aRect.iTl, EAlfModuleTestTypeRenderStageChangeWindowPosition )
+
+#define AMT_MAP_RENDER_STAGE_FLAG_CHANGED() \
+        AMT_MAP_SET_VALUE_IF( ( aWindowTreeNode.Window() && MWsWindowTreeObserver::EVisible == aFlag ), iBoolMap, aWindowTreeNode.Window()->Handle(), aNewValue, EAlfModuleTestTypeRenderStageChangeWindowVisibility )
+
 #define AMT_MAP_RENDER_STAGE_TEXT_CURSOR_CHANGE() \
         AMT_MAP_INC_VALUE_IF( ( aWindowTreeNode.NodeType() == MWsWindowTreeNode::EWinTreeNodeStandardTextCursor && aAttribute == ECursorType ), iIntMap, AMT_MAP_TEXT_CURSOR_HANDLE, EAlfModuleTestTypeRenderStageChangeTextCursorType ); \
         AMT_MAP_INC_VALUE_IF( ( aWindowTreeNode.NodeType() == MWsWindowTreeNode::EWinTreeNodeStandardTextCursor && aAttribute == ECursorClipRect ), iIntMap, AMT_MAP_TEXT_CURSOR_HANDLE, EAlfModuleTestTypeRenderStageChangeTextCursorClipRect ); \
         AMT_MAP_INC_VALUE_IF( ( aWindowTreeNode.NodeType() == MWsWindowTreeNode::EWinTreeNodeStandardTextCursor && aAttribute == ECursorFlags ), iIntMap, AMT_MAP_TEXT_CURSOR_HANDLE, EAlfModuleTestTypeRenderStageChangeTextCursorFlag ); \
         AMT_MAP_INC_VALUE_IF( ( aWindowTreeNode.NodeType() == MWsWindowTreeNode::EWinTreeNodeStandardTextCursor && aAttribute == ECursorColor ), iIntMap, AMT_MAP_TEXT_CURSOR_HANDLE, EAlfModuleTestTypeRenderStageChangeTextCursorColor )
 
-#define AMT_MAP_RENDER_STAGE_ADD_LAYER() \
-        AMT_MAP_APPEND_IF( aLayer, iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), TSurfaceId::CreateNullId(), EAlfModuleTestTypeRenderStageCreateLayer ); \
-        AMT_MAP_APPEND_IF( aLayer, iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), TSurfaceId::CreateNullId(), EAlfModuleTestTypeRenderStageReleaseLayer )
+#define AMT_MAP_RENDER_STAGE_LAYER_ADDED() \
+        AMT_MAP_APPEND_LINK( iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), EAlfModuleTestTypeCreateLayer ); \
+        AMT_MAP_APPEND_LINK( iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), EAlfModuleTestTypeReleaseLayer ); \
+        AMT_MAP_APPEND_LINK( iIntMap, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), EAlfModuleTestTypeLayerOrdinalPosition ); \
+        AMT_MAP_APPEND_LINK( iIntMap, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), EAlfModuleTestTypeLayerNodeOrdinalPosition ); \
+        AMT_MAP_APPEND_LINK( iSurfaceMap, aWindowTreeNode.Window()->Handle(), AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeGceCreateLayer ); \
+        AMT_MAP_APPEND_LINK( iSurfaceMap, aWindowTreeNode.Window()->Handle(), AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeGceReleaseLayer ); \
+        AMT_MAP_APPEND_LINK( iIntMap, aWindowTreeNode.Window()->Handle(), AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeGceLayerPosition ); \
+        AMT_MAP_APPEND_LINK( iIntMap, aWindowTreeNode.Window()->Handle(), AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeGceLayerOpacity ); \
+        AMT_MAP_APPEND_LINK( iRectMap, aWindowTreeNode.Window()->Handle(), AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeGceLayerExtent ); \
+        \
+        AMT_MAP_SET_VALUE( iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), aLayer.Surface(), EAlfModuleTestTypeCreateLayer )
 
-#define AMT_MAP_RENDER_STAGE_ADD_LAYER_LINK() \
-        AMT_MAP_APPEND_LINK( iSurfaceMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeRenderStageCreateLayer ); \
-        AMT_MAP_APPEND_LINK( iSurfaceMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeRenderStageReleaseLayer ); \
-        \
-        AMT_MAP_SET_VALUE( iSurfaceMap, windowId, aLayer.Surface(), EAlfModuleTestTypeRenderStageCreateLayer )
+#define AMT_MAP_RENDER_STAGE_REMOVE_LAYER() \
+        AMT_MAP_SET_VALUE_IF( aLayer, iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), aLayer->Surface(), EAlfModuleTestTypeReleaseLayer )
 
 
 // Streamer defines
@@ -205,9 +258,27 @@
         AMT_MAP_INC_VALUE_IF( ( attribute == MWsWindowTreeObserver::ECursorFlags ), iIntMap, AMT_MAP_TEXT_CURSOR_HANDLE, EAlfModuleTestTypeHierarchyModelChangeTextCursorFlag ); \
         AMT_MAP_INC_VALUE_IF( ( attribute == MWsWindowTreeObserver::ECursorColor ), iIntMap, AMT_MAP_TEXT_CURSOR_HANDLE, EAlfModuleTestTypeHierarchyModelChangeTextCursorColor )
 
-                                 
+
 // Alfserver defines
 
+#define AMT_MAP_NODE_CREATED() \
+        AMT_MAP_INC_VALUE_IF( node && nodeType == MWsWindowTreeNode::EWinTreeNodeClient, iIntMap, node->iId, EAlfModuleTestTypeHierarchyModelCreateWindow ); \
+        AMT_MAP_INC_VALUE_IF( node && nodeType == MWsWindowTreeNode::EWinTreeNodeGroup, iIntMap, node->iId, EAlfModuleTestTypeHierarchyModelCreateWindowGroup )
+
+#define AMT_MAP_NODE_RELEASED() \
+        AMT_MAP_INC_VALUE_IF( node && nodeType == MWsWindowTreeNode::EWinTreeNodeClient, iIntMap, nodeId, EAlfModuleTestTypeHierarchyModelReleaseWindow ); \
+        AMT_MAP_INC_VALUE_IF( node && nodeType == MWsWindowTreeNode::EWinTreeNodeGroup, iIntMap, nodeId, EAlfModuleTestTypeHierarchyModelReleaseWindowGroup )
+
+#define AMT_MAP_NODE_ACTIVATED() \
+        AMT_MAP_SET_VALUE_IF( node && nodeType == MWsWindowTreeNode::EWinTreeNodeClient, iBoolMap, nodeId, ETrue, EAlfModuleTestTypeHierarchyModelActiveWindow )
+
+#define AMT_MAP_NODE_EXTENT_CHANGED() \
+        AMT_MAP_SET_VALUE_IF( node && node->iWindow, iSizeMap, node->iWindow->WsInfo().iClientSideId.iWindowIdentifer, rect.Size(), EAlfModuleTestTypeHierarchyModelChangeWindowSize ); \
+        AMT_MAP_SET_VALUE_IF( node && node->iWindow, iPositionMap, node->iWindow->WsInfo().iClientSideId.iWindowIdentifer, rect.iTl, EAlfModuleTestTypeHierarchyModelChangeWindowPosition )
+
+#define AMT_MAP_NODE_FLAG_CHANGED() \
+        AMT_MAP_SET_VALUE_IF( node && node->iWindow && MWsWindowTreeObserver::EVisible == flag, iBoolMap, node->iWindow->WsInfo().iClientSideId.iWindowIdentifer, newValue, EAlfModuleTestTypeHierarchyModelChangeWindowVisibility )
+
 #define AMT_MAP_BRIDGE_ADD_VISUAL() \
         AMT_MAP_APPEND_AND_LINK( iIntMap, aWindowNodeId, aClientSideId, 0, EAlfModuleTestTypeBridgeCreateWindow ); \
         AMT_MAP_APPEND_AND_LINK( iIntMap, aWindowNodeId, aClientSideId, 0, EAlfModuleTestTypeBridgeReleaseWindow ); \
@@ -245,7 +316,44 @@
         AMT_MAP_INC_VALUE_IF( viz, iIntMap, AMT_MAP_TEXT_CURSOR_HANDLE, EAlfModuleTestTypeBridgeChangeTextCursorFlag ); \
         AMT_MAP_INC_VALUE_IF( viz, iIntMap, AMT_MAP_TEXT_CURSOR_HANDLE, EAlfModuleTestTypeBridgeChangeTextCursorColor )
 
-        
+#define AMT_MAP_BRIDGE_SET_ORDINAL_POSITION() \
+        AMT_MAP_SET_VALUE_IF( windowAttributes, iIntMap, windowNodeId, windowAttributes->iOrdinalPosition, EAlfModuleTestTypeLayerOrdinalPosition )
+
+#define AMT_MAP_NODE_SET_ORDINAL_POSITION() \
+        AMT_MAP_SET_VALUE( iIntMap, iId, ordinal, EAlfModuleTestTypeLayerNodeOrdinalPosition )
+
+
+// GCE defines
+
+#define AMT_MAP_GCE_ADD_LAYER() \
+        AMT_MAP_APPEND_IF( aLayer, iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), TSurfaceId::CreateNullId(), EAlfModuleTestTypeGceCreateLayer ); \
+        AMT_MAP_APPEND_IF( aLayer, iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), TSurfaceId::CreateNullId(), EAlfModuleTestTypeGceReleaseLayer ); \
+        AMT_MAP_APPEND_IF( aLayer, iIntMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), 0, EAlfModuleTestTypeGceLayerPosition ); \
+        AMT_MAP_APPEND_IF( aLayer, iIntMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), 0, EAlfModuleTestTypeGceLayerOpacity ); \
+        AMT_MAP_APPEND_IF( aLayer, iRectMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), TRect(), EAlfModuleTestTypeGceLayerExtent )
+
+#define AMT_MAP_GCE_SET_SURFACE() \
+        AMT_MAP_SET_VALUE( iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( static_cast< MWsLayer* >( this ) ), aSurface, EAlfModuleTestTypeGceCreateLayer )
+
+#define AMT_MAP_GCE_REMOVE_LAYER() \
+        AMT_MAP_SET_VALUE_IF( aLayer, iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), aLayer->Surface(), EAlfModuleTestTypeGceReleaseLayer )
+
+#define AMT_MAP_GCE_SET_LAYER_OPACITY() \
+        AMT_MAP_SET_VALUE( iIntMap, AMT_MAP_PTR_TO_KEY_CAST( static_cast< MWsLayer* >( this ) ), iLayer->Opacity(), EAlfModuleTestTypeGceLayerOpacity )
+
+#define AMT_MAP_GCE_SET_LAYER_EXTENT() \
+        AMT_MAP_SET_VALUE( iRectMap, AMT_MAP_PTR_TO_KEY_CAST( static_cast< MWsLayer* >( this ) ), aExtent, EAlfModuleTestTypeGceLayerExtent )
+
+
+// Goom defines
+
+#define AMT_MAP_CANVAS_TEXTURE_CACHE_SET_MEMORY_LEVEL() \
+        AMT_MAP_SET_VALUE( iIntMap, AMT_MAP_TEXTURE_CACHE_MEMORY_LEVEL, iMemoryLevel, EAlfModuleTestTypeCoreToolkitGoom ); \
+        AMT_MAP_SET_VALUE( iIntMap, AMT_MAP_CACHED_IMAGES_COUNT, iCachedImages.Count(), EAlfModuleTestTypeCoreToolkitGoom ); \
+        AMT_MAP_SET_VALUE( iIntMap, AMT_MAP_CACHED_TEXTS_COUNT, iCachedTexts.Count(), EAlfModuleTestTypeCoreToolkitGoom ); \
+        AMT_MAP_SET_VALUE( iIntMap, AMT_MAP_CACHED_RENDER_BUFFERS_COUNT, iCachedRenderBuffers.Count(), EAlfModuleTestTypeCoreToolkitGoom )
+
+
 #endif // ALF_MODULE_TEST_DEFINES_H
 
 // End of File
--- a/uiacceltk/hitchcock/CommonInc/alfmoduletestitem.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletestitem.h	Thu Jul 22 16:43:39 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 /**
  * @note This class is provided only if module test hooks are set on.
  */
--- a/uiacceltk/hitchcock/CommonInc/alfmoduletestmap.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletestmap.h	Thu Jul 22 16:43:39 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 /**
  * @note This class is provided only if module test hooks are set on.
  */
@@ -61,7 +45,8 @@
      * Constructor to initialize variables.
      */
     TAlfModuleTestMap():
-        iArrayCount( 0 )
+        iArrayCount( 0 ),
+        iAcceptArrayCount( 0 )
         {
         }
 
--- a/uiacceltk/hitchcock/CommonInc/alfmoduletesttype.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletesttype.h	Thu Jul 22 16:43:39 2010 +0100
@@ -1,19 +1,3 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
 /**
  * @note Contents of this file are provided only if module test hooks are set on.
  */
@@ -33,8 +17,6 @@
     EAlfModuleTestTypeNone,
     
     // Render stage component specific tests
-    EAlfModuleTestTypeRenderStageCreateLayer,
-    EAlfModuleTestTypeRenderStageReleaseLayer,
     EAlfModuleTestTypeRenderStageCreateWindow,
     EAlfModuleTestTypeRenderStageReleaseWindow,    
     EAlfModuleTestTypeRenderStageCreateWindowGroup,
@@ -80,10 +62,23 @@
     EAlfModuleTestTypeBridgeChangeTextCursorFlag,
     EAlfModuleTestTypeBridgeChangeTextCursorColor,
     EAlfModuleTestTypeBridgeVisualVisibility,
+    EAlfModuleTestTypeBridgeGoom,
     
     // Core toolkit component specific tests
     EAlfModuleTestTypeCoreToolkitDrawWindow,
     EAlfModuleTestTypeCoreToolkitDrawFromRenderBuffer,
+    EAlfModuleTestTypeCoreToolkitGoom,
+    
+    // Layer tests
+    EAlfModuleTestTypeCreateLayer,
+    EAlfModuleTestTypeReleaseLayer,
+    EAlfModuleTestTypeLayerOrdinalPosition,
+    EAlfModuleTestTypeLayerNodeOrdinalPosition,
+    EAlfModuleTestTypeGceCreateLayer,
+    EAlfModuleTestTypeGceReleaseLayer,
+    EAlfModuleTestTypeGceLayerPosition,
+    EAlfModuleTestTypeGceLayerExtent,
+    EAlfModuleTestTypeGceLayerOpacity,
     
     // Do not use this value when creating item.
     // This is just meant for Find operations when all tests are accepted.
--- a/uiacceltk/hitchcock/CommonInc/huiwscanvascommands.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/CommonInc/huiwscanvascommands.h	Thu Jul 22 16:43:39 2010 +0100
@@ -120,22 +120,20 @@
 
      // 80
      EAlfSetShapeRegion,
-     
      EAlfContentTag,
      EAlfFrameFlags,
-     EAlfFrameOrientation,
-    
+     EAlfFrameOrientation,    
      EAlfPacketReady,
      EAlfPacketNotReady,
      EAlfPacketPadding,
      EAlfDrawCommandsEnd,
      EAlfSetWindowId,
      EAlfWindowInactivateWindow,
+     
+     // 90
      EAlfWrap,
      EAlfJumpToAnotherChunk,
 	 EAlfDestroyChunk,
-
-     // 90
      EAlfSetExtent,
      EAlfNodeCreated,
      EAlfNodeReleased,
@@ -143,11 +141,11 @@
      EAlfNodeExtentChanged,
      EAlfNodeSiblingOrderChanged,
      EAlfNodeFlagChanged,
+     
+     // 100
      EAlfNodeAttributeChanged,
      EAlfNodeFadeCountChanged,
      EAlfNodeTransparentRegionChanged,
-
-     // 100
      EAlfNodeLayerAdded,
      EAlfNodeMovedToWindowGroup,
      EAlfNodeWindowGroupChained,
@@ -155,11 +153,11 @@
      EAlfCommandNotInitialized,
      EAlfCommitBatch,
      EAlfFrameContainsUnsupportedCommands,
+     
+     // 110     
      EAlfDebugTrackNode,
      EAlfNodeLayerExtentChanged,
      EAlfNodeLayerUsesAlphaFlagChanged,
-
-     // 110
      EAlfNodeFadeAllChildren,
      EAlfCommandIndexArray,
      EAlfCommandIndexArrayHeader,
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h	Thu Jul 22 16:43:39 2010 +0100
@@ -66,13 +66,15 @@
                         CHuiVisual* aTemporaryPresenterVisual,
                         TBool aIsLayout, 
                         TBool aHideWhenFinished,
-                        TBool aCanDestroyOrHideImmediately) 
+                        TBool aCanDestroyOrHideImmediately,
+                        TBool aIsFullScreenEffect) 
                 : iHandle(aHandle), 
                 iEffectedVisual(aEffectedVisual),
                 iTemporaryPresenterVisual(aTemporaryPresenterVisual),
                 iIsLayout(aIsLayout),
                 iHideWhenFinished(aHideWhenFinished),
-                iCanDestroyOrHideImmediately(aCanDestroyOrHideImmediately)
+                iCanDestroyOrHideImmediately(aCanDestroyOrHideImmediately),
+                iIsFullScreenEffect(aIsFullScreenEffect)
                         {
 //                        RDebug::Printf("TEffectCleanupStruct - 0x%x 0x%x, %d", iEffectedVisual, iTemporaryPresenterVisual, iIsLayout );
                         };
@@ -84,7 +86,9 @@
                 TBool iHideWhenFinished;
                 
                 TBool iCanDestroyOrHideImmediately;
-				
+
+                TBool iIsFullScreenEffect;
+                
 				// not own, unless iEffectedVisual has EShouldDestroy flag enabled
                 CHuiVisual* iEffectedVisual;
 				// owned
@@ -201,7 +205,7 @@
     TInt FindClientWindowGroupId( TInt aScreenNumber, CHuiControlGroup& aControlGroup );
     TInt FindWindowGroupNodeId( TInt aScreenNumber, CHuiControlGroup& aControlGroup ) const;
     
-    void RemoveAllTemporaryPresenterVisuals();
+    void CleanAllFxVisuals();
 
     /**
      * Helper function to abort fullscreen effect
@@ -279,7 +283,15 @@
      * 
      */
     void GfxTriggerEndFullScreen(CFullScreenEffectState* aFullScreenEffectData);
-    
+
+    /**
+	 * UpdateSecondaryEffectL
+	 *
+	 * Resolve filename for two part effect that is used with slowly starting applications
+	 * 
+	 */
+    TBool UpdateSecondaryEffectL(const CFullScreenEffectState& aState);
+
    /*
 	*	GfxTriggerEffectWhenFullScreenDrawn
 	*
@@ -292,7 +304,20 @@
     TBool GfxTriggerEffectWhenFullScreenDrawn(CHuiControlGroup* aToGroup = NULL);
     
 	// Experimental
-    TBool IsFullScreenDrawn( TInt aOrientation);
+	TBool IsLayoutSwitchReady( TInt aDuration );
+    TBool IsLayoutSwitchReadyRecursive(
+            CHuiLayout* aLayout,
+            CHuiControlGroup& aControlGroup,
+            CHuiControl& aControl,
+            TBool& aFullscreenCovered, 
+            const TRect& aFullscreen,
+            CAlfScreen* aScreen,
+            TBool aChildCanBeOpaque, 
+            TBool aOnlyForEmbeddedAlfApp,
+            TInt aOrientation,
+            TInt aDuration,
+            TBool& aCoverageRegionModified );
+
 	
     void LayoutSwitchStart();
     void LayoutSwitchComplete();
@@ -427,25 +452,27 @@
 	 *	@return	ETrue, 	if layout have been initialized succesfully for the effect
 	 			EFalse,	if any visuals have been removed. Effect should not be applied.
      */
-    TBool SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect, TBool aCanDestroyOrHideImmediately);
+    TBool SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsFullScreenEffect, TBool aIsExitEffect, TBool aCanDestroyOrHideImmediately);
 
     /*
-     *	AddEffectItemL
+     *	AddFxItemL
 	 *
 	 *	Prepares visual for the effect. Removes previous effect if necessary. @aItemDestroyed will return EFalse,
 	 *	if the visual has been destroyed during the previous effect.
 	 *	
 	 *	@param	aItemDestroyed	
      */
-    CHuiCanvasVisual* AddEffectItemL(
+    CHuiCanvasVisual* AddFxItemL(
             TInt aEffectHandle,
             CHuiVisual* aSourceVisual, 
             CHuiLayout* aTargetLayout, 
             CHuiControl* aEffectControl,
             TBool aInsertTemporaryVisual,
             TBool& aItemDestroyed,
+            TBool aIsFullScreenEffect,
             TBool aIsExitEffect = EFalse,
-            TBool aCanDestroyOrHideImmediately = EFalse);
+            TBool aCanDestroyOrHideImmediately = EFalse
+            );
             
 
     /*
@@ -457,6 +484,7 @@
             CHuiLayout* aTargetLayout,
             CHuiControl* aEffectControlGroup,
             TInt& aItemsDestroyed,
+            TBool aIsFullScreenEffect,
             TBool aAddLayout = ETrue,
             TBool aIsExitEffect = EFalse,
             TBool aCanDestroyOrHideImmediately = EFalse);
@@ -467,14 +495,14 @@
     void ListFamilyTreeL( RPointerArray<CHuiLayout>& aArray, const CHuiLayout* aLayout );
 
     /*
-     * RemoveTemporaryPresenterItem
+     * CleanFxItem
      * 
      * Effects are shown indirectly by a another visual, that is in iFullScreenEffect control group. 
      * This methods unbinds the external content and the removes temporary presenter visual 
 	 * from iFullScreenEffect group and . It does not delete the CHuiFxEffect 
 	 * object associated with the content visual. See also iEffectCleanupStack.  
      */
-    TBool RemoveTemporaryPresenterItem(TEffectCleanupStruct& aEffectItem);
+    TBool CleanFxItem(TEffectCleanupStruct& aEffectItem);
 
     /*
      * FindTemporaryPresenterLayout
@@ -529,21 +557,21 @@
 	*/
     TInt FindEffectHandle(CHuiVisual* aVisual);
     /*
-     * RemoveTemporaryPresenterVisual
+     * CleanFxVisual
      * 
      * Effects are shown indirectly by a another visual, that is in iFullScreenEffect control group. 
      * This methods unbinds the external content and the removes temporary presenter visual 
 	 * from iFullScreenEffect group and . It does not delete the CHuiFxEffect 
 	 * object associated with the content visual. See also iEffectCleanupStack.  
      */
-    TBool RemoveTemporaryPresenterVisual(CHuiVisual* aVisual, TInt aHandle = KErrNotFound);
+    TBool CleanFxVisual(CHuiVisual* aVisual, TInt aHandle = KErrNotFound);
     
     /*
-     *	RemoveTemporaryPresenterVisuals
+     *	CleanFxVisuals
      *	
      *	See above. 
      */
-    TBool RemoveTemporaryPresenterVisuals();
+    TBool CleanFxVisuals();
     
 	void HandleNewWindowL( TAlfBridgerData& aData );
 	
@@ -594,6 +622,7 @@
     void HandleSetLayoutSwitchEffectL();
 	
     void ClearCanvasVisualCommandSets(TBool aInactiveOnly);
+    static void ClearCanvasVisualCommandSetsRecursive(CHuiCanvasVisual* aVisual, TBool aInactiveOnly);
     
     void ClipVisualRect(TRect& aRect, const TRect& aClippingRect);
 
@@ -607,6 +636,15 @@
 
     void ShowWindowGroupControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber );
     
+	/**
+	 * HasActiveAlfContent
+	 *
+	 * Determine if the window group in question has active Alf visuals
+	 *
+	 *	@return 	ETrue, if active clients
+	 */
+    TBool HasActiveAlfContent( TInt aClientWgId );
+    
 private:
          
     /**
@@ -906,7 +944,7 @@
     RArray<TEffectCleanupStruct> iEffectCleanupStack;
     
     // Same as iEffectCleanupStack, but only the ones that can be now cleaned away.
-    // See method RemoveTemporaryPresenterVisuals.
+    // See method CleanFxVisuals.
     RArray<TInt> iFinishedCleanupStackEffects;
     
 	
@@ -914,7 +952,18 @@
      * Full screen effect state.
      * Own.
      */
-    CFullScreenEffectState* iFullScreenEffectData;
+    CFullScreenEffectState* iFSFxData;
+    
+    /**
+     *  Long app start effect consists of two effects. The app_start_long.fxml is 
+     *  applied after a short timeout. Then system waits the EndFullScreen event is
+     *  received or heuristics determine that new application has drawn itself 
+     *  properly. When application is drawn, the original requested effect is applied. 
+     *  
+     *  iFSFXDataPart2 defines the original requested effect, while iFSFxData
+     *  is used to define the coming or ongoing fullscreen app start effect.
+     */
+    CFullScreenEffectState* iFSFXDataPart2;
     
     /**
      * Control effect state.
@@ -925,10 +974,7 @@
     // these save the current full screen transition data
     // so that the correct transition can be ended from the callback
     // when the effect ends
-    TInt iLastFullScreenEffectWindowGroup;
-    TInt iLastFullScreenScreen;
-    TInt iLastAction;
-    TInt iLastEffectHandle;
+    
     CAlfEffectEndTimer* iEffectEndTimer;
     TBool iLayoutInitializedForExitEffect;
     
@@ -1009,6 +1055,8 @@
     mutable RRegionBuf<KAlfBridgeRegionGranularity> iTempVisualRegion;
     mutable RRegionBuf<KAlfBridgeRegionGranularity> iTempIntersectingRegion;
     mutable RRegionBuf<KAlfBridgeRegionGranularity> iTempRegion;
+    mutable RRegionBuf<KAlfBridgeRegionGranularity> iTempRegion2;
+    
     TBool iBgSurfaceFound;
     TBool iInLowMemMode;
     TBool iLayoutSwitchInProgress;
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfeffectutils.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfeffectutils.h	Thu Jul 22 16:43:39 2010 +0100
@@ -19,6 +19,15 @@
 #include <akntranseffect.h>
 #include "alfbridge.h"
 
+enum TEffectState
+    {
+    EBeginFullScreenReceived, // first request of effect received
+    EWaitingWindowGroup,
+    EWaitEndFullScreen,
+    EEndFullScreenReceivedWaitingWindowGroup,
+    EEndFullscreenReceived,
+    EFinalEffectActive
+    };
 // Timer to send finish full screen effect
 // ---------------------------------------------------------
 // CAlfFinishTimer
@@ -45,6 +54,7 @@
         CAlfBridge& iBridge;
  	public:
 	   	TInt iSafeCounter;
+	   	TInt iSafeCounterDelta;
         TCallBack iCallBack;        
     };
 
@@ -124,6 +134,9 @@
         TState NextBlankState(TEvent aEvent);
         TState NextThemeState(TEvent aEvent);
 
+        void HandleFreezeEvent(TEvent aEvent);
+        void HandleThemeEvent(TEvent aEvent);
+
         void FreezeFinished();
 
     public:            
@@ -152,6 +165,7 @@
         void FreezeRoster(TBool aFrozen);
         
         static TInt DoFreezeFinished(TAny* aAny);
+        static TInt DoNextLayoutSwitchContext(TAny* aAny);
         
     private: // Data
         
@@ -228,6 +242,8 @@
     public:
         ~CFullScreenEffectState();
         
+        void ConstructL(const CFullScreenEffectState& aEffectState);
+        
         void ConstructL(TInt aAction, RMemReadStream& aStream);
         
         // Information from BeginFullScreen
@@ -239,18 +255,37 @@
         TInt iToSecureId;
         TInt iFromSecureId;
         TRect iRect;
+        TBool iLongAppStartTimeout;
+        TBool iTimeout;
         
-        // ETrue if waiting for window group to appear
-        TBool iWaitingWindowGroup;
+         
+        void SetState(TEffectState aState);
+       
+        TEffectState State();
+       
+      
+private:
+        TEffectState iState;
+        
+public:
         // ETrue if end fullscreen has been performed
         TBool iEndFullScreen;
         // ETrue if setup effect container has been done
         TBool iSetupDone;
-
+        // effect has fade out and fade in. The fade in part is active, when this is ETrue.
+        enum TEffectPhase
+            {
+            EOnlyOnePart = 0,
+            EFirstPartActive,
+            EFirstPartRunning,
+            ESecondPartActive,
+            ESecondPartRunning
+            };
+        
+        TEffectPhase iTwoPhaseEffect;
         // used for resolving the iCleanupStackItem that holds the frozen app layout underneath the starting application
         TInt iAppStartScreenshotItemHandle;
         
-        
         enum TEffectType
         {
             ENotDefinedEffect = 0,
@@ -260,16 +295,6 @@
         
         TEffectType iEffectType;
         
-        // Display dimension, iPaintedRegion is clipped to this when determining, if there is enough drawing to the group
-        TSize iDisplaySize;
-        
-        // gathers the painted region for the effected application. When enough region has been painted, the effect is forced.
-        RRegion iPaintedRegion;
-        
-        CAlfBridge* iBridge; // for callback. not own.
-        
         // If the visual is shown by some other visual by a screenshot, this is set ETrue.
         TBool iCanDestroyOrHideImmediately;
-        
-        CPeriodic* iDrawingCompleteTimer;
         };
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfscreen.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfscreen.h	Thu Jul 22 16:43:39 2010 +0100
@@ -26,27 +26,6 @@
 #include <uiacceltk/HuiTextVisual.h>
 #include "alfshareddisplaycoecontrol.h"
 
-enum TAlfControlGroupRole
-    {
-    /** Unknown */
-    EAlfUnknownContainer,
-    
-    /** Alf application control group */
-    EAlfSessionContainer,
-    
-    /** WSERV window group */
-    EAlfWindowGroupContainer,
-    
-    /** WSERV floating sprite group */
-    EAlfWindowFloatingSpriteContainer,
-
-    /** Group for showing effects */
-    EAlfFullScreenEffectContainer,
-    
-    /** Group for FPS indicator */
-    EAlfFpsIndicatorContainer
-    };
-
 NONSHARABLE_CLASS( TAlfControlGroupEntry )  
     {
 public:
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfstreamerconsts.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfstreamerconsts.h	Thu Jul 22 16:43:39 2010 +0100
@@ -46,7 +46,9 @@
     EAlfGetNumberOfActiveEffects,
     EAlfRequestSignal,
     EAlfCompleteSignal,
-    EAlfSetDistractionWindow
+    EAlfSetDistractionWindow,
+    EAlfVolunteerForGoomTarget,
+    EAlfExcludeFromGoomTargets
 
     };
 
@@ -93,8 +95,14 @@
 enum TAlfSignalFlags
     {
     EAlfSignalEffectStarted = 0x1,
-    EAlfSignalEffectComplete = 0x2,    
-    
+    EAlfSignalEffectComplete = 0x2,     
     };
     
+enum TAlfWindowGroupListType
+    {    
+    EAlfInactiveWgs = 0,
+    EAlfAllWgsWithSurface,
+    EAlfVolunteersForCommonGood
+    };
+     
 #endif
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfstreamerserver.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfstreamerserver.h	Thu Jul 22 16:43:39 2010 +0100
@@ -71,11 +71,13 @@
 
     void RemoveTargetFromInactiveSurfaces(TInt aTarget);
     void AddTargetFromInactiveSurfaces(TInt aTarget);
-    void GetListOfWGsHavingInactiveSurfacesL(const RMessage2& aMessage, TBool aActiveAlso = ETrue);
+    void GetListOfWGsHavingInactiveSurfacesL(const RMessage2& aMessage, TInt aActiveAlso = ETrue);
     void QueueRequestBGAnimSessionsL(const TPtrC8& aPtr, TInt aOp);
 
     void AddSignal(CAlfStreamerServerSession* aSession, const RMessage2& aMessage);
     void CompleteSignal(TInt aSignal, TInt aType);
+    void FormAQueueL(TInt aOp, TInt aSecureId, TInt aWindowGroupId);
+
     
 private:
     void ConstructL();
@@ -145,13 +147,14 @@
     struct TAlfCompParams
         {
         TInt iTarget; 
-        TInt iTarget2;  // padding actually
+        TInt iSecureId; // used with optional GRAM list
         TInt iWindowHandle;
         TInt iWindowGroup;
         }; 
 
     RArray<TAlfCompParams> iAlfTargets;
     RArray<TAlfCompParams> iInactiveSurfaces;
+    RArray<TAlfCompParams> iOptionalGRAM;
     };
 
 NONSHARABLE_CLASS(CAlfStreamerServerSession): public CSession2
--- a/uiacceltk/hitchcock/ServerCore/Src/alfappserver.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappserver.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -297,8 +297,10 @@
         return;       
         }
     
+    TBool lastActiveDying = EFalse;
     if ( dying->ClientWindowGroup() == iLastActiveClientWg )
         {
+        lastActiveDying = ETrue;
         iLastActiveClientWg = KErrNotFound;
         parentWg = dying->ParentWindowGroupId();
         }
@@ -349,8 +351,10 @@
             }
         delete wgs;
         }
-    
-    TRAP_IGNORE(FocusedWindowGroupChangedL(newFocusSession, parentWg))
+    if( lastActiveDying || newFocusSession )
+        {
+        TRAP_IGNORE(FocusedWindowGroupChangedL(newFocusSession, parentWg));
+        }
     }
 
 
@@ -1054,6 +1058,18 @@
     return iObjectConIx->CreateL();
     }
 
+// ---------------------------------------------------------------------------
+// Releases container back to server.
+// ---------------------------------------------------------------------------
+// 
+void CAlfAppServer::ReleaseContainer(CObjectCon& aContainer)
+    {
+    if ( iObjectConIx )
+        {
+        iObjectConIx->Remove(&aContainer);
+        }
+    }
+
 // ======== RnD FUNCTIONS ========
 
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/ServerCore/Src/alfappsrvsession.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappsrvsession.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -1592,9 +1592,9 @@
 
         // If we are reusing deleted texture, remove it from "deleted" array
         TInt index = iTextures.Find(&texture);
-        if (index != KErrNotFound)
+        if (index == KErrNotFound)
            {
-           iTextures.Remove(index);                
+           iTextures.Append(env->TextureManager().Texture(id));                
            }                    
 
 
@@ -1727,9 +1727,9 @@
 
         // If we are reusing deleted texture, remove it from "deleted" array
         TInt index = iTextures.Find(&textureRef);
-        if (index != KErrNotFound)
+        if (index == KErrNotFound)
            {
-           iTextures.Remove(index);                
+           iTextures.Append(env->TextureManager().Texture(id));                
            }                    
         
         // Add texture to skin content
--- a/uiacceltk/hitchcock/ServerCore/Src/alfappsrvsessionBase.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappsrvsessionBase.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -36,6 +36,8 @@
 #include "alf/alfextensionfactory.h"
 #include "alf/alfversion.h"
 #include "alfsrvsettingshandler.h"
+#include "alfstreamerconsts.h"
+#include "alfdecoderserverclient.h"
 
 const TUint KAlfMaxCpuUsageDuringPointerEvent = 35; // Percentage
 
@@ -106,6 +108,7 @@
     RMessagePtr2 iSystemEvent;
     TInt iParentId;
     TBool iActive;
+    TUint iSecureId;
     }; 
 
 // ======== MEMBER FUNCTIONS ========
@@ -129,11 +132,17 @@
 // ---------------------------------------------------------------------------
 //
 EXPORT_C CAlfAppSrvSessionBase::~CAlfAppSrvSessionBase()
-    { 
+    {
+        
     iHost->HandleClientExit(reinterpret_cast<TInt>(this));
     
     if ( iData )
         {
+        if (AlfAppUi()->BridgerClient())
+            {
+            AlfAppUi()->BridgerClient()->SendBlind(EAlfExcludeFromGoomTargets, TIpcArgs(iData->iSecureId,iData->iClientWindowGroupId));
+            }
+            
         iData->iHandles.Close();
         delete iData->iObjectIx;
     
@@ -154,6 +163,11 @@
             {
             iData->iSystemEvent.Complete(KErrCancel);
             }
+        
+        if ( iData->iContainer )
+            {
+            iHost->ReleaseContainer( *iData->iContainer );
+            }
         delete iData;
         }
     iHost = NULL;
@@ -203,6 +217,7 @@
 //
 EXPORT_C void CAlfAppSrvSessionBase::ServiceL(const RMessage2& aMessage)
     {
+    iData->iSecureId = aMessage.SecureId(); // one time would be enough    
     if(iHost->MetricsInterface())
         {
         iHost->MetricsInterface()->EnterClientMessageL(reinterpret_cast<TInt>(this), aMessage);
@@ -391,6 +406,10 @@
     {
     __ASSERT_DEBUG(iData, USER_INVARIANT());
     iData->iClientWindowGroupId = aId;
+    if (AlfAppUi()->BridgerClient())
+        {
+        AlfAppUi()->BridgerClient()->SendBlind(EAlfVolunteerForGoomTarget, TIpcArgs(iData->iSecureId, iData->iClientWindowGroupId));
+        }
     }
 
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/ServerCore/Src/alfappui.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappui.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -67,6 +67,12 @@
 #define ALF_USE_EMULATOR_LAYOUT_SWITCH_BUTTON
 #endif
 
+// Implements just Error() to avoid panic
+NONSHARABLE_CLASS(CSimpleScheduler) : public CActiveScheduler
+    {
+    void Error( TInt ) const{} // From CActiveScheduler
+    };
+
 NONSHARABLE_CLASS(TAlfEffectObserver): public MHuiEffectObserver
     {
     public:    
@@ -603,7 +609,7 @@
     if (err == KErrNone)
         {
         // Set up scheduler and cleanup stack for this thread
-        CActiveScheduler* scheduler = new CActiveScheduler;
+        CActiveScheduler* scheduler = new CSimpleScheduler();
         if (!scheduler)
             {
             return KErrNoMemory;
@@ -690,10 +696,6 @@
 //
 EXPORT_C CAlfAppUi::CAlfAppUi()
     {
-    if (CCoeEnv::Static())    
-        {
-        SetFullScreenApp(EFalse); // to avoid getting queued/suspended in case of S60 system events
-        }
     }
 
 // ---------------------------------------------------------------------------
@@ -808,25 +810,12 @@
     User::LeaveIfError(AMT_CONTROL()->OpenGlobalObjects());
     #endif
       
-    TInt flags = EStandardApp|ENoScreenFurniture|ENonStandardResourceFile|EAknEnableSkin;
-    CCoeEnv* coe = CCoeEnv::Static();
     iData =  new (ELeave) CAlfAppUiData();
 
     iData->iSettingsHandler = CAlfSrvSettingsHandler::NewL( *this );
     CreateHuiEnvL();
     
-    if (coe)
-        {
-        // initialize app basic services
-        CAknAppUi::BaseConstructL(flags);
-
-        // create direct pointer to server so no need to access coestatics whenever server needed
-        iData->iServer = static_cast<CAlfAppServer*>(static_cast<CEikonEnv*>(coe)->AppServer());
-        }
-    else
-        { 
-        iData->iServer = CAlfAppServer::NewAppServerL();
-        }
+    iData->iServer = CAlfAppServer::NewAppServerL();
 
     iData->iServer->SetAppUi(this);     
     
@@ -838,34 +827,25 @@
     mainWg.SetOrdinalPosition(-1,ECoeWinPriorityNeverAtFront);
 
 
-    if (!coe) // multiple screen support missing, for main display only atm
-        {
-        TUid appUid = TUid::Uid(KAlfAppServerInterfaceUid3);
-        // complete server construction
-        TName serverName;
-        _LIT(KServerNameFormat, "%08x_%08x_AppServer");
-        serverName.Format( 
+    TUid appUid = TUid::Uid(KAlfAppServerInterfaceUid3);
+    // complete server construction
+    TName serverName;
+    _LIT(KServerNameFormat, "%08x_%08x_AppServer");
+    serverName.Format( 
                 KServerNameFormat, 
                 appUid, 
                 appUid.iUid );
         
-        iData->iServer->ConstructL(serverName);
+    iData->iServer->ConstructL(serverName);
         
-        // parametrize our window group
-        CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(CHuiStatic::WsSession());
-        wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc.
-        wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down    
-        wgName->SetCaptionL(_L("ALF"));
-        wgName->SetAppUid(appUid);
-        wgName->SetWindowGroupName(mainWg);
-        CleanupStack::PopAndDestroy();
-        }
-    // misc settings for surroundings     
-    if (coe)
-        { // we ndon't need these in NGA
-        mainWg.EnableFocusChangeEvents();
-        }
-        
+    // parametrize our window group
+    CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(CHuiStatic::WsSession());
+    wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc.
+    wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down    
+    wgName->SetCaptionL(_L("ALF"));
+    wgName->SetAppUid(appUid);
+    wgName->SetWindowGroupName(mainWg);
+    CleanupStack::PopAndDestroy();        
     CHuiStatic::WsSession().ComputeMode(RWsSession::EPriorityControlDisabled);
 
     RThread thread; 
@@ -873,27 +853,16 @@
 
     // delegates..
     iData->iResourceManager = CAlfSrvResourceManager::NewL( *iData->iHuiEnv );
-
-    if (coe)
-        {
-        iData->iSharedWindow = new (ELeave) CAlfSharedDisplayCoeControl();
-        iData->iSharedWindow->ConstructL();
-        iData->iSharedWindow->DrawableWindow()->EnableVisibilityChangeEvents();
-        }
-    else
-        { 
-        //mainWg.EnableScreenChangeEvents();
         
-        CHuiStatic::WsSession().EnableWindowSizeCacheL();
-        iData->iPlainWindow = new (ELeave) RWindow(CHuiStatic::WsSession());
-        iData->iPlainWindow->Construct(*CHuiStatic::RootWin(),0x000FAB10); // FYI: multiple display support neglegted atm
-        iData->iPlainWindow->SetExtentErr(TPoint(0,0),CHuiStatic::ScreenDevice()->SizeInPixels()); // FYI: multiple display support neglegted atm            
-        iData->iPlainWindow->Size(); // to populate size cache
-        iData->iPlainWindow->Activate();
-        iData->iPlainWindow->SetVisible(ETrue);
-        iData->iPlainWindow->SetTransparencyAlphaChannel();
-        iData->iPlainWindow->SetBackgroundColor(~0);          
-        }
+    CHuiStatic::WsSession().EnableWindowSizeCacheL();
+    iData->iPlainWindow = new (ELeave) RWindow(CHuiStatic::WsSession());
+    iData->iPlainWindow->Construct(*CHuiStatic::RootWin(),0x000FAB10); // FYI: multiple display support neglegted atm
+    iData->iPlainWindow->SetExtentErr(TPoint(0,0),CHuiStatic::ScreenDevice()->SizeInPixels()); // FYI: multiple display support neglegted atm            
+    iData->iPlainWindow->Size(); // to populate size cache
+    iData->iPlainWindow->Activate();
+    iData->iPlainWindow->SetVisible(ETrue);
+    iData->iPlainWindow->SetTransparencyAlphaChannel();
+    iData->iPlainWindow->SetBackgroundColor(~0);          
 
     iData->iBridge = CAlfStreamerBridge::NewL(0);
     iData->iBridge->iAlfWindowData.iAlfWindowGrpId = mainWg.Identifier();
@@ -908,19 +877,12 @@
 	iData->iAlfEffectObserver = new (ELeave) TAlfEffectObserver(&iData->iBridge->iActiveEffectCount, *iData->iBridgeObj);
 	iData->iHuiEnv->EffectsEngine()->SetObserver(iData->iAlfEffectObserver);
 			
-    if( !iData->iPlainWindow)
-        {
-        // Create default CAlfScreen already now to be able to show controlgroups early enough... 
-  	    iData->iBridgeObj->AddNewScreenL(iData->iSharedWindow);
-        }
-    else 
-        {
-  	    iData->iBridgeObj->AddNewScreenFromWindowL(iData->iPlainWindow);
-        iData->iEventAo = new (ELeave) CAlfEventBridge(*this, *iData->iBridgeObj->Display(0));
+    iData->iBridgeObj->AddNewScreenFromWindowL(iData->iPlainWindow);
+    iData->iEventAo = new (ELeave) CAlfEventBridge(*this, *iData->iBridgeObj->Display(0));
         
-        RThread eventThread;
+    RThread eventThread;
 
-        User::LeaveIfError(eventThread.Create(
+    User::LeaveIfError(eventThread.Create(
             KAlfEventThreadName,
             AlfEventThreadStartFunction,
             16384, // magic
@@ -928,9 +890,8 @@
             (TAny*)iData->iEventAo, 
             EOwnerThread));
 
-        eventThread.Resume();
-        eventThread.Close();
-        }
+    eventThread.Resume();
+    eventThread.Close();
 
     AppendDisplayOnSharedWindowL(*(iData->iBridgeObj->Display(0)));
     
@@ -941,9 +902,11 @@
     iData->iServer->TextureManager().HandleEnvCreateL( *iData->iHuiEnv );
     
     // Construct transition effect instance if it does not yet exist
+    // OBSOLETE
 	iData->iServer->CreateTransitionEffectsL();
 	
 	// Load Tfx server client API plugin, if exists
+    // OBSOLETE
 	iData->iServer->CreateTfxServerPlugin();
     
 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
@@ -956,21 +919,11 @@
 // ---------------------------------------------------------------------------
 // From class CAknAppUi.
 // Handles system event.
+// OBSOLETE
 // ---------------------------------------------------------------------------
 //
-EXPORT_C void CAlfAppUi::HandleSystemEventL(const TWsEvent& aEvent)
+EXPORT_C void CAlfAppUi::HandleSystemEventL(const TWsEvent&)
     {
-    switch (*(TApaSystemEvent*)(aEvent.EventData()))
-		{
-	case EApaSystemEventBroughtToForeground:
-        { // we need to suppress this event as it causes undesired effects on applications underneath
-        break;
-        }
-    default:
-        CAknAppUi::HandleSystemEventL(aEvent);
-        }
-
-    return;
     }
 
 void CAlfAppUi::StartPointerEventHandling()
@@ -991,31 +944,29 @@
 
 void CAlfAppUi::UpdateActiveSession(CAlfAppSrvSessionBase* aSession)
     {
-    EndPointerEventHandling();
-    iData->iActiveSession = aSession;
+    if( iData->iActiveSession  != aSession )
+        {
+        EndPointerEventHandling();
+        iData->iActiveSession = aSession;
+        
+        iData->iResourceManager->SetActiveSession( iData->iActiveSession );
     
-    iData->iResourceManager->SetActiveSession( iData->iActiveSession );
-
-    if (CCoeEnv::Static())
-        {   
-        if( aSession )
+        if(!aSession)
             {
-            CHuiStatic::RootWin()->EnableGroupListChangeEvents();
+            if (iData->iMainDisplay) // TBD: multiple display support once again...
+                {
+                TRAP_IGNORE(iData->iMainDisplay->SetClearBackgroundL(CHuiDisplay::EClearNone));
+                }
             }
-        else
-            {
-            CHuiStatic::RootWin()->DisableGroupListChangeEvents();
-            }
-        }
-    if(!aSession)
-        {
-        if (iData->iMainDisplay) // TBD: multiple display support once again...
-            {
-            TRAP_IGNORE(iData->iMainDisplay->SetClearBackgroundL(CHuiDisplay::EClearNone));
-            }
+        iData->iBridgeObj->HandleVisualVisibility( 0 );
         }
     }
     
+CAlfAppSrvSessionBase* CAlfAppUi::ActiveSession()
+    {
+    return iData->iActiveSession;
+    }
+
 // ---------------------------------------------------------------------------
 // From class CAknAppUi.
 // Handles window server event.
@@ -1023,41 +974,14 @@
 //
 EXPORT_C void CAlfAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination)
     {
-    TBool handlingPtrEvent(EFalse);
-    
     if (aEvent.Type() >= EEventPointer && aEvent.Type() <= 	EEventDragDrop )
         {
         StartPointerEventHandling();
-        handlingPtrEvent = ETrue; // just to play it safe
-        }
-
-    // A Fix for AlfServer not shutting down on power off (ANIA-7EWFV6)
-    if ( aEvent.Type() == EEventPowerMgmt ) 
-        {
-        TApaSystemEvent systemEvent( *(TApaSystemEvent*)(aEvent.EventData()) );
-        if ( systemEvent == EApaSystemEventShutdown || systemEvent == EApaSystemEventSecureShutdown )
-            {
-            // Don't let this event go further to base class' HandleWsEventL,
-            // since it'll start the appShutter, which will be ignored first,
-            // and when it would be really needed (after AllClientsClosed), it's already destroyed. 
-            return;
-            }
         }
     
-    if (!iData->iEventAo) // CCoeEnv exists
+    if( aEvent.Type() == EEventScreenDeviceChanged  )
         {
-        CAknAppUi::HandleWsEventL(aEvent, aDestination);
-        if (handlingPtrEvent)
-            {
-            EndPointerEventHandling();
-            }
-        }
-    else
-        {
-        if( aEvent.Type() == EEventScreenDeviceChanged  )
-            {
-            HandleResourceChangeL( KEikDynamicLayoutVariantSwitch );
-            }
+        HandleResourceChangeL( KEikDynamicLayoutVariantSwitch );
         }
     
     switch ( aEvent.Type() )
@@ -1180,8 +1104,7 @@
 //
 EXPORT_C TBool CAlfAppUi::FrameworkCallsRendezvous() const
     {
-    // just basecall for now    
-    return CAknAppUi::FrameworkCallsRendezvous();      
+    return EFalse;
     }
 
 // ---------------------------------------------------------------------------
@@ -1219,7 +1142,7 @@
     
     if ( aType == KEikDynamicLayoutVariantSwitch || aType == KAknsMessageSkinChange && iData->iHuiEnv)
         {
-        iData->iHuiEnv->Skin().NotifyDisplaySizeChangedL();
+        iData->iHuiEnv->Display(0).SetSkinSizeChangePending();
         }
         
     // Send notification events to clients here if needed    
@@ -1248,12 +1171,8 @@
 // Called when a command is received.
 // ---------------------------------------------------------------------------
 //
-EXPORT_C void CAlfAppUi::HandleCommandL(TInt aCommand)
+EXPORT_C void CAlfAppUi::HandleCommandL(TInt)
     {
-    if (aCommand == EEikCmdExit && iData->iAllClientsClosed)
-        {
-        Exit();
-        }
     }
 
 // ---------------------------------------------------------------------------
@@ -1269,27 +1188,8 @@
 // Updates non-fading setting to window.
 // ---------------------------------------------------------------------------
 //
-void CAlfAppUi::SetContainerNonFading( TBool aNonFading )
+void CAlfAppUi::SetContainerNonFading(TBool)
     {
-    const TBool nonFading = iData->iSharedWindowNonFading;
-    if ( ( nonFading && !aNonFading ) ||
-         ( !nonFading && aNonFading ) )
-        {
-        // Update window server setting.
-        iData->iSharedWindowNonFading = aNonFading;
-        iData->iSharedWindow->DrawableWindow()->SetNonFading( aNonFading );
-        
-        // If non-fading is turned off, update fading to correct value.
-        // It's assumed that alfred applications are not shown in a pop up.
-        // If it were possible, we would need to know if alfred pop up is
-        // topmost.
-        if ( !aNonFading )
-            {
-            iData->iSharedWindow->DrawableWindow()->SetFaded( 
-                IsFaded(),
-                RWindowTreeNode::EFadeIncludeChildren );
-            }
-        }
     }
 
 // ---------------------------------------------------------------------------
@@ -1355,7 +1255,7 @@
 
 TTypeUid::Ptr CAlfAppUi::MopSupplyObject(TTypeUid aId)
     {
-    return CAknAppUi::MopSupplyObject(aId);
+    return TTypeUid::Null();
     }
 
 // ---------------------------------------------------------------------------
@@ -1384,8 +1284,7 @@
 void CAlfAppUi::ShowControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber )
     {
     iData->iBridgeObj->ShowControlGroupL(aRoster, aGroup, aWhere, aScreenNumber);    
-    iData->iBridgeObj->HandleVisualVisibility( aScreenNumber );    
-
+    iData->iBridgeObj->HandleVisualVisibility( aScreenNumber );
     }
 
 // ---------------------------------------------------------------------------
@@ -1431,18 +1330,6 @@
 //
 void CAlfAppUi::NotifyLowMemory(TInt aAmountOfFreeMemRequested)
     {
-/*
-	// Toggle between normal & low memory levels
-    if (!aAmountOfFreeMemRequested)
-        {
-        iData->iBridgeObj->SetMemoryLevel(EHuiMemoryLevelNormal);
-        }
-    else
-        {
-        iData->iBridgeObj->SetMemoryLevel(EHuiMemoryLevelLow);        
-        }
-*/
-
 	// Enable "ultra-low" memory mode
     if (!aAmountOfFreeMemRequested)
         {
@@ -1511,11 +1398,6 @@
         {
         User::Leave(KErrPermissionDenied);    
         }
-    
-//	if (iData->iBridgeObj->LayoutSwitchEffectCoordinator())
-//		{
-//		iData->iBridgeObj->LayoutSwitchEffectCoordinator()->EnableSafeCounter(EFalse); // let capserver rule  
-//		}
   
     TBool pause = aMessage.Int0();
     
@@ -1525,4 +1407,13 @@
     // let the session complete message  
     }
 
+RAlfBridgerClient* CAlfAppUi::BridgerClient()
+    {
+    if (iData)
+        {
+        return iData->iBridgeObj->BridgerClient();  
+        }    
+    return 0;
+    }
+
 // end of file
--- a/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -109,6 +109,30 @@
 
 const TInt KFadeAction = 6000;
 
+// IsLayoutSwitchReady heuristic constants:
+
+// Duration to wait that visual display rects are fully inside fullscreen rect. 
+// 1 unit = 50ms.
+const TInt KAlfCheckVisualDisplayRect = 15;
+
+// Duration to wait that visual has drawing inside screen area.
+const TInt KAlfCheckVisualDrawRect = 15;
+
+// Duration to wait that visual has drawing that covers the whole display rect.
+const TInt KAlfCheckVisualDrawingComplete = 20;
+
+// Duration to wait that visual has some drawing (not necessarily complete).
+const TInt KAlfCheckVisualDrawingNotEmpty = 28;
+
+// Duration to wait that fullscreen is covered by visual drawing.
+const TInt KAlfCheckFullscreenCoveredByVisualDrawing = 50;
+
+// Duration to wait if coverage is modified by multiple control groups.
+// This may indicate that topmost application hasn't yet had time to update
+// its layout properly.
+const TInt KAlfCheckCoverageFromMultipleGroups = 20;
+
+
 NONSHARABLE_CLASS( TAlfBridgeDrawerWrapper ) : public MAlfDrawerScreenInterface
     {
 public:
@@ -158,6 +182,8 @@
 // 
 CAlfBridge::~CAlfBridge()
 	{
+    iTempRegion2.Close();
+    
     iAlfNativeClientsWgIds.Close();
 	delete iOrphanStorage;
 	delete iFadeEffectFile;
@@ -170,7 +196,8 @@
     delete iEffectEndTimer;
     iDeadControlGroups.Close();
     iEffectWindowGroups.Close();
-    delete iFullScreenEffectData;
+    delete iFSFxData;
+    delete iFSFXDataPart2;
 
     if (iActivated)
         {
@@ -361,7 +388,7 @@
         TInt aClientSideGroupId,
         CHuiCanvasVisual* aVisual )
     {
-    __ALFFXLOGSTRING1("CAlfBridge::AddVisual 0x%x", aWindowNodeId);
+    __ALFFXLOGSTRING4("CAlfBridge::AddVisual id: %d (%d,%d), visual: 0x%x", aWindowNodeId, aClientSideId, aClientSideGroupId, aVisual);
     THashVisualStruct visualStruct( aVisual, aClientSideId, aClientSideGroupId);
     iWindowHashArray.Insert( aWindowNodeId, visualStruct );
     iPreviouslySearchedVisualId = aWindowNodeId;
@@ -406,7 +433,7 @@
         iPreviouslySearchedVisual = visualStruct->iVisual;
         return iPreviouslySearchedVisual; 
         }
-    __ALFFXLOGSTRING1("CAlfBridge::FindVisual - Visual 0x%x not found", aWindowNodeId);
+    __ALFLOGSTRING1("CAlfBridge::FindVisual - Visual 0x%x not found", aWindowNodeId);
     return NULL;
     }
 
@@ -554,9 +581,9 @@
 //
 CHuiControlGroup* CAlfBridge::FindControlGroupByFullScreenToEffect() const
     {
-    if ( iFullScreenEffectData )
-        {
-        return FindControlGroupBySecureId( iFullScreenEffectData->iToSecureId, iFullScreenEffectData->iToWg ); 
+    if ( iFSFxData )
+        {
+        return FindControlGroupBySecureId( iFSFxData->iToSecureId, iFSFxData->iToWg ); 
         }
     return NULL;
     }
@@ -567,9 +594,9 @@
 //
 CHuiControlGroup* CAlfBridge::FindControlGroupByFullScreenFromEffect() const
     {
-    if ( iFullScreenEffectData )
-        {
-        return FindControlGroupBySecureId( iFullScreenEffectData->iFromSecureId, iFullScreenEffectData->iFromWg );
+    if ( iFSFxData )
+        {
+        return FindControlGroupBySecureId( iFSFxData->iFromSecureId, iFSFxData->iFromWg );
         }
     return NULL;
     }
@@ -602,7 +629,7 @@
 void CAlfBridge::ResolveAfterEffectAppearingApplicationL(CHuiControlGroup* aGroup)
     {
 #ifdef USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
-    if (iFullScreenEffectData && iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
+    if (iFSFxData && iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect)
         {
         CHuiControlGroup *exitingGroupInEffect = FindControlGroupByFullScreenToEffect();
         if (exitingGroupInEffect == aGroup)
@@ -626,9 +653,9 @@
                     {
                     if (iAlfScreens[0]->iControlGroups[j].iControlGroup == nextToBecomeVisible)
                         {
-                        iFullScreenEffectData->iFromSecureId = iAlfScreens[0]->iControlGroups[j].iSecureId;
-                        iFullScreenEffectData->iFromWg = iAlfScreens[0]->iControlGroups[j].iClientWindowGroupId;
-                        __ALFFXLOGSTRING2("CAlfBridge::ResolveAfterEffectAppearingApplicationL - Found underneath application uid: 0x%x, window group: %d -  Start track drawing for exit effect.", iFullScreenEffectData->iFromSecureId, iFullScreenEffectData->iFromWg );
+                        iFSFxData->iFromSecureId = iAlfScreens[0]->iControlGroups[j].iSecureId;
+                        iFSFxData->iFromWg = iAlfScreens[0]->iControlGroups[j].iClientWindowGroupId;
+                        __ALFFXLOGSTRING2("CAlfBridge::ResolveAfterEffectAppearingApplicationL - Found underneath application uid: 0x%x, window group: %d -  Start track drawing for exit effect.", iFSFxData->iFromSecureId, iFSFxData->iFromWg );
                         break;
                         }
                     }
@@ -664,13 +691,23 @@
                 TBool anyVisualHasEffect(EFalse);
                 TInt familyIndex(0);
                 TInt familySize = familyTree.Count();
+                TInt activeEffectIndex = KErrNotFound; 
                 while(familyIndex < familySize && !anyVisualHasEffect)
                     {
-                    anyVisualHasEffect = HasActiveEffect(familyTree[familyIndex++]);
+                    anyVisualHasEffect = HasActiveEffect(familyTree[familyIndex++], activeEffectIndex); 
+                    
                     }
                 
                 if (anyVisualHasEffect)
                     {
+                    TInt activeEffectHandle = iEffectCleanupStack[activeEffectIndex].iHandle;
+                    if (iFSFXDataPart2 && iFSFXDataPart2->iHandle == activeEffectHandle)
+                        {
+                        __ALFFXLOGSTRING1("CAlfBridge::DeleteControlGroupL - WARNING! Control group with 2 phase effect is being destroyed. Canceling second phase for handle %d", activeEffectHandle);
+                        delete iFSFXDataPart2;
+                        iFSFXDataPart2 = NULL;
+                        }
+                    
                     __ALFFXLOGSTRING1("Layout 0x%x has external content", layout);
                     // EHuiVisualFlagShouldDestroy destroy flag should have come for the windows in this layout already
                     layout->SetFlags(EHuiVisualFlagShouldDestroy);
@@ -692,10 +729,16 @@
                     effectControlGroup.AppendL(layout, effectControlGroupLayout); // this will remove it from the previous layout
                     layout->SetOwner(effectControlGroup);
                     
-                    for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++)
-                        {
-                        familyTree[familyIndex]->SetOwner(effectControlGroup);
-                        }
+                    for(TInt familyIndex = familyTree.Count() - 1; familyIndex >= 0; --familyIndex)
+                       {
+                       familyTree[familyIndex]->SetOwner(effectControlGroup);                      
+                       
+                       if (!HasActiveEffect(familyTree[familyIndex]))
+                           {
+                           TInt dummy;
+                           AddFxItemL(activeEffectHandle, familyTree[familyIndex], NULL, NULL, EFalse, dummy, ETrue, EFalse);
+                           }
+                       }
                     }
                 else
                     {
@@ -705,11 +748,13 @@
                      for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++)
                          {
                          CHuiLayout* removedVisual = familyTree[familyIndex];
-                         RemoveTemporaryPresenterVisual(removedVisual);
+                         CleanFxVisual(removedVisual);
           
                          if ( removedVisual != layout ) // let control group delete the layout
 					         {
 					         control.Remove(removedVisual); // remove ownership from the original control (group)
+					         __ALFFXLOGSTRING1("CAlfBridge::DeleteControlGroupL - adding to orphonage 0x%x", layout);
+					         CleanFxVisual(removedVisual);
 					         if ( removedVisual->Layout() == layout ) 
 					             {
 					             iOrphanStorage->AppendL( removedVisual );
@@ -762,7 +807,7 @@
         cntrl->ConstructL();
         group->AppendL(cntrl);
         CleanupStack::Pop(cntrl);
-        cntrl->SetRole(EAlfWindowGroupContainer);
+        cntrl->SetRole(EHuiWindowGroupContainer);
 
         layout = CHuiCanvasVisual::AddNewL(*cntrl);
         layout->SetTagL(KAlfWindowGroupContainerControlTag);
@@ -786,11 +831,15 @@
         entry.iClientWindowGroupId = aClientWindowGroupId;  
         entry.iSecureId = aSecureId;
         // we have received start effect for this group, but the group did not exist in alf universe at the time. hide the group.
-        if (iFullScreenEffectData
-                && iFullScreenEffectData->iWaitingWindowGroup
-                && iFullScreenEffectData->iToSecureId == aSecureId)
-            {
-            iFullScreenEffectData->iToWg = aClientWindowGroupId;
+        if (iFSFxData
+                && (iFSFxData->State() == EWaitingWindowGroup || iFSFxData->State() == EEndFullScreenReceivedWaitingWindowGroup)
+                && iFSFxData->iToSecureId == aSecureId)
+            {
+            iFSFxData->iToWg = aClientWindowGroupId;
+            if (iFSFXDataPart2)
+                {
+                iFSFXDataPart2->iToWg = aClientWindowGroupId;
+                }
             CHuiControlGroup* fromGroup = NULL;
             CHuiLayout* fromLayout = NULL; 
             fromGroup = FindControlGroupByFullScreenFromEffect();
@@ -803,20 +852,26 @@
             
             // First HandleGfxEvent, then clear iWaitingWindowGroup.
             __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - try triggering effect 0x%x", layout);
-            TBool failed = HandleGfxEventL( *iFullScreenEffectData, layout, fromLayout );
-            if ( iFullScreenEffectData )
-                {
-                iFullScreenEffectData->iWaitingWindowGroup = EFalse;
-                }
+            TBool failed = HandleGfxEventL( *iFSFxData, layout, fromLayout );
+            if ( iFSFxData->State() == EWaitingWindowGroup)
+                {
+                iFSFxData->SetState(EWaitEndFullScreen);
+                }
+            else
+                {  
+				// was CFullScreenEffectState::EEndFullScreenReceivedWaitingWindowGroup           
+                iFSFxData->SetState(EEndFullscreenReceived);
+                }
+            
             if ( failed )
                 {
                 // Effect failed, reset state
                 __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - effect failed on layout 0x%x", layout);
-                HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
+                HandleGfxStopEvent( EFalse ); // destroys iFSFxData and iFSFXDataPart2
                 }
             }     
         entry.iScreenNumber = aScreenNumber;
-//        entry.iRole = EAlfWindowGroupContainer;
+//        entry.iRole = EHuiWindowGroupContainer;
 
         iAlfScreens[aScreenNumber]->iControlGroups.Append(entry);
         CleanupStack::Pop(group);                
@@ -861,7 +916,7 @@
 // disappear.
     if ( aGroup.Control(0).Visual(0).Effect() )
         {
-        if ( aGroup.Control(0).Role() != EAlfWindowGroupContainer )
+        if ( aGroup.Control(0).Role() != EHuiWindowGroupContainer )
             {
             // The case where the application control group is deleted by window server
             // has been solved by deleting the tag when window server wants to delete
@@ -871,13 +926,13 @@
             }
         }
 
-    if (aGroup.Control(0).Role() == EAlfWindowGroupContainer)      
+    if (aGroup.Control(0).Role() == EHuiWindowGroupContainer)      
         {
         // Window group control groups
         ShowWindowGroupControlGroupL(aRoster, aGroup, aWhere, aScreenNumber);
         aGroup.SetAcceptInput(EFalse);
         }
-    else if (aGroup.Control(0).Role() == EAlfSessionContainer)      
+    else if (aGroup.Control(0).Role() == EHuiSessionContainer)      
         {
         // ALF application control groups    
         ShowSessionContainerControlGroupL(aRoster, aGroup, aWhere, aScreenNumber);
@@ -965,7 +1020,7 @@
                 move = ETrue;
                 }
             
-            if (aRoster.ControlGroup(i).Control(0).Role() == EAlfSessionContainer)
+            if (aRoster.ControlGroup(i).Control(0).Role() == EHuiSessionContainer)
                 {
                 index++;                                                
                 }                    
@@ -1002,44 +1057,52 @@
         TInt index = 0; // Index for Window group control groups
         TBool added = EFalse;
         for (TInt i=0; i<aRoster.Count() - screen->FixedControlGroupCount(); i++)
-            {
-            if (index == aWhere)
-                {
-                TBool lSyncAlfAppAndAlfEventGroup = EFalse;
-                if ( i>0 &&  aRoster.ControlGroup(i).iAlfApp && aRoster.ControlGroup(i-1).ResourceId() == iAlfWindowGroupNodeId  && &aRoster.ControlGroup(i) != &aGroup)
-                    {
-                    // we still need to check that there are no other alf client window groups on top.
-					// if one native alf application is embedding another native alf application, WServ
-					// seems to update wg chains so that the following check must be done  
-                    TInt u = i+1;
-                    TBool clienWgFoundOntop =EFalse;
-                    for(;u < aRoster.Count() - screen->FixedControlGroupCount(); u++)
-                        {
-                        if(aRoster.ControlGroup(u).iAlfApp)
-                            {
-                            clienWgFoundOntop = ETrue;
-                            break;
-                            }
-                        }
-                    
-                    if(!clienWgFoundOntop)
-                        {
-                        lSyncAlfAppAndAlfEventGroup = ETrue;
-                        }
-                    }
-                aRoster.ShowL(aGroup, i);
-                added = ETrue;
-                if (lSyncAlfAppAndAlfEventGroup && i< (aRoster.Count()-1) )
-                {
-                CHuiControlGroup &lGroup = aRoster.ControlGroup(i+1);
-                TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
-                iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
-                }
-                
-                break;
-                }
-
-            if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer &&
+                   {
+                   if (index == aWhere)
+                       {
+                       TBool lSyncAlfAppAndAlfEventGroup = EFalse;
+                       if ( i>0 &&  aRoster.ControlGroup(i).iAlfApp && aRoster.ControlGroup(i-1).ResourceId() == iAlfWindowGroupNodeId  && &aRoster.ControlGroup(i) != &aGroup)
+                           {
+                           // we still need to check that there are no other alf client window groups on top.
+                           // if one native alf application is embedding another native alf application, WServ
+                           // seems to update wg chains so that the following check must be done  
+                           TInt u = i+1;
+                           TBool clienWgFoundOntop =EFalse;
+                           for(;u < aRoster.Count() - screen->FixedControlGroupCount(); u++)
+                               {
+                               if(aRoster.ControlGroup(u).iAlfApp)
+                                   {
+                                   clienWgFoundOntop = ETrue;
+                                   break;
+                                   }
+                               }
+                           
+                           if(!clienWgFoundOntop)
+                               {
+                               lSyncAlfAppAndAlfEventGroup = ETrue;
+                               }
+                           }
+                       aRoster.ShowL(aGroup, i);
+                       added = ETrue;
+                       TBool lSyncDone(EFalse);
+                       if (lSyncAlfAppAndAlfEventGroup && i< (aRoster.Count()-1) )
+                       {
+                       lSyncDone = ETrue;
+                       CHuiControlGroup &lGroup = aRoster.ControlGroup(i+1);
+                       TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, 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 );
+                          iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
+                           }
+                       break;
+                       }
+
+            if (aRoster.ControlGroup(i).Control(0).Role() == EHuiWindowGroupContainer &&
                 &aRoster.ControlGroup(i) != &aGroup)
                 {
                 index++;                                                
@@ -1052,7 +1115,7 @@
             // Topmost
             for (TInt i=aRoster.Count() - screen->FixedControlGroupCount(); i >= 0; i--)
                 {
-                if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer)
+                if (aRoster.ControlGroup(i).Control(0).Role() == EHuiWindowGroupContainer)
                     {
                     // increasing the count, assuming that WindowControlGroup is not in the Roster
                     i++;
@@ -1070,7 +1133,7 @@
 // 
 void CAlfBridge::SetAlfWindowGroupId(TInt aAlfWindowGroupId)
     {
-    iAlfWindowGroupId = aAlfWindowGroupId;        
+    iAlfWindowGroupId = aAlfWindowGroupId;
     // check if hithcock window group was already there
     TInt secureId = RThread().SecureId(); 
     if (iAlfScreens.Count())
@@ -1081,6 +1144,11 @@
                  iAlfScreens[0]->iControlGroups[i].iClientWindowGroupId != CHuiStatic::RootWin(0)->Identifier())
                 {
                 iAlfWindowGroupNodeId = iAlfScreens[0]->iControlGroups[i].iWindowGroupNodeId;
+                
+                CHuiControlGroup* controlGroup = FindControlGroup(iAlfWindowGroupNodeId, 0);
+                CHuiControl& control = controlGroup->Control(0);
+                CHuiVisual* layout = &control.Visual(0);
+                iAlfScreens[0]->iDisplay->Roster().SetAlfEventWindow(layout);
                 return;
                 }
             }        
@@ -1115,7 +1183,7 @@
         for (TInt j=0; j<roster.Count();j++)
             {
             CHuiControlGroup& controlGroup = roster.ControlGroup(j);
-            if (controlGroup.Control(0).Role() == EAlfSessionContainer)
+            if (controlGroup.Control(0).Role() == EHuiSessionContainer)
                 {
                 controlGroupOrder.Append(&controlGroup);
                 roster.Hide(controlGroup);
@@ -1143,7 +1211,7 @@
         CHuiRoster& roster = iAlfScreens[aScreenNumber]->iDisplay->Roster();
         for (TInt j=0; j<roster.Count();j++)
             {
-            if( roster.ControlGroup(j).Control(0).Role() == EAlfSessionContainer 
+            if( roster.ControlGroup(j).Control(0).Role() == EHuiSessionContainer 
                 || roster.ControlGroup(j).ResourceId() == iAlfWindowGroupNodeId )
                 {
                 return j; // Alf groups positioned just above alf servers window group   
@@ -1197,7 +1265,7 @@
     {
     // Look for the correct display
     TInt screenNumber = ResolveScreenNumber(aDisplay);
-    RemoveTemporaryPresenterVisuals();
+    CleanFxVisuals();
     if ( screenNumber != KErrNotFound )
         {
         // FPS Counter with hitchcock drawing
@@ -1270,7 +1338,12 @@
         {
         return EFalse;
         }
-    if ( aVisual.Layout() && IsNonFadeEffect( aVisual.Layout()->Effect() ) )
+    
+    // Note: The long startup effect uses opaque effect to hide the background. 
+    if ( aVisual.Layout() 
+            && (IsNonFadeEffect( aVisual.Layout()->Effect() ) 
+			&& !IsOpaqueEffect(aVisual.Layout()->Effect() ))
+            )
         {
         return EFalse;
         }
@@ -1369,6 +1442,7 @@
         return;
             
     iTempRegion.Clear();
+    iTempRegion2.Clear();
     
     CAlfScreen* screen = iAlfScreens[aScreenNumber];
     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
@@ -1427,7 +1501,7 @@
         CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
         CHuiControl& control = controlgroup.Control(0);
 
-        if (control.Role() == EAlfFpsIndicatorContainer)
+        if (control.Role() == EHuiFpsIndicatorContainer)
             {
             // FPS container doesn't contain canvas visuals
             continue;
@@ -1454,11 +1528,18 @@
         
         
         // Dont mess with alf control group visuals, alf session handling does it for us
-        if (control.Role() == EAlfSessionContainer)
+        if (control.Role() == EHuiSessionContainer)
             {
             CHuiLayout* hostContainer = control.ContainerLayout( NULL );
-            TInt flags = hostContainer->Flags();            
-            if (!fullscreenCovered || alfClientWindowGroupVisible)
+            TInt flags = hostContainer->Flags();   
+            CAlfAppSrvSessionBase* activeSession = NULL;
+            if (iAppUi)
+                {
+                activeSession = iAppUi->ActiveSession();
+                }
+            // !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)
                 {
                 // clear inactive flag if client has not made this controlgroup hidden
                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
@@ -1579,6 +1660,27 @@
             {
             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());
+            }
+ 
             
 		// 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
@@ -1603,22 +1705,7 @@
                 layout->ClearCanvasFlags(EHuiCanvasFlagExternalFadeExistsInsideVisualTree);            
                 }
             }
-        
-        TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
-        if (isLayoutActive && !hasActiveVisualsInVisualTree)
-            {
-            // 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.
-            layout->SetFlag(EHuiVisualFlagInactive);
-            }
-        else if(!isLayoutActive && hasActiveVisualsInVisualTree)
-            {
-            layout->ClearFlag(EHuiVisualFlagInactive);
-            layout->SetPos(fullscreen.iTl);
-            layout->SetSize(fullscreen.Size());
-            }
-        
+               
 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Control group index: %d", j );
         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Active visuals : %d", activevisualcount );
@@ -1686,13 +1773,11 @@
             iHomeScreenPSValue = value;
             }
         }
-
-    
     if ( iSwRenderingEnabled )
         {
-        screen->iDisplay->SetForegroundTextureOptions( alfWindowGroupFoundVisible );
-        }
-
+        screen->iDisplay->SetForegroundTextureOptions( alfWindowGroupFoundVisible || alfClientWindowGroupVisible );
+        }
+   
     // Finally, if there are fadeeffects applied to windowgroups, make sure first one does not
     // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others
     // would clear the screen areas where they do not really draw.
@@ -1715,11 +1800,7 @@
                 
                 if ((controlgroup.ResourceId() == iAlfWindowGroupNodeId))
                     {
-                    // Special handling for ALF fading...fading happens via empty alf originated event window group
-                    TInt flags = layout->Effect()->EffectFlags();
-                    flags |= KHuiFxEnableBackgroundInAllLayers; // This forces effect to happen to background pixels that are read from surface. 
-                    flags |= KHuiFxFrozenBackground; // To get optimal UI performance, we ignore changes in ALF scene when it is faded.
-                    layout->Effect()->SetEffectFlags(flags);                            
+					// no special actions needed currently for alf content.
                     }                
                 firstFadedWindowGroupFound = ETrue;
                 }
@@ -1963,8 +2044,8 @@
         // Sprites and effects as we consider them always as transparent and also
         // if controlgroup is transformed somehow    
         
-        if (aControl.Role() == EAlfFullScreenEffectContainer 
-            || aControl.Role() == EAlfWindowFloatingSpriteContainer ||
+        if (aControl.Role() == EHuiFullScreenEffectContainer 
+            || aControl.Role() == EHuiWindowFloatingSpriteContainer ||
             aControlGroup.IsTransformed())
             {
             visualIsOpaque = EFalse;    
@@ -2164,8 +2245,8 @@
         CHuiControlGroup& controlgroup = iAlfScreens[0]->iDisplay->Roster().ControlGroup(j);
         CHuiControl& control = controlgroup.Control(0);
 
-        if ( control.Role() == EAlfSessionContainer ||
-             control.Role() == EAlfFpsIndicatorContainer )
+        if ( control.Role() == EHuiSessionContainer ||
+             control.Role() == EHuiFpsIndicatorContainer )
             {
             continue;
             }
@@ -2174,19 +2255,39 @@
         for (TInt i=layout->Count()-1; i >= 0; i--)
             {
             CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&layout->Visual(i));
-            if (!aInactiveOnly)
-                {
-                canvasVisual->ClearCommandSet();
-                }
-            else if (aInactiveOnly && (canvasVisual->Flags() & EHuiVisualFlagInactive))
-                {
-                canvasVisual->ClearCommandSet();                        
-                }
-            else
-                {
-                // dont clear
-                }
-            }
+            ClearCanvasVisualCommandSetsRecursive(canvasVisual, aInactiveOnly);            
+            }
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// 
+void CAlfBridge::ClearCanvasVisualCommandSetsRecursive(CHuiCanvasVisual* aVisual, TBool aInactiveOnly)
+    {
+    if (!aVisual)
+        {
+        return;
+        }
+
+    if (!aInactiveOnly)
+        {
+        aVisual->ClearCommandSet();
+        }
+    else if (aInactiveOnly && (aVisual->Flags() & EHuiVisualFlagInactive))
+        {
+        aVisual->ClearCommandSet();                        
+        }
+    else
+        {
+        // dont clear
+        }
+        
+    for (TInt i=aVisual->Count()-1; i >= 0; --i)
+        {
+        CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&aVisual->Visual(i));
+        ClearCanvasVisualCommandSetsRecursive(canvasVisual, aInactiveOnly);            
         }
     }
 
@@ -2485,6 +2586,13 @@
 	                __ALFLOGSTRING1("AlfScreens[0]->iDisplay->SetOrientation: %d",huiOrientation);  	                
 	                }
 	            
+                if (!iLayoutSwitchInProgress) // LayoutSwitchStart wasn't called, so inform that all is fine.
+                    {
+                    if (iActivated)
+                        {
+                        iBridgerClient.SendBlind(KAlfCompositionLayoutSwitchComplete, TIpcArgs());
+                        }            
+                    }
                 break;         
                 }
            case EAlfEffectFxBeginSyncronizedGroup:
@@ -2610,7 +2718,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, 
@@ -2715,6 +2823,9 @@
         CHuiLayout* lVisual = familyTree[familyIndex];
         lVisual->Owner().Remove(lVisual);
         iOrphanStorage->AppendL( lVisual );
+        CleanFxVisual(lVisual);
+        
+        __ALFLOGSTRING1("CAlfBridge::DestroyWindow - orphons: %d", iOrphanStorage->VisualCount());
         }
     familyTree.Close();
          
@@ -2726,7 +2837,7 @@
     if (!aUseForce)
         {
         // we can remove from iEffectCleanupStack only when this method was called from HandleDestroyWindow. Otherwise
-        // messing iEffectCleanupStack is likely to cause forever loop in some RemoveTemporaryPresenterVisuals method
+        // messing iEffectCleanupStack is likely to cause forever loop in some CleanFxVisuals method
         for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
             {
             TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
@@ -3128,7 +3239,7 @@
 			TInt wsWindowGroupCount = 0;
 			for (TInt i=0; i<iAlfScreens[screenNumber]->iDisplay->Roster().Count();i++)
 				{
-                if (iAlfScreens[screenNumber]->iDisplay->Roster().ControlGroup(i).Control(0).Role()==EAlfWindowGroupContainer)
+                if (iAlfScreens[screenNumber]->iDisplay->Roster().ControlGroup(i).Control(0).Role()==EHuiWindowGroupContainer)
 					{
 					wsWindowGroupCount++;    
 					}
@@ -3204,7 +3315,9 @@
 			}
 		}
   
-	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
+	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed
+
+	AMT_MAP_BRIDGE_SET_ORDINAL_POSITION();
 	}
 
 // ---------------------------------------------------------------------------
@@ -3259,6 +3372,27 @@
 			{
 			viz->ClearCommandSet();
 			}
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+		if (!(viz->Flags() & EHuiVisualFlagInactive))
+		    {
+            TInt secureId = viz->Owner().ControlGroup()->SecureId();
+            TInt64 temp(KErrNotFound);
+            TBool effects(EFalse);
+            AMT_GET_TIME(temp, secureId, 0, effects);
+            if (temp != KErrNotFound && effects == EFalse)
+                {
+                TTime time;
+                time.UniversalTime();
+                TTime startTime(temp);
+                    
+                TInt64 reactionTime = time.MicroSecondsFrom(startTime).Int64();
+                    
+                RDebug::Printf("CAlfBridge::HandlePostCanvasBufferL - Reaction time \t0x%x\t%f", secureId, (TReal)reactionTime / 1000000.0f );
+                AMT_RESET_TIME(secureId);
+                }
+		    }
+#endif
+		
 		// If tracking has been enabled for this CHuiCanvasVisual object, the buffers will be marked for tracking aswell in CHuiCanvasVisual
 		switch( bufferAttributes->iPartStatus )
 			{
@@ -3294,12 +3428,12 @@
 		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
 		}    
 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
-	    if (iFullScreenEffectData 
-	            && iFullScreenEffectData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
-	            && !iFullScreenEffectData->iEndFullScreen)
+	    if (iFSFxData
+	            && iFSFxData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
+	            && ((iFSFxData->State() == EWaitEndFullScreen && iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::ESecondPartActive)))
 	        {
 	        CHuiControlGroup *to_group = NULL;
-            if (iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
+            if (iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect)
                 {
                 to_group = FindControlGroupByFullScreenFromEffect();
                 }
@@ -3327,7 +3461,7 @@
 // 
 void CAlfBridge::GfxTriggerEndFullScreen(CFullScreenEffectState* aFullScreenEffectData)
     {
-    if (aFullScreenEffectData->iEndFullScreen)
+    if (iFSFxData->State() == EFinalEffectActive)
         {
         return;
         }
@@ -3354,11 +3488,11 @@
     if (to_layout)
         {
         // from layout may be undefined
-        __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEndFullScreenTimeout : Enough app drawing. Trigger EndFullScreen for layout 0x%x", to_layout);    
+        __ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEndFullScreen : Enough app drawing. Trigger EndFullScreen for layout 0x%x", to_layout);    
         HandleGfxEventL( *aFullScreenEffectData, to_layout, from_layout );
-        }
-
-    aFullScreenEffectData->iEndFullScreen = ETrue;
+        aFullScreenEffectData->SetState(EFinalEffectActive);
+        }
+
     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
     }
 
@@ -3387,7 +3521,7 @@
         {
         __ALFFXLOGSTRING2("CAlfBridge::SetWindowActiveL 0x%x has active effect. New state: %d", aVisual, aActive);
         // Has effect
-		// these flags are put to action in RemoveTemporaryPresenterItem
+		// these flags are put to action in CleanFxItem
         if (aActive)
             {
 			// this prevents windows appearing before their "effected" time
@@ -4090,7 +4224,7 @@
         CHuiControlGroup& controlgroup = screen->iDisplay->Roster().ControlGroup(j);
         CHuiControl& control = controlgroup.Control(0);
 
-        if( control.Role() == EAlfWindowGroupContainer)
+        if( control.Role() == EHuiWindowGroupContainer)
             {
             // Only update layout which are made to correspond window groups. 
             // Layouts that fullscreen effects are applied to
@@ -4173,6 +4307,7 @@
                     effectFlags |= KHuiFxEffectExcludeChildrenFlag;
                     //RDebug::Print(_L("CAlfBridge::SetupFadeEffectL - no children faded by parent"));
                     }
+                __ALFFXLOGSTRING1("CAlfBridge::SetupFadeEffectL - insert fade 0x%x", &aVisual);
                 TRAP( err, engine->LoadEffectL(*iFadeEffectFile, effect, aVisual.Effectable(), NULL, NULL, 0, effectFlags ) );
                 didFadeEffectLoad = ETrue;
         		}
@@ -4184,6 +4319,7 @@
         if (alreadyFaded)
             {
             aVisual.SetEffect( NULL );
+            __ALFFXLOGSTRING1("CAlfBridge::SetupFadeEffectL - remove fade: 0x%x", &aVisual);
             alreadyFaded = EFalse;
             }
         }
@@ -4269,7 +4405,9 @@
         else 
             {
             __ALFLOGSTRING("CAlfBridge::HandleMoveWindowToNewGroupL cannot find new group! orphaning the visual");
-            iOrphanStorage->AppendL( viz );
+            
+            CleanFxVisual(viz);
+             iOrphanStorage->AppendL( viz );
             }
         }
     else
@@ -4488,8 +4626,9 @@
 
 TBool CAlfBridge::HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout *aFromLayout)
     {
-    __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - To SecureUid: 0x%x, From SecureUid: 0x%x", aEvent.iToSecureId, aEvent.iFromSecureId);
+    __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);
+    
     TInt err = KErrNone;
     TBool failed = EFalse;
     
@@ -4522,7 +4661,7 @@
 					if (!HasActiveEffect(aToLayout, dummy))
 						{
 						__ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Add layout 0x%x with handle %d to cleanupstack", aToLayout, aEvent.iHandle);
-                    	AddEffectItemL(aEvent.iHandle, aToLayout, NULL, NULL, EFalse, dummy, EFalse);
+                    	AddFxItemL(aEvent.iHandle, aToLayout, NULL, NULL, EFalse, dummy, ETrue, EFalse);
 						}
                     }
 				// Screenshot was requested, but it could not be taken. Lets cancel the effect.	
@@ -4544,6 +4683,11 @@
                         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)
+                            {
+                            iFSFXDataPart2->iEffectType = CFullScreenEffectState::EStartEffect; 
+                            }
+                                
                         aEvent.iCanDestroyOrHideImmediately = ETrue; // enable hiding of windows during application start/activate effects
                         break;
                         }
@@ -4558,18 +4702,26 @@
 
                         // The layout should be visible at this time. if not, then this is assumed
                         // as effect to an background application and ignored.
-                        if (aToLayout->Effect())
-                            {
+						
+                        if (aToLayout->Effect() 
+							&& !(aToLayout->Effect()->EffectFlags() & KHuiFadeEffectFlag ))                         
+							{
+							// If the exit effect took a screesnhot (above), then the layout is freezed to show the screenshot. 
+							// Layout may not be unfrozen before EndFullScreen, or flicker will occur.
                             // effect on a layout must be an application start effect. 
                             // External content visual is not used for that.
                             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Found effect on layout 0x%x. Removing effect 0x%x", aToLayout, aToLayout->Effect());
                             aToLayout->SetEffect(NULL);
+                            aToLayout->SetFreezeState(EFalse); // Only if a screenshot was taken earlier then freeze state would be ETrue
                             }
+							
                         __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Layout 0x%x is active:  %d", aToLayout, !TBool(aToLayout->Flags() & EHuiVisualFlagInactive) );
                         if (!(aToLayout->Flags() & EHuiVisualFlagInactive)) 
                             {
                             TInt index;
-                            if (aToLayout->StoredRenderBuffer() && HasActiveEffect(aToLayout, index) && index != KErrNotFound)
+                            if (aToLayout->StoredRenderBuffer() 
+                                    && HasActiveEffect(aToLayout, index) 
+                                    && index != KErrNotFound)
                                 {
 	                            // a screenshot has been saved into the layout, and the layout was added to cleanupstack
     	                        // for cleaning. SetupEffectLayoutContainerL will add the same layout 
@@ -4579,7 +4731,7 @@
                                 }
                             // this will tag the visual, that they cannot be hidden by HandleVisualVisibility
                             // Initialize layout for the exit effect  
-                            iLayoutInitializedForExitEffect = SetupEffectLayoutContainerL(aEvent.iHandle, aToLayout, ETrue, aEvent.iCanDestroyOrHideImmediately);
+                            iLayoutInitializedForExitEffect = SetupEffectLayoutContainerL(aEvent.iHandle, aToLayout, ETrue, ETrue, aEvent.iCanDestroyOrHideImmediately);
                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - EBeginFullscreen - iLayoutInitializedForExitEffect: %d", iLayoutInitializedForExitEffect);
                             aEvent.iSetupDone = iLayoutInitializedForExitEffect; 
                             }
@@ -4587,7 +4739,11 @@
                             {
                             iLayoutInitializedForExitEffect = EFalse;
                             aEvent.iSetupDone = EFalse;
-							failed = ETrue;
+                            failed = ETrue;
+                            }
+                        if (iFSFXDataPart2)
+                            {
+                            iFSFXDataPart2->iSetupDone = aEvent.iSetupDone;
                             }
                          return failed;
                          }
@@ -4608,6 +4764,17 @@
                         
                     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)
+                            {
+                            __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL  - taking screenshot for the timeout appstart effect. Handle: %d",  aEvent.iHandle );
+                            aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
+                            TBool neededStoredBuffers(EFalse); // dummy 
+                            StoreLayoutIfRequiredByEffectL(aToLayout, aEvent, neededStoredBuffers);
+                            }
+                        
                         aToLayout->iOpacity.Set(1.0f);
                         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - loading effect, handle %d", aEvent.iHandle );
                         if (aEvent.iAction == AknTransEffect::EApplicationExit)
@@ -4621,7 +4788,11 @@
                             // add visuals to visual cleanupstack
                             aToLayout->SetStoredRenderBufferModificationsEnabled(EFalse);
                             TInt index;
-                            if (aToLayout->StoredRenderBuffer() && HasActiveEffect(aToLayout, index) && index != KErrNotFound)
+                            if (aToLayout->StoredRenderBuffer() 
+                                    && HasActiveEffect(aToLayout, index) 
+                                    && index != KErrNotFound
+                                    && aEvent.iTwoPhaseEffect != CFullScreenEffectState::ESecondPartActive // effects second phase
+                                    )
                                 {
 	                            // a screenshot has been saved into the layout, and the layout was added to cleanupstack
     	                        // for cleaning. SetupEffectLayoutContainerL will add the same layout 
@@ -4629,7 +4800,16 @@
                                 __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Removing the layout 0x%x with screenshot from iEffectCleanupStack", aToLayout);
                                 iEffectCleanupStack.Remove(index);
                                 }
-                            layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle,aToLayout, EFalse, aEvent.iCanDestroyOrHideImmediately);
+                            if (aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive || aEvent.iSetupDone)
+                                {
+                                // two phase effect, setup has been made with the first part of the effect. 
+                                // Only changing the effect is required.
+                                layoutEffectable = ETrue; 
+                                }
+                            else
+                                {
+                                layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle,aToLayout, ETrue, EFalse, aEvent.iCanDestroyOrHideImmediately);
+                                }
                             aEvent.iSetupDone = layoutEffectable; 
                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
                             }
@@ -4643,12 +4823,16 @@
                                 engine->AddEffectToGroup(activeEffectGroup);
                                 }
                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Active effect group: %d", activeEffectGroup);
-                            effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn; 
-                            if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName))
+                            effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
+                            if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName) ||
+                                    aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive)
                                 {
-                                // Performance improvement, but this would be better to be a special hint param in the fxml
                                 effectFlags |= KHuiFxOpaqueHint;
                                 }
+                            if (iFSFXDataPart2)
+                                {
+                                iFSFXDataPart2->iSetupDone = ETrue;
+                                }
                             
                             if (aEvent.iRect != TRect())
                                 {
@@ -4660,13 +4844,27 @@
                                 }
                             effect = NULL;
                             // only use the effect if the effect file was correctly parsed
+                            aToLayout->SetFreezeState(EFalse);
+                                                            
                             if (err != KErrNone)
                                 {
                                 // visuals added to "active effect visual" stack, but they wont be used, because effect loading has failed. cleanup.
-                                RemoveTemporaryPresenterVisual(NULL, aEvent.iHandle);
+                                CleanFxVisual(NULL, aEvent.iHandle);
                                 aToLayout->SetEffect(NULL);
                                 failed = ETrue;
                                 }
+                            else
+                                {
+                                switch(aEvent.iTwoPhaseEffect)
+                                    {
+                                    case CFullScreenEffectState::EFirstPartActive:
+                                        aEvent.iTwoPhaseEffect = CFullScreenEffectState::EFirstPartRunning;
+                                        break;
+                                    case CFullScreenEffectState::ESecondPartActive:
+                                        aEvent.iTwoPhaseEffect = CFullScreenEffectState::ESecondPartRunning;
+                                        break;
+                                    }
+                                }
                             }
                         else
                             {
@@ -4684,7 +4882,8 @@
                 }
             }
         }
-    iLastAction = aEvent.iAction; // TODO: useless?
+    
+    iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
     return failed;
     }
 
@@ -4693,14 +4892,14 @@
     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;
-    	    AddEffectItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, EFalse);
-	        iFullScreenEffectData->iAppStartScreenshotItemHandle = aHandle;
+    	    AddFxItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
+	        iFSFxData->iAppStartScreenshotItemHandle = aHandle;
 			}
         }
     }
@@ -4708,23 +4907,23 @@
 void CAlfBridge::HandleGfxStopEvent( TBool aClientRequest )
     {
     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent BEGIN");
-    if (!iFullScreenEffectData)
+    if (!iFSFxData)
         {
         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END: none");
-        RemoveAllTemporaryPresenterVisuals();
+        CleanAllFxVisuals();
         delete iControlEffectData;
         iControlEffectData = NULL;
         return;
         }
     
-    CFullScreenEffectState* fxData = iFullScreenEffectData;
-    iFullScreenEffectData = NULL;
+    CFullScreenEffectState* fxData = iFSFxData;
+    iFSFxData = NULL;
     CleanupStack::PushL( fxData );
     
      __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - handle: %d, toAppUid: 0x%x", fxData->iHandle, fxData->iToAppId);
     
     // clean effects with this handle       
-    RemoveTemporaryPresenterVisual(NULL, fxData->iHandle);
+    CleanFxVisual(NULL, fxData->iHandle);
     // this was abort, so we might have received earlier event hiding this window. Here we'll bring it 
     // back
     if (fxData->iToAppId && fxData->iToAppId != KErrNotFound)
@@ -4733,7 +4932,7 @@
         RemoveEffectFromApp(fxData->iFromSecureId, fxData->iFromWg );
         }
     // abort ALL other possible control effects
-    RemoveAllTemporaryPresenterVisuals();
+    CleanAllFxVisuals();
     
     delete iControlEffectData;
     iControlEffectData = NULL;
@@ -4747,6 +4946,8 @@
         }
     
     CleanupStack::PopAndDestroy( fxData );
+    delete iFSFXDataPart2;
+    iFSFXDataPart2 = NULL;
     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END");
     }
 
@@ -4777,7 +4978,7 @@
         if (handle != KErrNotFound)
             {
             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - layout visual: 0x%x ; handle: %d ", layout, handle);
-            RemoveTemporaryPresenterVisual(NULL, handle);
+            CleanFxVisual(NULL, handle);
             }
         layout->iOpacity.Set(1.0f); 
         }
@@ -4815,10 +5016,10 @@
      
     if ( operation == MAlfGfxEffectPlugin::EBeginFullscreen )
         {
-        if ( !iFullScreenEffectData || !iFullScreenEffectData->iSetupDone )
+        if ( !iFSFxData || !iFSFxData->iSetupDone )
             {
             // No fullsceen effect ongoing or fullscreen effect hasn't yet been set up, 
-            // so we can initialize iFullScreenEffectData from stream.
+            // so we can initialize iFSFxData from stream.
             
             __ALFFXLOGSTRING("HandleGfxEffectsL - fresh start");
             
@@ -4829,31 +5030,33 @@
         	
 			// the effect handle of freezed layout (iAppStartScreenshotItemHandle) must match the actual
 			// effect handle that is run. Only then frozen application can be freed at the end of the effect
-			if (iFullScreenEffectData)
+			if (iFSFxData)
 			{
             	for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
             	{
                	 TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
-               	 if (iFullScreenEffectData->iAppStartScreenshotItemHandle == effectItem.iHandle)
+               	 if (iFSFxData->iAppStartScreenshotItemHandle == effectItem.iHandle)
                	     {
                	     effectItem.iHandle = fxData->iHandle;
                	     }
                	}
 			}
             
-            if (iFullScreenEffectData && iFullScreenEffectData->iToAppId != fxData->iToAppId)
+            if (iFSFxData && iFSFxData->iToAppId != fxData->iToAppId)
                 {
 				__ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - WARNING - Another fullscreen effect to different app. Deleting the previous ongoing effect"); 
-                RemoveEffectFromApp(iFullScreenEffectData->iToSecureId, iFullScreenEffectData->iToWg);// Fullscreen effect for another app has arrived, and the previous has not finished and abort effect was not called.
-                RemoveEffectFromApp(iFullScreenEffectData->iFromSecureId, iFullScreenEffectData->iFromWg);
-                __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - Effect request has changed from appUid 0x%x to 0x%x. Cancel previous effect.", iFullScreenEffectData->iToAppId, fxData->iToAppId);
-                RemoveEffectFromApp(iFullScreenEffectData->iToAppId);
+                RemoveEffectFromApp(iFSFxData->iToSecureId, iFSFxData->iToWg);// Fullscreen effect for another app has arrived, and the previous has not finished and abort effect was not called.
+                RemoveEffectFromApp(iFSFxData->iFromSecureId, iFSFxData->iFromWg);
+                __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - Effect request has changed from appUid 0x%x to 0x%x. Cancel previous effect.", iFSFxData->iToAppId, fxData->iToAppId);
+                RemoveEffectFromApp(iFSFxData->iToAppId);
                 // Fullscreen effect for another 
                 }
 
-               delete iFullScreenEffectData;
-            iFullScreenEffectData = fxData;
-            iFullScreenEffectData->iAppStartScreenshotItemHandle = fxData->iHandle;
+               delete iFSFxData;
+               delete iFSFXDataPart2;
+               iFSFXDataPart2 = NULL;
+            iFSFxData = fxData;
+            iFSFxData->iAppStartScreenshotItemHandle = fxData->iHandle;
             
             stream.Release();
             }
@@ -4866,7 +5069,15 @@
             __ALFFXLOGSTRING("HandleGfxEffectsL - END: ongoing");
             
             // Client expects completion to be signalled with this handle.
-            iFullScreenEffectData->iCompletionHandle = stream.ReadInt32L();
+            iFSFxData->iCompletionHandle = stream.ReadInt32L();
+            if (iFSFXDataPart2)
+                {
+                // Two phase effect path has been chosen. First part is now ongoing, and second part will be 
+                // triggered after that. Client has now notified, that its screen is ready. We may trigger the 
+                // second effect as soon as the first part finishes.
+                __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Trigger second part. when 1st part done.");
+                iFSFXDataPart2->iCompletionHandle = iFSFxData->iCompletionHandle;
+                }
             
             stream.Release();           
             return ; 
@@ -4874,31 +5085,107 @@
         }
     else // MAlfGfxEffectPlugin::EEndFullscreen
         {
-        stream.Release();
-
         // End fullscreen signal received. We proceed only if there is really
         // effect ongoing and "end fullscreen" hasn't already been processed.
         
-        if ( !iFullScreenEffectData || iFullScreenEffectData->iEndFullScreen )
-            {
-            __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - END: fx ready");
+        if ( !iFSFxData 
+                || iFSFxData->State() == EFinalEffectActive
+                || iFSFxData->State() == EEndFullscreenReceived)
+            {
+            if (iFSFxData)
+            __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEffectsL - END: fx ready, state %d ", iFSFxData->State());
+            stream.Release();
             return;
             }
-
-        __ALFFXLOGSTRING("HandleGfxEffectsL - process end");
-        iFullScreenEffectData->iEndFullScreen = ETrue;
-
-#ifdef USE_APPLICATION_ENDFULLSCREEN_TIMEOUT		
-        if (iFullScreenEffectData->iDrawingCompleteTimer)
-            {
-            iFullScreenEffectData->iDrawingCompleteTimer->Cancel();
-            }
-#endif			
-        }
-
-    CFullScreenEffectState* fxData = iFullScreenEffectData;
+        CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState;
+        CleanupStack::PushL( fxData );
+        fxData->ConstructL( KErrUnknown, stream );
+        
+        TBool timeout = fxData->iTimeout;
+        // could the application be ready?
+        TBool applicationExists = FindControlGroupByFullScreenToEffect() != NULL ? ETrue : EFalse;
+
+        // It may be, that application exited already and it was moved already to effect group
+        if (iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect && !applicationExists )
+            {
+            applicationExists = FindLayoutByEffectHandle(fxData->iHandle) != NULL ? ETrue : EFalse;
+            }
+                
+        TBool longAppStartTimeout = fxData->iLongAppStartTimeout; 
+        
+        if (iFSFxData &&
+                !iFSFXDataPart2 && // second part has not been requested yet
+                longAppStartTimeout && // this is indeed timeout for app start effect
+                iFSFxData->iTwoPhaseEffect == CFullScreenEffectState::EOnlyOnePart && // second part has not been activated. note, that iFSFXDataPart2 would be NULL in this case 
+                (iFSFxData->State() == EWaitEndFullScreen 
+                 || iFSFxData->State() == EWaitingWindowGroup))
+            {
+            // Load the whole structure. If timeout was triggered then request effect name to be
+            // updated.
+            UpdateSecondaryEffectL(*fxData);
+            iFSFxData->iLongAppStartTimeout = fxData->iLongAppStartTimeout;
+            iFSFxData->iTwoPhaseEffect = CFullScreenEffectState::EFirstPartActive;
+            iFSFxData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
+            }
+
+        __ALFFXLOGSTRING4("HandleGfxEffectsL - iTwoPhaseEffect %d, Setup done: %d, Timeout: %d, long app start timeout: %d", iFSFxData->iTwoPhaseEffect,iFSFxData->iSetupDone, timeout,longAppStartTimeout);
+        if (!fxData->iLongAppStartTimeout) // endfullscreen originating from the application
+            {
+            if (iFSFxData->State() == EWaitingWindowGroup)
+                {
+                iFSFxData->SetState(EEndFullScreenReceivedWaitingWindowGroup);
+                }
+            else
+                {
+                iFSFxData->SetState(EEndFullscreenReceived);
+                }
+            
+            if (iFSFXDataPart2)
+                {
+                iFSFXDataPart2->SetState(EEndFullscreenReceived);
+                }
+            
+            }
+        CleanupStack::PopAndDestroy( fxData );
+        fxData = NULL;
+        
+        __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEffectsL - Regular timeout: %d, Slow start timeout: %d, Effect setup: %d, State: %d",
+                timeout,
+                longAppStartTimeout,
+                iFSFxData->iSetupDone,
+                iFSFxData->State());
+
+        stream.Release();// We should respect normal timeouts.
+        if (iFSFxData->iTwoPhaseEffect > CFullScreenEffectState::EOnlyOnePart
+                && iFSFxData->iSetupDone && timeout && longAppStartTimeout) // timeout = endfullscreen was requested or it was normal endfullscreen timeout, longAppStartTime = 
+            {
+            // If this is two phased effect, it can be started only by application request of endfullscreen (!timeout)
+            // or screen drawn (triggered from 
+            __ALFFXLOGSTRING("HandleGfxEffectsL - Two phase effect. Waiting second part to start. Skip this event.");
+            return;
+            }
+        
+        // If client triggered EndFullScreen has been received, and still we haven't seen sign of the application, we know
+        // things have gone wrong and will not go right. Clean up the mess.
+        if (iFSFxData->State() == EEndFullscreenReceived && !applicationExists && !timeout)
+            {
+            HandleGfxStopEvent(ETrue);
+            return;
+            }
+	    // If a long two part app start effect is ongoing or about to start, we can skip directly to the 
+		// second part when EndFullScreen request arrives.
+        if (iFSFXDataPart2 && iFSFxData 
+				&& applicationExists
+                && iFSFXDataPart2->State() == EEndFullscreenReceived 
+                && iFSFxData->iHandle == iFSFXDataPart2->iHandle )
+            {
+            AlfGfxEffectEndCallBack(iFSFxData->iHandle);
+            return;
+            }
+        }
+
+    CFullScreenEffectState* fxData = iFSFxData;
     fxData->iOperation = operation;
-    fxData->iWaitingWindowGroup = EFalse;
 
     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEffectsL - Operation: %d, handle: %d, type: %d", operation, fxData->iHandle, fxData->iType);
     __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - towg: %d, fromwg: %d", fxData->iToWg, fxData->iFromWg);
@@ -4933,18 +5220,23 @@
         if (toLayout)
             {
             failed = HandleGfxEventL(*fxData, toLayout, fromLayout);
+            // We found layout, and this was beginfullscreen event. Wait for endfullscreen to be triggered
+            if (fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen)
+                {
+                iFSFxData->SetState(EWaitEndFullScreen);
+                }
             }
         else
             {
             __ALFFXLOGSTRING("HandleGfxEffectsL - waiting window group");            
-            fxData->iWaitingWindowGroup = ETrue;
+            fxData->SetState(EWaitingWindowGroup);
             }
         }
 
     if ( failed )
         {
         // Effect failed, reset state
-        HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
+        HandleGfxStopEvent( EFalse ); // destroys iFSFxData and iFSFXDataPart2
         }
     else
         {
@@ -4969,13 +5261,33 @@
     __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - END");
     }
 
+TBool CAlfBridge::UpdateSecondaryEffectL(const CFullScreenEffectState& aState)
+    {
+    
+    __ALFFXLOGSTRING1("CAlfBridge::UpdateSecondaryEffectL - appstart timeout triggered: %d", aState.iLongAppStartTimeout);
+    if (aState.iLongAppStartTimeout) // only application start effects can trigger this timeout 
+        {
+        // clone the primary startup effect for later usage
+        delete iFSFXDataPart2;
+        iFSFXDataPart2 = new (ELeave) CFullScreenEffectState;
+        iFSFXDataPart2->ConstructL(*iFSFxData);
+        iFSFXDataPart2->iLongAppStartTimeout = EFalse;
+        
+        delete iFSFxData->iEffectName;
+        iFSFxData->iEffectName = NULL;
+        iFSFxData->iEffectName = aState.iEffectName->AllocL();
+        }
+    __ALFFXLOGSTRING("CAlfBridge::UpdateSecondaryEffectL <<" );
+    return EFalse;
+    }    
+
 TBool CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn(CHuiControlGroup* aToGroup)
     {
     if (!aToGroup || (aToGroup && aToGroup->Count() == 0))
         {
         return EFalse;
         }
-      iTempRegion.Clear();
+    iTempRegion.Clear();
     
     CAlfScreen* screen = iAlfScreens[0];
     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
@@ -4992,10 +5304,35 @@
     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
     IsFullScreenDrawnRecursive(toLayout, *aToGroup, control, fullscreenCovered, fullscreen, screen, dummy, opaque, iAlfScreens[0]->iDisplay->Orientation());
     fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
-    __ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - Covered: %d", fullscreenCovered);
+    // alf content check is relavant only for alf apps
+    if (!fullscreenCovered && aToGroup->iAlfApp) 
+        {
+        TInt clientGroupId = FindClientWindowGroupId(0, *aToGroup);
+        if (clientGroupId != KErrNotFound)
+            {
+            fullscreenCovered = HasActiveAlfContent(clientGroupId);
+            }
+        }
+    
+    __ALFFXLOGSTRING2("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - SecureId: 0x%x, Covered: %d", aToGroup->SecureId(), fullscreenCovered);
     if (fullscreenCovered)
         {
-        GfxTriggerEndFullScreen(iFullScreenEffectData);
+        if (iFSFxData->iTwoPhaseEffect == CFullScreenEffectState::EFirstPartRunning)
+            {
+            // effect has two parts, and the first one is ongoing. We'll skip to the second part. 
+            delete iFSFxData;
+            iFSFxData = iFSFXDataPart2;
+            iFSFXDataPart2 = NULL;
+            iFSFxData->iTwoPhaseEffect = CFullScreenEffectState::ESecondPartActive;
+             // Client notified of the EndFullScreen during the effect. Trigger the end part immediately.
+             __ALFFXLOGSTRING("CAlfBridge::AlfGfxEffectEndCallBack - End was received. Trigger second part.");
+             GfxTriggerEndFullScreen(iFSFxData);
+             iFSFxData->SetState(EFinalEffectActive);
+            }
+        else
+            {
+            GfxTriggerEndFullScreen(iFSFxData); // trigger effect
+            }
         return ETrue;
         }
     return EFalse;
@@ -5022,7 +5359,7 @@
 
     // operation tells if this is abort full screen or something else
     // When this function is used to abort control transitions, all data is 0s
-    if ( iFullScreenEffectData )
+    if ( iFSFxData )
         {
         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill fullscreen");        
         HandleGfxStopEvent( ETrue );
@@ -5031,7 +5368,7 @@
     if ( !toAppUi )
         {
         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill all");
-        RemoveAllTemporaryPresenterVisuals();
+        CleanAllFxVisuals();
         iHuiEnv->ContinueRefresh();
         }
     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - end");
@@ -5054,7 +5391,7 @@
     if (handle != KErrNotFound)
         {
         __ALFFXLOGSTRING1("CAlfBridge::HandleGfxStopControlEffectsL - Remove effect with handle: %d", handle);
-        RemoveTemporaryPresenterVisual(NULL, handle);
+        CleanFxVisual(NULL, handle);
         iHuiEnv->ContinueRefresh();
         }
     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopControlEffectsL - end");
@@ -5082,7 +5419,7 @@
         }
     else
         {
-        __ALFFXLOGSTRING2("CAlfBridge::HandleGfxControlEffectsL - Control not found. iClientHandle %d, iClientGroupHandle %d", 
+        __ALFFXLOGSTRING2("CAlfBridge::HandleSetDistractionWindowL - Control not found. iClientHandle %d, iClientGroupHandle %d. Cache request.", 
                 fxData->iClientHandle, 
                 fxData->iClientGroupHandle);
         return;
@@ -5138,15 +5475,17 @@
         }
     }
 
-CHuiCanvasVisual* CAlfBridge::AddEffectItemL(
+CHuiCanvasVisual* CAlfBridge::AddFxItemL(
         TInt aEffectHandle, 
         CHuiVisual* aSourceVisual, 
         CHuiLayout* aTargetLayout, 
         CHuiControl* aEffectControl, 
         TBool aInsertTemporaryVisual,
         TInt& aItemDestroyed,
+        TBool aIsFullScreenEffect,
         TBool aIsExitEffect,
-        TBool aCanDestroyOrHideImmediately)
+        TBool aCanDestroyOrHideImmediately 
+        )
     {
     CHuiCanvasVisual* temporaryPresenterVisual = NULL;
     TInt enableEffect = ETrue;
@@ -5172,7 +5511,7 @@
         // cleanup stack iEffectCleanupStack
         enableEffect = aSourceVisual->Flags() & EHuiVisualFlagShouldDestroy ? 0 : 1;
         __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - visual 0x%x is having effect. EShouldBeDestroyed flag state %d", &aSourceVisual, enableEffect );
-        RemoveTemporaryPresenterVisual(aSourceVisual);
+        CleanFxVisual(aSourceVisual);
         if (!enableEffect)
             {
             aItemDestroyed++;
@@ -5196,7 +5535,8 @@
                     temporaryPresenterVisual,
                     ETrue,
                     aIsExitEffect,
-                    aCanDestroyOrHideImmediately);
+                    aCanDestroyOrHideImmediately,
+                    aIsFullScreenEffect);
             iEffectCleanupStack.AppendL(item);
             }
         else
@@ -5206,7 +5546,8 @@
             TEffectCleanupStruct item = TEffectCleanupStruct(aEffectHandle,
                         aSourceVisual, NULL, EFalse,
                         aIsExitEffect,
-                        aCanDestroyOrHideImmediately);
+                        aCanDestroyOrHideImmediately,
+                        aIsFullScreenEffect);
             iEffectCleanupStack.AppendL(item);
             }
      }
@@ -5219,6 +5560,7 @@
         CHuiLayout* aTargetLayout, 
         CHuiControl* aEffectControl,
         TInt& aItemsDestroyed,
+        TBool aIsFullScreenEffect,
         TBool aAddLayout,
         TBool aIsExitEffect,
         TBool aCanDestroyOrHideImmediately)
@@ -5226,7 +5568,7 @@
     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x is having %d children", aSourceLayout, aSourceLayout->Count());
     if (aAddLayout)
         {
-        AddEffectItemL(aEffectHandle, aSourceLayout, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsExitEffect, aCanDestroyOrHideImmediately);
+        AddFxItemL(aEffectHandle, aSourceLayout, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
         }
         
     for (TInt i = 0; i < aSourceLayout->Count(); i++)
@@ -5236,10 +5578,10 @@
            if (sourceVisual.Count())
                {
                CHuiLayout& layout = static_cast<CHuiLayout&> (aSourceLayout->Visual(i));
-               AddToEffectLayoutContainerL(aEffectHandle, &layout, NULL, aEffectControl, aItemsDestroyed, EFalse,aIsExitEffect, aCanDestroyOrHideImmediately );
+               AddToEffectLayoutContainerL(aEffectHandle, &layout, NULL, aEffectControl, aItemsDestroyed, aIsFullScreenEffect,  EFalse, aIsExitEffect, aCanDestroyOrHideImmediately );
                }
            TInt oldItemsDestroyed = aItemsDestroyed;
-           AddEffectItemL(aEffectHandle, &sourceVisual, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsExitEffect, aCanDestroyOrHideImmediately);
+           AddFxItemL(aEffectHandle, &sourceVisual, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
            if (oldItemsDestroyed != aItemsDestroyed)
                {
                // Visual was destroyed. If so, then we must adjust index.
@@ -5249,9 +5591,9 @@
     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count());
     }
 
-TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect, TBool aCanDestroyOrHideImmediately)
-    {
-    __ALFFXLOGSTRING4("CAlfBridge::SetupEffectLayoutContainerL - aHandle: %d, aSourceLayout: 0x%x, aIsExitEffect: % d, CanDestroyOrHideImmediately: %d >>", 
+TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsFullScreenEffect, TBool aIsExitEffect, TBool aCanDestroyOrHideImmediately)
+    {
+    __ALFFXLOGSTRING4("CAlfBridge::SetupEffectLayoutContainerL - aHandle: %d, aSourceLayout: 0x%x, aIsExitEffect: %d, CanDstrOrHideImd.:%d >>", 
             aHandle, 
             aSourceLayout, 
             aIsExitEffect,
@@ -5270,17 +5612,17 @@
     // CHuiCanvasVisual* temporaryPresenterLayout = CHuiCanvasVisual::AddNewL( effectControlGroup, &effectControlGroupLayout);
     // create presenter visual and set bindings
     TInt itemsDestroyed(0);
-    AddToEffectLayoutContainerL(aHandle, aSourceLayout, NULL, &effectControlGroup, itemsDestroyed, EFalse, aIsExitEffect, aCanDestroyOrHideImmediately);
+    AddToEffectLayoutContainerL(aHandle, aSourceLayout, NULL, &effectControlGroup, itemsDestroyed, aIsFullScreenEffect, EFalse, aIsExitEffect, aCanDestroyOrHideImmediately);
 
     if (aIsExitEffect)
         {
-        CHuiCanvasVisual* temporaryPresenterVisual = AddEffectItemL(aHandle, aSourceLayout, &effectControlGroupLayout, &effectControlGroup, ETrue, itemsDestroyed, aIsExitEffect, EFalse);
+        CHuiCanvasVisual* temporaryPresenterVisual = AddFxItemL(aHandle, aSourceLayout, &effectControlGroupLayout, &effectControlGroup, ETrue, itemsDestroyed, aIsFullScreenEffect, aIsExitEffect, EFalse);
         aSourceLayout->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
         __ALFFXLOGSTRING3("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout)-> 0x%x (presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout, temporaryPresenterVisual);
         }
     else
         {
-        AddEffectItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, EFalse, itemsDestroyed, EFalse, EFalse);
+        AddFxItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, EFalse, itemsDestroyed, aIsFullScreenEffect, EFalse, EFalse);
         __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout), NO presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout);
         }
     iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue;
@@ -5385,7 +5727,7 @@
     CHuiFxEngine* engine = NULL;
     // engine is not owned by us, it is a member of HuiEnv
     engine = iHuiEnv->EffectsEngine();
-    if (engine)
+    if (engine && aCanvasVisual)
         {
         if (NeedsStoredBuffers(engine, *aEvent.iEffectName))
             {
@@ -5394,31 +5736,26 @@
 
         // clear out old effect if this visual has one
         __ALFFXLOGSTRING2("HandleGfxControlEffectsL - loading effect %S on visual 0x%x", aEvent.iEffectName, aCanvasVisual );
-        __ALFFXLOGSTRING1("HandleGfxControlEffectsL - loading control effect, handle %d", aEvent.iHandle );
+        __ALFFXLOGSTRING2("HandleGfxControlEffectsL - loading control effect, handle %d, Action: %d", aEvent.iHandle, aEvent.iAction );
         if (aCanvasVisual->Effect())
             {
             __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x has active effect. Requesting removal.", aCanvasVisual);
             // another effect coming to already effected visual. E.g. close options menu, while opening effect still ongoing
-            RemoveTemporaryPresenterVisual(aCanvasVisual);
+            CleanFxVisual(aCanvasVisual);
             }
         TBool layoutEffectable(EFalse);
         if (aEvent.iAction == KGfxControlDisappearAction)
-            { // TODO: revise
-            // The control stays visible because the inactive flag is not set
-            // if the window is reserved.
-            /*if (aCanvasVisual->iOpacity.Target() == 0.0f)
-                {
-                // this visual was hidden, before the effect arrived. sounds like trouble.
-                // Lets make it visible again, and ask it to be hidden in the end of the effect
-                // this enables at least the notes disappear effects
-                aCanvasVisual->iOpacity.Set(KAlfVisualDefaultOpacity);
-                // visual->SetFlag(EHuiVisualFlagShouldBeHidden);
-                }*/
-            layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, ETrue, EFalse);
+            {
+            if (aCanvasVisual->Flags() & EHuiVisualFlagInactive)
+                {
+                __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x is inactive. Skipping effect.", aCanvasVisual);
+                return;
+                }
+            layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, ETrue, EFalse);
             }
         else
             {
-            layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, EFalse);
+            layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, EFalse, EFalse);
             }
         if (layoutEffectable)
             {
@@ -5444,10 +5781,10 @@
             }
         //            RDebug::Print(_L("HandleGfxControlEffectsL - loading effect returned %d"), err );
         // only use the effect if the effect file was correctly parsed
+        aCanvasVisual->SetFreezeState(EFalse);
+                  
         if (err == KErrNone)
             {
-            iLastEffectHandle = aEvent.iHandle;
-
 #ifdef HUI_DEBUG_TRACK_DRAWING  
             visual->SetTracking(ETrue);
 #endif                
@@ -5458,13 +5795,13 @@
         else
             {
             // visuals added to "active effect visual" stack, but they wont be used, because effect loading has failed. cleanup.
-            RemoveTemporaryPresenterVisual(NULL, aEvent.iHandle);
+            CleanFxVisual(NULL, aEvent.iHandle);
             }
         effect = NULL; // HuiVisual has taken ownership
         }
     }
 
-TBool CAlfBridge::RemoveTemporaryPresenterItem(TEffectCleanupStruct& aEffectItem)
+TBool CAlfBridge::CleanFxItem(TEffectCleanupStruct& aEffectItem)
     {
     CHuiVisual* sourceViz = aEffectItem.iEffectedVisual;
     CHuiCanvasVisual* sourceViz2 = dynamic_cast<CHuiCanvasVisual*> (aEffectItem.iEffectedVisual);
@@ -5477,8 +5814,37 @@
         sourceViz2->FreeRenderBuffer();
         }
     sourceViz->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
-    TBool hideVisual = sourceViz->Flags() & EHuiVisualFlagShouldBeHidden;
-    TBool showVisual = sourceViz->Flags() & EHuiVisualFlagShouldBeShown;
+    TBool hideVisual = EFalse;
+    TBool showVisual = ETrue;
+    // Effect request flow:
+    // 1. Effect request
+	// 2. If component is found, effect started immediately.
+	// 	   If component is not found, effect request is cached and applied when window is created. 
+	//	     NOTE: Only one effect request can be cached at time. Possible TODO, if this causes
+	//       issues.
+    // 3. Possible change of component visibility (hide / show)
+    // 4. At the end of the effect the requested visiblity is applied to the visual (hidden / shown)
+    
+    // Exceptions 1: If it was disappear effect (aEffectItem.iHideWhenFinished is ETrue), the 
+    //              component is hidden. This is to guaranteen that e.g. options menu would not popup 
+    //              after disappear effect, if visual destruction / hiding request did not come in time.
+    //
+    // Exception 2: If disapper effect was requested, and component was requested to be hidden, 
+    //              and then component was requested to be visible DURING the effect, the 
+    //              component will be shown at the end of the effect. Use case: the same component shows 
+    //              two sequentive notes and each note dismissal has disappear effect and no appear
+	//              effect between.
+    if(!aEffectItem.iIsFullScreenEffect)
+        {
+        hideVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeHidden) || (aEffectItem.iHideWhenFinished && !(sourceViz->Flags() & EHuiVisualFlagShouldBeShown));
+        showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown) && (!aEffectItem.iHideWhenFinished || !hideVisual);
+        }
+    else
+        {
+        hideVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeHidden);
+        showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown);
+        }
+    __ALFFXLOGSTRING4("CAlfBridge::RemoveTemporaryPresenterItem - iIsFullScreenEffect: %d, iHideWhenFinished: %d, Hide: %d, Show: %d", aEffectItem.iIsFullScreenEffect, aEffectItem.iHideWhenFinished, hideVisual, showVisual);
     TBool destroyVisual = sourceViz->Flags() & EHuiVisualFlagShouldDestroy;
     TBool shouldInactivate = sourceViz->Flags() & EHuiVisualFlagShouldBeInactive;
     TBool shouldBeUnderOpaqueHint = sourceViz->Flags() & EHuiVisualFlagShouldBeUnderOpaqueHint;
@@ -5582,8 +5948,8 @@
     return TBool(destroyVisual);
     }
 
-// RemoveTemporaryPresenterVisual removes the temporary presenter visual, and unbinds it from the source. 
-TBool CAlfBridge::RemoveTemporaryPresenterVisual(CHuiVisual* aVisual,
+// CleanFxVisual removes the temporary presenter visual, and unbinds it from the source. 
+TBool CAlfBridge::CleanFxVisual(CHuiVisual* aVisual,
         TInt aHandle)
     {
     __ALFFXLOGSTRING2("CAlfBridge::RemoveTemporaryPresenterVisual - cleaning handle: %d, 0x%x", aHandle, aVisual);
@@ -5594,7 +5960,7 @@
         if (aVisual == effectItem.iEffectedVisual || 
 		    aHandle == effectItem.iHandle)
             {
-            if (RemoveTemporaryPresenterItem(effectItem))
+            if (CleanFxItem(effectItem))
                 {
                 visualsRemoved++;
                 }
@@ -5673,7 +6039,7 @@
     }
 
 
-TBool CAlfBridge::RemoveTemporaryPresenterVisuals()
+TBool CAlfBridge::CleanFxVisuals()
     {
     if (!iFinishedCleanupStackEffects.Count())
         {
@@ -5693,7 +6059,7 @@
              
             if (iFinishedCleanupStackEffects[0] == effectItem.iHandle)
                 {
-                if (RemoveTemporaryPresenterItem(effectItem))
+                if (CleanFxItem(effectItem))
                     {
                     itemsRemoved++;
                     }
@@ -5719,7 +6085,7 @@
     return itemsRemoved;
     }
 
-void CAlfBridge::RemoveAllTemporaryPresenterVisuals()
+void CAlfBridge::CleanAllFxVisuals()
     {
     CHuiControl& effectControlGroup =  iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0);
     CHuiLayout* effectControlGroupLayout = (CHuiLayout*) &effectControlGroup.Visual(0);
@@ -5728,7 +6094,7 @@
     while(iEffectCleanupStack.Count())
         {
         TEffectCleanupStruct& effectItem = iEffectCleanupStack[0];
-        RemoveTemporaryPresenterItem(effectItem);
+        CleanFxItem(effectItem);
         iEffectCleanupStack.Remove(0);
         }
     
@@ -5752,6 +6118,37 @@
     // around will be cleared when HandleGfxStopEffectsL is called
 
     // iFinishedCleanupStackEffects.Append(aHandle);
+    
+	// check if the first part of application start effect finished
+    if (iFSFxData 
+            && iFSFxData->iHandle == aHandle
+            && iFSFxData->iLongAppStartTimeout && iFSFXDataPart2)
+        {
+        delete iFSFxData;
+        iFSFxData = iFSFXDataPart2;
+        iFSFXDataPart2 = NULL;
+        iFSFxData->iTwoPhaseEffect = CFullScreenEffectState::ESecondPartActive;
+        if (iFSFxData->State() == EEndFullscreenReceived)
+            {
+            // Client notified of the EndFullScreen during the effect. Trigger the end part immediately.
+            __ALFFXLOGSTRING("CAlfBridge::AlfGfxEffectEndCallBack - End was received. Trigger second part.");
+            GfxTriggerEndFullScreen(iFSFxData);
+            iFSFxData->SetState(EFinalEffectActive);
+			// skip cleanup. It will be run, when this effect finishes
+            return;
+            }
+        else
+            {
+            iFSFxData->SetState(EWaitEndFullScreen);
+            }
+        
+        iFSFxData->iEffectType = CFullScreenEffectState::EStartEffect;
+        
+        CHuiControlGroup* toGroup = FindControlGroupByFullScreenToEffect();
+        GfxTriggerEffectWhenFullScreenDrawn(toGroup);
+        return;
+        }
+    
     if (!iEffectEndTimer->IsActive())
         {
         TRAP_IGNORE(iEffectEndTimer->AddFinishedHandleL(aHandle));
@@ -5786,18 +6183,21 @@
         __ALFFXLOGSTRING("invalid handle");
         }
     // alftranstion plugin may cancel end timers connected to this effect
-    TBool fsEffectDone = iFullScreenEffectData && aHandle == iFullScreenEffectData->iHandle;
+    TBool fsEffectDone = iFSFxData && aHandle == iFSFxData->iHandle;
     if ( fsEffectDone )
         {
-        aHandle = iFullScreenEffectData->iCompletionHandle;
+        aHandle = iFSFxData->iCompletionHandle;
         }
     RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, aHandle );
 
     // Effect finished
     if ( fsEffectDone )
         {
-        delete iFullScreenEffectData;
-        iFullScreenEffectData = NULL;
+        delete iFSFxData;
+        iFSFxData = NULL;
+        
+        delete iFSFXDataPart2;
+        iFSFXDataPart2 = NULL;
         }
     }
     
@@ -5841,7 +6241,7 @@
 
         TFileName processName = iCommandDebug->WServClientFileName( clientWindowGroupId, CHuiStatic::WsSession() );
 #endif         
-        if (indexedGroup.Control(0).Role() == EAlfWindowGroupContainer)
+        if (indexedGroup.Control(0).Role() == EHuiWindowGroupContainer)
             {
             if (aRoster.ControlGroup(i).ResourceId() == iAlfWindowGroupNodeId)
                 {
@@ -5860,7 +6260,7 @@
 #endif
                 }                    
             }
-        else if (indexedGroup.Control(0).Role() == EAlfSessionContainer)
+        else if (indexedGroup.Control(0).Role() == EHuiSessionContainer)
             {
 #ifdef  HUI_DEBUG_TRACK_DRAWING
             __ALFLOGSTRING2(">> %d ALF GROUP, %d", i, clientWindowGroupId);                        
@@ -5868,7 +6268,7 @@
             __ALFLOGSTRING1(">> %d ALF GROUP", i);                                    
 #endif
             }
-        else if (indexedGroup.Control(0).Role() == EAlfWindowFloatingSpriteContainer)
+        else if (indexedGroup.Control(0).Role() == EHuiWindowFloatingSpriteContainer)
             {
 #ifdef  HUI_DEBUG_TRACK_DRAWING			
             __ALFLOGSTRING3(">> %d FLOATING SPRITE GROUP %S, %d", i, &processName, clientWindowGroupId);                                            
@@ -5876,7 +6276,7 @@
             __ALFLOGSTRING1(">> %d FLOATING SPRITE GROUP", i);                                            
 #endif
             }
-        else if (indexedGroup.Control(0).Role() == EAlfFullScreenEffectContainer)
+        else if (indexedGroup.Control(0).Role() == EHuiFullScreenEffectContainer)
             {
 #ifdef  HUI_DEBUG_TRACK_DRAWING
             __ALFLOGSTRING3(">> %d EFFECT GROUP %S, %d", i, &processName, clientWindowGroupId );                                                                
@@ -5884,7 +6284,7 @@
             __ALFLOGSTRING1(">> %d EFFECT GROUP", i);                                                                
 #endif
             }
-        else if (indexedGroup.Control(0).Role() == EAlfFpsIndicatorContainer)
+        else if (indexedGroup.Control(0).Role() == EHuiFpsIndicatorContainer)
             {
 #ifdef  HUI_DEBUG_TRACK_DRAWING
             __ALFLOGSTRING3(">> %d FPS GROUP %S, %d", i, &processName, clientWindowGroupId );                                                                
@@ -6123,6 +6523,13 @@
         }
     
     iSwRenderingEnabled = aEnable;    
+    
+    AMT_MAP_SET_VALUE(
+            iBoolMap,
+            AMT_MAP_SW_ENABLED_HANDLE,
+            iSwRenderingEnabled,
+            EAlfModuleTestTypeBridgeGoom );
+    
     for (TInt i=0; i<iAlfScreens.Count();i++)
         {
         PrepareSwRenderingTarget(iAlfScreens[i]);        
@@ -6231,6 +6638,13 @@
 void CAlfBridge::SetLowMemory(TBool aEnabled)
     {
     iLowMemoryMode = aEnabled;
+    
+    AMT_MAP_SET_VALUE(
+            iBoolMap,
+            AMT_MAP_LOW_MEMORY_MODE_HANDLE,
+            iLowMemoryMode,
+            EAlfModuleTestTypeBridgeGoom );
+    
     DoUpdateMemoryLevel();
     }
 
@@ -6240,6 +6654,13 @@
 TInt CAlfBridge::ForceSwRendering(TBool aEnabled)
     {
     iForcedSwRendering = aEnabled;
+    
+    AMT_MAP_SET_VALUE(
+            iBoolMap,
+            AMT_MAP_FORCE_SW_HANDLE,
+            iForcedSwRendering,
+            EAlfModuleTestTypeBridgeGoom );
+    
     DoUpdateMemoryLevel();
     return KErrNone;        
     }
@@ -6448,70 +6869,69 @@
     return (aVisual.Owner().ControlGroup()->ResourceId() == iAlfWindowGroupNodeId);
     }
 
-// experimental
-TBool CAlfBridge::IsFullScreenDrawn( TInt aOrientation)
-    {
+
+// ---------------------------------------------------------------------------
+// Checks if layout switch is ready. The aDuration parameter is the duration
+// since layout switch started. So this allows heuristics to loosen as there
+// may be applications that do not behave as expected. aDuration is meant
+// to be given in units of 50ms.
+// ---------------------------------------------------------------------------
+// 
+TBool CAlfBridge::IsLayoutSwitchReady( TInt aDuration )
+    {
+    TBool visualTreeReady = ETrue;
+
     if (!iAlfScreens.Count())
         return EFalse;
-    aOrientation = iAlfScreens[0]->iDisplay->Orientation();            
+   
     iTempRegion.Clear();
+    iTempRegion2.Clear();
     
     CAlfScreen* screen = iAlfScreens[0];
     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
-    __ALFFXLOGSTRING3("CAlfBridge::IsFullScreenDrawn - new orientation %d, screen size: (%d,%d)", aOrientation, fullscreen.iBr.iX, fullscreen.iBr.iY );
+    TInt orientation = screen->iDisplay->Orientation();
+
+    __ALFLOGSTRING2("CAlfBridge::IsLayoutSwitchReady begin o:%d d:%d", orientation, aDuration);
+    
     TBool fullscreenCovered = EFalse;
-        
-    // Check if effect group has an effect with opaque hint.
-    CHuiControlGroup& fxcontrolgroup = *(iAlfScreens[0]->iFullscreenEffectControlGroup);
-    CHuiControl& fxcontrol = fxcontrolgroup.Control(0);
-    CHuiCanvasVisual* fxlayout = (CHuiCanvasVisual*)&fxcontrol.Visual(0);
-    CHuiVisual* fxExternalContent = fxlayout->ExternalContent();
-    
-    if (fxlayout && IsOpaqueEffect(fxlayout->Effect()))
-        {
-        fullscreenCovered = ETrue;    
-        }
-    else if (fxExternalContent && IsOpaqueEffect(fxExternalContent->Effect()))
-        {
-        fullscreenCovered = ETrue;
-        }    
-
-    TBool alfClientWindowGroupVisible = EFalse;
-    
-    AMT_SET_VALUE( iVisibleVisualCount, 0 );
-    
-    // skip the topmost (effect) layer, start from floating sprite group
+	TBool alfClientWindowGroupVisible = EFalse;
+	
+	TInt coverageModifiedGroupCount = 0;
+		
+    // Skip the topmost (effect) layer, start from floating sprite group
     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
         {                
-        CHuiControlGroup& controlgroup = iAlfScreens[0]->iDisplay->Roster().ControlGroup(j);
+        CHuiControlGroup& controlgroup = screen->iDisplay->Roster().ControlGroup(j);
         CHuiControl& control = controlgroup.Control(0);
-		__ALFFXLOGSTRING1("CAlfBridge::IsFullScreenDrawn : Group owner 0x%x", controlgroup.SecureId());
-                
-        
-        if (control.Role() == EAlfFpsIndicatorContainer)
+
+        if (control.Role() == EHuiFpsIndicatorContainer)
             {
             // FPS container doesn't contain canvas visuals
             continue;
             }
 
+        if (controlgroup.ResourceId() == iAlfWindowGroupNodeId)
+            {
+            // ALF window doesn't have drawing and it's meant to be completely semitransparent,
+            // so skip.
+            continue;
+            }
+
         CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
-       
+        
         // For optimization reasons, check if all visuals below in Z-order are covered    
         if (!fullscreenCovered)
             {
-            fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
-            if(fullscreenCovered)
-                {
-                return ETrue;
-                }
-            for(TInt ii=0;ii< iTempRegion.Count(); ii++)
-                {
-                __ALFFXLOGSTRING4("CAlfBridge::IsFullScreenDrawn (%d,%d)-(%d,%d)", iTempRegion[ii].iTl.iX, iTempRegion[ii].iTl.iY , iTempRegion[ii].iBr.iX, iTempRegion[ii].iBr.iY );
-                }
-            }
+            fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);            
+            }
+    
+        if (fullscreenCovered)
+            {
+            break;
+            }    
         
-        // Dont mess with alf control group visuals, alf session handling does it for us
-        if (control.Role() == EAlfSessionContainer)
+        // ALF applications are handled by checking if their visuals cover the whole screen.
+        if (control.Role() == EHuiSessionContainer)
             {
             CHuiLayout* hostContainer = control.ContainerLayout( NULL );
             TInt flags = hostContainer->Flags();            
@@ -6539,29 +6959,296 @@
             continue;
             }
         
-        __ALFLOGSTRING1("CAlfBridge::IsFullScreenDraw - fullscreen covered %d", fullscreenCovered)
-        TBool subTreeCovered = EFalse;
-        TBool hasActiveVisualsInVisualTree = 
-                IsFullScreenDrawnRecursive( layout, controlgroup, control, fullscreenCovered, fullscreen, screen,subTreeCovered, IsVisualOpaque(*layout), aOrientation );    
-        // If root visuals effect is marked as opaque, then add whole screen area as covered.
-        /*
-        if (!fullscreenCovered)
-            {
-            fullscreenCovered = IsOpaqueEffect(layout->Effect());
-            }                    
-        */    
-       
-        if(controlgroup.iAlfApp && layout->iOpacity.Now() > 0.0f )
+        TBool hasActiveVisualsInVisualTree(EFalse);
+        TBool coverageRegionModified(EFalse);
+        
+        if (alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId))
+            {
+            visualTreeReady =
+               IsLayoutSwitchReadyRecursive( layout, controlgroup, control, 
+                   hasActiveVisualsInVisualTree, fullscreen, screen, 
+                   IsVisualOpaque(*layout), alfClientWindowGroupVisible, 
+                   orientation, aDuration, coverageRegionModified );            
+            }
+        else
+            {
+            visualTreeReady =
+               IsLayoutSwitchReadyRecursive( layout, controlgroup, control, 
+                   fullscreenCovered, fullscreen, screen, 
+                   IsVisualOpaque(*layout), EFalse, orientation, 
+                   aDuration, coverageRegionModified );            
+            }
+
+        if (!visualTreeReady)
+            {
+            // Problem found in IsLayoutSwitchReadyRecursive
+            visualTreeReady = EFalse;
+            break;
+            }
+
+        if (coverageRegionModified)
+            {
+            coverageModifiedGroupCount++;
+            }
+
+        // Heuristic: If coverage region is modified by multiple apps, then it's possible that
+        // foreground application hasn't had time to update its layout. So give little time to do that.
+        if (aDuration <= KAlfCheckCoverageFromMultipleGroups && coverageRegionModified > 1)
+            {
+            __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - multiple groups");
+            visualTreeReady = EFalse;
+            break;
+            }
+
+        if( controlgroup.iAlfApp && layout->iOpacity.Now() > 0.0f )
             {
             alfClientWindowGroupVisible = ETrue;
             }
+        }
+
+    __ALFLOGSTRING2("CAlfBridge::IsLayoutSwitchReady done %d (groups %d)", visualTreeReady, coverageModifiedGroupCount);
+    iTempRegion2.Clear();
+    
+    // Heuristic: Check that visual drawing covers the whole screen.
+    if ( visualTreeReady && ( aDuration <= KAlfCheckFullscreenCoveredByVisualDrawing ) )
+        {
+        if ( !IsRectCoveredByRegion( fullscreen, iTempRegion ) )
+            {
+            __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - screen not covered");
+            visualTreeReady = EFalse;
+            }
+        }
+    
+    return visualTreeReady;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Checks if rect is inside fullscreen area.
+// ---------------------------------------------------------------------------
+// 
+static TBool CheckVisualRect(const TRect aRect, const TRect& aFullScreen)
+    {
+    if (aRect.IsEmpty())
+        {
+        return EFalse;
+        }
+         
+    if (!aFullScreen.Contains(aRect.iTl))
+        {
+        return EFalse;
+        }
+
+    TPoint br = aRect.iBr;
+    br.iX--;
+    br.iY--;
+    if (!aFullScreen.Contains(br))
+        {
+        return EFalse;
+        }
+    
+    return ETrue;
+    }
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// 
+TBool CAlfBridge::IsLayoutSwitchReadyRecursive(
+        CHuiLayout* aLayout,
+        CHuiControlGroup& aControlGroup,
+        CHuiControl& aControl,
+        TBool& aFullscreenCovered, 
+        const TRect& aFullscreen,
+        CAlfScreen* aScreen,
+        TBool aChildCanBeOpaque, 
+        TBool aOnlyForEmbeddedAlfApp,
+        TInt aOrientation,
+        TInt aDuration,
+        TBool& aCoverageRegionModified )
+    {
+    TBool visualTreeReady = ETrue;
+    TRect visualDisplayRect;
+    TBool visualRectIsCovered = EFalse;
+    TBool visualIsOpaque = EFalse;
+    TBool visualIsActive = EFalse;
+    CHuiCanvasVisual* canvasVisual = NULL;
+
+    for (TInt i = aLayout->Count() - 1; i >= 0; i--)
+        {
+        visualDisplayRect = TRect(0,0,0,0);
+        visualRectIsCovered = EFalse;
+        visualIsOpaque = EFalse;
+        visualIsActive = EFalse;
         
-        if (fullscreenCovered)
-            {
-            return ETrue;
-            }
-        }
-    return fullscreenCovered;
+        canvasVisual = (CHuiCanvasVisual*)(&aLayout->Visual(i));
+
+        // Distraction windows are completely ignored.
+        TBool distractionWindow = (canvasVisual->CanvasFlags() & EHuiCanvasFlagDistractionWindow);
+        if ( distractionWindow )
+            {
+            continue;
+            }
+
+        visualIsOpaque = aChildCanBeOpaque && IsVisualOpaque(*canvasVisual);
+        TBool visualIsVisible = (canvasVisual->iOpacity.Now() > 0.01f);       
+        
+        if (canvasVisual->Count() && visualIsVisible)
+            {
+            TBool ready = IsLayoutSwitchReadyRecursive( canvasVisual, aControlGroup, aControl, 
+                aFullscreenCovered, aFullscreen, aScreen, 
+                visualIsOpaque, EFalse, aOrientation, 
+                aDuration, aCoverageRegionModified );
+                
+            if (!ready)
+                {
+                visualTreeReady = EFalse;
+                break;
+                }
+            }
+
+        // Calculate visual display rect
+        visualDisplayRect = canvasVisual->DisplayRect();
+    
+        ClipVisualRect(visualDisplayRect, aLayout->DisplayRect());
+        ClipVisualRect(visualDisplayRect, aFullscreen);
+        
+        // Check if covered.
+        if (aFullscreenCovered)
+            {
+            visualRectIsCovered = ETrue;    
+            }
+        else
+            {            
+            // Check if this visual is covered by other opaque visuals which rects are in "covered" region
+            // it should not check for alf event window group, when we have embedded alf application,
+            // because we have assumed that alf app will have full screen covered
+            if(!aOnlyForEmbeddedAlfApp)
+                {
+                visualRectIsCovered = IsRectCoveredByRegion(visualDisplayRect, iTempRegion);
+                }                                
+            }
+
+        // Heuristic: Check that visual display rect is ok (not empty, inside screen)
+        if ( aDuration <= KAlfCheckVisualDisplayRect && !visualRectIsCovered && 
+             !CheckVisualRect(visualDisplayRect, aFullscreen) )
+            {
+            __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - display rect not ok");
+            visualTreeReady = EFalse;
+            break;
+            }
+    
+	    // Determine if visual is active from coverage point of view.
+        visualIsActive = EFalse;
+        if (visualRectIsCovered)
+            {                                        
+            if (!(canvasVisual->Flags() & EHuiVisualFlagAlwaysDraw)) 
+                {
+                visualIsActive = EFalse;                
+                }
+            else
+                { 
+                visualIsActive = ETrue;
+                }                
+            }
+        else
+            {
+			visualIsActive = ETrue;
+            }
+        
+        // Sprites and effects as we consider them always as transparent and also
+        // if controlgroup is transformed somehow    
+        if (aControl.Role() == EHuiFullScreenEffectContainer || 
+            aControl.Role() == EHuiWindowFloatingSpriteContainer ||
+            aControlGroup.IsTransformed())
+            {
+            visualIsOpaque = EFalse;    
+            }
+           
+        // Check that command buffers are ok.
+        if ( visualIsActive )
+            {
+            TRect displayRect = visualDisplayRect;
+            visualDisplayRect = canvasVisual->CommandBufferCoverage(aOrientation);
+
+            // Heuristic: Check that visual drawing isn't completely empty.
+            if ( aDuration <= KAlfCheckVisualDrawingNotEmpty && !visualRectIsCovered &&
+                 visualIsVisible && visualDisplayRect.IsEmpty() )
+                {
+                __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - no drawing");
+                visualTreeReady = EFalse;
+                break;
+                }
+            
+            // Heuristic: Check that visual drawing isn't outside the screen.
+            if ( aDuration <= KAlfCheckVisualDrawRect && !visualRectIsCovered &&
+                 visualIsVisible && !CheckVisualRect(visualDisplayRect, aFullscreen) )
+                {
+                __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - bad drawing");
+                visualTreeReady = EFalse;
+                break;
+                }
+
+            // Heuristic: Check that visual drawing is complete.
+            if ( aDuration <= KAlfCheckVisualDrawingComplete && !visualRectIsCovered &&
+                 visualIsVisible && displayRect != visualDisplayRect )
+                {
+                __ALFLOGSTRING("CAlfBridge::IsLayoutSwitchReady not ready - incomplete drawing");
+                visualTreeReady = EFalse;
+                break;
+                }
+
+            // Make sure we clip visual rect to visible screen area
+            ClipVisualRect(visualDisplayRect, aFullscreen);
+            
+            // Heuristic: Union of opaque visual drawing regions should cover the whole screen.
+            // Note - coverage is checked at the end of IsLayoutSwitchReady.
+            if (visualIsOpaque && visualIsVisible && !visualRectIsCovered)
+                {
+                iTempRegion2.AddRect( visualDisplayRect );
+                iTempRegion2.Tidy();
+                }
+            }
+			
+        if (visualIsActive && visualIsOpaque && !visualRectIsCovered)
+            { 
+            // New visibility system takes only window shape into account.
+            if ( canvasVisual->CanvasFlags() & EHuiCanvasFlagIncludeToVisibilityCalculation )
+                {
+                if ( !canvasVisual->HasCustomShape() )
+                    {
+                    aCoverageRegionModified = ETrue;
+                    
+                    TRect displayRect(canvasVisual->DisplayRect());
+                    ClipVisualRect(displayRect, aLayout->DisplayRect());
+                    ClipVisualRect(displayRect, aFullscreen);
+
+                    iTempRegion.AddRect(displayRect);
+                    iTempRegion.Tidy();
+                    }
+                else
+                    {
+                    aCoverageRegionModified = ETrue;
+                    
+                    TRect displayRect = canvasVisual->DisplayRect();
+                    const TRegion& region = canvasVisual->ShapeRegion();
+                    TPoint delta = -canvasVisual->ShapeOrigin() + displayRect.iTl;
+                
+                    for (TInt i = 0; i < region.Count(); ++i)
+                        {
+                        TRect coveredRect(region[i]);
+                        coveredRect.Move(delta);
+                        ClipVisualRect(coveredRect, aFullscreen);
+
+                        iTempRegion.AddRect(coveredRect);
+                        }
+                    iTempRegion.Tidy();
+                    }
+                }
+            }        
+        } // for loop end : children checking loop
+     
+    return visualTreeReady;
     }
 
 TBool CAlfBridge::IsFullScreenDrawnRecursiveAlfContent(CHuiVisual* aVisual, TRect& aFullScreen)
@@ -6670,8 +7357,8 @@
         
         // Sprites and effects as we consider them always as transparent and also
         // if controlgroup is transformed somehow    
-        if (aControl.Role() == EAlfFullScreenEffectContainer 
-            || aControl.Role() == EAlfWindowFloatingSpriteContainer ||
+        if (aControl.Role() == EHuiFullScreenEffectContainer 
+            || aControl.Role() == EHuiWindowFloatingSpriteContainer ||
             aControlGroup.IsTransformed())
             {
             visualIsOpaque = EFalse;    
@@ -6713,7 +7400,7 @@
         CHuiControlGroup& controlgroup = screen->iDisplay->Roster().ControlGroup(j);
         CHuiControl& control = controlgroup.Control(0);
 
-        if (control.Role() == EAlfFpsIndicatorContainer || control.Role() == EAlfSessionContainer)
+        if (control.Role() == EHuiFpsIndicatorContainer || control.Role() == EHuiSessionContainer)
             {
             // FPS container doesn't contain canvas visuals and alfsession containers cannot have surfaces
             continue;
@@ -6763,6 +7450,7 @@
         {
         iIdForLayoutSwitchFrameSync = iIdForEAlfDSSynchronizeOp - KPreventingCollisionOfIdsInSynchDrawRequests;
         iHuiEnv->Synchronize( iIdForLayoutSwitchFrameSync, this );
+        AsynchRefresh(); // In SW mode, device is in manual refresh mode - enforce refresh in order to get synchronize done.
         }
     }
 
@@ -6825,4 +7513,30 @@
         }
     }
 
+TBool CAlfBridge::HasActiveAlfContent( TInt aClientWgId )
+    {
+    TBool hasAlfContent = EFalse;
+    if(iAppUi)
+        {
+        CAlfAppSrvSessionBase* activeAlfSession = iAppUi->ActiveSession();
+        CAlfScreen* screen = iAlfScreens[0];
+        for(TInt i = 0 ; i < screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount() ; i++)
+            {
+            CHuiControlGroup& controlgroup = screen->iDisplay->Roster().ControlGroup(i);
+            CHuiControl& control = controlgroup.Control(0);
+            if (control.Role() == EHuiSessionContainer)
+                {
+                CAlfAppSrvSessionBase* alfSrvSession = iAppUi->SrvSessionForControlGroup(controlgroup);
+                if(alfSrvSession && 
+                   (alfSrvSession->ClientWindowGroup() == aClientWgId))
+                    {
+                    hasAlfContent = ETrue;
+                    break;
+                    }
+                }
+            }
+        }
+    return hasAlfContent;
+    }
+
 // end of file
--- a/uiacceltk/hitchcock/ServerCore/Src/alfeffectutils.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfeffectutils.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -20,7 +20,13 @@
 #include <akntransitionutils.h>
 #include <alflogger.h>
 
+// Delay after which first end check is performed.
 const TInt KRosterFreezeEndTimeoutInMs = 100;
+// Interval between end checks.
+const TInt KRosterFreezeEndIntervalInMs = 50;
+// Maximum amount of end checks to be performed. 
+// This can be lower, should be visible enough to see, if heuristics fail.
+const TInt KRosterFreezeEndAttempts = 50;
 
 // ---------------------------------------------------------
 // CAlfRosterFreezeEndTimer
@@ -59,6 +65,7 @@
     if (!IsActive())
         {
         iSafeCounter = 0;
+        iSafeCounterDelta = Min(1, aPeriod.Int() / (KRosterFreezeEndIntervalInMs*1000));
         After( aPeriod );
         }
     }
@@ -71,22 +78,24 @@
 	
 	if (iSafeCounter >= 0)	
 	    {
-		iSafeCounter++;
-		if (iSafeCounter == 100) // can be lower, 100 should be visible enough to see, if heuristics fail
+		iSafeCounter += iSafeCounterDelta;
+		if (iSafeCounter >= KRosterFreezeEndAttempts)
 			{
 			timeout = ETrue;
 			iSafeCounter = 0;
 			}
 		}
 
-    if (!iBridge.IsFullScreenDrawn(0) && !timeout)
+    if (!iBridge.IsLayoutSwitchReady(iSafeCounter) && !timeout)
         {
         __ALFLOGSTRING("CAlfRosterFreezeEndTimer::RunL - Not ready in new orientation. waiting 50ms more");
-        After( 50000 );
+        iSafeCounterDelta = 1;
+        After( KRosterFreezeEndIntervalInMs * 1000 );
         return;
         }
     else
         {
+        __ALFLOGSTRING("CAlfRosterFreezeEndTimer::RunL - Ready in new orientation.");
         iCallBack.CallBack();
         }
     }
@@ -168,16 +177,18 @@
     // - EEventLayoutSwitch: If effect available, EStateThemeFx. Otherwise EStateFreezeFx.
     //
     // From EStateFreezeFx:
-    // - EEventBlankOn: EStateBlankFx
     // - implicit Finish - EStateIdle
     //
     // From EStateBlankFx:
     // - EEventBlankOff: EStateFreezeFx (we use freeze to ensure that result is ok)
-    // - EEventLayoutSwitch: If effect available, EStateThemeFx.
+    // - EEventLayoutSwitch: If effect available, EStateThemeFx. Otherwise EStateFreezeFx.
     //
     // From EStateThemeFx:
     // - EEventLowMemory: If blank still on, EStateBlankFx. Otherwise EStateFreezeFx.
     // - implicit Finish - EStateIdle
+    //
+    // There is special handling if layout switch event is received while previous
+    // layout switch is ongoing.
 
     TState nextState = EStateIdle;
     
@@ -205,6 +216,69 @@
         {
         Transition( nextState, iCurrentState );
         }
+    else
+        {
+        // We stay in the same state, but still need special handling in a couple of scenarios
+        if ( nextState == EStateFreezeFx )
+            {
+            HandleFreezeEvent( aEvent );
+            }
+        if ( nextState == EStateThemeFx )
+            {
+            HandleThemeEvent( aEvent );
+            }                        
+        }
+    }
+
+// ---------------------------------------------------------
+// CAlfLayoutSwitchEffectCoordinator::HandleFreezeEvent
+// Special handling for Freeze effect.
+// ---------------------------------------------------------
+//
+void CAlfLayoutSwitchEffectCoordinator::HandleFreezeEvent(TEvent aEvent)
+    {
+    if ( aEvent == EEventLayoutSwitch && iRosterFreezeEndTimer && iRosterFreezeEndTimer->IsActive() )
+        {                                
+        // New layout switch while previous is ongoing => restart freeze end timer.
+        __ALFLOGSTRING("CAlfLayoutSwitchEffectCoordinator::HandleFreezeEvent restart timer");
+        iRosterFreezeEndTimer->Cancel();
+        iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000, TCallBack(DoFreezeFinished, this));                
+        }
+    }
+
+// ---------------------------------------------------------
+// CAlfLayoutSwitchEffectCoordinator::HandleFreezeEvent
+// Special handling for Theme effect.
+// ---------------------------------------------------------
+//
+void CAlfLayoutSwitchEffectCoordinator::HandleThemeEvent(TEvent aEvent)
+    {
+    if ( aEvent == EEventLayoutSwitch )
+        {                                
+        // If layout switch occurs while freeze end timer is ongoing, restart.
+        if ( iRosterFreezeEndTimer && iRosterFreezeEndTimer->IsActive() )
+            {
+            __ALFLOGSTRING("CAlfLayoutSwitchEffectCoordinator::HandleThemeEvent restart timer");
+            iRosterFreezeEndTimer->Cancel();
+            iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000, TCallBack(DoNextLayoutSwitchContext, this));                
+            }
+
+        // If layout switch occurs while theme effect is ongoing in exit phase, restart.
+        if ( iLayoutSwitchEffectContext == AknTransEffect::ELayoutSwitchExit )
+            {
+            __ALFLOGSTRING("CAlfLayoutSwitchEffectCoordinator::HandleThemeEvent restart themefx");
+            TBool oldLayoutSwitchNotCompleted = iLayoutSwitchNotCompleted;
+            iLayoutSwitchNotCompleted = EFalse;
+                
+            Transition( EStateIdle, iCurrentState );
+            Transition( EStateThemeFx, iCurrentState );
+                
+            if (oldLayoutSwitchNotCompleted)
+                {
+                iLayoutSwitchNotCompleted = ETrue;
+                }  
+            }
+        }
     }
 
 // ---------------------------------------------------------
@@ -214,7 +288,7 @@
 void CAlfLayoutSwitchEffectCoordinator::Transition(
         TState aNewState, TState aPreviousState)
     {
-    __ALFLOGSTRING2("CAlfLayoutSwitchEffectCoordinator::Transition from: %d to: %d", aNewState, aPreviousState);
+    __ALFLOGSTRING2("CAlfLayoutSwitchEffectCoordinator::Transition from: %d to: %d", aPreviousState, aNewState);
     iCurrentState = aNewState;
         
     // Undo previous state - don't unfreeze roster.
@@ -269,7 +343,7 @@
                 
             // Remove all other effects
             iBridge.HandleGfxStopEvent( EFalse );
-            iBridge.RemoveAllTemporaryPresenterVisuals();
+            iBridge.CleanAllFxVisuals();
 
             // Set remove freeze timer
             __ALFLOGSTRING("CAlfLayoutSwitchEffectCoordinator::Transition - Freeze timer started");
@@ -299,7 +373,7 @@
             
         // Remove all other effects
         iBridge.HandleGfxStopEvent( EFalse );
-        iBridge.RemoveAllTemporaryPresenterVisuals();
+        iBridge.CleanAllFxVisuals();
             
         // Set first layout switch effect 
         SetLayoutSwitchEffect(AknTransEffect::ELayoutSwitchStart);
@@ -324,6 +398,7 @@
         FreezeRoster(EFalse);
         iBridge.iHuiEnv->Display(0).SetDirty();
         iBridge.SetVisualTreeVisibilityChanged(ETrue);
+        iBridge.AsynchRefresh();
         }
         break;
         }    
@@ -394,9 +469,6 @@
     switch ( aEvent )
         {
     case EEventBlankOn:
-        state = EStateBlankFx;
-        break;
-    
     case EEventLayoutSwitch:    
     case EEventBlankOff:
     case EEventLowMemory:
@@ -424,6 +496,10 @@
             {
             state = EStateThemeFx;
             }
+        else
+            {
+            state = EStateFreezeFx;
+            }
         break;
     
     case EEventBlankOff:
@@ -592,7 +668,8 @@
 // ---------------------------------------------------------
 //
 // todo: rename
-TInt DoNextLayoutSwitchContext(TAny* aLayoutSwitchCoordinator)
+TInt CAlfLayoutSwitchEffectCoordinator::DoNextLayoutSwitchContext(
+        TAny* aLayoutSwitchCoordinator)
     {
     CAlfLayoutSwitchEffectCoordinator* coordinator = (CAlfLayoutSwitchEffectCoordinator*)aLayoutSwitchCoordinator;
     coordinator->AlfGfxEffectEndCallBack(KErrNotFound);
@@ -803,38 +880,52 @@
 
 CFullScreenEffectState::~CFullScreenEffectState()
     {
-    iPaintedRegion.Close();
-    if (iDrawingCompleteTimer)
-        {
-        iDrawingCompleteTimer->Cancel();
-        delete iDrawingCompleteTimer;
-        iDrawingCompleteTimer = NULL;
-        }
     }
 
+void CFullScreenEffectState::ConstructL(const CFullScreenEffectState& aEffectState)
+    {
+    iAction = aEffectState.iAction;
+    iHandle = aEffectState.iHandle;
+    iType = aEffectState.iType;
+    iLongAppStartTimeout = aEffectState.iLongAppStartTimeout;
+    iTimeout = aEffectState.iTimeout;
+    iToWg = aEffectState.iToWg;
+    iFromWg = aEffectState.iFromWg;
+    iToAppId = aEffectState.iToAppId;
+    iFromAppId = aEffectState.iFromAppId;
+
+    iToSecureId = aEffectState.iToSecureId;
+    iFromSecureId = aEffectState.iFromSecureId;
+    
+    iRect.iTl.iX = aEffectState.iRect.iTl.iX;
+    iRect.iTl.iY = aEffectState.iRect.iTl.iY;
+    iRect.iBr.iX = aEffectState.iRect.iBr.iX;
+    iRect.iBr.iY = aEffectState.iRect.iBr.iY;
+    iState = aEffectState.iState;
+    iEffectName = aEffectState.iEffectName->AllocL();
+    iEffectType = aEffectState.iEffectType;
+    iCompletionHandle = aEffectState.iCompletionHandle;
+    iTwoPhaseEffect = CFullScreenEffectState::EOnlyOnePart;
+    }
 
 void CFullScreenEffectState::ConstructL(
         TInt aAction,
         RMemReadStream& aStream)
     {
     iAction = aAction;
-
     iHandle = aStream.ReadInt32L();
-
     iType = aStream.ReadInt32L();
+    iLongAppStartTimeout = aStream.ReadInt32L();
+    iTimeout = aStream.ReadInt32L();
     iToWg = aStream.ReadInt32L();
     iFromWg = aStream.ReadInt32L();
     iToAppId = aStream.ReadInt32L();
     iFromAppId = aStream.ReadInt32L();
 
-    if (iType == AknTransEffect::EParameterType)
-        {
-        iToSecureId = aStream.ReadInt32L();
-        iFromSecureId = aStream.ReadInt32L();
-        /*screen1 =*/aStream.ReadInt32L();
-        /*screen2 =*/aStream.ReadInt32L();
-        }
-    /*TInt flags =*/
+    iToSecureId = aStream.ReadInt32L();
+    iFromSecureId = aStream.ReadInt32L();
+    
+    // TInt flags
     aStream.ReadInt32L();
     iRect.iTl.iX = aStream.ReadInt32L();
     iRect.iTl.iY = aStream.ReadInt32L();
@@ -844,8 +935,29 @@
     ResolveFileNameL(aStream);
 
     iCompletionHandle = iHandle;
+    iTwoPhaseEffect = CFullScreenEffectState::EOnlyOnePart;
     }
 
+void CFullScreenEffectState::SetState(TEffectState aState)
+    {
+    if (aState >= iState)
+        {
+        __ALFFXLOGSTRING2("CFullScreenEffectState::SetState - Set %d -> %d", iState, aState);
+        iState = aState;
+        }
+    else
+        {
+        __ALFFXLOGSTRING2("CFullScreenEffectState::SetState - WARNING! Trying to set to previous state. %d -> %d", iState, aState);
+        }
+    };
+        
+TEffectState CFullScreenEffectState::State()
+    {
+    __ALFFXLOGSTRING1("CFullScreenEffectState::State - %d", iState);
+    return iState;
+    }
+      
+
 void CControlEffectState::ConstructL(TInt aAction,
         RMemReadStream& aStream)
     {
--- a/uiacceltk/hitchcock/ServerCore/Src/alfhierarchymodel.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfhierarchymodel.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -139,7 +139,7 @@
 #ifdef ALF_DEBUG_TRACK_DRAWING 
     delete iCommandDebugger;
 #endif
-    
+    iUpdateRegion.Close();    
 #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
     delete AMT_CONTROL();
     Dll::FreeTls();
@@ -803,14 +803,7 @@
         }
 #endif
 
-    AMT_INC_COUNTER_IF(node && (nodeType==MWsWindowTreeNode::EWinTreeNodeClient), iWindowNodeCount ); 
-    AMT_INC_COUNTER_IF(node && (nodeType==MWsWindowTreeNode::EWinTreeNodeGroup),  iWindowGroupNodeCount ); 
-    AMT_INC_COUNTER_IF(node, iTotalNodeCount );
-    
-    AMT_MAP_INC_VALUE_IF( node && nodeType == MWsWindowTreeNode::EWinTreeNodeClient,
-                          iIntMap, node->iId, EAlfModuleTestTypeHierarchyModelCreateWindow );
-    AMT_MAP_INC_VALUE_IF( node && nodeType == MWsWindowTreeNode::EWinTreeNodeGroup,
-                          iIntMap, node->iId, EAlfModuleTestTypeHierarchyModelCreateWindowGroup );
+    AMT_MAP_NODE_CREATED();
     }
 
 // ---------------------------------------------------------------------------
@@ -841,14 +834,7 @@
         USER_INVARIANT();
         }
 
-    AMT_DEC_COUNTER_IF(node && (nodeType==MWsWindowTreeNode::EWinTreeNodeClient), iWindowNodeCount ); 
-    AMT_DEC_COUNTER_IF(node && (nodeType==MWsWindowTreeNode::EWinTreeNodeGroup),  iWindowGroupNodeCount ); 
-    AMT_DEC_COUNTER_IF(node, iTotalNodeCount );
-    
-    AMT_MAP_INC_VALUE_IF( node && nodeType == MWsWindowTreeNode::EWinTreeNodeClient,
-                          iIntMap, nodeId, EAlfModuleTestTypeHierarchyModelReleaseWindow );
-    AMT_MAP_INC_VALUE_IF( node && nodeType == MWsWindowTreeNode::EWinTreeNodeGroup,
-                          iIntMap, nodeId, EAlfModuleTestTypeHierarchyModelReleaseWindowGroup );
+    AMT_MAP_NODE_RELEASED();
     }
 
 // ---------------------------------------------------------------------------
@@ -868,12 +854,8 @@
         {
         USER_INVARIANT();
         }
-    
-    AMT_INC_COUNTER_IF( node && (nodeType==MWsWindowTreeNode::EWinTreeNodeClient), iWindowNodeActivatedCount );
-    
-    AMT_MAP_SET_VALUE_IF( node && nodeType == MWsWindowTreeNode::EWinTreeNodeClient,
-                          iBoolMap, nodeId, ETrue,
-                          EAlfModuleTestTypeHierarchyModelActiveWindow );    
+
+    AMT_MAP_NODE_ACTIVATED();
     }
 
 // ---------------------------------------------------------------------------
@@ -904,14 +886,7 @@
         }
 #endif
 
-    AMT_INC_COUNTER_IF(node, iNodeExtentChangedCount );
-    AMT_SET_VALUE_IF(node, iLatestNodeExtentRect, rect );
-    AMT_MAP_SET_VALUE_IF( node && node->iWindow,
-                          iSizeMap, node->iWindow->WsInfo().iClientSideId.iWindowIdentifer, 
-                          rect.Size(), EAlfModuleTestTypeHierarchyModelChangeWindowSize );
-    AMT_MAP_SET_VALUE_IF( node && node->iWindow,
-                          iPositionMap, node->iWindow->WsInfo().iClientSideId.iWindowIdentifer, 
-                          rect.iTl, EAlfModuleTestTypeHierarchyModelChangeWindowPosition );
+    AMT_MAP_NODE_EXTENT_CHANGED();
     }
 
 // ---------------------------------------------------------------------------
@@ -972,12 +947,7 @@
         USER_INVARIANT();
         }
 
-    AMT_INC_COUNTER_IF(node, iTotalNodeFlagChangedCount );
-    AMT_MAP_SET_VALUE_IF( node && node->iWindow && MWsWindowTreeObserver::EVisible == flag,
-                          iBoolMap, 
-                          node->iWindow->WsInfo().iClientSideId.iWindowIdentifer,
-                          newValue,
-                          EAlfModuleTestTypeHierarchyModelChangeWindowVisibility ); 
+    AMT_MAP_NODE_FLAG_CHANGED();
     }
 
 // ---------------------------------------------------------------------------
@@ -1034,6 +1004,8 @@
     iStream->ReadInt8L();
     ReadRegionL( iStream, newOpaqueRegion );
     // TODO: Implement actions
+    newTransparentRegion.Close();
+    newOpaqueRegion.Close();
     }
 
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -1317,6 +1317,7 @@
                     (TAny*)offset );
             }
         }
+    AMT_MAP_NODE_SET_ORDINAL_POSITION();
     }
 
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/ServerCore/Src/alfscreen.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfscreen.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -142,7 +142,7 @@
 	CHuiControl* cntrl = new (ELeave) CHuiControl(aHuiEnv);
 	CleanupStack::PushL(cntrl); 
 	cntrl->ConstructL();
-	cntrl->SetRole(EAlfWindowFloatingSpriteContainer);
+	cntrl->SetRole(EHuiWindowFloatingSpriteContainer);
 	iFloatingSpriteControlGroup->AppendL(cntrl);
 	CleanupStack::Pop(cntrl);
 	CHuiCanvasVisual* layout = CHuiCanvasVisual::AddNewL(*cntrl);            
@@ -153,7 +153,7 @@
 	CHuiControl* effectCntrl = new (ELeave) CHuiControl(aHuiEnv);		    
 	CleanupStack::PushL(effectCntrl); 
 	effectCntrl->ConstructL();
-	effectCntrl->SetRole(EAlfFullScreenEffectContainer);
+	effectCntrl->SetRole(EHuiFullScreenEffectContainer);
 	iFullscreenEffectControlGroup->AppendL(effectCntrl);
 	CleanupStack::Pop(effectCntrl);
 	CHuiCanvasVisual* effectLayout = CHuiCanvasVisual::AddNewL(*effectCntrl);            
@@ -169,7 +169,7 @@
     	CHuiControl* fpsCntrl = new (ELeave) CHuiControl(aHuiEnv);	    
 	    CleanupStack::PushL(fpsCntrl);
 	    fpsCntrl->ConstructL();
-	    fpsCntrl->SetRole(EAlfFpsIndicatorContainer);
+	    fpsCntrl->SetRole(EHuiFpsIndicatorContainer);
 	    iFpsControlGroup->AppendL(fpsCntrl);
 	    CleanupStack::Pop(fpsCntrl);
         
--- a/uiacceltk/hitchcock/ServerCore/Src/alfsrvcontrolgroupsubsession.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfsrvcontrolgroupsubsession.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -76,7 +76,7 @@
         
     iHostControl = new (ELeave) CAlfSrvHostControl( *Session().SharedHuiEnv() );
     iHostControl->ConstructL();
-    iHostControl->SetRole(EAlfSessionContainer);
+    iHostControl->SetRole(EHuiSessionContainer);
         
     CHuiLayout* sessionContainer = CHuiDeckLayout::AddNewL( *iHostControl, NULL );
     sessionContainer->SetFlags( EHuiVisualFlagManualLayout );
--- a/uiacceltk/hitchcock/ServerCore/Src/alfstreamerserver.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfstreamerserver.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -32,6 +32,12 @@
 #include <alf/AlfTransEffectPlugin.hrh>
 
 
+// Implements just Error() to avoid panic
+NONSHARABLE_CLASS(CSimpleScheduler) : public CActiveScheduler
+    {
+    void Error( TInt ) const{} // From CActiveScheduler
+    };
+
 // ==================================
 // Launcher implementation.
 // ==================================   
@@ -66,7 +72,7 @@
         thread.Close();
 
         // Set up scheduler and cleanup stack for this thread
-        CActiveScheduler* scheduler = new CActiveScheduler;
+        CActiveScheduler* scheduler = new CSimpleScheduler;
         if (!scheduler)
             {
             return KErrNoMemory;
@@ -228,6 +234,7 @@
     iCompositionTokens.Close();
     iWindowServerSessions.Close();
     iAlfTargets.Close();
+    iOptionalGRAM.Close();
     }
 
 void CAlfStreamerServer::AppendCompositionSessionL(CAlfStreamerServerSession* aSession, TBool aHost)
@@ -403,6 +410,30 @@
     __ALFLOGSTRING("CAlfStreamerServer::ReleasePermissionTokenL: Not Found <<")
     }
 
+void CAlfStreamerServer::FormAQueueL(TInt aOp, TInt aSecureId, TInt aWindowGroup)
+    {
+    __ALFLOGSTRING3("CAlfStreamerServer::FormAQueueL( %d, %d, %d )",aOp, aSecureId, aWindowGroup)
+    if (aOp == EAlfVolunteerForGoomTarget)
+        {
+        TAlfCompParams param = {aSecureId, aSecureId, aWindowGroup, aWindowGroup};
+        if (iOptionalGRAM.Find(param) != KErrNotFound)
+            {
+            __ALFLOGSTRING("CAlfStreamerServer::FormAQueueL: Already added");
+            return;
+            }    
+        User::LeaveIfError(iOptionalGRAM.Append(param));
+        }
+    else
+        {
+        for(TInt i = iOptionalGRAM.Count()-1; i >= 0; i-- )
+            {
+            if ( iOptionalGRAM[i].iWindowGroup == aWindowGroup )
+                {
+                iOptionalGRAM.Remove(i);
+                }       
+            }    
+        }    
+    }
 void CAlfStreamerServer::QueueRequestSessionsL(TInt aAlfToken, const TPtrC8& aPtr, TInt aOp)
     {
     __ALFLOGSTRING("CAlfStreamerServer::QueueRequestSessionsL >>")
@@ -670,12 +701,29 @@
         }
     }
     
-void CAlfStreamerServer::GetListOfWGsHavingInactiveSurfacesL(const RMessage2& aMessage, TBool aActiveAlso)
+void CAlfStreamerServer::GetListOfWGsHavingInactiveSurfacesL(const RMessage2& aMessage, TInt aActiveAlso)
     {
-    RArray<TAlfCompParams>& arrayRef = aActiveAlso?iAlfTargets:iInactiveSurfaces;
+    TBool optionalOnly(aActiveAlso==EAlfVolunteersForCommonGood);  // to lessen ambiquity..
         
+    RArray<TAlfCompParams>* arrayPtr = 0;
+    switch (aActiveAlso)
+        {
+        case EAlfInactiveWgs:
+            arrayPtr = &iInactiveSurfaces;
+            break;
+        case EAlfAllWgsWithSurface:
+            arrayPtr = &iAlfTargets;
+            break;
+        case EAlfVolunteersForCommonGood:
+        default:
+            arrayPtr = &iOptionalGRAM;      
+            break;
+        }
+    
+    RArray<TAlfCompParams>& arrayRef =  *arrayPtr; // :)
+            
     TInt count = arrayRef.Count();    
-   __ALFLOGSTRING1("CAlfStreamerServer::GetListOfWGsHavingInactiveSurfacesL >> count %d", count)
+    __ALFLOGSTRING1("CAlfStreamerServer::GetListOfWGsHavingInactiveSurfacesL >> count %d", count);
     if ( count == 0)
         {
         aMessage.Complete(KErrNotFound);
@@ -683,20 +731,29 @@
         }
                 
     TInt maxLength = aMessage.GetDesMaxLength(0);
-    TInt* array = new (ELeave) TInt [maxLength/4];
+    TInt* arrayStart = new (ELeave) TInt [maxLength/4];
+    TInt* array = arrayStart;
+	
+    TInt payloadSize = optionalOnly?8:4; // what a waste
+    count = Min(maxLength/payloadSize-1, count);
     
-    count = Min(maxLength/4-1, count);
     for ( TInt i = 0; i<count; i++ ) 
         {
         __ALFLOGSTRING1("CAlfStreamerServer::GetListOfWGsHavingInactiveSurfacesL adding %d", arrayRef[i].iWindowGroup);
-        array[i] = arrayRef[i].iWindowGroup;
+        *array = arrayRef[i].iWindowGroup;
+        array++;
+        if (optionalOnly)
+            {           
+            *array = arrayRef[i].iSecureId;
+            array++;
+            }
         }
         
-    array[count] = 0;
+    *array = 0;
         
-    TPtr8 ptr((TUint8*)array,maxLength,maxLength);
+    TPtr8 ptr((TUint8*)arrayStart,maxLength,maxLength);
     aMessage.WriteL(0, ptr);
-    delete[] array;
+    delete[] arrayStart;
     aMessage.Complete(KErrNone);
    __ALFLOGSTRING("CAlfStreamerServer::GetListOfWGsHavingInactiveSurfacesL <<")
     }
@@ -988,6 +1045,14 @@
             server->Bridge()->AddData( EAlfDSSetDistractionWindow, windowGroupId, windowHandle, (TAny*)state );
             break;
             }
+        case EAlfVolunteerForGoomTarget:  
+        case EAlfExcludeFromGoomTargets:
+            { // all these volunteers, just get into a line..
+            server->FormAQueueL(op, aMessage.Int0(), aMessage.Int1());    
+            break;    
+            }            
+            
+            
         default:
             {
             aMessage.Complete(KErrNotSupported);
--- a/uiacceltk/hitchcock/ServerCore/Src/alfvisualhandlers.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfvisualhandlers.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -46,6 +46,9 @@
 #include "alfsrvsubsessionbase.h"
 #include "alfsrvtransformationsubsession.h"
 
+#define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
+#include "alfmoduletest.h" 
+
 #ifdef RD_ALF_IN_PLATFORM
 #include <aknlayout2hierarchy.h>
 #endif
@@ -768,8 +771,16 @@
             CHuiFxEngine* engine = iVisual->Env().EffectsEngine();
             if (engine)
                 {
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+                TTime time;
+                time.UniversalTime();
+                AMT_ADD_TIME(params->iHandle, time.Int64(), ETrue);
+#endif  
                 CHuiFxEffect* effect = NULL;
-                engine->LoadEffectL( params->iFileName, effect, iVisual->Effectable(), NULL , NULL, params->iHandle, KHuiFxDelayRunUntilFirstFrameHasBeenDrawn );
+                // Note: alf effects do not support taking screenshot 
+				// Note: alf effects do not support freezing.
+				engine->LoadEffectL( params->iFileName, effect, iVisual->Effectable(), NULL , NULL, params->iHandle, KHuiFxDelayRunUntilFirstFrameHasBeenDrawn );
+	            iVisual->SetFreezeState(EFalse); 
                 // The effect will be automatically set to the visual if parsing succeeds
                 }
             break;
@@ -781,11 +792,19 @@
             CHuiFxEngine* engine = iVisual->Env().EffectsEngine();
             if (engine)
                 {
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+                TTime time;
+                time.UniversalTime();
+                AMT_ADD_TIME(params->iHandle, time.Int64(), ETrue);
+#endif  
                 CHuiFxEffect* effect = NULL;
                 // this will add the group, if it does not exist already
                 // Begin and End group events are supposed to come through GfxTransEffect API.
                 engine->BeginGroupEffect(groupHandle);
+                // Note: alf effects do not support taking screenshot 
+				// Note: alf effects do not support freezing.
                 engine->LoadGroupEffectL( params->iFileName, effect, iVisual->Effectable(),groupHandle, NULL, NULL, params->iHandle, KHuiFxDelayRunUntilFirstFrameHasBeenDrawn );
+	            iVisual->SetFreezeState(EFalse);
                 // The effect will be automatically set to the visual if parsing succeeds
                 }
             break;
@@ -793,6 +812,7 @@
         case EAlfVisualRemoveEffect:
             {
             iVisual->SetEffect(NULL);
+            iVisual->SetFreezeState(EFalse); // Note: alf effects do not support freezing.
             break;
             }
 
--- a/uiacceltk/hitchcock/ServerCore/Src/alfwindowmanager.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfwindowmanager.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -74,8 +74,6 @@
     RPointerArray<CAlfWindow> iWindows;
     RArray<TPluginInfo> iPlugins;
     CAlfHierarchyModel* iTree;
-    
-    RPointerArray<CAlfWindow> iChangedWindows;    
     };
 
 // ---------------------------------------------------------------------------
@@ -440,10 +438,6 @@
 //
 void CAlfWindowManager::ContentReady(CAlfWindow& aWindow, CAlfWindowBuffer* aOutBuffer)
     {
-    //ASSERT(iData->iChangedWindows.Find(&aWindow) == KErrNotFound); // no plugin should produce more frames
-                                                            // than actually bound to scene
-    iData->iChangedWindows.Append(&aWindow);
-
     if(!aWindow.IsInsertedToScene())
     	{
     	TRAPD( err, BindWindowToHitchL(&aWindow, this) );
@@ -648,7 +642,6 @@
 //   
 void CAlfWindowManager::PrepareNewFrame(TUint aEstimatedInterval)
     {
-    iData->iChangedWindows.Reset();
     for (TInt i = iData->iPlugins.Count()-1; i >= 0 ; i--)
         {
         TRAP_IGNORE(iData->iPlugins[i].iPlugin->PrepareFrameL(aEstimatedInterval));
--- a/uiacceltk/hitchcock/ServerInterface/src/alfdocument.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/ServerInterface/src/alfdocument.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -42,7 +42,8 @@
 //
 CEikAppUi* CAlfDocument::CreateAppUiL()
     {
-    return new (ELeave) CAlfAppUi;
+    User::Leave(KErrNotSupported);    
+    return 0;
     }
 
 
--- a/uiacceltk/hitchcock/backgroundanim/inc/sensor.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/backgroundanim/inc/sensor.h	Thu Jul 22 16:43:39 2010 +0100
@@ -1,20 +1,3 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
-
 #ifndef __SENSOR_H__
 #define __SENSOR_H__
 
--- a/uiacceltk/hitchcock/backgroundanim/src/sensor.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/backgroundanim/src/sensor.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -1,20 +1,3 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
-
 #include <sensrvaccelerometersensor.h>
 
 #include "sensor.h"
--- a/uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF	Thu Jul 22 16:43:39 2010 +0100
@@ -1391,12 +1391,12 @@
 	?RegisterParameterL@CHuiFxVisualLayer@@IAEXABVTDesC16@@PAM@Z @ 1390 NONAME ; void CHuiFxVisualLayer::RegisterParameterL(class TDesC16 const &, float *)
 	?NewL@CHuiFxEffect@@SAPAV1@AAVCHuiFxEngine@@@Z @ 1391 NONAME ; class CHuiFxEffect * CHuiFxEffect::NewL(class CHuiFxEngine &)
 	?ConstructL@CHuiFxVisualLayer@@IAEXPAVMHuiEffectable@@@Z @ 1392 NONAME ; void CHuiFxVisualLayer::ConstructL(class MHuiEffectable *)
-	?Draw@CHuiFxEffect@@QAEHAAVCHuiGc@@ABVTRect@@@Z @ 1393 NONAME ; int CHuiFxEffect::Draw(class CHuiGc &, class TRect const &)
+	?Draw@CHuiFxEffect@@QAEHAAVCHuiGc@@ABVTRect@@H@Z @ 1393 NONAME ; int CHuiFxEffect::Draw(class CHuiGc &, class TRect const &)
 	?TargetRect@CHuiFxLayer@@QBEABVTRect@@XZ @ 1394 NONAME ; class TRect const & CHuiFxLayer::TargetRect(void) const
 	?AdvanceTime@CHuiFxVisualLayer@@UAEXM@Z @ 1395 NONAME ; void CHuiFxVisualLayer::AdvanceTime(float)
 	?Filter@CHuiFxFilterLayer@@QBEAAVCHuiFxFilter@@XZ @ 1396 NONAME ; class CHuiFxFilter & CHuiFxFilterLayer::Filter(void) const
 	?IsFreeForm@CHuiFxFilter@@QBEHXZ @ 1397 NONAME ; int CHuiFxFilter::IsFreeForm(void) const
-	?Draw@CHuiFxFilterLayer@@UAEXAAVCHuiFxEngine@@AAVCHuiGc@@AAVCHuiFxRenderbuffer@@2@Z @ 1398 NONAME ; void CHuiFxFilterLayer::Draw(class CHuiFxEngine &, class CHuiGc &, class CHuiFxRenderbuffer &, class CHuiFxRenderbuffer &)
+	?Draw@CHuiFxFilterLayer@@UAEXAAVCHuiFxEngine@@AAVCHuiGc@@AAVCHuiFxRenderbuffer@@2H@Z @ 1398 NONAME ; void CHuiFxFilterLayer::Draw(class CHuiFxEngine &, class CHuiGc &, class CHuiFxRenderbuffer &, class CHuiFxRenderbuffer &)
 	?SetSourceRect@CHuiFxLayer@@QAEXABVTRect@@@Z @ 1399 NONAME ; void CHuiFxLayer::SetSourceRect(class TRect const &)
 	??1CHuiFxRenderbuffer@@UAE@XZ @ 1400 NONAME ; CHuiFxRenderbuffer::~CHuiFxRenderbuffer(void)
 	?SetBlendingMode@CHuiFxLayer@@QAEXW4THuiFxBlendingMode@@@Z @ 1401 NONAME ; void CHuiFxLayer::SetBlendingMode(enum THuiFxBlendingMode)
@@ -1416,7 +1416,7 @@
 	?Changed@CHuiFxFilterLayer@@UBEHXZ @ 1415 NONAME ; int CHuiFxFilterLayer::Changed(void) const
 	?AddLayerL@CHuiFxEffect@@QAEXPBVCHuiFxLayer@@@Z @ 1416 NONAME ; void CHuiFxEffect::AddLayerL(class CHuiFxLayer const *)
 	?EffectsEngine@CHuiEnv@@QBEPAVCHuiFxEngine@@XZ @ 1417 NONAME ; class CHuiFxEngine * CHuiEnv::EffectsEngine(void) const
-	?Draw@CHuiFxGroupLayer@@UAEXAAVCHuiFxEngine@@AAVCHuiGc@@AAVCHuiFxRenderbuffer@@2@Z @ 1418 NONAME ; void CHuiFxGroupLayer::Draw(class CHuiFxEngine &, class CHuiGc &, class CHuiFxRenderbuffer &, class CHuiFxRenderbuffer &)
+	?Draw@CHuiFxGroupLayer@@UAEXAAVCHuiFxEngine@@AAVCHuiGc@@AAVCHuiFxRenderbuffer@@2H@Z @ 1418 NONAME ; void CHuiFxGroupLayer::Draw(class CHuiFxEngine &, class CHuiGc &, class CHuiFxRenderbuffer &, class CHuiFxRenderbuffer &)
 	??0CHuiFxRenderbuffer@@IAE@XZ @ 1419 NONAME ; CHuiFxRenderbuffer::CHuiFxRenderbuffer(void)
 	?AddEffectL@CHuiFxEngine@@IAEXPAVCHuiFxEffect@@@Z @ 1420 NONAME ; void CHuiFxEngine::AddEffectL(class CHuiFxEffect *)
 	?Engine@CHuiFxEffect@@QBEAAVCHuiFxEngine@@XZ @ 1421 NONAME ; class CHuiFxEngine & CHuiFxEffect::Engine(void) const
@@ -1460,7 +1460,7 @@
 	?SetEffect@CHuiVisual@@QAEXPAVCHuiFxEffect@@@Z @ 1459 NONAME ; void CHuiVisual::SetEffect(class CHuiFxEffect *)
 	?SetMargin@CHuiFxFilter@@QAEXABVTSize@@@Z @ 1460 NONAME ; void CHuiFxFilter::SetMargin(class TSize const &)
 	?PrepareDrawL@CHuiFxFilterLayer@@UAEHAAVCHuiFxEngine@@@Z @ 1461 NONAME ; int CHuiFxFilterLayer::PrepareDrawL(class CHuiFxEngine &)
-	?Draw@CHuiFxVisualLayer@@UAEXAAVCHuiFxEngine@@AAVCHuiGc@@AAVCHuiFxRenderbuffer@@2@Z @ 1462 NONAME ; void CHuiFxVisualLayer::Draw(class CHuiFxEngine &, class CHuiGc &, class CHuiFxRenderbuffer &, class CHuiFxRenderbuffer &)
+	?Draw@CHuiFxVisualLayer@@UAEXAAVCHuiFxEngine@@AAVCHuiGc@@AAVCHuiFxRenderbuffer@@2H@Z @ 1462 NONAME ; void CHuiFxVisualLayer::Draw(class CHuiFxEngine &, class CHuiGc &, class CHuiFxRenderbuffer &, class CHuiFxRenderbuffer &)
 	?SkinInstance@CHuiStatic@@SAPAVMAknsSkinInstance@@XZ @ 1463 NONAME ; class MAknsSkinInstance * CHuiStatic::SkinInstance(void)
 	?SetTrackCommandSet@CHuiCanvasVisual@@QAEXAAV?$TBuf@$0BAA@@@H@Z @ 1464 NONAME ; void CHuiCanvasVisual::SetTrackCommandSet(class TBuf<256> &, int)
 	?PopTransformationMatrix@CHuiCanvasGc@@UAEXXZ @ 1465 NONAME ; void CHuiCanvasGc::PopTransformationMatrix(void)
@@ -1598,4 +1598,9 @@
 	?AddEffectToGroup@CHuiFxEngine@@QAEHH@Z @ 1597 NONAME ; int CHuiFxEngine::AddEffectToGroup(int)
 	?FxmlUsesOpaqueHint@CHuiFxEngine@@QAEHABVTDesC16@@@Z @ 1598 NONAME ; int CHuiFxEngine::FxmlUsesOpaqueHint(class TDesC16 const &)
 	?InitializeL@CHuiCanvasRenderBuffer@@UAEXABVTSize@@H@Z @ 1599 NONAME ; void CHuiCanvasRenderBuffer::InitializeL(class TSize const &, int)
+	?Clear@CAppIconCache@@QAEXXZ @ 1600 NONAME ; void CAppIconCache::Clear(void)
+	?Insert@CAppIconCache@@QAEHAAUTRasterizedBitmap@@@Z @ 1601 NONAME ; int CAppIconCache::Insert(struct TRasterizedBitmap &)
+	?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)	
 
--- a/uiacceltk/hitchcock/coretoolkit/eabi/hitchcocku.DEF	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/eabi/hitchcocku.DEF	Thu Jul 22 16:43:39 2010 +0100
@@ -1733,7 +1733,7 @@
 	_ZN12CHuiFxEffect10ConstructLEv @ 1732 NONAME
 	_ZN12CHuiFxEffect11AdvanceTimeEf @ 1733 NONAME
 	_ZN12CHuiFxEffect20SetEffectEndObserverEP21MAlfGfxEffectObserveri @ 1734 NONAME
-	_ZN12CHuiFxEffect4DrawER6CHuiGcRK5TRect @ 1735 NONAME
+	_ZN12CHuiFxEffect4DrawER6CHuiGcRK5TRecti @ 1735 NONAME
 	_ZN12CHuiFxEffect4NewLER12CHuiFxEngine @ 1736 NONAME
 	_ZN12CHuiFxEffect7ChangedEv @ 1737 NONAME
 	_ZN12CHuiFxEffect9AddLayerLEPK11CHuiFxLayer @ 1738 NONAME
@@ -1773,7 +1773,7 @@
 	_ZN16CHuiFxGroupLayer10VisualAreaER5TRect @ 1772 NONAME
 	_ZN16CHuiFxGroupLayer11AdvanceTimeEf @ 1773 NONAME
 	_ZN16CHuiFxGroupLayer12PrepareDrawLER12CHuiFxEngine @ 1774 NONAME
-	_ZN16CHuiFxGroupLayer4DrawER12CHuiFxEngineR6CHuiGcR18CHuiFxRenderbufferS5_ @ 1775 NONAME
+	_ZN16CHuiFxGroupLayer4DrawER12CHuiFxEngineR6CHuiGcR18CHuiFxRenderbufferS5_i @ 1775 NONAME
 	_ZN16CHuiFxGroupLayer4NewLEi @ 1776 NONAME
 	_ZN16CHuiFxGroupLayer9AddLayerLEPK11CHuiFxLayer @ 1777 NONAME
 	_ZN16CHuiFxGroupLayerC1Ev @ 1778 NONAME
@@ -1784,14 +1784,14 @@
 	_ZN17CHuiFxFilterLayer10ConstructLEP12CHuiFxFilter @ 1783 NONAME
 	_ZN17CHuiFxFilterLayer11AdvanceTimeEf @ 1784 NONAME
 	_ZN17CHuiFxFilterLayer12PrepareDrawLER12CHuiFxEngine @ 1785 NONAME
-	_ZN17CHuiFxFilterLayer4DrawER12CHuiFxEngineR6CHuiGcR18CHuiFxRenderbufferS5_ @ 1786 NONAME
+	_ZN17CHuiFxFilterLayer4DrawER12CHuiFxEngineR6CHuiGcR18CHuiFxRenderbufferS5_i @ 1786 NONAME
 	_ZN17CHuiFxVisualLayer10ConstructLEP14MHuiEffectable @ 1787 NONAME
 	_ZN17CHuiFxVisualLayer10VisualAreaER5TRect @ 1788 NONAME
 	_ZN17CHuiFxVisualLayer11AdvanceTimeEf @ 1789 NONAME
 	_ZN17CHuiFxVisualLayer12PrepareDrawLER12CHuiFxEngine @ 1790 NONAME
 	_ZN17CHuiFxVisualLayer18RegisterParameterLERK7TDesC16P4TRgb @ 1791 NONAME
 	_ZN17CHuiFxVisualLayer18RegisterParameterLERK7TDesC16Pf @ 1792 NONAME
-	_ZN17CHuiFxVisualLayer4DrawER12CHuiFxEngineR6CHuiGcR18CHuiFxRenderbufferS5_ @ 1793 NONAME
+	_ZN17CHuiFxVisualLayer4DrawER12CHuiFxEngineR6CHuiGcR18CHuiFxRenderbufferS5_i @ 1793 NONAME
 	_ZN17CHuiFxVisualLayer4NewLEP14MHuiEffectable @ 1794 NONAME
 	_ZN17CHuiFxVisualLayer9ParameterERK7TDesC16 @ 1795 NONAME
 	_ZN17CHuiFxVisualLayerD0Ev @ 1796 NONAME
@@ -1999,4 +1999,9 @@
 	_ZN12CHuiFxEngine16AddEffectToGroupEi @ 1998 NONAME
 	_ZN12CHuiFxEngine18FxmlUsesOpaqueHintERK7TDesC16 @ 1999 NONAME
 	_ZN22CHuiCanvasRenderBuffer11InitializeLERK5TSizei @ 2000 NONAME
+	_ZN13CAppIconCache4FindEx5TSize @ 2001 NONAME
+	_ZN13CAppIconCache5ClearEv @ 2002 NONAME
+	_ZN13CAppIconCache6InsertER17TRasterizedBitmap @ 2003 NONAME
+	_ZNK7CHuiEnv12AppIconCacheEv @ 2004 NONAME
+	_ZN11CHuiDisplay24SetSkinSizeChangePendingEv @ 2005 NONAME
 
--- a/uiacceltk/hitchcock/coretoolkit/group/huitk_base.mmp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/group/huitk_base.mmp	Thu Jul 22 16:43:39 2010 +0100
@@ -76,6 +76,8 @@
 SOURCE          HuiImageLoaderUtil.cpp
 SOURCE          huifixmath.cpp
 
+SOURCE		appiconcache.cpp
+
 // Toolkit Core
 SOURCE          HuiTimedValue.cpp
 SOURCE          HuiTimedPoint.cpp
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffect.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffect.h	Thu Jul 22 16:43:39 2010 +0100
@@ -102,7 +102,7 @@
     IMPORT_C static CHuiFxEffect* NewL(CHuiFxEngine& aEngine);
     IMPORT_C void AddLayerL(const CHuiFxLayer* aLayer); // takes ownership
     IMPORT_C void AdvanceTime(TReal32 aElapsedTime);
-    IMPORT_C TBool Draw(CHuiGc& aGc, const TRect& aDisplayRect);
+    IMPORT_C TBool Draw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aHasSurface);
     IMPORT_C CHuiFxEngine& Engine() const;
     IMPORT_C TBool VisualArea(TRect& aRect) const;
     IMPORT_C TBool Changed();
@@ -168,7 +168,7 @@
      *                   
      *  @return ETrue if drawing was done, otherwise EFalse   
      */
-    TBool CachedDraw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aRefreshCachedRenderTarget, TBool aOpaque, const TRegion& aClipRegion, TInt aAlpha = 255);
+    TBool CachedDraw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aRefreshCachedRenderTarget, TBool aOpaque, const TRegion& aClipRegion, TBool aHasSurface, TInt aAlpha = 255);
     TBool CachedDraw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aRefreshCachedRenderTarget, TBool aOpaque);
 
     void FxmlVisualInputs(RArray<THuiFxVisualSrcType> &aArray);
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxFilter.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxFilter.h	Thu Jul 22 16:43:39 2010 +0100
@@ -34,7 +34,7 @@
     IMPORT_C virtual ~CHuiFxFilter();
     IMPORT_C virtual TBool PrepareDrawL(CHuiFxEngine& aEngine);
     IMPORT_C virtual TBool Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource,
-                               const TRect& aTargetRect, const TRect& aSourceRect) = 0;
+                               const TRect& aTargetRect, const TRect& aSourceRect, TBool aHasSurface) = 0;
     // CalculateMargin will be called before PrepareDrawL(), so 
     // parameters are not ready, so margin calculation need to use 
     // either previous frame parameter values, or should be independent 
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxFilterLayer.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxFilterLayer.h	Thu Jul 22 16:43:39 2010 +0100
@@ -31,7 +31,7 @@
     IMPORT_C ~CHuiFxFilterLayer();
     IMPORT_C static CHuiFxFilterLayer* NewL(CHuiFxFilter* aFilter); // takes ownership
     IMPORT_C TBool PrepareDrawL(CHuiFxEngine& aEngine);
-    IMPORT_C void Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource);
+    IMPORT_C void Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource, TBool aHasSurface);
     IMPORT_C CHuiFxFilter& Filter() const;
     IMPORT_C TBool Changed() const;
     IMPORT_C void AdvanceTime(TReal32 aElapsedTime);
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h	Thu Jul 22 16:43:39 2010 +0100
@@ -28,7 +28,7 @@
     IMPORT_C ~CHuiFxGroupLayer();
     IMPORT_C static CHuiFxGroupLayer* NewL(TBool aIsRoot = EFalse);
     IMPORT_C TBool PrepareDrawL(CHuiFxEngine& aEngine);
-    IMPORT_C void Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource);
+    IMPORT_C void Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource, TBool aHasSurface);
     IMPORT_C void AddLayerL(const CHuiFxLayer* aLayer); // takes ownership
     IMPORT_C void AdvanceTime(TReal32 aElapsedTime);
     IMPORT_C TBool Changed() const;
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxLayer.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxLayer.h	Thu Jul 22 16:43:39 2010 +0100
@@ -32,7 +32,7 @@
     IMPORT_C virtual ~CHuiFxLayer();
 
     IMPORT_C virtual TBool PrepareDrawL(CHuiFxEngine& aEngine);
-    virtual void Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource) = 0;
+    virtual void Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource, TBool aHasSurface) = 0;
     IMPORT_C virtual TBool VisualArea(TRect& aRect);
     IMPORT_C virtual TBool Margin( TMargins &m );
     IMPORT_C virtual void AdvanceTime(TReal32 aElapsedTime);
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxVisualLayer.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxVisualLayer.h	Thu Jul 22 16:43:39 2010 +0100
@@ -32,7 +32,7 @@
     IMPORT_C static CHuiFxVisualLayer* NewL(MHuiEffectable* aVisual); // param mandatory
     IMPORT_C ~CHuiFxVisualLayer();
     IMPORT_C TBool PrepareDrawL(CHuiFxEngine& aEngine);
-    IMPORT_C void Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource);
+    IMPORT_C void Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource, TBool aHasSurface);
     IMPORT_C TBool VisualArea( TRect& aRect );
     IMPORT_C void AdvanceTime(TReal32 aElapsedTime);
     IMPORT_C TBool Changed() const;
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiRosterImpl.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiRosterImpl.h	Thu Jul 22 16:43:39 2010 +0100
@@ -336,6 +336,12 @@
     // From MHuiMemoryLevelObserver
     void SetMemoryLevel(THuiMemoryLevel aLevel);
     
+	// For handling native ALF applications drawing 
+    void SetAlfEventWindow(CHuiVisual* aVisual);
+    const CHuiVisual* AlfEventWindow();
+    TBool NativeAppsContentChanged();
+    void DrawNativeAppsContent( CHuiGc &aGc, CHuiDisplay* aDisplay) const;
+    
 protected:
 
     /* Methods. */
@@ -512,6 +518,10 @@
 	
 	TBool iRosterIsFrozen;
 	TBool iMonitorMemoryLevel;
+	
+	/* not owned */
+	CHuiVisual* iAlfEventWindowVisual;
+	TBool iPreviousAlfContentDrawn;
 	};
 
 #endif  // __HUIROSTERIMPL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/coretoolkit/inc/appiconcache.h	Thu Jul 22 16:43:39 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef __APPICONCACHE_H__
+#define __APPICONCACHE_H__
+
+#include <e32base.h>
+#include <e32cmn.h>
+#include <fbs.h>
+
+NONSHARABLE_STRUCT(TRasterizedBitmap)
+    {
+    TRasterizedBitmap(TInt64 aBitmapSerial, CFbsBitmap* aBitmap) : iBitmapSerial(aBitmapSerial), iBitmap(aBitmap)
+        {
+        }
+    TRasterizedBitmap() : iBitmapSerial(0), iBitmap(NULL) {}
+    TInt64 iBitmapSerial;
+    CFbsBitmap* iBitmap;
+    };
+
+
+NONSHARABLE_CLASS(CAppIconCache) : public CBase
+    {
+    public:
+        static CAppIconCache* NewL(TInt aCacheLimit);
+        virtual ~CAppIconCache();
+        
+        IMPORT_C CFbsBitmap* Find(TInt64 aSerialNumber, TSize aSize);
+        IMPORT_C TInt Insert(TRasterizedBitmap& aBitmap);
+        IMPORT_C void Clear();
+        
+    protected:
+        CAppIconCache(TInt aCacheLimit);
+        void ConstructL();
+    
+    private:
+        RArray<TRasterizedBitmap> iCache;
+        TInt iCacheLimit;
+    };
+
+
+
+#endif
--- a/uiacceltk/hitchcock/coretoolkit/inc/huicanvasdebugwsgc.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huicanvasdebugwsgc.h	Thu Jul 22 16:43:39 2010 +0100
@@ -116,6 +116,8 @@
 
     // Canvas functionality
     virtual void BeginActionL(TInt aAction, TRect aDisplayRect,const CHuiCanvasVisual& aUser, TBool aIsCachePrepared, const TRegion& aUpdateRegion);
+    virtual void EnableUpdateRegion(const TRegion& aUpdateRegion, TBool aClear);
+    virtual void DisableUpdateRegion();
     virtual void EndActionL(const TRegion& aUpdateRegion, TBool aUpdateDisplay);
     virtual TInt SetCapturingBufferL(CFbsBitmap* aTarget);
     virtual CHuiCanvasGc& CanvasGc() const;     
@@ -131,13 +133,14 @@
     
     virtual THuiCanvasWsGcType Type() const;
     
-    virtual void EnableUpdateRegion(const TRegion& aUpdateRegion, TBool aClear);
-    virtual void DisableUpdateRegion();
+    virtual void ClearCapturingBufferArea(const TRect& aRect);
     
   ~CHuiCanvasDebugWsGc();
   
   static CHuiCanvasDebugWsGc* NewL( CHuiCanvasWsGc* aHuiCanvasGc, CAlfCommandDebug& aCommandDebugger ); 
   
+  void SetInternalGc(CHuiCanvasWsGc* aHuiCanvasGc);
+  
 private:
     
     CHuiCanvasDebugWsGc( CAlfCommandDebug& aCommandDebugger );
@@ -146,8 +149,8 @@
   
   	private:
   	    
-  	CHuiCanvasWsGc* iCanvasWsGc;
-  	CAlfCommandDebug& iCommandDebugger;
+  	CHuiCanvasWsGc* iCanvasWsGc; // not owned
+  	CAlfCommandDebug& iCommandDebugger; // not owned
     };
     
 #endif  // __HUICANVASDEBUGWSGC_H__
--- a/uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h	Thu Jul 22 16:43:39 2010 +0100
@@ -36,6 +36,10 @@
 class CHuiCanvasWsHwGc;
 class CAlfCommandDebug;
 class CHuiCanvasWsBitGc;
+#ifdef HUI_DEBUG_TRACK_DRAWING
+class CHuiCanvasDebugWsGc;
+#endif
+    
 
 /**
  * This class is used internally by the toolkit and thus should
@@ -186,6 +190,7 @@
     void DoHandleBufferL(TInt aIndex, TRect& aDisplayRect, TInt aAction, const CHuiCanvasVisual& aUser, CHuiGc* aGc, TPoint& aPos); 
     void DoHandleBufferStringL(TInt aIndex, TRect& aDisplayRect, TInt aAction, const CHuiCanvasVisual& aUser, CHuiGc* aGc, TPoint& aPos, TPtr8 aCommandBuffer, CHuiCanvasCommandBuffer *aBuffer);
 
+    void DoPeekBufferAndUpdateShapeRegionL();
     void DoPeekBufferL(TInt aIndex);     
     void DoDigestPaddingL();
 
@@ -284,6 +289,9 @@
     
     virtual void ClearCapturingBufferArea(const TRect& aRect);
     
+    void ApplyShapeRegion();
+    void TranslateShapeRegion(const TPoint& aNewOrigin);
+    
 private:
     
     /** Region which this painter updates with current command buffers */
@@ -314,6 +322,8 @@
     TBool iAutomaticRenderBufferUsage;
     
     /** Flags to tell whether the window shape region has been changed  */
+    TBool iShapeRegionAvailable;
+    TPoint iShapeRegionOrigin;
     TBool iShapeRegionClearingPending;
     TBool iShapeRegionClippingPending;
     
@@ -385,11 +395,11 @@
     mutable RRegionBuf<KHuiCanvasWsPainterRegionGranularity> iTempIntersectingRegion;
 
 #ifdef HUI_DEBUG_TRACK_DRAWING
-    CAlfCommandDebug* iCommandDebugger;
+    CHuiCanvasDebugWsGc* iCanvasDebugWsGc; 
 #endif
     
     // Boolean flag indicating if render buffer ought to be used.
     TBool iEnableRenderBuffer;
-  };
+    };
     
 #endif  // __HUICANVASWSPAINTER_H__
--- a/uiacceltk/hitchcock/coretoolkit/inc/huistatictlsdata.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huistatictlsdata.h	Thu Jul 22 16:43:39 2010 +0100
@@ -35,6 +35,12 @@
 
 class TFakeProbe;
 class CAppFwProxy;
+#ifdef HUI_DEBUG_TRACK_DRAWING
+class CAlfCommandDebug;   
+ #ifndef __WINSCW__
+extern TTlsData globalWriteableData;
+ #endif
+#endif
 /**
  * Thread local storage space. Writable static data is not supported in
  * Symbian, so static data is stored in this struct.
@@ -123,6 +129,10 @@
     CAlfModuleTestDataControl* iAlfModuleTestDataControl;
 #endif
 
+#ifdef HUI_DEBUG_TRACK_DRAWING
+    CAlfCommandDebug* iCommandDebugger;   
+#endif
+
     CWsScreenDevice* WsScreenDevice(TInt aScreenNumber)
         {
         if (aScreenNumber < iScreenDevices.Count())
@@ -232,6 +242,20 @@
         iAlfModuleTestDataControl = NULL;
 #endif        
         }
+
+#ifdef HUI_DEBUG_TRACK_DRAWING
+    static CAlfCommandDebug* CommandDebugger() 
+        {
+        #ifndef __WINSCW__
+        TTlsData* data = &globalWriteableData;
+        #else
+        TTlsData* data = static_cast<TTlsData*>(Dll::Tls());
+        #endif
+
+        return data->iCommandDebugger;
+        }   
+#endif
+    
     };
 
 
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/group/huirendervg10.mmp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/group/huirendervg10.mmp	Thu Jul 22 16:43:39 2010 +0100
@@ -48,6 +48,7 @@
 
 USERINCLUDE     ../../inc
 USERINCLUDE     ../inc
+USERINCLUDE     ../../../CommonInc
 
 //Added as part of break team support changes.
 #include "../../../../../group/stdinc.mmh"
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10BevelFilter.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10BevelFilter.h	Thu Jul 22 16:43:39 2010 +0100
@@ -29,7 +29,7 @@
     CHuiFxVg10BevelFilter *CloneL() const;
 protected:
     void ConstructL();
-    void DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight);
+    void DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight, TBool aHasSurface);
 private:
     TReal32             iOutlineX;
     TReal32             iOutlineY;
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10BlurFilter.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10BlurFilter.h	Thu Jul 22 16:43:39 2010 +0100
@@ -28,9 +28,9 @@
     static CHuiFxVg10BlurFilter* NewL();
     TBool Draw(CHuiFxEngine& aEngine, CHuiGc& aGc,
             CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource,
-            const TRect& aTargetRect, const TRect& aSourceRect);
+            const TRect& aTargetRect, const TRect& aSourceRect, TBool aHasSurface);
 
-    void DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight);
+    void DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight, TBool aHasSurface);
     void CalculateMargin(TMargins &aMargin) const;  
     CHuiFxVg10BlurFilter *CloneL() const;
 protected:
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10ColorMatrixFilterBase.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10ColorMatrixFilterBase.h	Thu Jul 22 16:43:39 2010 +0100
@@ -29,7 +29,7 @@
     static CHuiFxVg10ColorMatrixFilterBase* NewL();
 protected:
     void ConstructL();
-    void DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight);
+    void DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight, TBool aHasSurface);
     virtual void UpdateColorMatrix();
     void CopyFromL(const CHuiFxVg10ColorMatrixFilterBase *aOldFilter);
     CHuiFxVg10ColorMatrixFilterBase *CloneL() const;
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10FilterBase.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10FilterBase.h	Thu Jul 22 16:43:39 2010 +0100
@@ -35,10 +35,10 @@
 public: // from CHuiFxFilter
     virtual TBool Draw(CHuiFxEngine& aEngine, CHuiGc& aGc,
             CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource,
-            const TRect& aTargetRect, const TRect& aSourceRect);
+            const TRect& aTargetRect, const TRect& aSourceRect, TBool aHasSurface);
 
 private:
-    virtual void DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight) = 0;
+    virtual void DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight, TBool aHasSurface) = 0;
 protected:
     TBool wasEnoughMemory();
     
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10OutlineFilter.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10OutlineFilter.h	Thu Jul 22 16:43:39 2010 +0100
@@ -28,7 +28,7 @@
     static CHuiFxVg10OutlineFilter* NewL();
 protected:
     void ConstructL();
-    void DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight);
+    void DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight, TBool aHasSurface);
     void CalculateMargin(TMargins &aMargin) const;  
     CHuiFxVg10OutlineFilter *CloneL() const;
 private:
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10TransformFilter.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiFxVg10TransformFilter.h	Thu Jul 22 16:43:39 2010 +0100
@@ -26,9 +26,9 @@
 public: // from CHuiFxFilter
     virtual TBool Draw(CHuiFxEngine& aEngine, CHuiGc& aGc,
                        CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource,
-                       const TRect& aTargetRect, const TRect& aSourceRect);
+                       const TRect& aTargetRect, const TRect& aSourceRect, TBool aHasSurface);
     static CHuiFxVg10TransformFilter* NewL();
-    void DrawEffect(CHuiFxEngine& /*aEngine*/, VGImage /*aTargetImage*/, VGImage /*aSourceImage*/, TInt /*aWidth*/, TInt /*aHeight*/) {}
+    void DrawEffect(CHuiFxEngine& /*aEngine*/, VGImage /*aTargetImage*/, VGImage /*aSourceImage*/, TInt /*aWidth*/, TInt /*aHeight*/, TBool /*aHasSurface*/) {}
     void CalculateMargin(TMargins &aMargin) const;  
     CHuiFxVg10TransformFilter *CloneL() const;
 protected:
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Texture.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Texture.h	Thu Jul 22 16:43:39 2010 +0100
@@ -160,7 +160,7 @@
      * @param   aDestSize   Destination size for the VGImage
      * @return  Handle to the rasterized image or <code>VG_INVALID_HANDLE</code> if something went wrong.
      */ 
-    VGImage CreateRenderedImage(CNvgEngine* aNvgEngine, HBufC8* aNVGData, const TSize& aDestSize);
+    VGImage CreateRenderedImage(CNvgEngine* aNvgEngine, HBufC8* aNVGData, const TSize& aDestSize, TInt64 aSerialNumber = 0);
     
     /** 
      * Identifies whether this texture contains extended texture data
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10BevelFilter.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10BevelFilter.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -59,7 +59,7 @@
     return filter;
     }
 
-void CHuiFxVg10BevelFilter::DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight)
+void CHuiFxVg10BevelFilter::DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight, TBool /*aHasSurface*/)
     {
     VGfloat outline_x = clamp(iOutlineX, EPSILON, 128.0f);
     VGfloat outline_y = clamp(iOutlineY, EPSILON, 128.0f);
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10BlurFilter.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10BlurFilter.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -84,7 +84,7 @@
 }
 
 TBool CHuiFxVg10BlurFilter::Draw(CHuiFxEngine& aEngine, CHuiGc& /* aGc */, CHuiFxRenderbuffer& aTarget,
-                                 CHuiFxRenderbuffer& aSource, const TRect& aTargetRect, const TRect& aSourceRect)
+                                 CHuiFxRenderbuffer& aSource, const TRect& aTargetRect, const TRect& aSourceRect, TBool aHasSurface)
     {
     aTarget.BindAsTexture(ERenderbufferUsageWriteOnly);
     aSource.BindAsTexture(ERenderbufferUsageReadOnly);
@@ -96,7 +96,7 @@
 
     if(opacity > EPSILON)
         {
-        DrawEffect(aEngine, destImage, srcImage, aSourceRect.Width(), aSourceRect.Height());
+        DrawEffect(aEngine, destImage, srcImage, aSourceRect.Width(), aSourceRect.Height(), aHasSurface);
         }
     else
         {
@@ -116,7 +116,7 @@
     return wasEnoughMemory();
     }
 
-void CHuiFxVg10BlurFilter::DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight)
+void CHuiFxVg10BlurFilter::DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight, TBool /*aHasSurface*/)
     {
     const VGfloat blur_x = clamp(iBlurX, EPSILON, 128.0f);
     const VGfloat blur_y = clamp(iBlurY, EPSILON, 128.0f);
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10BrightnessContrastFilter.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10BrightnessContrastFilter.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -87,5 +87,5 @@
     iColorMatrix[16] = oOff;
     iColorMatrix[17] = oOff;
     iColorMatrix[18] = oOff;
-    iColorMatrix[19] = 0.0f;
+    iColorMatrix[19] = 0.0f; 
     }
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10ColorMatrixFilterBase.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10ColorMatrixFilterBase.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -44,7 +44,7 @@
     CHuiFxVg10FilterBase::CopyFromL(aOldFilter);
     memcpy(iColorMatrix, aOldFilter->iColorMatrix, sizeof(iColorMatrix));
     }
-void CHuiFxVg10ColorMatrixFilterBase::DrawEffect(CHuiFxEngine& /*aEngine*/, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight )
+void CHuiFxVg10ColorMatrixFilterBase::DrawEffect(CHuiFxEngine& /*aEngine*/, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight,TBool aHasSurface )
     {
     // take opacity into account
     const VGfloat opacity = clamp(iOpacity, 0.0f, 1.0f);
@@ -55,6 +55,8 @@
             {
             UpdateColorMatrix();
             }
+
+        iColorMatrix[19] = aHasSurface ? 0.5f : 0.0f;
         vgColorMatrix(aTargetImage, aSourceImage, iColorMatrix);
         }
     else
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10FilterBase.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10FilterBase.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -25,7 +25,7 @@
 
 
 TBool CHuiFxVg10FilterBase::Draw(CHuiFxEngine& aEngine, CHuiGc& /* aGc */, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource,
-                                            const TRect& aTargetRect, const TRect& aSourceRect)
+                                            const TRect& aTargetRect, const TRect& aSourceRect, TBool aHasSurface)
     {
     aTarget.BindAsTexture(ERenderbufferUsageWriteOnly);
     aSource.BindAsTexture(ERenderbufferUsageReadOnly);
@@ -37,7 +37,7 @@
 
     if(opacity > EPSILON)
         {
-        DrawEffect(aEngine, destImage, srcImage, aSourceRect.Width(), aSourceRect.Height());
+        DrawEffect(aEngine, destImage, srcImage, aSourceRect.Width(), aSourceRect.Height(), aHasSurface);
         }
     else
         {
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10OutlineFilter.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10OutlineFilter.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -70,7 +70,7 @@
 }
 
 
-void CHuiFxVg10OutlineFilter::DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight)
+void CHuiFxVg10OutlineFilter::DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight, TBool /*aHasSurface*/)
     {
     VGfloat outline_x = clamp(iOutlineX, EPSILON, 128.0f);
     VGfloat outline_y = clamp(iOutlineY, EPSILON, 128.0f);
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10TransformFilter.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiFxVg10TransformFilter.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -154,7 +154,7 @@
 
 TBool CHuiFxVg10TransformFilter::Draw(CHuiFxEngine& /*aEngine*/, CHuiGc& /*aGc*/,
         CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource,
-        const TRect& /*aTargetRect*/, const TRect& aSourceRect)
+        const TRect& /*aTargetRect*/, const TRect& aSourceRect, TBool /*aHasSurface*/)
     {
     aSource.BindAsTexture(ERenderbufferUsageReadOnly);
     aTarget.BindAsRenderTarget();
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Gc.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Gc.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -105,6 +105,8 @@
     vgDestroyPaint(iPaint);
     vgDestroyPaint(iGradientPaint);
     vgDestroyPath(iEllipsePath);
+    
+    iTempRegion.Close();
     }
     
 
@@ -978,8 +980,8 @@
 #if defined(RENDER_DEBUG_RECTANGLES)
     color = Math::Random() | 0xff;
 #endif
-    
-    // Update the color of the current paint
+    vgSetPaint(iPaint, VG_FILL_PATH | VG_STROKE_PATH);
+   // Update the color of the current paint
     // if required
     if (iPaintColor != color)
         {
@@ -2085,12 +2087,12 @@
         1.0f,  aEndColor.Red()   * scale, aEndColor.Green()   * scale, aEndColor.Blue()   * scale, aEndOpacity,
         };
     
+
     vgSetParameterfv(iGradientPaint, VG_PAINT_LINEAR_GRADIENT, 2 * 2, gradientCoords);
     vgSetParameterfv(iGradientPaint, VG_PAINT_COLOR_RAMP_STOPS, 2 * 5, gradientStops);
     vgSetPaint(iGradientPaint, VG_FILL_PATH);
     HUI_VG_INVARIANT();
 
-    UpdateColor();
     UpdateMatrix(VG_MATRIX_PATH_USER_TO_SURFACE);
     
     // Draw the gradient as an image if we have a texture, otherwise draw a regular rectangle
@@ -2117,7 +2119,16 @@
 
         if (!tex)
             {
-            DrawRect(aRect);
+            UpdateMatrix(VG_MATRIX_PATH_USER_TO_SURFACE);
+            vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+            
+            vgTranslate(aRect.iTl.iX, aRect.iTl.iY);
+            vgScale(aRect.Width(),aRect.Height());
+            
+            vgDrawPath(iRectPath, VG_FILL_PATH);
+            
+            vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+            UpdateMatrix(VG_MATRIX_PATH_USER_TO_SURFACE);
             }
         else
             {
@@ -2127,12 +2138,20 @@
         }
     else
         {
-        DrawRect(aRect);
+        UpdateMatrix(VG_MATRIX_PATH_USER_TO_SURFACE);
+        vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+        
+        vgTranslate(aRect.iTl.iX, aRect.iTl.iY);
+        vgScale(aRect.Width(),aRect.Height());
+        
+        vgDrawPath(iRectPath, VG_FILL_PATH);
+        
+        vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+        UpdateMatrix(VG_MATRIX_PATH_USER_TO_SURFACE);
         }
     HUI_VG_INVARIANT();
     
-    // Restore the original paint
-    vgSetPaint(iPaint, VG_FILL_PATH | VG_STROKE_PATH);
+    // Restore the original color & paint
     UpdateColor();
     }
 
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10RenderSurface.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10RenderSurface.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -28,6 +28,9 @@
 #include <gdi.h>
 #include "uiacceltk/HuiProbe.h"
 #include "uiacceltk/HuiEnv.h"
+#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#include <graphics/wstfxconst.h>
+#endif
 
 #include <M3G/m3g_core.h>
 
@@ -196,6 +199,10 @@
     if(iDisplay->NativeWindow())
         {
         HUI_DEBUG(_L("CHuiVg10RenderSurface::CreateSurface() - Attempting to create a real window surface."));
+#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+        RDebug::Printf("STFX: ALF_HACK CHuiVg10RenderSurface::CreateSurface()");
+        iDisplay->NativeWindow()->SetPurpose(ETfxPurposeDesktopWindow);
+#endif
         EGLSurface surf = eglCreateWindowSurface(iEglDisplay, aConfig,
                                       iDisplay->NativeWindow(), attriblistPtr);
 
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -29,6 +29,7 @@
 #include "uiacceltk/HuiTextureProcessor.h"
 #include "uiacceltk/HuiUtil.h"
 #include "uiacceltk/HuiPanic.h"
+#include "appiconcache.h"
 
 #include "huiextension.h"
 
@@ -1155,7 +1156,7 @@
         
         // Create the real image from NVG databuf
         iNVGData = dataBuf;
-        image = CreateRenderedImage(&nvgEngine, dataBuf, Size());
+        image = CreateRenderedImage(&nvgEngine, dataBuf, Size(),aBitmap.SerialNumber());
         
         // New functionality for checking the mask
         if (header.GetBitmapId() != maskHeader.GetBitmapId() && maskDataBuf &&
@@ -1210,7 +1211,9 @@
     return returnValue;
     }
 
-VGImage CHuiVg10Texture::CreateRenderedImage(CNvgEngine* aNvgEngine, HBufC8* aNVGData, const TSize& aDestSize)
+
+
+VGImage CHuiVg10Texture::CreateRenderedImage(CNvgEngine* aNvgEngine, HBufC8* aNVGData, const TSize& aDestSize, TInt64 aSerialNumber)
     {
     HUI_VG_INVARIANT();
     
@@ -1339,23 +1342,41 @@
     // drawn icons would show correctly, and no issues with transparency would arise)
     VGint blendMode = vgGeti(VG_BLEND_MODE);
     vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
-    if (iIconCommands)
+    TAknIconHeader iconheader = GetNvgIconHeader(aNVGData);
+    TBool direct = EFalse;
+    if (iconheader.IsMarginCorrection() && aSerialNumber)
         {
-        //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing iIconCommands"));
-        iIconCommands->Draw(aDestSize, aNvgEngine);
+        CFbsBitmap* entry = CHuiStatic::Env().AppIconCache().Find(aSerialNumber, aDestSize);
+        if (entry)
+            {
+            TSize entrySize = entry->SizeInPixels();
+            entry->BeginDataAccess();
+            TUint8* dataPtr = (TUint8*)entry->DataAddress();
+            vgImageSubData(image, dataPtr, CFbsBitmap::ScanLineLength(entrySize.iWidth, EColor16MAP), VG_sARGB_8888_PRE, 0, 0, entrySize.iWidth, entrySize.iHeight);
+            entry->EndDataAccess();
+            direct = ETrue;
+            }
         }
-    else
+        
+    if (!direct)
         {
-        // If ObjectCached version failed, try to use the old way
-        //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing with DrawNvg"));
-        aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), aDestSize, NULL, NULL);
+        if (iIconCommands)
+            {
+            //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing iIconCommands"));
+            iIconCommands->Draw(aDestSize, aNvgEngine);
+            }
+        else
+            {
+            // If ObjectCached version failed, try to use the old way
+            //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing with DrawNvg"));
+            aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), aDestSize, NULL, NULL);
+            }
         }
     
     // NVG-TLV icon margin special case check:
     // Check, if the icon has to be margin corrected
-    TAknIconHeader iconheader = GetNvgIconHeader(aNVGData);
     TSize size = aDestSize; // For using the correct size also later on
-    if (iconheader.IsMarginCorrection())
+    if (iconheader.IsMarginCorrection() && !direct)
         {
         size = ApplyMargin(image, aDestSize, display, newSurface, context);
         if( size != aDestSize)
@@ -1366,6 +1387,37 @@
             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)
+            {
+            // can't leave here (we would screw up the transformation matrix
+            // for the primary surface)
+            CFbsBitmap* rasterizedIcon = new CFbsBitmap;
+            TInt rastererr(KErrNone);
+            if (rasterizedIcon)
+                {
+                rastererr = rasterizedIcon->Create(aDestSize, EColor16MAP);
+                }
+            if (!rastererr)
+                {                    
+                rasterizedIcon->BeginDataAccess();
+                TUint8* dataPtr = (TUint8*)rasterizedIcon->DataAddress();
+                vgGetImageSubData(image, dataPtr, CFbsBitmap::ScanLineLength(aDestSize.iWidth, EColor16MAP), VG_sARGB_8888_PRE, 0, 0, aDestSize.iWidth, aDestSize.iHeight);
+                rasterizedIcon->EndDataAccess();
+                // store for future use....
+                TRasterizedBitmap rbmp(aSerialNumber, rasterizedIcon);            
+                rastererr = CHuiStatic::Env().AppIconCache().Insert(rbmp);        
+                }
+            // either the bitmap creation failed, or cache insert failed
+            // delete the bitmap so that we don't leak memory
+            if (rastererr)
+                {
+                delete rasterizedIcon;
+                }
+            }
+#endif
         }
 
     // restore the old surface before restoring original modes
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -32,6 +32,15 @@
 #include <AknLayoutFont.h>
 #include <e32property.h>
 
+#include "alfmoduletestconf.h"
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    // Provides TLS object data for test cases.
+    // This is used only if module test hooks are set on.
+    #include "huistatictlsdata.h"
+#endif // USE_MODULE_TEST_HOOKS_FOR_ALF
+// Provides module test hook defines.
+#include "alfmoduletestdefines.h"
+
 // Enable this for debugging cache usage
 //#define HUI_DEBUG_PRINT_CANVAS_TEXTURE_CACHE
 //#define HUI_DEBUG_PRINT_CANVAS_TEXTURE_CACHE_EGL
@@ -60,7 +69,7 @@
 
 /** Constant to define target how much memory UI textures should use, 
     this is not a hard limit but effects how long unused textures are cached */
-const TInt KHuiMaxRecommendedTextureAmountInKBytes = 4096;
+const TInt KHuiMaxRecommendedTextureAmountInKBytes = 6114;
 
 /** Constant to define target how much memory UI render buffers should use, 
     this is not a hard limit but effects how long unused render buffers are cached */
@@ -2931,7 +2940,11 @@
         // Always delete bitmaps from unused entries, we can again duplicate pointers from handles when needed.
         // Pointers are kept only for perfromance reasons.
         CHuiCanvasGraphicImage* entry = aIndexEntries[i];
-
+        TBool is16bit = EFalse;
+        if (entry->iBitmap && !entry->iMask && entry->iBitmap->ExtendedBitmapType() == KNullUid && entry->iBitmap->DisplayMode() == EColor64K)
+            {
+            is16bit = ETrue;
+            }
         delete entry->iBitmap;    
         entry->iBitmap = NULL;
 
@@ -2948,7 +2961,7 @@
             }
                     
         TSize textureSize = entry->iTexture->Size();    
-        TInt textureEstimatedSizeInBytes = textureSize.iWidth * textureSize.iHeight * KHuiCanvasImageEstimatedBpp/8.f;
+        TInt textureEstimatedSizeInBytes = textureSize.iWidth * textureSize.iHeight * (is16bit ? KHuiCanvasImageEstimatedBpp/16.f : KHuiCanvasImageEstimatedBpp/8.f);
 
         if (totalUnusedTextureBytes + textureEstimatedSizeInBytes < iUnusedCanvasImageTextureCacheSizeInKBytes*1024)
             {
@@ -3147,8 +3160,14 @@
 
     for(TInt i=imageEntries.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)
+            {
+            is16bit = ETrue;
+            }
+
         TSize textureSize = imageEntries[i]->iTexture->Size();    
-        totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * KHuiCanvasImageEstimatedBpp/8.f;
+        totalUnusedTextureBytes += textureSize.iWidth * textureSize.iHeight * (is16bit ? KHuiCanvasImageEstimatedBpp/16.f : KHuiCanvasImageEstimatedBpp/8.f);
         }            
     
     imageEntries.Close();        
@@ -3508,6 +3527,8 @@
         iMaxTextureMemoryInKBytes = KHuiMaxRecommendedTextureAmountInKBytes;
         iMaxRenderBufferMemoryInKBytes = KHuiMaxRecommendedRenderBufferAmountInKBytes;       
         }    
+
+    AMT_MAP_CANVAS_TEXTURE_CACHE_SET_MEMORY_LEVEL();
     }
 
 TBool CHuiCanvasTextureCache::IsLowMemoryStateEnabled() const
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -244,13 +244,13 @@
     HandleBuffer(scannedRect, EScanBuffer, NULL); 
     
     // Note: this could be improved to take care of dirty rects 
-    if (Effect() && Display())
+    if (Effect() && Display() && CHuiEnv::Static()->MemoryLevel() != EHuiMemoryLevelLowest )
         {        
         // If there is effect enabled, we cannot say anything about dirty area so
         // we set whole screen dirty.
         scannedRect = TRect(TPoint(0,0), Display()->VisibleArea().Size());
         }
-    else if (IsBackgroundDrawingEnabled() || IsExternalContentDrawingEnabled())
+    else if (IsExternalContentDrawingEnabled())
         {
         // If the visual has external content or draws background, 
         // set always the whole window area as a content.
@@ -342,8 +342,15 @@
     
 TBool CHuiCanvasVisual::CanSkipDrawing() const
     {
+    if(Display()->RosterImpl().AlfEventWindow() == this)
+         {
+         return EFalse;
+         }
+    
     if (Effect())
         {
+        TBool hasStoredContent = (IsDelayedEffectSource() || Freezed()) && (StoredRenderBuffer() ||  iCanvasVisualData->iStoredRenderBuffer);
+    
         TBool semiTranparentEffectActive = Effect()->IsSemitransparent();
         if ((iOpacity.Now() <= EPSILON && !semiTranparentEffectActive))
             {
@@ -356,7 +363,8 @@
             !HasCommandBuffers(ETrue /*include children*/) && 
             !IsBackgroundDrawingEnabled() &&
             !IsExternalContentDrawingEnabled()&&
-            !IsExternalContentDrawingEnabled(ETrue /*include children*/))
+            !IsExternalContentDrawingEnabled(ETrue /*include children*/) &&
+            !hasStoredContent )
             {
             return ETrue;
             }
@@ -451,22 +459,27 @@
         transparent |= iOpacity.Now() < 1.0f; // Opacity less than 1.0f -> always transparent
                 
         TBool refreshCache = EFalse;        
+        TBool layer =  EFalse;
         if (EffectIsAppliedToChildren())
             {
             refreshCache |= ChildTreeChanged(EHuiCanvasFlagExcludeFromParentEffect);
 
             iCanvasVisualData->iPaintedRegion.Clear();
-            CollectRecursivePaintedRegion(iCanvasVisualData->iPaintedRegion, EHuiCanvasFlagExcludeFromParentEffect);
+            layer = CollectRecursivePaintedRegion(iCanvasVisualData->iPaintedRegion, EHuiCanvasFlagExcludeFromParentEffect);
             }
         else
             {
             refreshCache |= Changed();            
 
             iCanvasVisualData->iPaintedRegion.Clear();
-            CollectPaintedRegion(iCanvasVisualData->iPaintedRegion, 0);
+            layer = CollectPaintedRegion(iCanvasVisualData->iPaintedRegion, 0);
             }
-        
-        didDrawEffect = Effect()->CachedDraw(aGc, area, refreshCache, !transparent, iCanvasVisualData->iPaintedRegion);
+
+        if(Display()->RosterImpl().AlfEventWindow() == this)
+            {
+            refreshCache |= Display()->RosterImpl().NativeAppsContentChanged();
+            }
+        didDrawEffect = Effect()->CachedDraw(aGc, area, refreshCache, !transparent, iCanvasVisualData->iPaintedRegion,layer );
         
         }
     
@@ -536,10 +549,10 @@
         RDebug::Print(_L("CHuiCanvasVisual::DrawSelf - tracked visual"));
         }
 #endif		
-      
+    TBool alfEventWindow = (Display()->RosterImpl().AlfEventWindow() == this);
     TReal32 effectiveOpacity = EffectiveOpacity();
-        
-    if (effectiveOpacity <= 0 || !HasCommandBuffers(ETrue))
+    TBool hasStoredContent = (IsContentDrawingEnabled() && (IsDelayedEffectSource() || Freezed())) && (StoredRenderBuffer() || iCanvasVisualData->iStoredRenderBuffer);        
+    if ((effectiveOpacity <= 0 || !HasCommandBuffers(ETrue)) && !alfEventWindow && !hasStoredContent)
         {
         // In case background drawing is enabled, and even if we don't have command buffers we still
         // want to issue clear. If the background drawing is enabled here, it means that the
@@ -555,7 +568,7 @@
             }
         }
 
-    if (IsContentDrawingEnabled() && (IsDelayedEffectSource() || Freezed()))
+    if (hasStoredContent)
         {
         // Select right draw mode
         THuiCanvasDrawMode drawMode = (Flags() & EHuiVisualFlagOpaqueHint) ? EHuiCanvasDrawModeNormal : EHuiCanvasDrawModeBlend;
@@ -572,6 +585,12 @@
             }
         }    
 
+    if(alfEventWindow)
+         {
+         Display()->RosterImpl().DrawNativeAppsContent(aGc, Display());
+         return;
+         }
+    
     // Use 'under opaque' hint to optimize drawing.
     // See comment from CHuiCanvasVisual::Draw for further details. 
     const TBool drawVisualContent = !( Flags() & EHuiVisualFlagUnderOpaqueHint );
@@ -853,7 +872,8 @@
     iCanvasVisualData->iCanvasPainter->SetTrackCommandSet( aFileName, aTrack || iTrackVisual );
     }
 #else
-EXPORT_C void CHuiCanvasVisual::SetTrackCommandSet( TFileName&, TBool){
+EXPORT_C void CHuiCanvasVisual::SetTrackCommandSet( TFileName&, TBool)
+    {
     }
 #endif
 
@@ -874,7 +894,12 @@
         PrepareCache();
         }
     
-    SetChanged();
+    // don't call setchanged directly here, as it changes all
+    // the command buffers dirty. We don't want to do that
+    // as the drawing area might be significantly smaller in
+    // some cases
+    CHuiLayout::SetChanged();
+    Env().ContinueRefresh(ETrue);
     Env().CanvasTextureCache().EnableTouchCountCheck(EFalse);    
     }
 
@@ -997,6 +1022,7 @@
                     }                    
 
                 background.iPaintedRect = backgroundItems[aIndex].Rect();
+                backgroundItems.Close();
                 return background;
                 }
             else
@@ -1509,7 +1535,7 @@
 		}
     }
 
-void CHuiCanvasVisual::CollectPaintedRegion(TRegion& aPaintRegion, TInt aExcludeCanvasFlags) const
+TBool CHuiCanvasVisual::CollectPaintedRegion(TRegion& aPaintRegion, TInt aExcludeCanvasFlags) const
     {
     // Only our own painted areas.
     TInt paintedAreaCount = PaintedAreaCount();  
@@ -1518,12 +1544,13 @@
         aPaintRegion.AddRect( CanvasPaintedArea(i).iPaintedRect.Round() );
         }
     aPaintRegion.Tidy();
+    return !iCanvasVisualData->iLayerExtent.IsEmpty();
     }
 
-void CHuiCanvasVisual::CollectRecursivePaintedRegion(TRegion& aRecursivePaintRegion, TInt aExcludeCanvasFlags) const
+TBool CHuiCanvasVisual::CollectRecursivePaintedRegion(TRegion& aRecursivePaintRegion, TInt aExcludeCanvasFlags) const
     {
     // First our own painted areas...
-    CollectPaintedRegion(aRecursivePaintRegion, aExcludeCanvasFlags);
+    TBool layer = CollectPaintedRegion(aRecursivePaintRegion, aExcludeCanvasFlags);
             
     // ...then children (and their children).
     const TInt count = Count();
@@ -1543,13 +1570,14 @@
                     if (visual->Flags() & EHuiVisualFlagWserv)
                         {
                         CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)visual;
-                        canvasVisual->CollectRecursivePaintedRegion(aRecursivePaintRegion, aExcludeCanvasFlags);
+                        layer |= canvasVisual->CollectRecursivePaintedRegion(aRecursivePaintRegion, aExcludeCanvasFlags);
                         }
                     }
                 }        
             }
         }    
     aRecursivePaintRegion.Tidy();
+    return layer;
     }
 
 EXPORT_C TRect CHuiCanvasVisual::CommandBufferCoverage(TInt aOrientation)
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiDisplay.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiDisplay.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -50,6 +50,10 @@
 #include "HuiFxEngine.h"
 #include "huiextension.h"
 
+#include <e32math.h>
+
+//#define DEBUG_SW_MODE_DIRTY_AREAS
+
 const TUid KHuiInternalFbsBitmapBufferGcUid = {0x2000e5a3}; 
 
 //#define HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
@@ -187,6 +191,8 @@
     // full display refresh in many cases -> better performance.
     iGc->EnableTransformedClippingRects(iUseTransformedDirtyRegions);
 
+    iDisplaySizeChangePending = EFalse;
+    
     HUI_DEBUG1(_L("CHuiDisplay::ConstructL - Free memory when exiting ConstructL: %i"), HuiUtil::FreeMemory());
     }
 
@@ -218,6 +224,8 @@
     iVisibleAreaObservers.Reset();
     iRosterObservers.Reset();
 
+    iTempDirtyRegions.Close();
+    
     iDirtyRegions.Close();
     iDirtyRegions2.Close();
     if ( iCurrentDirtyRegions )
@@ -580,6 +588,11 @@
     	}
     // We must only transform the (new) dirtyregion, not combine or anything else here
     aDirtyRegion = transformedNewDirtyRect;
+    
+    if(iScanningAlfContent)
+        {
+		SetAlfContentChanged(ETrue);
+        }
     }
 
 
@@ -631,6 +644,7 @@
     startTime.UniversalTime();
 #endif
     
+    SetAlfContentChanged(EFalse);
     
     // Prevent display refresh, if the display is on background.
     if(!iOnForeground || IsScreenBufferLocked())
@@ -649,6 +663,9 @@
  	
     iWholeDisplayAreaIsDirty = EFalse;    
     
+    // Restore state to defaults. Alf client may have done some NVG drawing outside refresh loop and main drawing context may be wrong
+    iGc->RestoreState();
+    
     if(iUpdateRenderState)
         {
         // Set state when requested.
@@ -734,16 +751,18 @@
     // this frame and the previous frame (this is needed when buffer swapping
     // is used; with buffer copying a single list of dirty regions would
     // suffice).
-    RDirtyRegions dirty;
+
+
+    iTempDirtyRegions.Reset();
     for(i = 0; i < iCurrentDirtyRegions->Count(); ++i)
         {
-        dirty.Append((*iCurrentDirtyRegions)[i]);
+        iTempDirtyRegions.Append((*iCurrentDirtyRegions)[i]);
         }
     if (iPreviousDirtyRegions)
     	{
     	for(i = 0; i < iPreviousDirtyRegions->Count(); ++i)
         	{
-        	AddDirtyRegion((*iPreviousDirtyRegions)[i], dirty, EFalse);
+        	AddDirtyRegion((*iPreviousDirtyRegions)[i], iTempDirtyRegions, EFalse);
         	}
     	}
 
@@ -794,25 +813,25 @@
 	// Set dirty rect in render surface to minimize screen update
 	// Only implemented for BitGdi renderer for now
     TRect mergedDirtyRect;
-    if (dirty.Count() > 0)
+    if (iTempDirtyRegions.Count() > 0)
     	{
-    	mergedDirtyRect = dirty[0];
+    	mergedDirtyRect = iTempDirtyRegions[0];
     	}
     	
 	if (useDirtyRects)
 	    {
 		// When Bitgdi renderer used set dirty rect in render surface
 		// to minimize screen update in CHuiBitgdiRenderSurface::SwapBuffers
-	    if (dirty.Count() == 1)
+	    if (iTempDirtyRegions.Count() == 1)
 		    {
             ClipDirtyRect(mergedDirtyRect, VisibleAreaClippingRect());
             iRenderSurface->SetDirtyRect(mergedDirtyRect);
 		    }
-		else if (dirty.Count() > 1) 
+		else if (iTempDirtyRegions.Count() > 1) 
 		    {
-			for(i = 1; i < dirty.Count(); ++i)
+			for(i = 1; i < iTempDirtyRegions.Count(); ++i)
 				{
-				TRect r(dirty[i]);
+				TRect r(iTempDirtyRegions[i]);
 				// check top left corner to expand or not
 				if (r.iTl.iX < mergedDirtyRect.iTl.iX)
 				    {
@@ -852,8 +871,8 @@
 	// Merge into max one dirty area when HW accelrated drawing is used
 	if (useDirtyRects && IsRendererHWAccelerated())
 	    {
-	    dirty.Reset();
-	    dirty.Append(mergedDirtyRect);
+        iTempDirtyRegions.Reset();
+        iTempDirtyRegions.Append(mergedDirtyRect);
 	    }
 	
 #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
@@ -865,12 +884,13 @@
 #endif	
 	
     // Usually there is only one dirty region (if any).
-    for(i = 0; i < dirty.Count(); ++i)
+    iCurrentDirtyIndx = 0;
+    for(; iCurrentDirtyIndx < iTempDirtyRegions.Count(); ++iCurrentDirtyIndx)
         {
         // Set up the clipping rectangle.
-        TRect dirtyRect = dirty[i];
+        TRect dirtyRect = iTempDirtyRegions[iCurrentDirtyIndx];
         ClipDirtyRect(dirtyRect, VisibleAreaClippingRect());
-        
+        iCurrentDirtyRect = dirtyRect;
         iGc->PushClip();
         iGc->Clip(dirtyRect);        
         
@@ -886,34 +906,7 @@
             iBackgroundColor = oldBgColor;
             }
                 
-        // Clear background for the dirty area
-        if (iBackgroundItems.Count() != 0)
-            {
-            ClearWithBackgroundItems(dirtyRect);    
-            }
-        else
-            {
-            switch (iClearBackground)
-                {
-                case EClearWithColor:
-                    {
-                    ClearWithColor(dirtyRect);                            
-                    break;    
-                    }
-                case EClearWithSkinBackground:
-                    {
-                    ClearWithSkinBackground(dirtyRect);                                                    
-                    break;    
-                    }
-                case EClearNone:
-                default:
-                    {
-                    // Don't do anything
-                    break;    
-                    }                                                
-                }                                    
-            }                                        
-        
+         
         if ( iForegroundBitmapGc && iForegroundTextureTransparency )
             {
             // There is ALF content in the background, we have to
@@ -927,7 +920,7 @@
             iForegroundBitmapGc->SetPenColor(clearColor);
             iForegroundBitmapGc->SetBrushColor(clearColor);
             iForegroundBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
-  	        iForegroundBitmapGc->Clear();
+  	        iForegroundBitmapGc->Clear(dirtyRect);
   	        iForegroundBitmapGc->Reset();
             }
         		
@@ -965,7 +958,7 @@
         iGc->PopClip();
         }
 
-    dirty.Reset();
+    iTempDirtyRegions.Reset();
 
     // There must be no disparity in the number of pushed clipping rectangles.
     // (equivalent to __ASSERT_ALWAYS)
@@ -988,34 +981,7 @@
 		
 	// Clear current dirty regions	
 	iCurrentDirtyRegions->Reset();
-	
-	// Trick to swap gles buffers if we are drawing idle screens before refresh loop is going to
-	// sleep. 
-	if(	IsRendererHWAccelerated() && !iGotDirtyReports && !iScreenBufferObserver) 
-    		{
-	    	//RenderSurface().SwapBuffers(); [ohi]
-	    	}
-	    	
-	// Tell the screen buffer observer that the buffer is complete 
-	if(iScreenBufferObserver)
-		{
-		SetScreenBufferLock(ETrue); // the observer should do unlock!
-		
-		TRect rect(VisibleArea()); // This is not the real display rect in ALF display case(!)
-		TRect dirtyRect(mergedDirtyRect);
-		
-		// Update screen buffer GC bitmap
-		if (DisplayType() != CHuiDisplay::EDisplayOffScreenBuffer)
-			{
-			TRAP_IGNORE(CHuiStatic::Renderer().UpdateOffScreenBitmapL(*this));			
-			}
-						
-		if (iScreenBufferObserver->ScreenBufferComplete(iScreenBufferUid, rect, dirtyRect))
-			{
-			SetScreenBufferLock(EFalse);
-			}
-		}
-
+		    	
     iWholeDisplayAreaIsDirty = EFalse;    
 	
     HUI_PROBE_PROGRAMFLOW_EXIT(MHuiProbe::EProgramFlowPointRefresh)
@@ -1631,6 +1597,33 @@
 #endif
     }
 
+void CHuiDisplay::ScanningAlfContent(TBool aScanning )
+    {
+    iScanningAlfContent = aScanning;
+    }
+
+void CHuiDisplay::SetAlfContentChanged(TBool aChanged)
+    {
+    iDisplayContainsChangedAlfContent = aChanged;
+    }
+
+TBool CHuiDisplay::AlfContentChanged()
+    {
+    return iDisplayContainsChangedAlfContent;
+    }
+
+EXPORT_C void CHuiDisplay::SetSkinSizeChangePending()
+    {
+    iDisplaySizeChangePending = ETrue;
+    }
+
+TBool CHuiDisplay::QueryAndResetSkinSizeChangePendingStatus()
+    {
+    TBool ret = iDisplaySizeChangePending;
+    iDisplaySizeChangePending = EFalse;
+    return ret;
+    }
+
 void CHuiDisplay::ClipDirtyRect(TRect& aRect, TRect aClippingRect)
     {
     if (aRect.Intersects(aClippingRect))
@@ -1669,6 +1662,15 @@
     {
     if (iForegroundTexture && iForegroundBitmap && !aRect.IsEmpty())
         {
+#if defined(DEBUG_SW_MODE_DIRTY_AREAS)
+        TRgb penColor = TRgb(Math::Random());
+        penColor.SetAlpha(128);
+        iForegroundBitmapGc->SetPenStyle(CGraphicsContext::ESolidPen);
+        iForegroundBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
+        iForegroundBitmapGc->SetPenColor(penColor);
+        iForegroundBitmapGc->SetBrushColor(penColor);
+        iForegroundBitmapGc->DrawRect(aRect);
+#endif
         TRAP_IGNORE(DoUpdateForegroundTextureL(aRect));
         }
     }
@@ -1787,3 +1789,40 @@
         
     User::LeaveIfError( err );
     }
+
+void CHuiDisplay::DoBackgroundClear()
+    {
+    // Clear background for the dirty area
+    TRect dirtyRect = iTempDirtyRegions[iCurrentDirtyIndx];
+    if (iBackgroundItems.Count() != 0)
+        {
+        ClearWithBackgroundItems(dirtyRect);    
+        }
+    else
+        {
+        switch (iClearBackground)
+            {
+            case EClearWithColor:
+                {
+                ClearWithColor(dirtyRect);                            
+                break;    
+                }
+            case EClearWithSkinBackground:
+                {
+                ClearWithSkinBackground(dirtyRect);                                                    
+                break;    
+                }
+            case EClearNone:
+            default:
+                {
+                // Don't do anything
+                break;    
+                }                                                
+            }                                    
+        }
+    }
+
+TRect CHuiDisplay::CurrentDirtyRect()
+    {
+    return iCurrentDirtyRect;
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiEnv.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiEnv.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -46,6 +46,7 @@
 #include "uiacceltk/HuiThemeManager.h"
 #include "huicanvastexturecache.h"
 #include "HuiFxEngine.h"
+#include "appiconcache.h"
 
 #include "huisynchronizationobserver.h"
 
@@ -326,6 +327,7 @@
     //iThemeManager = CHuiThemeManager::NewL();
 
     iCanvasTextureCache = CHuiCanvasTextureCache::NewL();
+    iAppIconCache = CAppIconCache::NewL(128);
 
 #ifndef SYMBIAN_BUILD_GCE
 #ifndef __WINSCW__
@@ -372,6 +374,7 @@
     iDisplays.Reset();
     iOverlaidDisplays.Reset();
 
+	delete iAppIconCache;
     delete iCanvasTextureCache;
 
     delete iSharedRoster;
@@ -1717,6 +1720,11 @@
     {
     return *iCanvasTextureCache;    
     }
+    
+EXPORT_C CAppIconCache& CHuiEnv::AppIconCache() const
+    {
+    return *iAppIconCache;
+    }
 
 EXPORT_C CHuiFxEngine* CHuiEnv::EffectsEngine() const
     {
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -22,6 +22,16 @@
 #include "HuiRenderPlugin.h"
 #include "HuiCmdBufferBrush.h" // MHuiEffectable
 
+#include "alfmoduletestconf.h"
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    // Provides TLS object data for test cases.
+    // This is used only if module test hooks are set on.
+    #include "huistatictlsdata.h"
+#endif // USE_MODULE_TEST_HOOKS_FOR_ALF
+// Provides module test hook defines.
+#include "alfmoduletestdefines.h"
+
+
 EXPORT_C CHuiFxEffect* CHuiFxEffect::NewL(CHuiFxEngine& aEngine)
     {
     CHuiFxEffect* e = new (ELeave) CHuiFxEffect( aEngine );
@@ -107,6 +117,40 @@
         {
         return ETrue; // fade effect does not have observer that would need notification
         }
+    
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    TTime endTime;
+    endTime.UniversalTime();
+    
+	// There might be several BeginFullScreen for single effects. We want to calculate
+	// reaction time from the first BeginFullScreen event to this point
+    TInt timeStamps = 0;
+    AMT_GET_TIME_POINT_COUNT(iHandle, timeStamps);
+    
+    TInt64 temp;
+    TBool effects(EFalse); // dummy, 1 if effects were on for this time stamp
+    AMT_GET_TIME(temp, iHandle, 0, effects);
+    TTime startTime(temp);
+    
+    AMT_GET_TIME(temp, iHandle, timeStamps - 1, effects);
+    TTime effectStartTime(temp);
+    
+    TInt64 effectTime = endTime.MicroSecondsFrom(effectStartTime).Int64();
+    TReal fps = (TReal)iFramesDrawn / ((TReal)effectTime / 1000000.0f) ; 
+
+    TInt64 totalEffectTime = endTime.MicroSecondsFrom(startTime).Int64();
+    TInt64 reactionTime = effectStartTime.MicroSecondsFrom(startTime).Int64();
+        
+    RDebug::Printf("CHuiFxEffect::NotifyEffectEndObserver - Reaction time \t0x%x\t%f\tVisible effect time:\t%f\ts. (%f FPS). Total effect time:\t%f", 
+            iHandle,
+            (TReal)reactionTime / 1000000.0f,
+            ((TReal)effectTime)/1000000,
+            fps,
+            ((TReal)totalEffectTime)/1000000.0f 
+            );
+    AMT_RESET_TIME(iHandle);
+#endif
+    
     if (iEffectEndObserver)
         {
         // The callback can be called only once when the effect finishes
@@ -217,13 +261,13 @@
 TBool CHuiFxEffect::CachedDraw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aRefreshCachedRenderTarget, TBool aOpaque)
     {
     RRegion dummy;
-    TBool ret = CachedDraw(aGc, aDisplayRect, aRefreshCachedRenderTarget, aOpaque, dummy);
+    TBool ret = CachedDraw(aGc, aDisplayRect, aRefreshCachedRenderTarget, aOpaque, dummy,EFalse);
     dummy.Close();
     return ret;
     }
 
 // TODO: effect area should be reduced if aClipRegion is smaller than aDisplayRect.
-TBool CHuiFxEffect::CachedDraw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aRefreshCachedRenderTarget, TBool aOpaque, const TRegion& aClipRegion, TInt aAlpha)
+TBool CHuiFxEffect::CachedDraw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aRefreshCachedRenderTarget, TBool aOpaque, const TRegion& aClipRegion, TBool aHasSurface, TInt aAlpha)
     {
 #ifdef HUIFX_TRACE    
     RDebug::Print(_L("CHuiFxEffect::CachedDraw - 0x%x"), this);
@@ -320,7 +364,7 @@
             if (cachedRenderTargetNeedsRefresh)
                 {
                 // Render to cached render target
-                iRoot->Draw(*iEngine, aGc, *iCachedRenderTarget, *iCachedRenderTarget);                
+                iRoot->Draw(*iEngine, aGc, *iCachedRenderTarget, *iCachedRenderTarget, aHasSurface);                
 #ifdef HUIFX_TRACE    
                 RDebug::Print(_L("CHuiFxEffect::CachedDraw - refreshed cached render buffer 0x%x"), this);
 #endif
@@ -376,13 +420,13 @@
             }
         
         // Normal drawing
-        iRoot->Draw(*iEngine, aGc, *target, *target);
+        iRoot->Draw(*iEngine, aGc, *target, *target, aHasSurface);
         }
                 
     return ETrue;    
     }
 
-EXPORT_C TBool CHuiFxEffect::Draw(CHuiGc& aGc, const TRect& aDisplayRect)
+EXPORT_C TBool CHuiFxEffect::Draw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aHasSurface)
     {
     // Prepare all layers
 #ifdef HUIFX_TRACE    
@@ -439,7 +483,7 @@
         return EFalse;
         }
 
-    iRoot->Draw(*iEngine, aGc, *target, *target);
+    iRoot->Draw(*iEngine, aGc, *target, *target, aHasSurface);
     return ETrue;
     }
 
@@ -553,6 +597,13 @@
 
             if (iFramesDrawn == 1)
                 {
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+				// This is about the time when first frame from the effect is on screen
+                TTime endTime;
+                endTime.UniversalTime();
+                
+                AMT_ADD_TIME(iHandle, endTime.Int64(), ETrue);
+#endif
                 aElapsedTime = 0;
                 iFramesDrawn++;
                 }
@@ -561,6 +612,15 @@
         }
     else
         {
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+        if (iFramesDrawn == 1)
+            {
+            // This is about the time when first frame from the effect is on screen
+            TTime endTime;
+            endTime.UniversalTime();
+            AMT_ADD_TIME(iHandle, endTime.Int64(), ETrue);
+            }
+#endif
         iRoot->AdvanceTime(aElapsedTime);
         }
     iElapsedTime += aElapsedTime;
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxFilterLayer.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxFilterLayer.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -90,7 +90,7 @@
     iFilter->AdvanceTime(aElapsedTime);
     }
 
-EXPORT_C void CHuiFxFilterLayer::Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource)
+EXPORT_C void CHuiFxFilterLayer::Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource, TBool aHasSurface)
     {
 #ifdef HUIFX_TRACE 
 	RDebug::Print(_L("CHuiFxFilterLayer::Draw - 0x%x "), this);
@@ -107,7 +107,7 @@
     TRect targetRect(TPoint(0, 0), TargetRect().Size());
     TInt alpha = 0xff; // TODO
 
-    iFilter->Draw(aEngine, aGc, *backBuffer, aSource, targetRect, SourceRect());
+    iFilter->Draw(aEngine, aGc, *backBuffer, aSource, targetRect, SourceRect(), aHasSurface);
 
     // Composite the result
     TRect compositionSourceRect(targetRect);
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxGroupLayer.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxGroupLayer.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -172,7 +172,7 @@
     }
 
 EXPORT_C void CHuiFxGroupLayer::Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer& aTarget, 
-                                     CHuiFxRenderbuffer& aSource)
+                                     CHuiFxRenderbuffer& aSource, TBool aHasSurface)
     {
 #ifdef HUIFX_TRACE    
     RDebug::Print(_L("CHuiFxGroupLayer::Draw - 0x%x "), this);
@@ -230,7 +230,7 @@
     
     for (TInt i = 0; i < iLayers.Count(); i++)
         {
-        iLayers[i]->Draw(aEngine, aGc, *backBuffer, *sourceBuffer);
+        iLayers[i]->Draw(aEngine, aGc, *backBuffer, *sourceBuffer, aHasSurface);
         }
 
     // The root group does not support composition
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxVisualLayer.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxVisualLayer.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -233,7 +233,7 @@
     return ETrue;
     }
 
-EXPORT_C void CHuiFxVisualLayer::Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer &aTarget, CHuiFxRenderbuffer& /*aSource*/)
+EXPORT_C void CHuiFxVisualLayer::Draw(CHuiFxEngine& aEngine, CHuiGc& aGc, CHuiFxRenderbuffer &aTarget, CHuiFxRenderbuffer& /*aSource*/, TBool /*aHasSurface*/)
     {
 #ifdef HUIFX_TRACE    
     RDebug::Print(_L("CHuiFxVisualLayer::Draw - 0x%x "), this);
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiRosterImpl.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiRosterImpl.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -21,6 +21,7 @@
 #include "HuiRosterImpl.h"  // Class definition
 #include "HuiRosterEntry.h"
 #include "uiacceltk/HuiEnv.h"
+#include "uiacceltk/HuiSkin.h"
 #include "uiacceltk/HuiControlGroup.h"
 #include "uiacceltk/HuiControl.h"
 #include "uiacceltk/HuiDisplay.h"
@@ -504,7 +505,7 @@
             iEffect->ForceCachedRenderTargetUsage(ETrue);
             }        
         RRegion dummy;
-        didDrawEffect = iEffect->CachedDraw(aGc, displayRect, refreshCache, opaque, dummy, iEffectOpacity*255);        
+        didDrawEffect = iEffect->CachedDraw(aGc, displayRect, refreshCache, opaque, dummy, EFalse, iEffectOpacity*255);        
         dummy.Close();
         }
     
@@ -542,7 +543,8 @@
         DrawSelfFrozen(aGc, display);
         return;
         }
-
+    
+    
     TInt visualCount = 0;
     TInt entryCount = iEntries.Count();
     // Draw the visuals tree in the display.
@@ -550,7 +552,14 @@
         {
         CHuiRosterEntry& entry = *iEntries[j]; 
         CHuiControlGroup& group = entry.ControlGroup();
-
+        CHuiControl& control = group.Control(0);
+        
+        // skip all  alf client session drawing
+        if(control.Role() == EHuiSessionContainer )
+            {
+            continue;
+            }
+        
         // Init model matrix always for every group
         //aGc.LoadIdentity(EHuiGcMatrixModel);        
         aGc.Push(EHuiGcMatrixModel);
@@ -708,6 +717,127 @@
         }
     }
 
+void CHuiRosterImpl::SetAlfEventWindow(CHuiVisual* aVisual)
+    {
+    iAlfEventWindowVisual = aVisual;
+    }
+
+const CHuiVisual* CHuiRosterImpl::AlfEventWindow()
+    {
+    return iAlfEventWindowVisual;
+    }
+
+TBool CHuiRosterImpl::NativeAppsContentChanged()
+    {
+    // if we have multiple frames where alf content was changed, skip every other frame
+	// this should be only used if whole alf content has effect (is faded)
+    TBool alfContentChanged = iDisplay->AlfContentChanged();
+    if(!iPreviousAlfContentDrawn && alfContentChanged)
+        {
+        iPreviousAlfContentDrawn = ETrue;
+        }
+    else
+        {
+        iPreviousAlfContentDrawn = EFalse;
+        }
+    return iPreviousAlfContentDrawn;
+    }
+
+
+void CHuiRosterImpl::DrawNativeAppsContent(CHuiGc &aGc, CHuiDisplay* aDisplay) const
+    {
+    TInt i = 0;
+    TInt j = 0;
+
+    CHuiDisplay* display = aDisplay ? aDisplay : iDisplay;
+    
+    ASSERT(display!=NULL);
+
+    TBool clearDone = EFalse;
+    
+    TInt visualCount = 0;
+    TInt entryCount = iEntries.Count();
+    // Draw the visuals tree in the display.
+    for(j = 0; j < entryCount; ++j)
+        {
+        CHuiRosterEntry& entry = *iEntries[j]; 
+        CHuiControlGroup& group = entry.ControlGroup();
+        CHuiControl& control = group.Control(0);
+        // skip all but alf client session drawing
+        if(control.Role() != EHuiSessionContainer )
+            {
+            continue;
+            }
+        
+        // skip inactive
+        CHuiLayout* hostContainer = control.ContainerLayout( NULL );
+        if(hostContainer->Flags() & EHuiVisualFlagInactive )
+            {
+            continue;
+            }
+        
+        // Init model matrix always for every group
+        //aGc.LoadIdentity(EHuiGcMatrixModel);        
+        aGc.Push(EHuiGcMatrixModel);
+        
+        // Set up display-specifc transformations i.e. camera transformations       
+        display->Transformation().Execute(EHuiGcMatrixModel, aGc);
+        
+        // Set up a group-specific transformation.
+        if(group.IsTransformed())
+            {
+            group.Transformation().Execute(EHuiGcMatrixModel, aGc);
+            }
+        
+        // Draw visuals
+        visualCount = entry.iRootVisuals.Count();
+        for(i = 0; i < visualCount; ++i)
+            {
+            CHuiVisual* visual = entry.iRootVisuals[i];
+            //Ignore inactive visuals
+            if ( visual->Flags()& EHuiVisualFlagInactive || visual->LoadingEffect() )
+                {
+                continue; 
+                }
+            
+            if(!clearDone)
+                {
+                // also check if display size change is pending or not
+                if(display->QueryAndResetSkinSizeChangePendingStatus())
+                    {
+                    display->Env().Skin().NotifyDisplaySizeChangedL();
+                    }
+            
+                // only do clear if we really draw some alf native content
+                display->DoBackgroundClear();
+                clearDone = ETrue;
+                }
+            
+            visual->Draw(aGc);
+            
+            }       
+
+        if( display->DrawVisualOutline() != CHuiDisplay::EDrawVisualOutlineNone )
+            {           
+            for(i = 0; i < visualCount; ++i)
+                {   
+                // Draw Visual Outline depending on central repository setting
+                // and visual flag value
+                const TBool drawOutline =
+                    ( entry.iRootVisuals[i]->Flags() & EHuiVisualFlagEnableDebugMode ) ||  
+                    ( display->DrawVisualOutline() == CHuiDisplay::EDrawVisualOutlineAllVisuals );
+                
+                DrawBoundaries( aGc, entry.iRootVisuals[i], drawOutline );        
+                }
+            }
+        
+        aGc.Pop(EHuiGcMatrixModel);        
+        }
+    }
+
+
+
+
 void CHuiRosterImpl::DrawBoundaries( CHuiGc& aGc, CHuiVisual* aVisual, TBool aDrawOutline ) const
 	{
     if( aDrawOutline )
@@ -992,8 +1122,8 @@
         if(iDisplay)
             {
             iDisplay->AddDirtyRegion(iRect);
+            iDisplay->SetAlfContentChanged(ETrue);
             }
-        
         SetChanged(EFalse);
         return;
         }
@@ -1016,7 +1146,28 @@
            		{
            		continue; 
            		}
+            
+             CHuiControlGroup& group = entry.ControlGroup();
+             CHuiControl& control = group.Control(0);
+             
+             if(control.Role() == EHuiSessionContainer )
+                 {
+                 if (iDisplay)
+                     {
+                     iDisplay->ScanningAlfContent(ETrue);
+                     }
+                 
+                 }
+             
             entry.iRootVisuals[i]->ReportChanged();
+            
+            if(control.Role() == EHuiSessionContainer )
+                {
+                if(iDisplay)
+                    {
+                    iDisplay->ScanningAlfContent(EFalse);
+                    }
+                }
             }
         }
     }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiS60Skin.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiS60Skin.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -196,12 +196,8 @@
     {
     if (aReason == EAknsSkinStatusConfigurationDeployed)
         {
-        FreeAllBackgroundTextureResources();
-        Env().NotifySkinChangedL();
-        Env().TextStyleManager().NotifyDisplaySizeChangedL();
-        ReloadBgTexturesL();
+        Env().Display(0).SetSkinSizeChangePending();
         }
-    
     }
 
 EXPORT_C void CHuiS60Skin::SkinPackageChanged(
@@ -256,9 +252,11 @@
 
 EXPORT_C void CHuiS60Skin::NotifyDisplaySizeChangedL()
     {
-    // The background is now different.
-     SkinConfigurationChanged(EAknsSkinStatusConfigurationDeployed);
-    
+    // Reload all the skin bitmaps
+     FreeAllBackgroundTextureResources();
+     Env().NotifySkinChangedL();
+     Env().TextStyleManager().NotifyDisplaySizeChangedL();
+     ReloadBgTexturesL();
     }
 
 
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiStatic.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiStatic.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -33,7 +33,10 @@
 #include <bidivisual.h>
 #include "alfappfwproxyops.h"
 
-
+#ifdef HUI_DEBUG_TRACK_DRAWING
+#include "alfloggingconfiguration.h"
+#include "alfcommanddebug.h"
+#endif
 
 // Global writeable data, used in HW instead of TLS which relatively slow
 #ifndef __WINSCW__
@@ -388,6 +391,11 @@
     //Register for environment change ( here system time change ) event notification
     iChangeNotifier = CEnvironmentChangeNotifier::NewL(0, TCallBack(CHuiStatic::SettingChangedCallBack, this));
     iChangeNotifier->Start();
+    
+#ifdef HUI_DEBUG_TRACK_DRAWING
+    iData->iCommandDebugger = CAlfCommandDebug::NewL();
+#endif
+    
 #ifndef __WINSCW__
     globalWriteableData = *iData;
     #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
@@ -412,6 +420,11 @@
 
 CHuiStatic::~CHuiStatic()
     {
+#ifdef HUI_DEBUG_TRACK_DRAWING
+    delete iData->iCommandDebugger;
+    iData->iCommandDebugger = NULL;
+#endif
+
     if(iData)
         {
         if(iData->iFakeProbe)
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiVisual.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiVisual.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -156,6 +156,19 @@
         delete iVisualData->iStoredRenderBuffer;
         iVisualData->iStoredRenderBuffer = aRenderBuffer;
         }
+    else
+        {
+        if (aRenderBuffer != iVisualData->iStoredRenderBuffer)
+            {
+#ifdef _DEBUG
+            RDebug::Printf("CHuiVisual::SetStoredRenderBuffer - Warning: Not enabled (%x / %x)", 
+                aRenderBuffer, iVisualData->iStoredRenderBuffer);
+#endif
+            // Ownership was passed, but we do not need it.
+            delete aRenderBuffer;
+            aRenderBuffer = NULL;
+            }
+        }
     }
 EXPORT_C void CHuiVisual::SetStoredRenderBufferModificationsEnabled(TBool aEnabled)
     {
@@ -2154,8 +2167,6 @@
 
 EXPORT_C void CHuiVisual::SetEffect(CHuiFxEffect* aEffect)
     {
-    SetFreezeState(EFalse);
-
     __ALFFXLOGSTRING2("CHuiVisual::SetEffect - : 0x%d on visual 0x%x", aEffect, this );
     // If effect is replaced by a new effect, we don't want the effect end callback
     // as it would end the new effect
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/coretoolkit/src/appiconcache.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include "appiconcache.h"
+
+CAppIconCache::~CAppIconCache()
+    {
+    Clear();
+    }
+    
+CAppIconCache::CAppIconCache(TInt aCacheLimit) : iCache(32), iCacheLimit(aCacheLimit)
+    {
+    }
+
+CAppIconCache* CAppIconCache::NewL(TInt aCacheLimit)
+    {
+    CAppIconCache* self = new (ELeave) CAppIconCache(aCacheLimit);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+void CAppIconCache::ConstructL()
+    {
+    }
+
+EXPORT_C CFbsBitmap* CAppIconCache::Find(TInt64 aSerialNumber, TSize aSize)
+    {
+    TRasterizedBitmap rb;
+    for (TInt index = 0; index < iCache.Count(); index++)
+        {
+        if (iCache[index].iBitmapSerial == aSerialNumber && iCache[index].iBitmap->SizeInPixels() == aSize)
+            {
+            // if we found a match, move the entry to the beginning of
+            // the cache
+            rb = iCache[index];
+            iCache.Remove(index);
+            iCache.Insert(rb, 0);
+            return rb.iBitmap;
+            }
+        }
+    return NULL;   
+    }
+    
+EXPORT_C TInt CAppIconCache::Insert(TRasterizedBitmap& aBitmap)
+    {
+    TSize bitmapsize = aBitmap.iBitmap->SizeInPixels();
+    // assume 32bpp for the icon
+    TInt bitmapBytes = bitmapsize.iWidth*bitmapsize.iHeight*4;
+    if (bitmapBytes > 128*128*4)
+        {
+        return KErrTooBig;
+        }
+        
+    if (iCache.Count() > iCacheLimit)
+        {
+        // cache limit exceeded, remove
+        // the least recently used entry
+        delete iCache[iCache.Count()-1].iBitmap;
+        iCache.Remove(iCache.Count()-1);
+        }
+    return iCache.Insert(aBitmap, 0);
+    }
+
+EXPORT_C void CAppIconCache::Clear()
+    {
+    for (TInt index = 0; index < iCache.Count(); index++)
+        {
+        delete iCache[index].iBitmap;
+        }
+    iCache.Reset();
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvasdebugwsgc.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvasdebugwsgc.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -588,6 +588,11 @@
     return iCanvasWsGc->EnableRenderbuffer(aEnable);    
     }
 
+void CHuiCanvasDebugWsGc::ClearCapturingBufferArea(const TRect& aRect)
+    {
+    iCanvasWsGc->ClearCapturingBufferArea(aRect);
+    }
+
 THuiCanvasWsGcType CHuiCanvasDebugWsGc::Type() const
     {
     return iCanvasWsGc->Type();
@@ -616,6 +621,11 @@
      
     }
 
+void CHuiCanvasDebugWsGc::SetInternalGc(CHuiCanvasWsGc* aHuiCanvasGc)
+    {
+    iCanvasWsGc = aHuiCanvasGc;
+    }
+
 void CHuiCanvasDebugWsGc::SetPositionDelta(TPoint& aPoint)
     {
     iCanvasWsGc->SetPositionDelta(aPoint);
@@ -623,7 +633,6 @@
 
 CHuiCanvasDebugWsGc::~CHuiCanvasDebugWsGc()
     {
-    delete iCanvasWsGc;
     }
 
 void CHuiCanvasDebugWsGc::EnableUpdateRegion(const TRegion& aUpdateRegion, TBool aClear)
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvaspainter.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaspainter.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -248,17 +248,31 @@
 TRect CHuiCanvasPainter::CommandBufferCoverage(TInt aOrientation)
     {
     TInt bufferCount = iCommandBuffers.Count();
-    RRegion tempRegion;
+    RRegionBuf<1> tempRegion;
     
     for (TInt cb = 0; cb < bufferCount; cb++)
         {        
         if (iCommandBuffers[cb]->iOrientation == aOrientation)
             {
-            // should this be original display rect or update region
-            tempRegion.AddRect(iCommandBuffers[cb]->iOriginalDisplayRect);
+            // add update region of command buffer to region
+            TRect rect(iCommandBuffers[cb]->iOriginalUpdateRegion.BoundingRect());
+            rect.Move(-iCommandBuffers[cb]->iOriginalDisplayRect.Round().iTl);
+            
+            tempRegion.AddRect(rect);
+            tempRegion.Tidy();
             }
         }    
-    return tempRegion.BoundingRect();
+    
+    if (iCanvasVisual)
+        {
+        TRect displayRect(iCanvasVisual->DisplayRect());
+        tempRegion.ClipRect(TRect(displayRect.Size()));
+        tempRegion.Offset(displayRect.iTl);
+        }
+
+    TRect result = tempRegion.BoundingRect();
+    tempRegion.Close();
+    return result;
     }
 
 void CHuiCanvasPainter::ClearCapturingBufferArea(const TRect& /*aRect*/)
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvaswsbitgc.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswsbitgc.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -156,6 +156,7 @@
             }
         
         iCapturingBitGc->SetClippingRegion(aUpdateRegion);
+        iCapturingBitGc->SetClippingRect(CHuiEnv::Static()->Display(0).CurrentDirtyRect());
         
         TSize visualSize = iVisual->DisplayRect().Size().Round();        
         if (iCapturingBitBitmap->SizeInPixels() != visualSize)
@@ -168,6 +169,7 @@
             iCapturingBitGc->BitBlt(TPoint(0,0), iBitBitmap);
             }
         
+        iCapturingBitGc->CancelClippingRect();
         iCapturingBitGc->CancelClippingRegion();
         }
 
@@ -208,15 +210,5 @@
 
 void CHuiCanvasWsBitGc::ClearCapturingBufferArea(const TRect& aRect)
     {
-    if ( iCapturingBitGc )
-        {
-        TRgb clearColor = KRgbBlack;
-	    clearColor.SetAlpha(0x0);
-        
-	    iCapturingBitGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
-        iCapturingBitGc->SetPenColor(clearColor);
-        iCapturingBitGc->SetBrushColor(clearColor);
-        iCapturingBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
-  	    iCapturingBitGc->Clear(aRect);
-        }
+    
     }
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvaswshwgc.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswshwgc.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -987,9 +987,11 @@
             destinationRect.Move(-dx,-dy);
             
             TRgb oldPenColor = iCanvasGc->PenColor();
+            TReal32 oldOpacity = iCanvasGc->Opacity();
             if (cachedImage->iUseColorModulation)
                 {
                 iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));    
+                iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));
                 }
             
             // Draw            
@@ -998,6 +1000,7 @@
             if (cachedImage->iUseColorModulation)
                 {
                 iCanvasGc->SetPenColor(oldPenColor);                        
+                iCanvasGc->SetOpacity(oldOpacity);
                 }
             }        
         }
@@ -1027,9 +1030,11 @@
             destinationRect.Move(-dx,-dy);
             
             TRgb oldPenColor = iCanvasGc->PenColor();
+            TReal32 oldOpacity = iCanvasGc->Opacity();
             if (cachedImage->iUseColorModulation)
                 {
-                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));    
+                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));
+                iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));    
                 }
             
             // Draw            
@@ -1038,6 +1043,7 @@
             if (cachedImage->iUseColorModulation)
                 {
                 iCanvasGc->SetPenColor(oldPenColor);                        
+                iCanvasGc->SetOpacity(oldOpacity);
                 }
             }
         }
@@ -1068,10 +1074,12 @@
             destinationRect.Move(-dx,-dy);
             
             TRgb oldPenColor = iCanvasGc->PenColor();
+            TReal32 oldOpacity = iCanvasGc->Opacity();
             if (cachedImage->iUseColorModulation)
                 {
                 DrawTextBrush( destinationRect );
-                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));    
+                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));
+                iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));    
                 }
     
             // Draw            
@@ -1079,7 +1087,8 @@
     
             if (cachedImage->iUseColorModulation)
                 {
-                iCanvasGc->SetPenColor(oldPenColor);                        
+                iCanvasGc->SetPenColor(oldPenColor);
+                iCanvasGc->SetOpacity(oldOpacity);                        
                 }
             }
         }
@@ -1114,10 +1123,12 @@
             destinationRect.Move(-dx,-dy);
             
             TRgb oldPenColor = iCanvasGc->PenColor();
+            TReal32 oldOpacity = iCanvasGc->Opacity();
             if (cachedImage->iUseColorModulation)
                 {
                 DrawTextBrush( destinationRect );
-                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));    
+                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));
+                iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));    
                 }
     
             // Draw            
@@ -1125,7 +1136,8 @@
     
             if (cachedImage->iUseColorModulation)
                 {
-                iCanvasGc->SetPenColor(oldPenColor);                        
+                iCanvasGc->SetPenColor(oldPenColor);
+                iCanvasGc->SetOpacity(oldOpacity);                        
                 }
             }    
         }
@@ -1160,10 +1172,12 @@
             destinationRect.Move(-dx,-dy);
             
             TRgb oldPenColor = iCanvasGc->PenColor();
+            TReal32 oldOpacity = iCanvasGc->Opacity();
             if (cachedImage->iUseColorModulation)
                 {
                 DrawTextBrush( destinationRect );
-                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));    
+                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));
+                iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));    
                 }
     
             // Draw            
@@ -1171,7 +1185,8 @@
     
             if (cachedImage->iUseColorModulation)
                 {
-                iCanvasGc->SetPenColor(oldPenColor);                        
+                iCanvasGc->SetPenColor(oldPenColor);
+                iCanvasGc->SetOpacity(oldOpacity);                        
                 }
             }    
         }
@@ -1205,9 +1220,11 @@
             destinationRect.Move(-dx,-dy);
             
             TRgb oldPenColor = iCanvasGc->PenColor();
+            TReal32 oldOpacity = iCanvasGc->Opacity();
             if (cachedImage->iUseColorModulation)
                 {
                 iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));    
+                iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));
                 }
     
             // Draw            
@@ -1215,7 +1232,8 @@
     
             if (cachedImage->iUseColorModulation)
                 {
-                iCanvasGc->SetPenColor(oldPenColor);                        
+                iCanvasGc->SetPenColor(oldPenColor);
+                iCanvasGc->SetOpacity(oldOpacity);                        
                 }
             }    
         }
@@ -1248,9 +1266,11 @@
             destinationRect.Move(-dx,-dy);
             
             TRgb oldPenColor = iCanvasGc->PenColor();
+            TReal32 oldOpacity = iCanvasGc->Opacity();
             if (cachedImage->iUseColorModulation)
                 {
-                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));    
+                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));
+                iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));    
                 }
     
             // Draw            
@@ -1258,7 +1278,8 @@
     
             if (cachedImage->iUseColorModulation)
                 {
-                iCanvasGc->SetPenColor(oldPenColor);                        
+                iCanvasGc->SetPenColor(oldPenColor); 
+                iCanvasGc->SetOpacity(oldOpacity);                       
                 }
             }
         }
@@ -1292,10 +1313,12 @@
             destinationRect.Move(-dx,-dy);
             
             TRgb oldPenColor = iCanvasGc->PenColor();
+            TReal32 oldOpacity = iCanvasGc->Opacity();
             if (cachedImage->iUseColorModulation)
                 {
                 DrawTextBrush( destinationRect );
-                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));    
+                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));  
+                iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));  
                 }
     
             // Draw            
@@ -1303,7 +1326,8 @@
     
             if (cachedImage->iUseColorModulation)
                 {
-                iCanvasGc->SetPenColor(oldPenColor);                        
+                iCanvasGc->SetPenColor(oldPenColor); 
+                iCanvasGc->SetOpacity(oldOpacity);                       
                 }
             }
         }
@@ -1341,10 +1365,12 @@
             destinationRect.Move(-dx,-dy);
             
             TRgb oldPenColor = iCanvasGc->PenColor();
+            TReal32 oldOpacity = iCanvasGc->Opacity();
             if (cachedImage->iUseColorModulation)
                 {
                 DrawTextBrush( destinationRect );
-                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));    
+                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor)); 
+                iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));   
                 }
     
             // Draw            
@@ -1352,7 +1378,8 @@
     
             if (cachedImage->iUseColorModulation)
                 {
-                iCanvasGc->SetPenColor(oldPenColor);                        
+                iCanvasGc->SetPenColor(oldPenColor);
+                iCanvasGc->SetOpacity(oldOpacity);                        
                 }
             }
         }
@@ -1390,10 +1417,12 @@
             destinationRect.Move(-dx,-dy);
             
             TRgb oldPenColor = iCanvasGc->PenColor();
+            TReal32 oldOpacity = iCanvasGc->Opacity();
             if (cachedImage->iUseColorModulation)
                 {
                 DrawTextBrush( destinationRect );
-                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));    
+                iCanvasGc->SetPenColor(ConvertToLinear(iWsPenColor));  
+                iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));  
                 }
     
             // Draw            
@@ -1401,7 +1430,8 @@
     
             if (cachedImage->iUseColorModulation)
                 {
-                iCanvasGc->SetPenColor(oldPenColor);                        
+                iCanvasGc->SetPenColor(oldPenColor);
+                iCanvasGc->SetOpacity(oldOpacity);                        
                 }
             }
         }
@@ -1876,12 +1906,15 @@
     if (aUpdateDisplay && renderbuffer && iCanvasGc->Gc())
         {
         THuiRealRect updatedRect = aUpdateRegion.BoundingRect();
-
+        TInt w = 0; 
+		TInt h = 0;
         // Handle relative rotation
-        TRect displayArea = iVisual->Display()->VisibleArea();
-        TInt w = displayArea.Width();
-        TInt h = displayArea.Height();
-                
+        if (iVisual->Display())
+            {
+            TRect displayArea = iVisual->Display()->VisibleArea();
+            w = displayArea.Width();
+            h = displayArea.Height();
+            }
         // ...select right rotation...
         if (iRelativeOrientation == CHuiGc::EOrientationCW90)
             {
@@ -2103,6 +2136,15 @@
         }
     }
 
+static TRect CalculateClipRect(CHuiCanvasRenderBuffer* aRenderbuffer)
+    {
+    const TInt KHuiDefaultSize = 2048;
+    return 
+        aRenderbuffer && aRenderbuffer->IsInitialized() ? 
+        TRect( aRenderbuffer->Size() ) :
+        TRect( TSize( KHuiDefaultSize, KHuiDefaultSize ) );
+    }
+
 void CHuiCanvasWsHwGc::BindRenderBuffer(CHuiCanvasRenderBuffer* aRenderbuffer, const TRegion& aUpdateRegion)
     {
     // Disable effective opacity when rendering to a buffer
@@ -2125,15 +2167,15 @@
     
     // Set new clipping region which does not clip anything. 
     // We want always draw aUpdateRegion fully to the aRenderbuffer. 
-    TRect displayArea = iCanvasGc->Gc()->DisplayArea(); 
-    
-    iCanvasGc->Gc()->SetClip(displayArea); // this call does not transform region anymore
+            
+    iCanvasGc->Gc()->SetClip(CalculateClipRect(aRenderbuffer)); // this call does not transform region anymore
     
     // We use translation to get screen coordinates to match render buffer coordinates
     iCanvasGc->PushTransformationMatrix();
     iCanvasGc->Translate(x, y, 0.f);
         
     // Handle relative rotation
+    TRect displayArea = iCanvasGc->Gc()->DisplayArea();
     TInt w = displayArea.Width();
     TInt h = displayArea.Height();
     
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -44,6 +44,7 @@
 #ifdef HUI_DEBUG_TRACK_DRAWING
 #include "alfloggingconfiguration.h"
 #include "alfcommanddebug.h"
+#include "huistatictlsdata.h"
 #endif
 #include <e32cmn.h>
 #include <AknLayoutFont.h>
@@ -51,6 +52,15 @@
 
 #include "HuiCmdBufferBrush.h"
 
+#include "alfmoduletestconf.h"
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    // Provides TLS object data for test cases.
+    // This is used only if module test hooks are set on.
+    #include "huistatictlsdata.h"
+#endif // USE_MODULE_TEST_HOOKS_FOR_ALF
+// Provides module test hook defines.
+#include "alfmoduletestdefines.h"
+
 /** 
  * Constants to define enabling/disabling render buffer automatically 
  *  incase there are frequently new buffers posted. 
@@ -117,13 +127,16 @@
         // Never happens, right.
         }
     
-    iWsCommandBufferReader = new (ELeave) CHuiCanvasCmdBufferReader();    
-#ifdef HUI_DEBUG_TRACK_DRAWING
-    iCommandDebugger = CAlfCommandDebug::NewL();
-    CHuiCanvasWsGc* realGc = iCanvasWsGc;
-    iCanvasWsGc = CHuiCanvasDebugWsGc::NewL( realGc, *iCommandDebugger );
+    iWsCommandBufferReader = new (ELeave) CHuiCanvasCmdBufferReader(); 
     
-#endif
+    #ifdef HUI_DEBUG_TRACK_DRAWING
+    if (!iCanvasDebugWsGc)
+        {
+        iCanvasDebugWsGc = CHuiCanvasDebugWsGc::NewL( iCanvasWsGc, *TTlsData::CommandDebugger() );
+        iCanvasWsGc = iCanvasDebugWsGc;
+        }
+    
+    #endif
     }
 
 
@@ -148,7 +161,7 @@
     iTempCurrentSubRegion.Close();
     iTempIntersectingRegion.Close();
 #ifdef HUI_DEBUG_TRACK_DRAWING
-    delete iCommandDebugger;
+    delete iCanvasDebugWsGc;
 #endif
     iFullUpdateRegion.Close();
     iShapeRegion.Close();
@@ -246,6 +259,9 @@
         // Initialize canvas
         canvasGc.SetDefaults();   
 
+        // Ensure that all regions have been shifted to correct origin (before calculating iFullUpdateRegion).
+        UpdateBufferUpdateRegions(aPos);
+        
         // Make sure we got up to date update reagion
         iFullUpdateRegion.Clear();                
         TInt bufferCount = iCommandBuffers.Count();
@@ -313,7 +329,6 @@
             /* Begin draw. If render buffer is used this sets up the render buffer if needed */
             iCanvasWsGc->BeginActionL(aAction,aDisplayRect,aUser,cachePrepared,iFullUpdateRegion);                   
 
-            TBool isFullUpdateRegionCleared = EFalse;
             if(iShapeRegionClearingPending)
                 {
                 #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
@@ -323,7 +338,6 @@
                 TBool doClear = ETrue;
                 iCanvasWsGc->EnableUpdateRegion(iFullUpdateRegion, doClear);
                 iCanvasWsGc->DisableUpdateRegion(); 
-                isFullUpdateRegionCleared = ETrue;
                 iShapeRegionClearingPending = EFalse;
                 }
 
@@ -472,9 +486,7 @@
                                                TBool aIgnoreClippedBuffers, 
                                                TBool aIgnoreHandledBuffers,
                                                TBool aClearBeforeHandlingBuffers) 
-    {   
-    UpdateBufferUpdateRegions(aPos);
-
+    {
     TInt bufferCount = iCommandBuffers.Count();
     for (TInt cb = 0; cb < bufferCount; cb++)
         {
@@ -558,6 +570,12 @@
             
             // Clip drawing to update area. This seems to improve performance although
             // it may depend on used HW.
+
+            // Set position delta to zero, otherwise updateregion is adjusted incorrectly
+            // in SW mode. No effect on HW mode as it does not adjust the updateregion in
+            // EnableUpdateRegion call...
+            TPoint delta(0,0);
+            iCanvasWsGc->SetPositionDelta(delta);
             iCanvasWsGc->EnableUpdateRegion(iCommandBuffers[cb]->iUpdateRegion, aClearBeforeHandlingBuffers);
 
             #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
@@ -623,6 +641,23 @@
     CleanupStack::PopAndDestroy();
     }
 
+void CHuiCanvasWsPainter::DoPeekBufferAndUpdateShapeRegionL()
+    {
+    TBool hadShapeRegion = iShapeRegionAvailable;
+    iShapeRegionAvailable = EFalse;
+    
+    TInt latest = iCommandBuffers.Count() - 1;    
+    DoPeekBufferL(latest);
+    
+    if (hadShapeRegion && !iShapeRegionAvailable)
+        {
+        // Previously we had shape region, but not any more.
+        // So refresh update regions.
+        iShapeRegionClearingPending = ETrue;
+        iShapeRegionClippingPending = ETrue;        
+        }
+    }
+
 void CHuiCanvasWsPainter::DoPeekBufferL(TInt aIndex) 
     {   
     RMemReadStream& readerStream = iWsCommandBufferReader->Stream();
@@ -736,7 +771,7 @@
             }
         }
 
-    iCommandDebugger->StartFrame();
+    TTlsData::CommandDebugger()->StartFrame();
     if ( commandBuffer->iProcessName )
         {
         // UNCOMMENT THIS IF YOU WANT TO PRINT EVERYTHING
@@ -772,7 +807,7 @@
         {
         command = readerStream.ReadUint8L();
 #ifdef HUI_DEBUG_TRACK_DRAWING
-        iCommandDebugger->SetDescription( command );
+        TTlsData::CommandDebugger()->SetDescription( command );
 #endif
 
 		// Command cases are ordered approximately in the order so that most common ones are at first
@@ -1261,7 +1296,7 @@
        	
         } while( offset < bufLength );
 #ifdef HUI_DEBUG_TRACK_DRAWING
-    iCommandDebugger->EndFrame();
+    TTlsData::CommandDebugger()->EndFrame();
 #endif    
     }
     
@@ -1270,22 +1305,13 @@
     {
 	CHuiCanvasPainter::SetCommandSetL(aCommands);  
 
-    TInt latest = iCommandBuffers.Count() - 1;
-    DoPeekBufferL(latest);
+    DoPeekBufferAndUpdateShapeRegionL();
     SelectGcL();
        
     // If shape region has changed recalculate all update regions and remove redundant buffers
     if (iShapeRegionClippingPending)
         {
-        TInt bufferCount = iCommandBuffers.Count();
-        for (TInt cb = 0; cb < bufferCount; cb++)
-            {        
-            CHuiCanvasCommandBuffer* cmdbuffer = iCommandBuffers[cb];
-            cmdbuffer->iUpdateRegion.Copy(cmdbuffer->iOriginalUpdateRegion);                
-            cmdbuffer->iUpdateRegion.Intersect(iShapeRegion);
-            cmdbuffer->iUpdateRegion.Tidy();
-            }
-        iShapeRegionClippingPending = EFalse;       
+        ApplyShapeRegion();       
         RemoveRedundantBuffers();   
         }    
     
@@ -1307,8 +1333,11 @@
 #endif
 
     CHuiCanvasPainter::ClearCommandSet();
+    
+    iShapeRegionAvailable = EFalse;
+    
     // Release currently cached images. 
-    // They may still be taken into use after next HandleBuffferL call.
+    // They may still be taken into use after next HandleBufferL call.
     if (iCanvasVisual)
         {
         iCanvasVisual->Env().CanvasTextureCache().ReleaseAllCachedEntries(*iCanvasVisual); 
@@ -1338,23 +1367,10 @@
 #endif
 
     CHuiCanvasPainter::AddCommandSetL(aMoreCommands);
-    TInt latest = iCommandBuffers.Count() - 1;
-    DoPeekBufferL(latest);     
+    DoPeekBufferAndUpdateShapeRegionL();
     SelectGcL();
     
-    // If shape region has changed recalculate all update regions
-    if (iShapeRegionClippingPending)
-        {
-        TInt bufferCount = iCommandBuffers.Count();
-        for (TInt cb = 0; cb < bufferCount; cb++)
-            {        
-            CHuiCanvasCommandBuffer* cmdbuffer = iCommandBuffers[cb];
-            cmdbuffer->iUpdateRegion.Copy(cmdbuffer->iOriginalUpdateRegion);                
-            cmdbuffer->iUpdateRegion.Intersect(iShapeRegion);
-            cmdbuffer->iUpdateRegion.Tidy();
-            }
-        iShapeRegionClippingPending = EFalse;       
-        }    
+    ApplyShapeRegion();
     
     RemoveRedundantBuffers();   
     
@@ -2134,7 +2150,7 @@
     if (aIndex==-1) return; //TP
     // Update region is modified when new buffers are added after this buffer, 
     // so store the region only at first read. 
-    if (iCommandBuffers[aIndex]->iChanged && iCommandBuffers[aIndex]->iUpdateRegion.Count() == 0)
+    if (iCommandBuffers[aIndex]->iChanged && iCommandBuffers[aIndex]->iOriginalUpdateRegion.Count() == 0)
         {
         // Check first that the coordiates are not insane (sometimes thay are)
         TInt count = iTempRegion.Count();                    
@@ -2142,27 +2158,19 @@
         for (TInt i=count-1; i>=0; i--)
             {
             TRect rect = iTempRegion[i];
-            TRect screen = iCanvasVisual->Display()->VisibleArea();
-            if (rect.Intersects(screen) || rect == screen)
-                {
-                // - Sometimes updateregion is outiside window (WSERV...why?!) 
-                //   We clip it here to avoid ui probs.
-				// - Lets remove this for now, this seems to break scrollbars again
-				//   when window parent-child relations work..
-				// - Hmm, should we add this anyway because now the idle softkeys are lost again in landscape mode ?
-				// - Added again after WSERV fix in the window parent-child relations
+
+            // - Sometimes updateregion is outiside window (WSERV...why?!) 
+            //   We clip it here to avoid ui probs.
+            // - Lets remove this for now, this seems to break scrollbars again
+            //   when window parent-child relations work..
+            // - Hmm, should we add this anyway because now the idle softkeys are lost again in landscape mode ?
+            // - Added again after WSERV fix in the window parent-child relations
+            // - Rect may be outside the screen and that's fine (Visual may be moved later).
 #ifndef HUI_DISABLE_CANVAS_VISUAL_CLIPPING
-                rect.Intersection(displayRect); 
+            rect.Intersection(displayRect); 
 #endif                
-                iCommandBuffers[aIndex]->iUpdateRegion.AddRect(rect);    
-                iCommandBuffers[aIndex]->iOriginalUpdateRegion.AddRect(rect);    
-                }
-            else
-                {
-#ifdef _DEBUG
-                RDebug::Print(_L("CHuiCanvasWsPainter::WsSetUpdateRegionL: Incorrect update region removed from buffer, this should not happen !"));
-#endif
-                }
+            iCommandBuffers[aIndex]->iUpdateRegion.AddRect(rect);    
+            iCommandBuffers[aIndex]->iOriginalUpdateRegion.AddRect(rect);    
             }                
         
         // Combine areas that are next to each others
@@ -2210,16 +2218,19 @@
         iShapeRegion.Copy(iTempRegion);
 
         // note: iUpdateRegion will be updated later, set flags to indicate pending
+        iShapeRegionAvailable = ETrue;
+        iShapeRegionOrigin = iCanvasVisual->DisplayRect().Round().iTl;
+        
         iShapeRegionClearingPending = ETrue;
-        iShapeRegionClippingPending = ETrue;        
-       }
+        iShapeRegionClippingPending = ETrue;
+        }
     
 	
     #ifdef _DEBUG
     if (iShapeRegion.Count() == 0 && iTempRegion.Count() > 0)
         {
         HUI_DEBUG(_L("CHuiCanvasWsPainter::WsSetShapeRegionL. Error: iShapeRegion not set by any command buffer! However, there exists at least one command buffer that has shape region command."));
-         }
+        }
     #endif
     }
 
@@ -2268,9 +2279,9 @@
     
     RemoveBuffersWithoutRealDrawing();
 
-    // Remove buffers only with moved display rect and modify the clip region
-    // of buffers with changed size instead of completely removing all. 
-    RemoveBuffersWithMovedDisplayRect();
+    // Don't remove command buffers with modified display rect.
+	// Instead, apply clipping.
+    //RemoveBuffersWithMovedDisplayRect();
     ModifyBuffersWithChangedDisplayRect();
     //RemoveBuffersWithOldDisplayRect();
     
@@ -2304,16 +2315,32 @@
     TInt bufferCount = iCommandBuffers.Count();
     TRect canvasRect = iCanvasVisual->DisplayRect().Round();
     TRegionFix<1> region(canvasRect);
+
+    // We must first offset to canvasRect.iTl, otherwise region clipping doesn't work.
+    UpdateBufferUpdateRegions(canvasRect.iTl);
     
     // If the buffers have different update region than CanvasVisual, clip
     // the drawing to canvas visual's & cmdbuffer's updateregions' intersection.
     for (TInt cb = 0; cb < bufferCount; cb++)
         {
         CHuiCanvasCommandBuffer* cmdbuffer = iCommandBuffers[cb];
-        if (cmdbuffer->iOriginalDisplayRect.Round() != canvasRect)
+        TRect bufRect = cmdbuffer->iOriginalDisplayRect.Round();
+                
+        if (bufRect != canvasRect)
             {
             cmdbuffer->iUpdateRegion.Copy(cmdbuffer->iOriginalUpdateRegion);
+            
+            TPoint deltaPos = cmdbuffer->iPositionForUpdateRegion - cmdbuffer->iOriginalDisplayRect.Round().iTl;
+            cmdbuffer->iUpdateRegion.Offset(deltaPos);
+            
             cmdbuffer->iUpdateRegion.Intersect(region);
+            
+            if ( iShapeRegionAvailable )
+                {
+                TranslateShapeRegion(cmdbuffer->iPositionForUpdateRegion);
+                cmdbuffer->iUpdateRegion.Intersect(iShapeRegion);
+                }
+            
             cmdbuffer->iUpdateRegion.Tidy();
             }
         }
@@ -2379,11 +2406,16 @@
                 }
             
             CHuiCanvasCommandBuffer* cmdbuffer = iCommandBuffers[cb];
+            // Translate region to be relative to visual top left corner.
+            TPoint offset = -cmdbuffer->iOriginalDisplayRect.Round().iTl;
+
             for (TInt j=0; j < cmdbuffer->iOriginalUpdateRegion.Count();j++)
                 {
-                iTempRegion.AddRect(cmdbuffer->iOriginalUpdateRegion[j]);        
+                TRect rect = cmdbuffer->iOriginalUpdateRegion[j];
+                rect.Move(offset);
+                iTempRegion.AddRect(rect);
                 }
-                       
+                        
             // Check older buffers for overlapping regions against current buffer
             if (cb > 0)
                 {                   
@@ -2394,19 +2426,26 @@
                         break;    
                         }
 
-                    CHuiCanvasCommandBuffer* previousCommands = iCommandBuffers[i];            
+                    CHuiCanvasCommandBuffer* previousCommands = iCommandBuffers[i];
+                    TPoint previousCommandsOffset = previousCommands->iOriginalDisplayRect.Round().iTl;
+                    
                     // Keep count how many subregions of the prevous command are contained inside current command buffer region
                     TInt coveredRegionCount = 0;                    
                     for (TInt k=0; k < previousCommands->iOriginalUpdateRegion.Count();k++)
                         {
                         iTempCurrentSubRegion.Clear();
                         iTempIntersectingRegion.Clear();                                               
-                        iTempCurrentSubRegion.AddRect(previousCommands->iOriginalUpdateRegion[k]);                        
+                        iTempCurrentSubRegion.AddRect(previousCommands->iOriginalUpdateRegion[k]);
+                                                
+                        iTempCurrentSubRegion.Offset(-previousCommandsOffset);
+                        
                         iTempIntersectingRegion.Intersection(iTempRegion, iTempCurrentSubRegion);
                         iTempIntersectingRegion.Tidy();
                         
                         if (iTempIntersectingRegion.Count() == 1)
                             {
+                            iTempIntersectingRegion.Offset(previousCommandsOffset);
+                        
                             if (iTempIntersectingRegion[0] == previousCommands->iOriginalUpdateRegion[k])
                                 {
                                 coveredRegionCount++;
@@ -2432,6 +2471,45 @@
         }
     }
 
+void CHuiCanvasWsPainter::ApplyShapeRegion()
+    {
+    // If shape region has changed recalculate all update regions
+    if (iShapeRegionClippingPending)
+        {
+        TRect canvasRect = iCanvasVisual->DisplayRect().Round();
+
+        // We must first offset to canvasRect.iTl, otherwise region clipping doesn't work.
+        UpdateBufferUpdateRegions(canvasRect.iTl);
+
+        TInt bufferCount = iCommandBuffers.Count();
+        for (TInt cb = 0; cb < bufferCount; cb++)
+            {        
+            CHuiCanvasCommandBuffer* cmdbuffer = iCommandBuffers[cb];
+            cmdbuffer->iUpdateRegion.Copy(cmdbuffer->iOriginalUpdateRegion);                
+
+            TPoint deltaPos = cmdbuffer->iPositionForUpdateRegion - cmdbuffer->iOriginalDisplayRect.Round().iTl;
+            cmdbuffer->iUpdateRegion.Offset(deltaPos);
+
+            if ( iShapeRegionAvailable )
+                {
+                TranslateShapeRegion(cmdbuffer->iPositionForUpdateRegion);                 
+                cmdbuffer->iUpdateRegion.Intersect(iShapeRegion);
+                }
+            cmdbuffer->iUpdateRegion.Tidy();
+            }
+        iShapeRegionClippingPending = EFalse;       
+        }    
+    }
+    
+void CHuiCanvasWsPainter::TranslateShapeRegion(const TPoint& aNewOrigin)
+    {
+    if (iShapeRegionOrigin != aNewOrigin)
+        {
+        iShapeRegion.Offset(aNewOrigin - iShapeRegionOrigin);
+        iShapeRegionOrigin = aNewOrigin;
+        }
+    }
+
 CHuiCanvasGc& CHuiCanvasWsPainter::CanvasGc() const
 	{
 	return iCanvasWsGc->CanvasGc();
@@ -2684,9 +2762,19 @@
         }
 
     #ifdef HUI_DEBUG_TRACK_DRAWING
-    CHuiCanvasWsGc* realGc = iCanvasWsGc;
-    iCanvasWsGc = CHuiCanvasDebugWsGc::NewL( realGc, *iCommandDebugger );
+    if (!iCanvasDebugWsGc)
+        {
+        iCanvasDebugWsGc = CHuiCanvasDebugWsGc::NewL( iCanvasWsGc, *TTlsData::CommandDebugger() );
+        }
+    else if(iCanvasWsGc!=iCanvasDebugWsGc) 
+        {
+        iCanvasDebugWsGc->SetInternalGc(iCanvasWsGc);
+        }
+    
+    iCanvasWsGc = iCanvasDebugWsGc;
     #endif
+    
+    AMT_MAP_CANVAS_WS_PAINTER_SELECT_GC();
     }
 
 void CHuiCanvasWsPainter::RenewAllBuffers()
@@ -2704,18 +2792,28 @@
 	{
 	// iUpdateRegion is in screen coordinates. If visual moves position, iUpdateRegion 
 	// should be updated as well. Otherwise visual will encounter clipping.
-    for (TInt cb = 0; cb < iCommandBuffers.Count(); cb++)
+    TBool updated = EFalse;
+	
+	for (TInt cb = 0; cb < iCommandBuffers.Count(); cb++)
         {
 		if (iCommandBuffers[cb]->iPositionForUpdateRegion != aPos && !iCommandBuffers[cb]->iUpdateRegion.IsEmpty() )
 			{
+			updated = ETrue;
+			
 			TPoint deltaPos = aPos - iCommandBuffers[cb]->iPositionForUpdateRegion;
 			iCommandBuffers[cb]->iUpdateRegion.Offset(deltaPos);
 			iCommandBuffers[cb]->iPositionForUpdateRegion = aPos;
-			iCommandBuffers[cb]->ClearStatusFlags(EHuiCanvasBufferStatusAll);
-			iCommandBuffers[cb]->SetStatusFlags(EHuiCanvasBufferStatusNew);
 			}
+		
+		if (updated)
+		    {
+            // If one command buffer is drawn, then all following command
+            // buffers must be redrawn as well.
+            iCommandBuffers[cb]->ClearStatusFlags(EHuiCanvasBufferStatusAll);
+            iCommandBuffers[cb]->SetStatusFlags(EHuiCanvasBufferStatusNew);			
+            }
         }
-	}
+    }
 
 void CHuiCanvasWsPainter::SetMemoryLevel(THuiMemoryLevel /*aLevel*/)
     {
--- a/uiacceltk/hitchcock/goommonitor/data/goomconfig.xml	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/data/goomconfig.xml	Thu Jul 22 16:43:39 2010 +0100
@@ -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 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomactionlist.h	Thu Jul 22 16:43:39 2010 +0100
@@ -263,8 +263,11 @@
     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
+    TUint iAppIndex;
     };
 
 #include "goomactionlist.inl"
--- a/uiacceltk/hitchcock/goommonitor/inc/goomactionref.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomactionref.h	Thu Jul 22 16:43:39 2010 +0100
@@ -23,6 +23,7 @@
 #include "goomactionconfig.h"
 
 class CGOomRunPlugin;
+class CGOomAction;
 
 /**
  *  Encapsulates a reference to an action. 
@@ -61,6 +62,7 @@
     CGOomRunPlugin& RunPlugin();
     TInt CloseTimeout() const;
     TInt WaitAfterClose() const;
+    TBool IsRunning();
 
 private: //data
     
@@ -73,6 +75,8 @@
     CGOomRunPlugin* iRunPlugin; //For Plugins. Not owned
     TInt iCloseTimeout; //For AppClose
     TInt iWaitAfterClose; //For AppClose
+public:
+    CGOomAction* iAppPlugin; // because of stupid desing, not owned
     };
 
 #endif /*GOOMACTIONREF_H_*/
--- a/uiacceltk/hitchcock/goommonitor/inc/goomcloseapp.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomcloseapp.h	Thu Jul 22 16:43:39 2010 +0100
@@ -71,6 +71,10 @@
 
     inline TUint WgId() const;
     
+    
+    /** Ask nice */
+    void ConditionalClose();
+    
     /** When the gentle push is not enough (i.e. force is required) **/
     void KillTask();
     
@@ -100,6 +104,8 @@
      * Own
      */
     CGOomAppCloseWatcher* iAppCloseWatcher; 
+    
+    TBool iAlreadyGaveUp;
     };
 
 #include "goomcloseapp.inl"
--- a/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h	Thu Jul 22 16:43:39 2010 +0100
@@ -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);
@@ -91,9 +99,10 @@
     void SessionInCriticalAllocation(TBool aPostponeMemGood, TUint aClientId)
         {
         FUNC_LOG;
+        TInt oldCount = iClientsRequestingMemory.Count();
+        
         if (aPostponeMemGood)
             {
-            iPostponeMemGood++;
             if(iClientsRequestingMemory.Find(aClientId) == KErrNotFound)
                 iClientsRequestingMemory.Append(aClientId);
             
@@ -101,21 +110,20 @@
             }
         else
             {
-            iPostponeMemGood--;
+            if(aClientId == 0)
+                {
+                iClientsRequestingMemory.Reset();
+                }
+            
             TInt idx = iClientsRequestingMemory.Find(aClientId);
             if(idx != KErrNotFound)
                 {
                 iClientsRequestingMemory.Remove(idx);
                 TRACES2("SessionInCriticalAllocation : ENDING Critical Allocations for Client %x, ClientsRequestingMemory Count %d", aClientId, iClientsRequestingMemory.Count());
                 }
-            
-             if(iPostponeMemGood<0)
-                {
-                iPostponeMemGood = 0;
-                }
             }
         TRACES1("SessionInCriticalAllocation : ClientsRequestingMemory Count %d", iClientsRequestingMemory.Count());    
-        if (iClientsRequestingMemory.Count() == 0)
+        if (oldCount && iClientsRequestingMemory.Count() == 0)
             {
             DoPostponedMemoryGood();
             }
@@ -126,13 +134,14 @@
     
     TBool NeedToPostponeMemGood()
         {
-        //return (iPostponeMemGood != 0);
         return (iClientsRequestingMemory.Count() != 0);
         } 
     
     void WaitAndSynchroniseMemoryState();
     void SynchroniseMemoryState();
     
+    void SwitchMemMode(TGOomMemMode aMemMode);
+    
 private:
     CMemoryMonitor();
     void ConstructL();
@@ -201,13 +210,19 @@
     CGoomThresholdCrossed* iMemAllocationsGoingDown;
     
     TInt iForegroundAppUid;
-    TInt iPostponeMemGood;
     
     RArray<TUint> iClientsRequestingMemory;
     
     TGOomTrigger iTrigger;
     
     CGOomSynchTimer* iSynchTimer;
+    
+    TBool iMemMode;
+    TBool iForegroundAppHasChanged;
+    
+    TInt iRendswitched;
+    
+    RArray<TInt> iLowOnMemWgs;
     };
 
 
--- a/uiacceltk/hitchcock/goommonitor/inc/goomwindowgrouplist.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomwindowgrouplist.h	Thu Jul 22 16:43:39 2010 +0100
@@ -42,10 +42,10 @@
     static CGOomWindowGroupList* NewL(RWsSession& aWs);
     
     // Update the list of window groups
-    void RefreshL();
+    void RefreshL(TBool aOptionalOnly = EFalse);
     
     // Update the list of window groups, non-leaving version
-    void Refresh();
+    void Refresh(TBool aOptionalOnly = EFalse);
     
     // Return the number of application instances in this list
     inline TUint Count() const;
@@ -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,8 +90,10 @@
             return iLowOnMemWgs[aIndex];
             }
         }
-
+*/
+    TInt FindParentIdL(TInt aWgId);    
     
+    void GetListOfWindowGroupsWSurfaces(RArray<TInt>& aLowOnMemWgs);
     
 private:    
 
@@ -99,7 +101,6 @@
     
     void RemovePropertiesForClosedWindowsL();
 
-    TInt FindParentIdL(TInt aWgId);
 
 private:
     
@@ -133,6 +134,7 @@
     CApaWindowGroupName* iWgName;
     HBufC* iWgNameBuf;              // owned by iWgName
     RArray<TInt> iLowOnMemWgs;
+    RArray<TInt> iOptionalUids;
     RAlfBridgerClient iAlfClient;
     };
 
--- a/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -214,11 +214,12 @@
     {
     FUNC_LOG;
     
-//    iActionRefs.Reset();
-//    iCurrentActionIndex = 0;
+    // we can't reset action index here because plugins would miss memory good events
+
+    iAppIndex = 0;
     
-    aWindowGroupList.RefreshL();
-    
+    aWindowGroupList.RefreshL(iTryOptional);
+/*    
     for (TInt i = 0; aWindowGroupList.LowOnMemWgs(i) != KErrNotFound ; i++ )
         {
         if ( iLowOnMemWgs.Find(aWindowGroupList.LowOnMemWgs(i)) == KErrNotFound)
@@ -226,7 +227,7 @@
             iLowOnMemWgs.Append(aWindowGroupList.LowOnMemWgs(i));    
             }
         }
-        
+*/        
     iRunningKillAppActions = ETrue;
     
     if (aWindowGroupList.Count())
@@ -303,6 +304,7 @@
                     TInt err = iActionRefs.InsertInOrder(ref, ComparePriorities);
                     if ((err != KErrNone) && (err != KErrAlreadyExists))
                         {
+                        TRACES3("BuildActionListL: Adding app to action list, Uid = %x, wgId = %d, err = %d", appId, wgId, err);
                         User::Leave(err);
                         }
                     TRACES3("BuildActionListL: Adding app to action list, Uid = %x, wgId = %d, wgIndex = %d", appId, wgId, wgIndex);
@@ -352,25 +354,70 @@
         
         TActionRef ref = iActionRefs[iCurrentActionIndex];
         CGOomAction* action = NULL;
-        if (ref.Type() == TActionRef::EAppClose)
-            {
-            action = iCloseAppActions[numberOfRunningActions];
+        if (ref.Type() == TActionRef::EAppClose )
+            {     
+            iAppIndex%=iCloseAppActions.Count();
+            TRACES2("Proceeding with app action from index %d, out of %d", iAppIndex, iCloseAppActions.Count() );
+            action = iCloseAppActions[iAppIndex];
+            iAppIndex++;
             static_cast<CGOomCloseApp*>(action)->Reconfigure(ref);
             
+            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);
-            
-            CleanupStack::PopAndDestroy();
+                  
             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)
+                {
+                iCurrentActionIndex++;
+                if (iCurrentActionIndex >= iActionRefs.Count())
+                    {
+                    StateChanged();
+                    return;
+                    }
+                else
+                    {    
+                    continue;
+                    }
+                }
             }
         else
             {
@@ -426,11 +473,23 @@
     if (!memoryFreeingActionRun)
         {
         // No usable memory freeing action has been found, so we give up
-        TRACES("CGOomActionList::FreeMemory: No usable memory freeing action has been found");
         TInt freeMemory;
-        FreeMemoryAboveTarget(freeMemory);
-        iServer.CloseAppsFinished(freeMemory, EFalse);
-        iMonitor.WaitAndSynchroniseMemoryState();
+
+        if ( !FreeMemoryAboveTarget(freeMemory) && !iTryOptional && !iOptionalTried && freeMemory < 25*1024*1024 ) // magic, should read this from config
+            { 
+            iTryOptional = ETrue;
+            iOptionalTried = ETrue;
+            iMonitor.RunCloseAppActions(iMaxPriority);
+            }
+        else
+            {
+            iTryOptional = EFalse;
+            iOptionalTried = EFalse;
+            TRACES("CGOomActionList::FreeMemory: No usable memory freeing action has been found");
+            iFreeingMemory = EFalse;
+            iServer.CloseAppsFinished(freeMemory, EFalse);
+            iMonitor.WaitAndSynchroniseMemoryState();
+            }
         }
     }
 
@@ -439,7 +498,8 @@
 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
@@ -452,7 +512,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
 
@@ -462,7 +525,8 @@
         iWs.SendEventToWindowGroup(iLowOnMemWgs[i], event);
 #endif // #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
         iLowOnMemWgs.Remove(i);
-		}    
+		}
+*/		    
     }
 
 TBool CGOomActionList::FreeMemoryAboveTarget(TInt& aFreeMemory)
@@ -567,9 +631,13 @@
     FUNC_LOG;
 
     TInt index = iCloseAppActions.Count();
+    TRACES1("CGOomCloseApp::AppNotExiting: count of actions %d",index);
+
     while (index--)
         {
         CGOomCloseApp* action = iCloseAppActions[index];
+        TRACES3("CGOomCloseApp::AppNotExiting: %d %d %d", aWgId, action->WgId(), action->IsRunning());
+        
         if ( (action->WgId() == aWgId) && (action->IsRunning()) )
             {
             TRACES1("CGOomCloseApp::AppNotExiting: App with window group id %d has not responded to the close event", aWgId);
@@ -586,23 +654,12 @@
 
     TBool allActionsComplete = ETrue;
 
-    // Note that the actions themselves are responsible for timing out if necessary.
-    TInt index = iCloseAppActions.Count();
-    while ((index--) && (allActionsComplete))
+    TInt index = iActionRefs.Count();
+	while ((index--) && (allActionsComplete))
         {
-        if (iCloseAppActions[index]->IsRunning())
+        if (iActionRefs[index].IsRunning())
             {
-            TRACES1("CGOomActionList::StateChanged. CloseAppAction %d STILL RUNNING. PROBLEM !!! YOU SHOULD NEVER SEE THIS", index);
-            allActionsComplete = EFalse;
-            }
-        }
-
-    index = iRunPluginActions.Count();
-    while ((index--) && (allActionsComplete))
-        {
-        if (iRunPluginActions[index]->IsRunning())
-            {
-            TRACES1("CGOomActionList::StateChanged. PluginAction %d STILL RUNNING. PROBLEM !!! YOU SHOULD NEVER SEE THIS", index);
+            TRACES1("CGOomActionList::StateChanged. Action %d STILL RUNNING.", index);
             allActionsComplete = EFalse;
             }
         }
@@ -620,49 +677,44 @@
             // If we are still below the good-memory-threshold then continue running actions
             {            
             TRACES2("CGOomActionList::StateChanged: Finished Action %d out of %d",iCurrentActionIndex, iActionRefs.Count());
-            
-            
-            if (iCurrentActionIndex >= iActionRefs.Count())
+
+            if (iCurrentActionIndex < iActionRefs.Count())
                 {
-                if(iRunningKillAppActions)
+                // 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;
+
+                if (!iTryOptional && !iOptionalTried && freeMemory < 25*1024*1024 ) // magic, should read this from config
+                    { 
+                    iTryOptional = ETrue;
+                    iOptionalTried = ETrue;
+                    iMonitor.RunCloseAppActions(iMaxPriority);
+                    }
+                else
                     {
-                    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);
-                    
-                    /* Do not call memory good immidiately after freeing memory for some app
-                    if (freeMemory >= iCurrentTarget && !iMonitor.NeedToPostponeMemGood())
-                    {                    
-                    MemoryGood();
-                    }
-                     */
+                    iTryOptional = EFalse;       
                     iServer.CloseAppsFinished(freeMemory, EFalse);
                     iMonitor.WaitAndSynchroniseMemoryState();
                     }
-                else
-                    {
-                    TRACES1("CGOomActionList::StateChanged: All current Plugin actions complete, below good threshold, Time to kill bad guys. freeMemory=%d", freeMemory);
-                    iRunningKillAppActions = ETrue;
-                    iMonitor.RunCloseAppActions(iMaxPriority);
-                    }
-                
                 }
             else
                 {
-                // There are still more actions to try, so we continue
-                TRACES1("CGOomActionList::StateChanged: All current actions complete, running more actions. freeMemory=%d", freeMemory);
-                FreeMemory(iMaxPriority);
+                TRACES1("CGOomActionList::StateChanged: All current Plugin actions complete, below good threshold, Time to kill bad guys. freeMemory=%d", freeMemory);
+                iRunningKillAppActions = ETrue;
+                iMonitor.RunCloseAppActions(iMaxPriority);
                 }
+        
             }
         else
             {
             TRACES1("CGOomActionList::StateChanged: All current actions complete, memory good. freeMemory=%d", freeMemory);
-            /* Do not call memory good immidiately after freeing memory for some app
-			if(freeMemory > iMonitor.GetGoodThreshold() && !iMonitor.NeedToPostponeMemGood())
-                {
-                MemoryGood();
-                }
-            */
             iRunningKillAppActions = EFalse;
             iServer.CloseAppsFinished(freeMemory, ETrue);
             iMonitor.WaitAndSynchroniseMemoryState();
--- a/uiacceltk/hitchcock/goommonitor/src/goomactionref.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/src/goomactionref.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -17,14 +17,15 @@
 
 
 #include "goomactionref.h"
+#include "goomrunplugin.h"
 
 TActionRef::TActionRef(TActionType aType, TInt aPriority, TGOomSyncMode aSyncMode, TInt aRamEstimate, CGOomRunPlugin& aRunPlugin, TUint aWgIndexOfTargetApp)
-    : iType(aType), iPriority(aPriority), iSyncMode(aSyncMode), iRamEstimate(aRamEstimate), iWgIndex(aWgIndexOfTargetApp), iRunPlugin(&aRunPlugin)
+    : iType(aType), iPriority(aPriority), iSyncMode(aSyncMode), iRamEstimate(aRamEstimate), iWgIndex(aWgIndexOfTargetApp), iRunPlugin(&aRunPlugin), iAppPlugin(0)
     {   
     }
 
 TActionRef::TActionRef(TActionType aType, TInt aPriority, TGOomSyncMode aSyncMode, TInt aRamEstimate, TInt aWgId, TUint aWgIndex, TInt aCloseTimeout, TInt aWaitAfterClose)
-: iType(aType), iPriority(aPriority), iSyncMode(aSyncMode), iRamEstimate(aRamEstimate), iWgId(aWgId), iWgIndex(aWgIndex), iRunPlugin(NULL), iCloseTimeout(aCloseTimeout), iWaitAfterClose(aWaitAfterClose)
+: iType(aType), iPriority(aPriority), iSyncMode(aSyncMode), iRamEstimate(aRamEstimate), iWgId(aWgId), iWgIndex(aWgIndex), iRunPlugin(NULL), iCloseTimeout(aCloseTimeout), iWaitAfterClose(aWaitAfterClose), iAppPlugin(0)
     {   
     }
 
@@ -78,3 +79,16 @@
     {
     return *iRunPlugin;
     }
+
+TBool TActionRef::IsRunning()
+    {
+    if (iRunPlugin)
+        {
+        return iRunPlugin->IsRunning();
+        }
+    else if (iAppPlugin)
+        {
+        return iAppPlugin->IsRunning();
+        }
+    return EFalse;
+    }         
--- a/uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -18,6 +18,8 @@
 
 #include <apgtask.h>
 
+#include "goommemorymonitor.h"
+#include "goomwindowgrouplist.h"
 #include "goomcloseapp.h"
 #include "goomtraces.h"
 #include "goomappclosetimer.h"
@@ -42,18 +44,38 @@
     {
     FUNC_LOG;
 
+    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)
+        	{
+			iAppCloseTimer->Cancel();
+    		}
+			
+    	if (iAppCloseWatcher)
+        	{
+			iAppCloseWatcher->Cancel();
+			}
+			
+		RDebug::Printf("GOOM: I should not activate actions for app that already refused to exit !!!!");
+        MemoryFreed(KErrNone);
+        return;
+        }    
+
     iAppCloserRunning = ETrue;
     
     // Set the TApaTask to the app
     iCurrentTask.SetWgId(iWgId);
     
     // Start a timer and the thread watcher 
-    iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppClosing);
+    /*
+	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()
@@ -77,19 +99,19 @@
 
     // The application has closed (or we have a timeout)
     iAppCloserRunning = EFalse;
+    iAlreadyGaveUp = ETrue;
     
     if (iAppCloseTimer)
         {
-            iAppCloseTimer->Cancel();
-            iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppKilled);
-            iAppCloseTimer->After(iWaitAfterClose * 1000);
+        iAppCloseTimer->Cancel();
+        iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppKilled);
+        iAppCloseTimer->After(iWaitAfterClose * 1000);
         }
     
     if (iAppCloseWatcher)
+        {
         iAppCloseWatcher->Cancel(); 
-    
-    
-    //MemoryFreed(KErrNone);
+        }    
     }
 
 void CGOomCloseApp::Reconfigure(const TActionRef& aRef)
@@ -99,6 +121,7 @@
     iWgId = aRef.WgId();    
     iCloseTimeout = aRef.CloseTimeout();
     iWaitAfterClose = aRef.WaitAfterClose();
+	iAlreadyGaveUp = EFalse;
     }
 
 void CGOomCloseApp::ConstructL()
@@ -115,6 +138,38 @@
     FUNC_LOG;
     }
 
+TBool IsConsumingMemory(TInt aWgId)
+    {
+    FUNC_LOG;
+    // Something more efficient could be done here
+    CMemoryMonitor* globalMemoryMonitor = static_cast<CMemoryMonitor*>(Dll::Tls());
+    globalMemoryMonitor->GetWindowGroupList()->Refresh();
+    return (globalMemoryMonitor->GetWindowGroupList()->GetIndexFromWgId(aWgId) != KErrNotFound);
+    }    
+    
+void CGOomCloseApp::ConditionalClose()
+    {
+    FUNC_LOG;
+    // Start a timer and the thread watcher 
+    iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppClosing);
+    iAppCloseTimer->After(iCloseTimeout * 1000);
+    // 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 
+    TRACES2("CGOomCloseApp::FreeMemory: Closing app with window group id %d Timeout = %d",iWgId, iCloseTimeout);
+	TWsEvent event;
+	event.SetType(EEventUser);
+	TInt* eventData = (TInt*)(event.EventData());
+	*eventData = EApaSystemEventShutdown;
+	eventData++;
+	*eventData = KGoomMemoryLowEvent;
+	
+	// should proxy the session..
+    CMemoryMonitor* globalMemoryMonitor = static_cast<CMemoryMonitor*>(Dll::Tls());
+    globalMemoryMonitor->iWs.SendEventToWindowGroup(iWgId, event);
+    }    
+
+
 // ----------------------------------------------
 // Callback from iAppCloseTimer
 // App refused to exit gracefully on given time
@@ -127,12 +182,18 @@
         {
         iAppCloseWatcher->Cancel(); 
         }
-    
-    iCurrentTask.KillTask();
-    iAppCloserRunning = EFalse;
-    
-    iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppKilled);
-    iAppCloseTimer->After(iWaitAfterClose * 1000);
+        
+    if(IsConsumingMemory(iWgId))    
+        {    
+        iCurrentTask.KillTask();
+        iAppCloserRunning = EFalse; // not sure if intended (?)
+        iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppKilled);
+        iAppCloseTimer->After(iWaitAfterClose * 1000);
+        }
+    else
+        { // application has released its graphics resources -> we are no more interested about it
+        CloseAppEvent();
+        }    
     //MemoryFreed(KErrNone);
     }
 
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -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();
 
@@ -304,16 +320,47 @@
     iGOomActionList->SetCurrentTarget(iCurrentTarget);
 
     iTrigger = aTrigger;
+    
+    iGOomActionList->SetUseSwRendering(ETrue); //Always use SW rendering in low mode .. (for now..) 
     // 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)
     {
     FUNC_LOG;
     // Build the list of memory freeing actions (by killing apps)
-    iGOomActionList->BuildKillAppActionListL(*iGOomWindowGroupList, *iConfig);
+    TRAP_IGNORE(iGOomActionList->BuildKillAppActionListL(*iGOomWindowGroupList, *iConfig));
     iGOomActionList->FreeMemory(aMaxPriority);
     }
 
@@ -502,6 +549,7 @@
         if(iGOomActionList->IsRunningKillAppActions())  //this may be too late as killing of apps has already begun, but we might still be able to save the app 
             AppClosePriorityChanged(WgIdList[i], RGOomMonitorSession::EGOomPriorityBusy);
         }
+    WgIdList.Close();
     }
 
 void CMemoryMonitor::SetPriorityNormal(TInt aWgId)
@@ -519,6 +567,7 @@
         if(iGOomActionList->IsRunningKillAppActions())
             AppClosePriorityChanged(WgIdList[i], RGOomMonitorSession::EGOomPriorityNormal);
         }
+    WgIdList.Close();
     }
 
 void CMemoryMonitor::SetPriorityHigh(TInt aWgId)
@@ -536,6 +585,7 @@
         if(iGOomActionList->IsRunningKillAppActions())
             AppClosePriorityChanged(WgIdList[i], RGOomMonitorSession::EGOomPriorityHigh);
         }
+    WgIdList.Close();
     }
 
 TInt CMemoryMonitor::GetFreeMemory()
@@ -733,7 +783,6 @@
             }
         }
     
-    TRACES1("Going to process new request %d",iPostponeMemGood);
     return ETrue;
     }
 
@@ -773,15 +822,9 @@
     TInt current = GetFreeMemory();
     if(current >= iGoodThreshold)
         {
-        if(!NeedToPostponeMemGood())
-            {
-            TRACES("SynchroniseMemoryState calling MemoryGOOD");
-            iGOomActionList->MemoryGood();
-            }
-        else
-            {
-            iMemAllocationsGoingDown->Continue();
-            }
+        iClientsRequestingMemory.Reset();
+        TRACES("SynchroniseMemoryState calling MemoryGOOD");
+        iGOomActionList->MemoryGood();
         }
     else if(current < iLowThreshold)
         {
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -35,12 +35,7 @@
 CMemoryMonitorSession::~CMemoryMonitorSession()
     {
     FUNC_LOG;
-	/* TODO - need to add the right condition
-    if (iUseAbsoluteTargets)
-        { // se3ssion terminated while on critical allocation, release lock
-        Server().Monitor().SessionInCriticalAllocation(0);
-        }
-	*/
+    Server().Monitor().SessionInCriticalAllocation(0,0);
     CloseAppsFinished(0, EFalse);
     }
 
@@ -91,7 +86,12 @@
                 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);
--- a/uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -42,19 +42,31 @@
     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()
+void CGOomWindowGroupList::Refresh(TBool aOptionalOnly)
     {
     FUNC_LOG;
     
 #ifdef _DEBUG
-    TRAPD(err, RefreshL());
+    TRAPD(err, RefreshL(aOptionalOnly));
     if (err)
         {
         TRACES1("CGOomWindowGroupList::Refresh(): RefreshL leave %d", err);
         }
 #else
-    TRAP_IGNORE(RefreshL());
+    TRAP_IGNORE(RefreshL(aOptionalOnly));
     // Ignore any error
     // Errors are very unlikely, the only possibility is OOM errors (which should be very unlikely due to pre-created, re-reserved lists)
     // The outcome of any error is that the most foreground operations will be missing from the list
@@ -64,7 +76,7 @@
 
 // Update the list of window groups
 // Should be called whenever the 
-void CGOomWindowGroupList::RefreshL()
+void CGOomWindowGroupList::RefreshL(TBool aOptionalOnly)
     {
     FUNC_LOG;
   
@@ -72,12 +84,31 @@
         {
         User::LeaveIfError(iAlfClient.Connect());
         }
-    iLowOnMemWgs.Reset();
+    //iLowOnMemWgs.Reset();
     RArray<TInt> inactiveSurfaces;
 
-    User::LeaveIfError(iAlfClient.GetListOfInactiveWindowGroupsWSurfaces(&inactiveSurfaces));    
-    User::LeaveIfError(iAlfClient.GetListOfWindowGroupsWSurfaces(&iLowOnMemWgs));
+    // ignore possible errors, we have information from profiling extension anyway
+    if (!aOptionalOnly)
+        {
+        iAlfClient.GetListOfInactiveWindowGroupsWSurfaces(&inactiveSurfaces);    
+        //iAlfClient.GetListOfWindowGroupsWSurfaces(&iLowOnMemWgs);
+        }
+    else
+        { // first iteration: try to cope with window group ID's only
+          // Most likely that needs to be revisited because apps fail to name their window 
+          // groups properly on external screens...  
+        iAlfClient.GetOptionalGraphicsMemUsers(&inactiveSurfaces);    
+        iOptionalUids.Reset();
+        TInt count = inactiveSurfaces.Count(); 
+        for (TInt i = 0; i<count-1; i++)
+            {
+            iOptionalUids.Append(inactiveSurfaces[i+1]);
+            inactiveSurfaces.Remove(i+1);
+            count--;
+            }   
+        }
         
+    TRACES1("Optional list composed: %d", aOptionalOnly);     
     TRACES1("Inactive surfaces count %d", inactiveSurfaces.Count());     
     TRACES1("Windowgroups w/ surfaces count %d", iLowOnMemWgs.Count());     
 
@@ -85,16 +116,18 @@
     RArray<TUint> privMemUsed;
     RArray<TUint64> sparedProcessIds;
     
-   //if (inactiveSurfaces.Count() == 1) // ALF only 
-   //     {
-        NOK_resource_profiling eglQueryProfilingData = (NOK_resource_profiling)eglGetProcAddress("eglQueryProfilingDataNOK");
+   if (!aOptionalOnly)
+      {
+      NOK_resource_profiling eglQueryProfilingData = (NOK_resource_profiling)eglGetProcAddress("eglQueryProfilingDataNOK");
     
-        if (!eglQueryProfilingData)
-            {
-            TRACES("RefreshL EGL_NOK_resource_profiling not available");
-			return;
-            }
+      if (!eglQueryProfilingData && inactiveSurfaces.Count() == 0)
+        {
+        TRACES("RefreshL EGL_NOK_resource_profiling not available");
+        return;
+        }
     
+     if (eglQueryProfilingData)
+        {
         EGLint data_count;
         EGLint* prof_data;
         TInt i(0);
@@ -202,8 +235,8 @@
                     }
                 }
             }
-     //   }
-                
+        }
+      }            
     // Refresh window group list
     // get all window groups, with info about parents
     TInt numGroups = iWs.NumWindowGroups();
@@ -212,7 +245,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
@@ -223,7 +256,7 @@
         }
         
 #endif    
-    
+*/    
     // Note the current foreground window ID (if there is one)
     TBool oldForegroundWindowExists = EFalse;
 
--- a/uiacceltk/hitchcock/group/bld.inf	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/group/bld.inf	Thu Jul 22 16:43:39 2010 +0100
@@ -40,6 +40,7 @@
 // After effect system is complete and aknskins has taken over the correct 101f84b9.sel file
 // and manifest.mf file, we should no longer export these files.
 #ifndef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+#ifndef ALF_USE_OPENWF_COMPOSITION
 ../coretoolkit/data/101f84b9.sel /epoc32/data/z/resource/skins/101f84b9/101f84b9.sel
 ../coretoolkit/data/101f84b9.sel /epoc32/release/winscw/udeb/z/resource/skins/101f84b9/101f84b9.sel
 ../coretoolkit/data/101f84b9.sel /epoc32/release/winscw/urel/z/resource/skins/101f84b9/101f84b9.sel
@@ -59,7 +60,7 @@
 // For easier testing you can also copy the effect files onto a memory card into
 // /resource/effects/ directory.
 // These files can be changed any time and reregistered by changing the skin
-
+#endif // #ifndef ALF_USE_OPENWF_COMPOSITION
 #endif // #ifndef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
 
 // backround animation shaders
--- a/uiacceltk/hitchcock/group/core_exports.inc	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/group/core_exports.inc	Thu Jul 22 16:43:39 2010 +0100
@@ -3,7 +3,7 @@
 *  Name        : core_exports.inc
 *  Part of     : Alfred UI Toolkit
 *  Description : Exported header files.
-*  Version     : %version: tr1sido#8.1.36 %
+*  Version     : %version: tr1sido#8.1.37 %
 *
 *  Copyright © 2006-2007 Nokia.  All rights reserved.
 *  This material, including documentation and any related computer
@@ -53,6 +53,7 @@
 ../coretoolkit/data/app_activate.fxml /epoc32/release/winscw/urel/z/resource/effects/app_activate.fxml
 ../coretoolkit/data/app_exit.fxml /epoc32/release/winscw/urel/z/resource/effects/app_exit.fxml
 ../coretoolkit/data/app_start.fxml /epoc32/release/winscw/urel/z/resource/effects/app_start.fxml
+../coretoolkit/data/app_start_long.fxml /epoc32/release/winscw/urel/z/resource/effects/app_start_long.fxml
 ../coretoolkit/data/app_start_rect.fxml /epoc32/release/winscw/urel/z/resource/effects/app_start_rect.fxml
 ../coretoolkit/data/app_start_switch.fxml /epoc32/release/winscw/urel/z/resource/effects/app_start_switch.fxml
 ../coretoolkit/data/app_start_switch_rect.fxml /epoc32/release/winscw/urel/z/resource/effects/app_start_switch_rect.fxml
@@ -145,6 +146,7 @@
 ../coretoolkit/data/app_activate.fxml /epoc32/release/winscw/udeb/z/resource/effects/app_activate.fxml
 ../coretoolkit/data/app_exit.fxml /epoc32/release/winscw/udeb/z/resource/effects/app_exit.fxml
 ../coretoolkit/data/app_start.fxml /epoc32/release/winscw/udeb/z/resource/effects/app_start.fxml
+../coretoolkit/data/app_start_long.fxml /epoc32/release/winscw/udeb/z/resource/effects/app_start_long.fxml
 ../coretoolkit/data/app_start_rect.fxml /epoc32/release/winscw/udeb/z/resource/effects/app_start_rect.fxml
 ../coretoolkit/data/app_start_switch.fxml /epoc32/release/winscw/udeb/z/resource/effects/app_start_switch.fxml
 ../coretoolkit/data/app_start_switch_rect.fxml /epoc32/release/winscw/udeb/z/resource/effects/app_start_switch_rect.fxml
@@ -237,6 +239,7 @@
 ../coretoolkit/data/app_activate.fxml /epoc32/data/z/resource/effects/app_activate.fxml
 ../coretoolkit/data/app_exit.fxml /epoc32/data/z/resource/effects/app_exit.fxml
 ../coretoolkit/data/app_start.fxml /epoc32/data/z/resource/effects/app_start.fxml
+../coretoolkit/data/app_start_long.fxml /epoc32/data/z/resource/effects/app_start_long.fxml
 ../coretoolkit/data/app_start_rect.fxml /epoc32/data/z/resource/effects/app_start_rect.fxml
 ../coretoolkit/data/app_start_switch.fxml /epoc32/data/z/resource/effects/app_start_switch.fxml
 ../coretoolkit/data/app_start_switch_rect.fxml /epoc32/data/z/resource/effects/app_start_switch_rect.fxml
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/inc/gfxtransenginetfx.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/inc/gfxtransenginetfx.h	Thu Jul 22 16:43:39 2010 +0100
@@ -243,9 +243,9 @@
 	void DoStartTransitionL(TInt aHandle, const CTransitionData* aTransData);
 
     /*
-     * Generate start transition from begin capture in case of contol exit transition
+     * Generate transition event
      */
-	void GenerateTransitionL( const CCoeControl* aKey, const CTransitionData* aTransData);
+	void GenerateComponentTransitionEventL(const CTransitionData* aTransData, TInt aOp, TInt aHandle = KErrNotFound);
 	
 	/*
 	 * Connect to server and load plugin
@@ -324,6 +324,14 @@
 
     TInt iCurrHandle;
 
+    struct TControlEffect
+        {
+        TInt iHandle;
+        TInt iWindowGroup;
+        TInt iWindowHandle;
+        };
+    RArray<TControlEffect> iControlEffects;
+    
 //	TBool iIsWO;
 
 	TThreadId iClientId;
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -295,6 +295,8 @@
 CGfxTransAdapterTfx::~CGfxTransAdapterTfx()
 	{
 	
+    
+    iControlEffects.Close();
 	__ALFFXLOGSTRING("CGfxTransAdapterTfx for HWA transitionn effects, destructor ");
 //	iIgnoredWOChildControls.Close();
 	//iControlInfo.ResetAndDestroy();
@@ -456,17 +458,22 @@
 	    }
 	 
 	TInt err = KErrNone;    
-	TInt action = 0;
 	const CTransitionData* transdata;
 	err = iClient->GetTransitionData( aHandle, transdata );
-	if ( err == KErrNone )
-	    {
-    	action = transdata->iAction;
-	    }
 
 	switch(aState)
 		{
 		case EFallback:
+	    case EAbort:
+	        for(TInt i = 0 ; i < iControlEffects.Count(); i++ )
+	            {
+	            // clear ongoing effect for this handle
+	            if( iControlEffects[i].iHandle == aHandle)
+	                {
+	                iControlEffects.Remove(i);
+	                i--;
+	                }
+	            }
 		    break;
 		case EPreBeginCapture:
 		    break;
@@ -475,35 +482,45 @@
 			// GfxTransEffect::Begin(). This makes it possible (NOT QUARANTEENED)
 			// that effect request arrives to Alf before possible visiblity changes are made to 
 			// the control.
-		    if ( iHasPlugin && aKey && aKey->DrawableWindow())
+		    if (aKey && aKey->DrawableWindow() && err == KErrNone)
 		        {
-		        // We must generate our own transition as we won't be sending 
-		        // iClient->TransitionFinished back.
-		        // (Client did not ask for transition to be started, and won't be
-		        // interested in the end.)
-          		TRAP( err, GenerateTransitionL( aKey, transdata ) );
+                TControlEffect newEffect;
+                newEffect.iHandle = aHandle;
+                newEffect.iWindowGroup = aKey->DrawableWindow()->WindowGroupId();
+                newEffect.iWindowHandle =aKey->DrawableWindow()->ClientHandle(); 
+                iControlEffects.Append(newEffect);
 		        }
 		    break;
 		case EPreEndCapture:	
 		    break;
 		case EPostEndCapture:
-		    break;
-		case EAbort:
-		// Abort component transition, handle given.
+            if (aKey && err == KErrNone)
+                {
+                TRAP( err, GenerateComponentTransitionEventL( transdata, MAlfGfxEffectPlugin::EBeginComponentTransition, aHandle ) );
+                }
 		    break;
 		case EGlobalAbort:
-		// abort component transition, no handle.
+		    // abort component transition, no handle.
+		    for(TInt i = 0 ; i < iControlEffects.Count(); i++ )
+                {
+                // clear all on going effects
+                iControlEffects.Remove(i);
+                i--;
+                }
+          // TODO: send abort to server
+		   // TRAP( err, GenerateComponentTransitionEventL( transdata, MAlfGfxEffectPlugin::EAbortComponentTransition) );
+		    
 	        break;
 		case EBeginGroup:
 			{
-			__ALFFXLOGSTRING1("-- BeginGroup: New transition group for groupid: %d)",aHandle);
-			SendGroupCommand(aHandle, EFalse);
+            __ALFFXLOGSTRING1("-- BeginGroup: New transition group for groupid: %d)",aHandle);
+            SendGroupCommand(aHandle, EFalse);
 		    break;
 			}
 		case EEndGroup:
 			{
-			__ALFFXLOGSTRING1("-- EndGroup: closing transition group: %d)",aHandle);
-			SendGroupCommand(aHandle, ETrue);
+            __ALFFXLOGSTRING1("-- EndGroup: closing transition group: %d)",aHandle);
+            SendGroupCommand(aHandle, ETrue);
 		    break;
 			}
 		default:
@@ -782,90 +799,109 @@
     TSecureId result(aAppUid);
     if ( aAppUid == TUid::Null() )
         {
+        iCachedUidMapping.iWindowGroupId = -1;
         return result;
         }
-
-    TBool found = EFalse;
+    
+    __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid Searching SID&WGID for aAppUid: 0x%x", aAppUid.iUid );
 
     // first check the cache
     if ( iCachedUidMapping.iAppUid == aAppUid.iUid && iCachedUidMapping.iSecureId != 0 )
         {
-        result = iCachedUidMapping.iSecureId;
-        found = ETrue;
-    }
+        __ALFFXLOGSTRING2( "CGfxTransAdapterTfx::SecureIdFromAppUid using cached SID 0x%x and WGID: %d", 
+                iCachedUidMapping.iSecureId,
+                iCachedUidMapping.iWindowGroupId );
+        return TSecureId(iCachedUidMapping.iSecureId);
+        }
+
+    TInt windowGroupId = -1;
+    RProcess thisProcess;
+    TUidType uidType = thisProcess.Type();
     
-    if ( !found )
+    if ( uidType.IsValid() )
         {
-        // do the hard work
-        // first check this process - this is quick
-        // also, if this is the start-up effect on an application, the TApaTask is not yet updated with the 
-        // window group created by this application (yet).
-        TInt windowGroupId = -1;
-        RProcess thisProcess;
-        TUidType uidType = thisProcess.Type();
-        if ( uidType.IsValid() )
+        bool thisApplication = false;
+        if ( uidType[2] == aAppUid ) // 0 = UID1, 1 = UID2, 2 = UID3
+            { 
+            // this application
+            result = thisProcess.SecureId();
+            thisApplication = ETrue;
+            __ALFFXLOGSTRING2("CGfxTransAdapterTfx::SecureIdFromAppUid Own SID 0x%x in thread %S", 
+                    result.iId, 
+                    &RThread().Name() );
+            }
+        
+        CCoeEnv* env = CCoeEnv::Static();
+        RWsSession localSession;
+        RWsSession* usedWsSession = NULL;
+        if ( env ) 
             {
-            if ( uidType[2] == aAppUid ) // 0 = UID1, 1 = UID2, 2 = UID3
-                { 
-                result = thisProcess.SecureId();
-                // take the window gruop ID as well if available
-                CCoeEnv* env = CCoeEnv::Static();
-                if ( env )
-                    {
-                    windowGroupId = env->RootWin().Identifier();
-                    }
-                found = ETrue;
+            usedWsSession = &env->WsSession();
+            }
+        else 
+            {
+            if ( localSession.Connect() == KErrNone ) 
+                {
+                usedWsSession = &localSession;
                 }
             }
-        thisProcess.Close();
-
-        // If not this application, find UID using the TApaTask
-        if ( !found )
+        
+        // check if the AppArcServer has already information about this Application
+        if ( usedWsSession  ) 
             {
-            TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); 
+            TApaTaskList taskList( *usedWsSession ); 
             const TApaTask task = taskList.FindApp( aAppUid );
-            const TThreadId threadId = task.ThreadId();
-            RThread otherThread;
-            if ( otherThread.Open( threadId ) == KErrNone ) // ignore error
+            const TThreadId otherThreadId = task.ThreadId();
+            
+            if ( thisApplication ) 
                 {
-                result = otherThread.SecureId();
-                windowGroupId = task.WgId(); // take it for free at this point.
-                found = ETrue;
-                }
-            otherThread.Close();
-            }
-        
-        if ( found )
-            {
-            // update cache
-            if ( iCachedUidMapping.iAppUid == aAppUid.iUid )
-                {
-                // found the missing secure ID
-                iCachedUidMapping.iSecureId = result.iId;
-                
-                if ( windowGroupId > 0 )
+                // if security ID of the other thread matched, we take the WG ID from AppArcServer
+                RThread otherThread;
+                if ( otherThread.Open( otherThreadId ) == KErrNone ) 
                     {
-                    // if we got the window group ID, update that as well to the cache
-                    iCachedUidMapping.iWindowGroupId = windowGroupId;
+                    __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid Exising TApaTask found using thread %S", &otherThread.Name() );
+                    if ( otherThread.SecureId() == result )
+                        {
+                        windowGroupId = task.WgId();
+                        __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid SID match -> WGID : &d found from TApaTask", windowGroupId );
+                        }
+                    else 
+                        {
+                        __ALFFXLOGSTRING2("CGfxTransAdapterTfx::SecureIdFromAppUid otherSID 0x%x otherWGID : &d not matching in TApaTask", otherThread.SecureId().iId , task.WgId() );
+                        }
+                    }
+                otherThread.Close();
+
+                if ( windowGroupId == -1 && env )
+                    {
+                    // take the root WG ID
+                    windowGroupId = env->RootWin().Identifier();
+                    __ALFFXLOGSTRING1("CGfxTransAdapterTfx::SecureIdFromAppUid root WGID %d used", windowGroupId );
                     }
                 }
-            else 
+            else  
                 {
-                iCachedUidMapping.iAppUid = aAppUid.iUid;
-                iCachedUidMapping.iSecureId = result.iId;
-                // wgid might not be updated at this point.
-                iCachedUidMapping.iWindowGroupId = Max(windowGroupId,0); // might be -1 -> treat 0 and -1 is just 0
+                RThread otherThread;
+                if ( otherThread.Open( otherThreadId ) == KErrNone )
+                    {
+                    result = otherThread.SecureId();
+                    windowGroupId = task.WgId();
+                    __ALFFXLOGSTRING3("CGfxTransAdapterTfx::SecureIdFromAppUid Taking SID 0x%x WGID %d from thread %S via TApaTask", result.iId, windowGroupId, &otherThread.Name() );
+                    }
+                otherThread.Close();
                 }
             }
+
+        localSession.Close();
         }
+    thisProcess.Close();
     
-    if ( !found )
+    if ( windowGroupId != -1 )
         {
-        __ALFFXLOGSTRING1( "CGfxTransAdapterTfx::SecureIdFromAppUid AppUid 0x%x not found (yet)", aAppUid.iUid );
-        }
-    else if ( aAppUid.iUid != result.iId )
-        {
-        __ALFFXLOGSTRING2( "CGfxTransAdapterTfx::SecureIdFromAppUid SecureID 0x%x differs form AppUid 0x%x", result.iId, aAppUid.iUid );
+        // update cache
+        iCachedUidMapping.iAppUid = aAppUid.iUid;
+        iCachedUidMapping.iSecureId = result;
+        iCachedUidMapping.iWindowGroupId = windowGroupId;
         }
 
     return result;
@@ -877,55 +913,13 @@
 //
 TInt32 CGfxTransAdapterTfx::WindowGroupIdFromAppUid( TUid aAppUid )
     {
-    if ( aAppUid == TUid::Null() )
-        {
-        return 0;
-        }
-    
-    TInt result = 0;
-    TBool found = EFalse;
-    
-    // check the cache. most likely this is already up-to-date due the previous execution of SecureIdFromAppUid
-    if ( iCachedUidMapping.iAppUid == aAppUid.iUid )
-        {
-        if ( iCachedUidMapping.iWindowGroupId > 0 )
-            {
-            result = iCachedUidMapping.iWindowGroupId;
-            iCachedUidMapping.iSecureId = 0;
-            found = true;
-            }
-        }
-    
-    if ( !found )
+    TInt32 result = 0; 
+    if ( iCachedUidMapping.iAppUid == aAppUid.iUid ) 
         {
-        // do the hard work
-        TApaTaskList taskList( CCoeEnv::Static()->WsSession() ); 
-        const TApaTask task = taskList.FindApp( aAppUid );
-        result = TInt32(task.WgId());
-        
-        if ( result > 0 )
-            {
-            // update cache
-            found = ETrue;
-            if ( iCachedUidMapping.iAppUid != aAppUid.iUid )
-                {
-                iCachedUidMapping.iAppUid = aAppUid.iUid;
-                iCachedUidMapping.iSecureId = 0;
-                }
-            iCachedUidMapping.iWindowGroupId = result;
-            }
-        else
-            {
-            result = 0; // might be -1 -> treat 0 and -1 is just 0
-            }
+        result = iCachedUidMapping.iWindowGroupId;
         }
-    
-    if ( !found )
-        {
-        __ALFFXLOGSTRING1( "CGfxTransAdapterTfx::WindowGroupIdFromAppUid AppUid 0x%x not found (yet)", aAppUid.iUid );
-        }
-
-    return TInt32(result);
+    iCachedUidMapping.iSecureId = 0;
+    return result;
     }
 
 
@@ -1269,20 +1263,41 @@
 	__ALFFXLOGSTRING("CGfxTransAdapterTfx::DoStartTransitionL <<");
 	}
 
-void CGfxTransAdapterTfx::GenerateTransitionL( const CCoeControl* aKey, const CTransitionData* aTransData)
+void CGfxTransAdapterTfx::GenerateComponentTransitionEventL(const CTransitionData* aTransData, TInt aOp, TInt aHandle)
     {
 
     // We generate a transition call from begin capture for control exit transitions
-	TPtr8 inPtr = iTransferBuffer->Des();
-	inPtr.Zero();
-	TPtr8 outPtr = iReturnBuffer->Des();
-	outPtr.Zero();
-	RDesWriteStream inBuf( inPtr );
-    TInt op = MAlfGfxEffectPlugin::EBeginComponentTransition;
-    TInt windowGroup = aKey->DrawableWindow()->WindowGroupId();
-    TInt windowHandle = aKey->DrawableWindow()->ClientHandle(); 
+    TPtr8 inPtr = iTransferBuffer->Des();
+    inPtr.Zero();
+    TPtr8 outPtr = iReturnBuffer->Des();
+    outPtr.Zero();
+    RDesWriteStream inBuf( inPtr );
+    TInt op = aOp;
     
-    __ALFFXLOGSTRING4("CGfxTransAdapterTfx::GenerateTransitionL - Operation: MAlfGfxEffectPlugin::EBeginComponentTransition Action: %d,  Uid: 0x%x, WindowGroup: %d, WindowHandle: %d  >>",
+    TInt windowGroup = KErrNotFound;
+    TInt windowHandle = KErrNotFound;
+    if( aHandle != KErrNotFound )
+        {
+        for(TInt i = 0 ; i < iControlEffects.Count(); i++ )
+            {
+            // we take the last one. to make hopefully clean up any earlier effect that was not finished for some reason.
+            if( iControlEffects[i].iHandle == aHandle)
+                {
+                windowGroup = iControlEffects[i].iWindowGroup;
+                windowHandle = iControlEffects[i].iWindowHandle;
+                iControlEffects.Remove(i);
+                i--;
+                }
+            }
+        }
+    if(aHandle != KErrNotFound && (windowGroup == KErrNotFound  || windowHandle == KErrNotFound))
+        {
+        return;
+        }
+    
+    __ALFFXLOGSTRING1("CGfxTransAdapterTfx::GenerateComponentTransitionEventL - Operation: %d", op );
+
+    __ALFFXLOGSTRING4("CGfxTransAdapterTfx::GenerateComponentTransitionEventL - Action: %d,  Uid: 0x%x, WindowGroup: %d, WindowHandle: %d  >>",
         aTransData->iAction,
         aTransData->iUid.iUid,
         windowGroup,
@@ -1303,17 +1318,17 @@
     inBuf.Release();
     inBuf.Close();
 
-    __ALFFXLOGSTRING( "CGfxTransAdapterTfx::GenerateTransitionL" );
+    __ALFFXLOGSTRING( "CGfxTransAdapterTfx::GenerateTransitionL - iTfxServer.SendSynchronousData " );
     iTfxServer.SendSynchronousData( iPluginImplementation, inPtr, outPtr );
     // clear out used data    
-	inPtr.Zero();
-	outPtr.Zero();
-	
-	// Don't signal client because client did not request the transition to start
+    inPtr.Zero();
+    outPtr.Zero();
+    
+    // Don't signal client because client did not request the transition to start
     __ALFFXLOGSTRING("CGfxTransAdapterTfx::GenerateTransitionL <<");
-    }
-	
-	
+    }	
+
+
 // ---------------------------------------------------------------------------
 // finds a control
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/inc/alfdrawerengine.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/inc/alfdrawerengine.h	Thu Jul 22 16:43:39 2010 +0100
@@ -42,13 +42,12 @@
 	virtual TUint& Action() = 0;
 	virtual TInt& Flags() = 0;
 	virtual void IncreaseControlHandle() = 0;
-	virtual void IncreaseFullScreenHandle() = 0;
 	virtual TInt CurrentControlHandle() = 0;
 	virtual TInt CurrentFullScreenHandle() = 0;
 	virtual void StartEndChecker() = 0;
 	virtual void CancelEndChecker() = 0;
 	virtual void SendBeginFullscreen() = 0;
-	virtual TInt SendEndFullscreen() = 0;
+	virtual TInt SendEndFullscreen(TBool aTimeout = EFalse) = 0;
 	virtual TInt SendAbortFullscreen() = 0;
 	virtual TInt SendAbortControlTransition() = 0;
     virtual	TInt SendBeginControlTransition() = 0;
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/inc/alfgfxeffects.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/inc/alfgfxeffects.h	Thu Jul 22 16:43:39 2010 +0100
@@ -26,6 +26,7 @@
 #include "alftfxplugincommon.hrh"
 #include "../../../../ServerCore/Inc/alfwindowfxplugin.h"
 #include "wsserverdrawercontroller.h"
+#include "alfloggingconfiguration.h"
 
 // CONSTANTS
 const TUid KAlfGfxImplUid = { KAlfGfxImplUidValue };
@@ -117,7 +118,7 @@
      	* C++ contructor
      	*/
 		CAlfGfxEffects();
-#ifdef _DEBUG		
+#ifdef _ALF_FXLOGGING		
 		void PrintRequestInfo(TInt aOperation, TInt aAction );
 #endif
 		
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/inc/alfserverdrawer.h	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/inc/alfserverdrawer.h	Thu Jul 22 16:43:39 2010 +0100
@@ -69,7 +69,7 @@
     void BeginFullscreen( TInt aAction, const TRect& aEffectRect, 
 						TInt aType, const TUid aUid1, const TUid aUid2, TInt aData,
 						TSecureId aSid1, TInt aWg1, TSecureId aSid2, TInt aWg2);
-    void EndFullscreen();
+    void EndFullscreen(TBool aTimeout = EFalse);
     void CancelFullscreen();
     void AbortFullscreen();
     void RegisterAlfFullScreenEffect( TInt aAction, const TDesC& aResourceDir,
@@ -95,7 +95,6 @@
 	void IncreaseControlHandle();
 	TInt CurrentControlHandle();
 	
-	void IncreaseFullScreenHandle();
 	TInt CurrentFullScreenHandle();
 	
 	void StartEndChecker();
@@ -103,7 +102,12 @@
 
 	TInt SendBeginFullscreen(TInt aHandle, TUint aAction, const TUid& aUid, 
 							 const TUid& aPreviousUid, const TRect& aEffectRect);
-	TInt SendEndFullscreen();
+	/**
+	 *  SendEndFullscreen
+	 *  
+	 *  @return    1, If longer app start effect was triggered. Otherwise returns 0.
+	 */
+	TInt SendEndFullscreen(TBool aTimeout = EFalse);
 	TInt SendAbortFullscreen();
 	TInt SendAbortControlTransition();
 	void SendBeginFullscreen();
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfgfxeffects.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfgfxeffects.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -48,6 +48,9 @@
 
 #include "wsserverdrawercontroller.h"
 
+#define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
+#include "alfmoduletest.h" 
+
 // Constants
 //const TInt KAlfDefaultFocusGainedEffectDuration = 500;
 //const TInt KAlfDefaultFocusLostEffectDuration = 500;
@@ -118,6 +121,13 @@
 	                                     KThemesTransitionEffects);
     
     iSyncronizedGroupDefitionEndChecker = CEndCheck::NewL(*this);
+    
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    // Initiliaze global data in TLS and Open global module testing chunk and mutex
+    User::LeaveIfError(Dll::SetTls(new(ELeave) CAlfModuleTestDataControl()));
+    User::LeaveIfError(AMT_CONTROL()->OpenGlobalObjects());
+#endif
+
     __ALFFXLOGSTRING("CAlfGfxEffects::ConstructL <<");
     }
 
@@ -191,12 +201,29 @@
 		        // We should not get end full screen if the effect has not been even started
 		        // (could return KErrAbort in aOutBuf)
 		        err = KErrAbort;
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+		        action = inStream.ReadUint32L();
+                TRect effectRect( inStream.ReadInt32L(),
+                    inStream.ReadInt32L(), inStream.ReadInt32L(), inStream.ReadInt32L() );
+                TInt type = inStream.ReadInt32L();
+                uid1 = TUid::Uid( inStream.ReadInt32L() );
+                uid2 = TUid::Uid( inStream.ReadInt32L() );
+                TInt data = inStream.ReadInt32L();
+                
+                if ( type == AknTransEffect::EParameterType )
+                    {
+                    sid1 = TSecureId( inStream.ReadInt32L() ); // secureid is the only thing interesting to us
+                    }
+                TTime time;
+                time.UniversalTime();
+                AMT_ADD_TIME(sid1.iId, time.Int64(), EFalse);
+#endif
 		        break;
 		        }
 		    else
 		        {
 	            action = inStream.ReadUint32L();
-#ifdef _DEBUG    
+#ifdef _ALF_FXLOGGING    
     PrintRequestInfo( op, action);
 #endif    
 	            TRect effectRect( inStream.ReadInt32L(),
@@ -220,13 +247,13 @@
 		        }
             break;
         case MAlfGfxEffectPlugin::EEndFullscreen:
-#ifdef _DEBUG    
+#ifdef _ALF_FXLOGGING    
     PrintRequestInfo( op, action);
 #endif    
-            iEngine->EndFullscreen();
+            iEngine->EndFullscreen(EFalse); // not timeout, but official endfullscreen
             break;
         case MAlfGfxEffectPlugin::EAbortFullscreen:
-#ifdef _DEBUG    
+#ifdef _ALF_FXLOGGING
     PrintRequestInfo( op, action);
 #endif    
 
@@ -245,7 +272,7 @@
                 // we have enough information.
                 {
                 action = inStream.ReadUint32L();
-#ifdef _DEBUG    
+#ifdef _ALF_FXLOGGING    
     PrintRequestInfo( op, action);
 #endif    
                 
@@ -271,7 +298,7 @@
         case MAlfGfxEffectPlugin::ETfxServerOpAddFullscreenKMLEx:
             {
             action = inStream.ReadUint32L();
-#ifdef _DEBUG    
+#ifdef _ALF_FXLOGGING    
     PrintRequestInfo( op, action);
 #endif    
 
@@ -846,7 +873,8 @@
 	__ALFFXLOGSTRING("CAlfGfxEffects::VerifyResourceLocation - return KErrNotSupported <<");
 	return KErrNotSupported;
 	}
-#ifdef _DEBUG
+
+#ifdef _ALF_FXLOGGING
 void CAlfGfxEffects::PrintRequestInfo(TInt aOperation, TInt aAction )
     {
     HBufC16* buffer = HBufC16::NewL(256);
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -37,11 +37,23 @@
 #include <alflogger.h>
 #include <uiacceltk/HuiUtil.h>
 
+#define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
+#include "alfmoduletest.h" 
+
 // This sets the maximum time for an effect. Even if the fxml file has specified a longer duration, 
 // this will stop the effect.
-const TInt KAlfShortEffectTimeout = 4000000;
-const TInt KAlfLongEffectTimeout  = 5000000;
+const TInt KAlfShortEffectTimeout     = 4000000;
+
+// Note, The timeouts are DIFFERENT for EMULATOR AND ARMV5
+#ifdef __WINS__
+const TInt KAlfAppStartEffectTimeout  = 800000;
+const TInt KAlfLongEffectTimeout      = 10000000;
+#else
+const TInt KAlfAppStartEffectTimeout  = 300000;
+const TInt KAlfLongEffectTimeout      = 5000000;
+#endif
 const TInt KAlfActiveControlFxGranularity = 4;
+const TInt KAlfLongApplicationStartContext = 20;
 
 //const TInt KAlfLongEffectTimeout  = 500000;
 // Timer to send finish full screen effect
@@ -63,6 +75,11 @@
         
         void DoCancel();
 
+    public:
+        
+        TBool iTimeoutTriggered;
+        TBool iIsStartEffect;
+        
     private:
 
         CAlfFinishTimer();
@@ -108,6 +125,7 @@
 void CAlfFinishTimer::Start( TTimeIntervalMicroSeconds32 aPeriod, TCallBack aTimeoutCallback )
     {
     iCallback = aTimeoutCallback; 
+    iTimeoutTriggered = EFalse;
     After( aPeriod );
     }
 
@@ -118,6 +136,7 @@
     //
     if ( iStatus.Int() != KErrCancel )
         {
+        iTimeoutTriggered = ETrue;
         iCallback.CallBack();
         }
     }
@@ -266,6 +285,10 @@
     delete iFinishFullScreen;
     delete iFullScreenTimeout;
     iActiveControlFx.Close();
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    delete AMT_CONTROL();
+    Dll::FreeTls();
+#endif
     }
 
 // ---------------------------------------------------------------------------
@@ -501,11 +524,11 @@
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
-void CAlfServerDrawer::EndFullscreen()
+void CAlfServerDrawer::EndFullscreen(TBool aTimeout)
     {
     __ALFFXLOGSTRING("CAlfServerDrawer::EndFullscreen >>");
     CancelEndChecker();
-    iFullScreenController->EndFullscreen(EFalse);
+    iFullScreenController->EndFullscreen(aTimeout);
     iFullScreenController->AppInfoCache().ClearActions();
     __ALFFXLOGSTRING("CAlfServerDrawer::EndFullscreen <<");
     }
@@ -550,6 +573,11 @@
 //  
 void CAlfServerDrawer::DoSendBeginFullscreenL()
     {
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    TTime time;
+    time.UniversalTime();
+    AMT_ADD_TIME(iToSid.iId, time.Int64(), ETrue);
+#endif    
     __ALFFXLOGSTRING(" <- CAlfServerDrawer::SendBeginFullscreen");
     __ALFFXLOGSTRING(" <- Original window server ids");
     __ALFFXLOGSTRING2("From UID: 0x%X, To UID: 0x%X", iFromUid.iUid, iToUid.iUid);    
@@ -650,7 +678,7 @@
     // I don't think we need this
     TInt index = 0;
 
-    IncreaseFullScreenHandle();
+    iCurrentFullScreenHandle = iToSid.iId;
 
     iFullScreenTransitionEndObserver->Cancel();
     iFinishFullScreen->Cancel();
@@ -664,8 +692,10 @@
         RMemWriteStream stream( bridgeBuffer, bufferSize );
         // The writes should not leave if we have calculated our buffer length correctly.
         stream.WriteInt32L( MAlfGfxEffectPlugin::EBeginFullscreen );
-        stream.WriteInt32L(  iToSid.iId ); //iCurrentFullScreenHandle );
+        stream.WriteInt32L(  iToSid.iId );
         stream.WriteInt32L( iType );
+        stream.WriteInt32L( 0 ); // timeout? 0 always in BeginFullScreen
+        stream.WriteInt32L( 0 );
       	if ( iType == AknTransEffect::EParameterType && isExit )
       	    {
             stream.WriteInt32L( iToWg );
@@ -679,8 +709,6 @@
             stream.WriteInt32L( iToSid.iId );
             stream.WriteInt32L( iFromSid.iId );
                         
-            stream.WriteInt32L( KErrNotFound ); //  was iToScreen, obsolete
-            stream.WriteInt32L( KErrNotFound ); // was iToScreen, obsolete
        	    }
        	else if ( iType == AknTransEffect::EParameterType )
        	    {
@@ -695,19 +723,22 @@
             stream.WriteInt32L( iToSid.iId );
             stream.WriteInt32L( iFromSid.iId );
                         
-            stream.WriteInt32L( KErrNotFound );  // was iToScreen, obsolete
-            stream.WriteInt32L( KErrNotFound ); // was iToScreen, obsolete
             }
         else
             {
-            stream.WriteInt32L( KErrNotFound); // was iFocusWg 
-            stream.WriteInt32L( KErrNotFound); // was iFocusWg 
+            stream.WriteInt32L( KErrNotFound);  // dummy BEGIN
+            stream.WriteInt32L( KErrNotFound);  
+            stream.WriteInt32L( KErrNotFound);  
+            stream.WriteInt32L( KErrNotFound); 
+            stream.WriteInt32L( KErrNotFound);  
+            stream.WriteInt32L( KErrNotFound);  // dummy END
             }
         stream.WriteInt32L( iFlags );
         stream.WriteInt32L( iEffectRect.iTl.iX );
         stream.WriteInt32L( iEffectRect.iTl.iY );
         stream.WriteInt32L( iEffectRect.iBr.iX );
         stream.WriteInt32L( iEffectRect.iBr.iY );
+        
         stream << resourceDir;
         stream << fileName;    
         stream.CommitL();
@@ -725,13 +756,14 @@
     // iFlags and iAction will contain some extra information that can be used to control the effect:
     
     // All of these actions may not produce effects, they are here for now for debugging.
-    
+    TBool isAppStartEffect(EFalse);
     switch ( iAction )
         {
         case AknTransEffect::EApplicationActivate:
             __ALFFXLOGSTRING("EApplicationActivate - 1");
             break;
         case AknTransEffect::EApplicationStart:
+            isAppStartEffect = ETrue;
             __ALFFXLOGSTRING("EApplicationStart - 3");
             break;
         case AknTransEffect::EEmbeddedApplicationStart:
@@ -741,12 +773,15 @@
             __ALFFXLOGSTRING("EApplicationExit - 5");
             break;
         case AknTransEffect::EApplicationStartRect:
+            isAppStartEffect = ETrue;
             __ALFFXLOGSTRING("EApplicationStartRect - 6");
             break;
         case AknTransEffect::EApplicationStartSwitch:
+            isAppStartEffect = ETrue;
             __ALFFXLOGSTRING("EApplicationStartSwitch - 7");
             break;
         case AknTransEffect::EApplicationStartSwitchRect:
+            isAppStartEffect = ETrue;
             __ALFFXLOGSTRING("EApplicationStartSwitchRect - 8");
             break;
         case AknTransEffect::EEmbeddedApplicationExit:
@@ -783,40 +818,47 @@
     // It appears that folder open and close never send endfullscreen, so for them the effect
     // must be started as soon as we get beginfullscreen
     
-    iFullScreenTimeout->Start( KAlfLongEffectTimeout, TCallBack( FullScreenTimeout, this ) );
+    // isAppStartEffect = EFalse; // disable different timeout effect for appstart effects
+	
+    if (isAppStartEffect)
+        {
+		// The shorter timeout can be disabled here!
+        iFullScreenTimeout->Start( KAlfAppStartEffectTimeout, TCallBack( FullScreenTimeout, this ) );
+        iFullScreenTimeout->iIsStartEffect = ETrue;
+        }
+    else
+        {
+        iFullScreenTimeout->Start( KAlfLongEffectTimeout, TCallBack( FullScreenTimeout, this ) );
+        iFullScreenTimeout->iIsStartEffect = EFalse;
+        }
     }
     
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //	
-TInt CAlfServerDrawer::SendEndFullscreen()
+TInt CAlfServerDrawer::SendEndFullscreen(TBool aTimeout)
     {
-    __ALFFXLOGSTRING("CAlfServerDrawer::SendEndFullscreen");
+    __ALFFXLOGSTRING3("CAlfServerDrawer::SendEndFullscreen - Timeout: %d, iFullScreenEndSent: %d, IsStartEffect: %d", aTimeout, iFullScreenEndSent, iFullScreenTimeout->iIsStartEffect);
     
     if ( iFullScreenEndSent )
         {
         __ALFFXLOGSTRING("CAlfServerDrawer::SendEndFullscreen END no need");
         return KErrNone;
         }
-    iFullScreenEndSent = ETrue;
         
     __ALFFXLOGSTRING("CAlfServerDrawer::SendEndFullscreen");
     iFullScreenTransitionEndObserver->Cancel();
     iFullScreenTimeout->Cancel();
     iFinishFullScreen->Cancel();
-	/*
-    TUint action = iAction;   
-    if ( iType == AknTransEffect::EParameterAvkonInternal )
-        {
-        action = iOldAction;
-        }
-    */
-    // TEMPORARY HACK
-    // REMOVE AFTER APPSHELL HAS BEEN FIXED
-    //iDoNotClearEffectRect = EFalse;
+    TBool timeout = iFullScreenTimeout->iTimeoutTriggered;
+    TBool triggerStartEffectTimeout= iFullScreenTimeout->iTimeoutTriggered && iFullScreenTimeout->iIsStartEffect;
+    iFullScreenEndSent = !triggerStartEffectTimeout;
+    iFullScreenTimeout->iTimeoutTriggered = EFalse;
+    iFullScreenTimeout->iIsStartEffect = EFalse;
     
-    // This is where the second part of the effect should start
-    // The new window should already have something on the screen
+     // This is where the second part of the effect should start
+    // The new window should already have something on the screen.
+	// It might not be the case, if aTimeout is ETrue 
     
     // Send the data to CAlfAppUI via bridge
     
@@ -826,13 +868,27 @@
     
 	TPtrC resourceDir;
 	TPtrC fileName;
+	TInt cachePriority = 0;
+    TInt wantedTime = 0;
+    TInt minTime = 0;
 
+	if (triggerStartEffectTimeout)
+	    {
+        // if the following fails, then the effect from beginfullscreen will be used.
+        TInt err = iPolicyHandler.GetFullscreenKml( KAlfLongApplicationStartContext, iToUid, iFromUid, resourceDir, fileName,
+        cachePriority, wantedTime, minTime );
+		if (err != KErrNone)
+			{
+			triggerStartEffectTimeout = EFalse;
+			}
+	    }
+	
     // We must make a stream of the data as the length may vary.
     // At the moment we only send some numbers, but we should probably include
     // also the effect file name or something else to identify the effect 
     // that is going to be used
     
-    TInt bufferSize = 11 * sizeof(TInt); // operation, type, 2 wg ids, 2 app uids, flags and rect
+    TInt bufferSize = 13 * sizeof(TInt); // operation, type, 2 wg ids, 2 app uids, flags and rect, timeoutTriggered
     bufferSize += sizeof(TPtrC);
     bufferSize += resourceDir.Length() * 2;
     bufferSize += sizeof(TPtrC);
@@ -856,29 +912,24 @@
             stream.WriteInt32L( MAlfGfxEffectPlugin::EEndFullscreen );
             stream.WriteInt32L( iCurrentFullScreenHandle );
             stream.WriteInt32L( iType );
-
+            stream.WriteInt32L( triggerStartEffectTimeout );
+            stream.WriteInt32L( timeout );
             stream.WriteInt32L( iToWg );
             stream.WriteInt32L( iFromWg );
 
             // AppUid for the future. alfbridge can figure out the windog groups based on that
             stream.WriteInt32L( iToUid.iUid );
             stream.WriteInt32L( iFromUid.iUid );
+            
+            stream.WriteInt32L( iToSid.iId );
+            stream.WriteInt32L( iFromSid.iId );
 
-            if ( iType == AknTransEffect::EParameterType )
-                {
-                stream.WriteInt32L( iToScreen );
-                stream.WriteInt32L( iFromScreen );
-                }
-            /*else
-                {
-                //stream.WriteInt32L( iFocusWg );
-                //stream.WriteInt32L( iFocusWg );
-//              }*/
             stream.WriteInt32L( iFlags ); 
             stream.WriteInt32L( iEffectRect.iTl.iX );
             stream.WriteInt32L( iEffectRect.iTl.iY );
             stream.WriteInt32L( iEffectRect.iBr.iX );
             stream.WriteInt32L( iEffectRect.iBr.iY );
+            
             stream << resourceDir;
             stream << fileName;    
             stream.CommitL();    
@@ -892,6 +943,12 @@
         }
 
     iFullScreenFinished = EFalse;
+    iFullScreenTimeout->iIsStartEffect = EFalse;
+ 	
+    if (triggerStartEffectTimeout)
+        {
+        //return KErrNone;  // even long app start effects need some hardcore timeout
+        }
     if ( iAction == AknTransEffect::EApplicationExit /*||
         iAction == 1001*/  ) 
         {
@@ -902,7 +959,7 @@
         {
         iFinishFullScreen->Start( KAlfLongEffectTimeout, TCallBack( FinishFullScreenTimeout, this ) );
         }
-    return KErrNone;
+    return triggerStartEffectTimeout;
     }
 
 // ---------------------------------------------------------------------------
@@ -919,7 +976,8 @@
         }
 
     iFullScreenTransitionEndObserver->Cancel();
-    
+    iFinishFullScreen->Cancel();
+    iFullScreenTimeout->Cancel();
     iFullScreenFxSent = EFalse;
     iFullScreenEndSent = ETrue;
     
@@ -987,6 +1045,11 @@
 	TPtrC actionString;
 	
 	TInt err = KErrNone;
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+	TTime time;
+    time.UniversalTime();
+    AMT_ADD_TIME(iControlHandle, time.Int64(), ETrue);
+#endif    
 	err = iPolicyHandler.GetControlKml( iControlUid, iControlAction, resourceDir,
 	    fileName, actionString, cachePriority, wantedTime, minTime );
 	    
@@ -1239,13 +1302,6 @@
     highestHandle++;
     iCurrentControlHandle = highestHandle; 
 	}
-	
-void CAlfServerDrawer::IncreaseFullScreenHandle()
-    {
-    TInt highestHandle = iCurrentControlHandle > iCurrentFullScreenHandle ? iCurrentControlHandle : iCurrentFullScreenHandle;
-    highestHandle++;
-    iCurrentFullScreenHandle = highestHandle;
-    }
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
@@ -1292,7 +1348,7 @@
         iFullScreenTimeout->Cancel();
         // If we don't get an EndFullScreen in a timely manner, 
         // we generate an EndFullScreen signal by ourselves
-        EndFullscreen();
+        EndFullscreen(ETrue);
         }
     }
 
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/states.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/states.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -173,8 +173,16 @@
 		        }
             return CRestingState::NewL(iEngine,iHandler);
 		case EEndFullscreen:
-			iEngine.SendEndFullscreen();
-			return CPhase2State::NewL(iEngine,iHandler);
+			TInt triggeredLongStartEffect = iEngine.SendEndFullscreen();
+			__ALFFXLOGSTRING1("CPhase1State::SignalL - Was long app start triggered? Stay in Phase1", triggeredLongStartEffect);
+			if (triggeredLongStartEffect)
+			    {
+			    return CPhase1State::NewL(iEngine,iHandler);
+			    }
+			else
+			    {
+			    return CPhase2State::NewL(iEngine,iHandler);
+			    }
 		case EBeginFullscreen:
 			if(!IsBlocked(iEngine.FromUid(),iEngine.ToUid())) 
 				{
@@ -238,6 +246,9 @@
 				return CPhase1State::NewL(iEngine,iHandler);
 				}
 			return NULL;
+	     case EEndFullscreen:
+	            iEngine.SendEndFullscreen();
+	        return NULL;
 		case EBeginComponent:
 		    error = iEngine.SendBeginControlTransition();
 		    if ( error == KErrNone )
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/wsserverdrawercontroller.cpp	Mon Jun 21 22:39:28 2010 +0100
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/wsserverdrawercontroller.cpp	Thu Jul 22 16:43:39 2010 +0100
@@ -66,7 +66,8 @@
 		// startup blocked because startup exit leaves the screen black.
 		// must be debugged
         0x100058F4, // startup blocked for the time being
-        0x101f857A // camera
+        0x101f857A, // camera
+        0x2002d07f	// ovistore_2002D07F.exe, this does not draw anything, but launcher 
         // Application shell is Ok, folder open and close have KAknApplicationShellViewId
         // as both to and from ids. There is only one visual, so some sort of blur effect works...
 		//, KAknApplicationShellViewId
@@ -84,8 +85,8 @@
     {
 	0x0, // DO NOT REMOVE 0x0! this is here for compile reasons, it will not be included in the AllowedCustomUid check
     0x101f857A, // camera
-    0x2002A540  // conversation.exe , other launchable from messaging don't have effect either
-
+    0x2002A540,  // conversation.exe , other launchable from messaging don't have effect either
+    0x2002d07f // ovistore_2002D07F.exe, this does not draw anything, but launcher 
   //0xUID //Add UIds of applications that shouldn't have effects here
 	};
 
@@ -485,7 +486,7 @@
             }
         
         iAppInfo[index].iAction = aAction;
-        RDebug::Printf("CAppInfoCache::SetAction - Returned action %d", iAppInfo[index].iAction);
+        __ALFFXLOGSTRING1("CAppInfoCache::SetAction - Returned action %d", iAppInfo[index].iAction);
         return iAppInfo[index].iAction;
     }
 
@@ -743,11 +744,17 @@
 		//Adding uid to block list			
 		if(flags & AknTransEffect::TParameter::ENoEffects)
 			{
+            __ALFFXLOGSTRING1("CWsServerDrawerController::BeginFullscreen - Add to block list 0x%x", toUid);
 			iStates->AddBlockUid(toUid);
+			if (iLastToUid == aUid1)
+			    {
+                AbortTransition(EAbortFullscreen);
+			    }
 			}
 		//Removing uid from blocklist
 		if(flags & AknTransEffect::TParameter::EEnableEffects)	
 			{
+            __ALFFXLOGSTRING1("CWsServerDrawerController::BeginFullscreen - Remove from block list 0x%x", toUid);
 			iStates->RemoveBlockUid(toUid);
 			}
 		}
@@ -804,15 +811,14 @@
 	//we should know if its a dsa app before end can be called
 	if(iDSAActive)
 	    {
-        __ALFFXLOGSTRING("CWsServerDrawerController::BeginFullscreen - Phone is booting. Abort.");
+        __ALFFXLOGSTRING("CWsServerDrawerController::BeginFullscreen - DSA active. Abort.");
 	    return; //Do nothing if dsa active.
 	    }
 
 	//Special argument calls does not initiate any FS effect and is caught here.
-	// TODO: remove && !iEngine->WaitingForRootWgId() when appuids available from wserv
 	if(fstype == CStateHandler::ENone) 
 		{
-        __ALFFXLOGSTRING("CWsServerDrawerController::BeginFullscreen - Phone is booting. Abort.");
+        __ALFFXLOGSTRING("CWsServerDrawerController::BeginFullscreen - Special argument. Abort.");
 		return;
 		}
 
@@ -915,6 +921,7 @@
     // Convert 
 
     // Signal statemachine
+    SaveLastActionAndUid();
     iStates->Signal(CStateBase::EBeginFullscreen);
 	// Start end checker always.
 	if(flags & AknTransEffect::TParameter::EEndCheck)