201023
authorhgs
Tue, 08 Jun 2010 13:16:48 +0300
changeset 31 1b6909418757
parent 30 920e03da86f0
child 32 27a3ad0677c1
201023
rom/alfred.iby
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiDisplay.h
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiEnv.h
uiaccelerator_plat/alf_visual_api/inc/alf/alftimedvalue.h
uiacceltk/hitchcock/AlfCommandDebug/group/alfcommanddescriptions.rss
uiacceltk/hitchcock/AlfCommandDebug/src/alfcommanddebug.cpp
uiacceltk/hitchcock/AlfDecoderServerClient/src/alfcompositionclient.cpp
uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstage.cpp
uiacceltk/hitchcock/Client/src/alftimedvalue.cpp
uiacceltk/hitchcock/CommonInc/alfbridgecommands.h
uiacceltk/hitchcock/CommonInc/alfmoduletestdefines.h
uiacceltk/hitchcock/CommonInc/huiwscanvascommands.h
uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h
uiacceltk/hitchcock/ServerCore/Inc/alfeffectutils.h
uiacceltk/hitchcock/ServerCore/Src/alfappui.cpp
uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
uiacceltk/hitchcock/ServerCore/Src/alfeffectutils.cpp
uiacceltk/hitchcock/ServerCore/Src/alfhierarchymodel.cpp
uiacceltk/hitchcock/ServerCore/Src/alfstreamerserver.cpp
uiacceltk/hitchcock/ServerCore/Src/alfvisualhandlers.cpp
uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF
uiacceltk/hitchcock/coretoolkit/eabi/hitchcocku.DEF
uiacceltk/hitchcock/coretoolkit/group/huitk_base.mmp
uiacceltk/hitchcock/coretoolkit/inc/appiconcache.h
uiacceltk/hitchcock/coretoolkit/inc/huicanvasdebugwsgc.h
uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h
uiacceltk/hitchcock/coretoolkit/inc/huistatictlsdata.h
uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Texture.h
uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10RenderSurface.cpp
uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiDisplay.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiEnv.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiRosterImpl.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiS60Skin.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiStatic.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiVisual.cpp
uiacceltk/hitchcock/coretoolkit/src/appiconcache.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvasdebugwsgc.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvaspainter.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvaswsbitgc.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvaswshwgc.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp
uiacceltk/hitchcock/group/bld.inf
uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/inc/gfxtransenginetfx.h
uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/inc/alfgfxeffects.h
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/inc/alfserverdrawer.h
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfgfxeffects.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/states.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/wsserverdrawercontroller.cpp
--- a/rom/alfred.iby	Wed May 26 16:47:36 2010 +0300
+++ b/rom/alfred.iby	Tue Jun 08 13:16:48 2010 +0300
@@ -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!
@@ -162,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
@@ -172,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_core_toolkit_api/inc/uiacceltk/HuiDisplay.h	Wed May 26 16:47:36 2010 +0300
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiDisplay.h	Tue Jun 08 13:16:48 2010 +0300
@@ -819,11 +819,17 @@
     IMPORT_C void CopyScreenToBitmapL(CFbsBitmap* aBitmap);
     
     
+    /**
+     * Does background clearing for native alf application
+     */
     void DoBackgroundClear();
     
-    void ScanningAlfContent(TBool aScanning );
+    void ScanningAlfContent(TBool aScanning);
     void SetAlfContentChanged(TBool aChanged);
     TBool AlfContentChanged();
+    IMPORT_C void SetSkinSizeChangePending();
+    TBool QueryAndResetSkinSizeChangePendingStatus();
+    TRect CurrentDirtyRect();
     
 private:
 
@@ -1034,10 +1040,13 @@
     
     /** 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	Wed May 26 16:47:36 2010 +0300
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiEnv.h	Tue Jun 08 13:16:48 2010 +0300
@@ -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_visual_api/inc/alf/alftimedvalue.h	Wed May 26 16:47:36 2010 +0300
+++ b/uiaccelerator_plat/alf_visual_api/inc/alf/alftimedvalue.h	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/AlfCommandDebug/group/alfcommanddescriptions.rss	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/AlfCommandDebug/src/alfcommanddebug.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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/src/alfcompositionclient.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/AlfDecoderServerClient/src/alfcompositionclient.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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/AlfRenderStage/src/alfrenderstage.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstage.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/Client/src/alftimedvalue.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/CommonInc/alfbridgecommands.h	Tue Jun 08 13:16:48 2010 +0300
@@ -85,7 +85,7 @@
     EAlfDSIncludeToVisibilityCalculation,
     EAlfDSSetDistractionWindow,
 
-    KUnInitialized
+    KUnInitialized // This must be kept as last command!
     };
 
 #endif /* ALFBRIDGECOMMANDS_H_ */
--- a/uiacceltk/hitchcock/CommonInc/alfmoduletestdefines.h	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletestdefines.h	Tue Jun 08 13:16:48 2010 +0300
@@ -22,6 +22,8 @@
     #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.
@@ -107,6 +109,22 @@
                 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
 
 
@@ -169,37 +187,46 @@
         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(), EAlfModuleTestTypeCreateLayer ); \
-        AMT_MAP_APPEND_IF( aLayer, iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), TSurfaceId::CreateNullId(), EAlfModuleTestTypeReleaseLayer ); \
-        AMT_MAP_APPEND_IF( aLayer, iIntMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), 0, EAlfModuleTestTypeLayerOrdinalPosition ); \
-        AMT_MAP_APPEND_IF( aLayer, iIntMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), 0, EAlfModuleTestTypeLayerNodeOrdinalPosition )
-
-#define AMT_MAP_RENDER_STAGE_ADD_LAYER_LINK() \
-        AMT_MAP_APPEND_LINK( iSurfaceMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeCreateLayer ); \
-        AMT_MAP_APPEND_LINK( iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), windowId, EAlfModuleTestTypeCreateLayer ); \
-        AMT_MAP_APPEND_LINK( iSurfaceMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeReleaseLayer ); \
-        AMT_MAP_APPEND_LINK( iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), windowId, EAlfModuleTestTypeReleaseLayer ); \
-        AMT_MAP_APPEND_LINK( iIntMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeLayerOrdinalPosition ); \
-        AMT_MAP_APPEND_LINK( iIntMap, AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), windowId, EAlfModuleTestTypeLayerOrdinalPosition ); \
-        AMT_MAP_APPEND_LINK( iIntMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeLayerNodeOrdinalPosition ); \
-        AMT_MAP_APPEND_LINK( iIntMap, AMT_MAP_PTR_TO_KEY_CAST( &aWindowTreeNode ), windowId, EAlfModuleTestTypeLayerNodeOrdinalPosition ); \
-        AMT_MAP_APPEND_LINK( iSurfaceMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeGceCreateLayer ); \
-        AMT_MAP_APPEND_LINK( iSurfaceMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeGceReleaseLayer ); \
-        AMT_MAP_APPEND_LINK( iIntMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeGceLayerPosition ); \
-        AMT_MAP_APPEND_LINK( iIntMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeGceLayerOpacity ); \
-        AMT_MAP_APPEND_LINK( iRectMap, windowId, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), EAlfModuleTestTypeGceLayerExtent ); \
+#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, windowId, aLayer.Surface(), EAlfModuleTestTypeCreateLayer )
+        AMT_MAP_SET_VALUE( iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( &aLayer ), aLayer.Surface(), EAlfModuleTestTypeCreateLayer )
 
 #define AMT_MAP_RENDER_STAGE_REMOVE_LAYER() \
         AMT_MAP_SET_VALUE_IF( aLayer, iSurfaceMap, AMT_MAP_PTR_TO_KEY_CAST( aLayer ), aLayer->Surface(), EAlfModuleTestTypeReleaseLayer )
@@ -231,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 ); \
@@ -294,7 +339,7 @@
         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 ) ), Opacity(), EAlfModuleTestTypeGceLayerOpacity )
+        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 )
--- a/uiacceltk/hitchcock/CommonInc/huiwscanvascommands.h	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/CommonInc/huiwscanvascommands.h	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h	Tue Jun 08 13:16:48 2010 +0300
@@ -205,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
@@ -304,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();
@@ -442,14 +455,14 @@
     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, 
@@ -482,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
@@ -544,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 );
 	
@@ -609,6 +622,7 @@
     void HandleSetLayoutSwitchEffectL();
 	
     void ClearCanvasVisualCommandSets(TBool aInactiveOnly);
+    static void ClearCanvasVisualCommandSetsRecursive(CHuiCanvasVisual* aVisual, TBool aInactiveOnly);
     
     void ClipVisualRect(TRect& aRect, const TRect& aClippingRect);
 
@@ -930,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;
     
 	
@@ -938,9 +952,18 @@
      * Full screen effect state.
      * Own.
      */
-    CFullScreenEffectState* iFullScreenEffectData;
+    CFullScreenEffectState* iFSFxData;
     
-    CFullScreenEffectState* iSecondaryFullScreenEffectData;
+    /**
+     *  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.
@@ -1032,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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfeffectutils.h	Tue Jun 08 13:16:48 2010 +0300
@@ -26,7 +26,6 @@
     EWaitEndFullScreen,
     EEndFullScreenReceivedWaitingWindowGroup,
     EEndFullscreenReceived,
-    ESecondPhaseSetupActive,
     EFinalEffectActive
     };
 // Timer to send finish full screen effect
@@ -55,6 +54,7 @@
         CAlfBridge& iBridge;
  	public:
 	   	TInt iSafeCounter;
+	   	TInt iSafeCounterDelta;
         TCallBack iCallBack;        
     };
 
@@ -134,6 +134,9 @@
         TState NextBlankState(TEvent aEvent);
         TState NextThemeState(TEvent aEvent);
 
+        void HandleFreezeEvent(TEvent aEvent);
+        void HandleThemeEvent(TEvent aEvent);
+
         void FreezeFinished();
 
     public:            
@@ -162,6 +165,7 @@
         void FreezeRoster(TBool aFrozen);
         
         static TInt DoFreezeFinished(TAny* aAny);
+        static TInt DoNextLayoutSwitchContext(TAny* aAny);
         
     private: // Data
         
@@ -273,14 +277,15 @@
             {
             EOnlyOnePart = 0,
             EFirstPartActive,
-            ESecondPartActive
+            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,
@@ -290,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/Src/alfappui.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappui.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -1142,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    
--- a/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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,8 +196,8 @@
     delete iEffectEndTimer;
     iDeadControlGroups.Close();
     iEffectWindowGroups.Close();
-    delete iFullScreenEffectData;
-    delete iSecondaryFullScreenEffectData;
+    delete iFSFxData;
+    delete iFSFXDataPart2;
 
     if (iActivated)
         {
@@ -555,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;
     }
@@ -568,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;
     }
@@ -603,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)
@@ -627,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;
                         }
                     }
@@ -675,11 +701,11 @@
                 if (anyVisualHasEffect)
                     {
                     TInt activeEffectHandle = iEffectCleanupStack[activeEffectIndex].iHandle;
-                    if (iSecondaryFullScreenEffectData && iSecondaryFullScreenEffectData->iHandle == activeEffectHandle)
+                    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 iSecondaryFullScreenEffectData;
-                        iSecondaryFullScreenEffectData = NULL;
+                        delete iFSFXDataPart2;
+                        iFSFXDataPart2 = NULL;
                         }
                     
                     __ALFFXLOGSTRING1("Layout 0x%x has external content", layout);
@@ -710,7 +736,7 @@
                        if (!HasActiveEffect(familyTree[familyIndex]))
                            {
                            TInt dummy;
-                           AddEffectItemL(activeEffectHandle, familyTree[familyIndex], NULL, NULL, EFalse, dummy, ETrue, EFalse);
+                           AddFxItemL(activeEffectHandle, familyTree[familyIndex], NULL, NULL, EFalse, dummy, ETrue, EFalse);
                            }
                        }
                     }
@@ -722,13 +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);
-					         RemoveTemporaryPresenterVisual(removedVisual);
+					         CleanFxVisual(removedVisual);
 					         if ( removedVisual->Layout() == layout ) 
 					             {
 					             iOrphanStorage->AppendL( removedVisual );
@@ -805,14 +831,14 @@
         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->State() == EWaitingWindowGroup || iFullScreenEffectData->State() == EEndFullScreenReceivedWaitingWindowGroup)
-                && iFullScreenEffectData->iToSecureId == aSecureId)
-            {
-            iFullScreenEffectData->iToWg = aClientWindowGroupId;
-            if (iSecondaryFullScreenEffectData)
-                {
-                iSecondaryFullScreenEffectData->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; 
@@ -826,22 +852,22 @@
             
             // First HandleGfxEvent, then clear iWaitingWindowGroup.
             __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - try triggering effect 0x%x", layout);
-            TBool failed = HandleGfxEventL( *iFullScreenEffectData, layout, fromLayout );
-            if ( iFullScreenEffectData->State() == EWaitingWindowGroup)
-                {
-                iFullScreenEffectData->SetState(EWaitEndFullScreen);
+            TBool failed = HandleGfxEventL( *iFSFxData, layout, fromLayout );
+            if ( iFSFxData->State() == EWaitingWindowGroup)
+                {
+                iFSFxData->SetState(EWaitEndFullScreen);
                 }
             else
                 {  
 				// was CFullScreenEffectState::EEndFullScreenReceivedWaitingWindowGroup           
-                iFullScreenEffectData->SetState(EEndFullscreenReceived);
+                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;
@@ -1031,42 +1057,50 @@
         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 (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)
@@ -1231,7 +1265,7 @@
     {
     // Look for the correct display
     TInt screenNumber = ResolveScreenNumber(aDisplay);
-    RemoveTemporaryPresenterVisuals();
+    CleanFxVisuals();
     if ( screenNumber != KErrNotFound )
         {
         // FPS Counter with hitchcock drawing
@@ -1408,6 +1442,7 @@
         return;
             
     iTempRegion.Clear();
+    iTempRegion2.Clear();
     
     CAlfScreen* screen = iAlfScreens[aScreenNumber];
     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
@@ -1625,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
@@ -1649,24 +1705,7 @@
                 layout->ClearCanvasFlags(EHuiCanvasFlagExternalFadeExistsInsideVisualTree);            
                 }
             }
-        
-        TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
-        
-        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());
-            }
-        
+               
 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Control group index: %d", j );
         __ALFLOGSTRING1(">>>> HandleVisualVisibility: Active visuals : %d", activevisualcount );
@@ -1736,7 +1775,7 @@
         }
     if ( iSwRenderingEnabled )
         {
-        screen->iDisplay->SetForegroundTextureOptions( alfWindowGroupFoundVisible | alfClientWindowGroupVisible );
+        screen->iDisplay->SetForegroundTextureOptions( alfWindowGroupFoundVisible || alfClientWindowGroupVisible );
         }
    
     // Finally, if there are fadeeffects applied to windowgroups, make sure first one does not
@@ -2216,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);            
         }
     }
 
@@ -2527,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:
@@ -2757,7 +2823,7 @@
         CHuiLayout* lVisual = familyTree[familyIndex];
         lVisual->Owner().Remove(lVisual);
         iOrphanStorage->AppendL( lVisual );
-        RemoveTemporaryPresenterVisual(lVisual);
+        CleanFxVisual(lVisual);
         
         __ALFLOGSTRING1("CAlfBridge::DestroyWindow - orphons: %d", iOrphanStorage->VisualCount());
         }
@@ -2771,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];
@@ -3362,14 +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
-	            && !iSecondaryFullScreenEffectData
-	            && iFullScreenEffectData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
-	            && iFullScreenEffectData->State() == EWaitEndFullScreen
-	            && iFullScreenEffectData->iTwoPhaseEffect != CFullScreenEffectState::ESecondPartActive)
+	    if (iFSFxData
+	            && iFSFxData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
+	            && ((iFSFxData->State() == EWaitEndFullScreen && iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::EFirstPartRunning)))
 	        {
 	        CHuiControlGroup *to_group = NULL;
-            if (iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
+            if (iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect)
                 {
                 to_group = FindControlGroupByFullScreenFromEffect();
                 }
@@ -3397,7 +3461,7 @@
 // 
 void CAlfBridge::GfxTriggerEndFullScreen(CFullScreenEffectState* aFullScreenEffectData)
     {
-    if (iFullScreenEffectData->State() == EFinalEffectActive)
+    if (iFSFxData->State() == EFinalEffectActive)
         {
         return;
         }
@@ -3424,7 +3488,7 @@
     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->SetState(EFinalEffectActive);
         }
@@ -3457,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
@@ -4342,7 +4406,7 @@
             {
             __ALFLOGSTRING("CAlfBridge::HandleMoveWindowToNewGroupL cannot find new group! orphaning the visual");
             
-            RemoveTemporaryPresenterVisual(viz);
+            CleanFxVisual(viz);
              iOrphanStorage->AppendL( viz );
             }
         }
@@ -4597,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, ETrue, EFalse);
+                    	AddFxItemL(aEvent.iHandle, aToLayout, NULL, NULL, EFalse, dummy, ETrue, EFalse);
 						}
                     }
 				// Screenshot was requested, but it could not be taken. Lets cancel the effect.	
@@ -4619,9 +4683,9 @@
                         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 (iSecondaryFullScreenEffectData)
+                        if (iFSFXDataPart2)
                             {
-                            iSecondaryFullScreenEffectData->iEffectType = CFullScreenEffectState::EStartEffect; 
+                            iFSFXDataPart2->iEffectType = CFullScreenEffectState::EStartEffect; 
                             }
                                 
                         aEvent.iCanDestroyOrHideImmediately = ETrue; // enable hiding of windows during application start/activate effects
@@ -4638,13 +4702,19 @@
 
                         // 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)) 
                             {
@@ -4671,9 +4741,9 @@
                             aEvent.iSetupDone = EFalse;
                             failed = ETrue;
                             }
-                        if (iSecondaryFullScreenEffectData)
+                        if (iFSFXDataPart2)
                             {
-                            iSecondaryFullScreenEffectData->iSetupDone = aEvent.iSetupDone;
+                            iFSFXDataPart2->iSetupDone = aEvent.iSetupDone;
                             }
                          return failed;
                          }
@@ -4759,9 +4829,9 @@
                                 {
                                 effectFlags |= KHuiFxOpaqueHint;
                                 }
-                            if (iSecondaryFullScreenEffectData)
+                            if (iFSFXDataPart2)
                                 {
-                                iSecondaryFullScreenEffectData->iSetupDone = ETrue;
+                                iFSFXDataPart2->iSetupDone = ETrue;
                                 }
                             
                             if (aEvent.iRect != TRect())
@@ -4774,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
                             {
@@ -4814,8 +4898,8 @@
             // Freeze only, if buffer was reserved succesfully 
             aLayout->SetFreezeState(ETrue);
         	TBool itemsDestroyed;
-    	    AddEffectItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
-	        iFullScreenEffectData->iAppStartScreenshotItemHandle = aHandle;
+    	    AddFxItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
+	        iFSFxData->iAppStartScreenshotItemHandle = aHandle;
 			}
         }
     }
@@ -4823,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)
@@ -4848,7 +4932,7 @@
         RemoveEffectFromApp(fxData->iFromSecureId, fxData->iFromWg );
         }
     // abort ALL other possible control effects
-    RemoveAllTemporaryPresenterVisuals();
+    CleanAllFxVisuals();
     
     delete iControlEffectData;
     iControlEffectData = NULL;
@@ -4862,8 +4946,8 @@
         }
     
     CleanupStack::PopAndDestroy( fxData );
-    delete iSecondaryFullScreenEffectData;
-    iSecondaryFullScreenEffectData = NULL;
+    delete iFSFXDataPart2;
+    iFSFXDataPart2 = NULL;
     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END");
     }
 
@@ -4894,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); 
         }
@@ -4932,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");
             
@@ -4946,33 +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;
-               delete iSecondaryFullScreenEffectData;
-               iSecondaryFullScreenEffectData = NULL;
-            iFullScreenEffectData = fxData;
-            iFullScreenEffectData->iAppStartScreenshotItemHandle = fxData->iHandle;
+               delete iFSFxData;
+               delete iFSFXDataPart2;
+               iFSFXDataPart2 = NULL;
+            iFSFxData = fxData;
+            iFSFxData->iAppStartScreenshotItemHandle = fxData->iHandle;
             
             stream.Release();
             }
@@ -4985,14 +5069,14 @@
             __ALFFXLOGSTRING("HandleGfxEffectsL - END: ongoing");
             
             // Client expects completion to be signalled with this handle.
-            iFullScreenEffectData->iCompletionHandle = stream.ReadInt32L();
-            if (iSecondaryFullScreenEffectData)
+            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.");
-                iSecondaryFullScreenEffectData->iCompletionHandle = iFullScreenEffectData->iCompletionHandle;
+                iFSFXDataPart2->iCompletionHandle = iFSFxData->iCompletionHandle;
                 }
             
             stream.Release();           
@@ -5004,12 +5088,12 @@
         // End fullscreen signal received. We proceed only if there is really
         // effect ongoing and "end fullscreen" hasn't already been processed.
         
-        if ( !iFullScreenEffectData 
-                || iFullScreenEffectData->State() == EFinalEffectActive
-                || iFullScreenEffectData->State() == EEndFullscreenReceived)
-            {
-            if (iFullScreenEffectData)
-            __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEffectsL - END: fx ready, state %d ", iFullScreenEffectData->State());
+        if ( !iFSFxData 
+                || iFSFxData->State() == EFinalEffectActive
+                || iFSFxData->State() == EEndFullscreenReceived)
+            {
+            if (iFSFxData)
+            __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEffectsL - END: fx ready, state %d ", iFSFxData->State());
             stream.Release();
             return;
             }
@@ -5019,40 +5103,46 @@
         
         TBool timeout = fxData->iTimeout;
         // could the application be ready?
-        CHuiControlGroup* applicationExists = FindControlGroupByFullScreenToEffect();
+        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 (iFullScreenEffectData &&
-                !iSecondaryFullScreenEffectData && // second part has not been requested yet
+        if (iFSFxData &&
+                !iFSFXDataPart2 && // second part has not been requested yet
                 longAppStartTimeout && // this is indeed timeout for app start effect
-                iFullScreenEffectData->iTwoPhaseEffect == CFullScreenEffectState::EOnlyOnePart && // second part has not been activated. note, that iSecondaryFullScreenEffectData would be NULL in this case 
-                (iFullScreenEffectData->State() == EWaitEndFullScreen 
-                 || iFullScreenEffectData->State() == EWaitingWindowGroup))
+                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);
-            iFullScreenEffectData->iLongAppStartTimeout = fxData->iLongAppStartTimeout;
-            iFullScreenEffectData->iTwoPhaseEffect = CFullScreenEffectState::EFirstPartActive;
-            iFullScreenEffectData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
-            }
-
-        __ALFFXLOGSTRING4("HandleGfxEffectsL - iTwoPhaseEffect %d, Setup done: %d, Timeout: %d, long app start timeout: %d", iFullScreenEffectData->iTwoPhaseEffect,iFullScreenEffectData->iSetupDone, timeout,longAppStartTimeout);
+            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 (iFullScreenEffectData->State() == EWaitingWindowGroup)
-                {
-                iFullScreenEffectData->SetState(EEndFullScreenReceivedWaitingWindowGroup);
+            if (iFSFxData->State() == EWaitingWindowGroup)
+                {
+                iFSFxData->SetState(EEndFullScreenReceivedWaitingWindowGroup);
                 }
             else
                 {
-                iFullScreenEffectData->SetState(EEndFullscreenReceived);
+                iFSFxData->SetState(EEndFullscreenReceived);
                 }
             
-            if (iSecondaryFullScreenEffectData)
-                {
-                iSecondaryFullScreenEffectData->SetState(EEndFullscreenReceived);
+            if (iFSFXDataPart2)
+                {
+                iFSFXDataPart2->SetState(EEndFullscreenReceived);
                 }
             
             }
@@ -5062,12 +5152,12 @@
         __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEffectsL - Regular timeout: %d, Slow start timeout: %d, Effect setup: %d, State: %d",
                 timeout,
                 longAppStartTimeout,
-                iFullScreenEffectData->iSetupDone,
-                iFullScreenEffectData->State());
+                iFSFxData->iSetupDone,
+                iFSFxData->State());
 
         stream.Release();// We should respect normal timeouts.
-        if (iFullScreenEffectData->iTwoPhaseEffect > CFullScreenEffectState::EOnlyOnePart
-                && iFullScreenEffectData->iSetupDone && timeout && longAppStartTimeout) // timeout = endfullscreen was requested or it was normal endfullscreen timeout, longAppStartTime = 
+        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 
@@ -5077,14 +5167,24 @@
         
         // 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 (iFullScreenEffectData->State() == EEndFullscreenReceived && !applicationExists && !timeout)
+        if (iFSFxData->State() == EEndFullscreenReceived && !applicationExists && !timeout)
             {
             HandleGfxStopEvent(ETrue);
             return;
             }
-        }
-
-    CFullScreenEffectState* fxData = iFullScreenEffectData;
+	    // 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;
 
     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEffectsL - Operation: %d, handle: %d, type: %d", operation, fxData->iHandle, fxData->iType);
@@ -5123,7 +5223,7 @@
             // We found layout, and this was beginfullscreen event. Wait for endfullscreen to be triggered
             if (fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen)
                 {
-                iFullScreenEffectData->SetState(EWaitEndFullScreen);
+                iFSFxData->SetState(EWaitEndFullScreen);
                 }
             }
         else
@@ -5136,7 +5236,7 @@
     if ( failed )
         {
         // Effect failed, reset state
-        HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
+        HandleGfxStopEvent( EFalse ); // destroys iFSFxData and iFSFXDataPart2
         }
     else
         {
@@ -5168,14 +5268,14 @@
     if (aState.iLongAppStartTimeout) // only application start effects can trigger this timeout 
         {
         // clone the primary startup effect for later usage
-        delete iSecondaryFullScreenEffectData;
-        iSecondaryFullScreenEffectData = new (ELeave) CFullScreenEffectState;
-        iSecondaryFullScreenEffectData->ConstructL(*iFullScreenEffectData);
-        iSecondaryFullScreenEffectData->iLongAppStartTimeout = EFalse;
+        delete iFSFXDataPart2;
+        iFSFXDataPart2 = new (ELeave) CFullScreenEffectState;
+        iFSFXDataPart2->ConstructL(*iFSFxData);
+        iFSFXDataPart2->iLongAppStartTimeout = EFalse;
         
-        delete iFullScreenEffectData->iEffectName;
-        iFullScreenEffectData->iEffectName = NULL;
-        iFullScreenEffectData->iEffectName = aState.iEffectName->AllocL();
+        delete iFSFxData->iEffectName;
+        iFSFxData->iEffectName = NULL;
+        iFSFxData->iEffectName = aState.iEffectName->AllocL();
         }
     __ALFFXLOGSTRING("CAlfBridge::UpdateSecondaryEffectL <<" );
     return EFalse;
@@ -5214,10 +5314,25 @@
             }
         }
     
-    __ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - Covered: %d", fullscreenCovered);
+    __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;
@@ -5244,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 );
@@ -5253,7 +5368,7 @@
     if ( !toAppUi )
         {
         __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill all");
-        RemoveAllTemporaryPresenterVisuals();
+        CleanAllFxVisuals();
         iHuiEnv->ContinueRefresh();
         }
     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - end");
@@ -5276,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");
@@ -5360,7 +5475,7 @@
         }
     }
 
-CHuiCanvasVisual* CAlfBridge::AddEffectItemL(
+CHuiCanvasVisual* CAlfBridge::AddFxItemL(
         TInt aEffectHandle, 
         CHuiVisual* aSourceVisual, 
         CHuiLayout* aTargetLayout, 
@@ -5396,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++;
@@ -5453,7 +5568,7 @@
     __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x is having %d children", aSourceLayout, aSourceLayout->Count());
     if (aAddLayout)
         {
-        AddEffectItemL(aEffectHandle, aSourceLayout, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
+        AddFxItemL(aEffectHandle, aSourceLayout, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, aIsExitEffect, aCanDestroyOrHideImmediately);
         }
         
     for (TInt i = 0; i < aSourceLayout->Count(); i++)
@@ -5466,7 +5581,7 @@
                AddToEffectLayoutContainerL(aEffectHandle, &layout, NULL, aEffectControl, aItemsDestroyed, aIsFullScreenEffect,  EFalse, aIsExitEffect, aCanDestroyOrHideImmediately );
                }
            TInt oldItemsDestroyed = aItemsDestroyed;
-           AddEffectItemL(aEffectHandle, &sourceVisual, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsFullScreenEffect, 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.
@@ -5478,7 +5593,7 @@
 
 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsFullScreenEffect, TBool aIsExitEffect, TBool aCanDestroyOrHideImmediately)
     {
-    __ALFFXLOGSTRING4("CAlfBridge::SetupEffectLayoutContainerL - aHandle: %d, aSourceLayout: 0x%x, aIsExitEffect: % d, CanDestroyOrHideImmediately: %d >>", 
+    __ALFFXLOGSTRING4("CAlfBridge::SetupEffectLayoutContainerL - aHandle: %d, aSourceLayout: 0x%x, aIsExitEffect: %d, CanDstrOrHideImd.:%d >>", 
             aHandle, 
             aSourceLayout, 
             aIsExitEffect,
@@ -5501,13 +5616,13 @@
 
     if (aIsExitEffect)
         {
-        CHuiCanvasVisual* temporaryPresenterVisual = AddEffectItemL(aHandle, aSourceLayout, &effectControlGroupLayout, &effectControlGroup, ETrue, itemsDestroyed, aIsFullScreenEffect, 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, aIsFullScreenEffect, 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;
@@ -5621,26 +5736,21 @@
 
         // 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);
-                }*/
+            {
+            if (aCanvasVisual->Flags() & EHuiVisualFlagInactive)
+                {
+                __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x is inactive. Skipping effect.", aCanvasVisual);
+                return;
+                }
             layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse, ETrue, EFalse);
             }
         else
@@ -5671,6 +5781,8 @@
             }
         //            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)
             {
 #ifdef HUI_DEBUG_TRACK_DRAWING  
@@ -5683,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);
@@ -5704,16 +5816,35 @@
     sourceViz->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
     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;
-        showVisual = (sourceViz->Flags() & EHuiVisualFlagShouldBeShown) && !aEffectItem.iHideWhenFinished;
+        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;
@@ -5817,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);
@@ -5829,7 +5960,7 @@
         if (aVisual == effectItem.iEffectedVisual || 
 		    aHandle == effectItem.iHandle)
             {
-            if (RemoveTemporaryPresenterItem(effectItem))
+            if (CleanFxItem(effectItem))
                 {
                 visualsRemoved++;
                 }
@@ -5908,7 +6039,7 @@
     }
 
 
-TBool CAlfBridge::RemoveTemporaryPresenterVisuals()
+TBool CAlfBridge::CleanFxVisuals()
     {
     if (!iFinishedCleanupStackEffects.Count())
         {
@@ -5928,7 +6059,7 @@
              
             if (iFinishedCleanupStackEffects[0] == effectItem.iHandle)
                 {
-                if (RemoveTemporaryPresenterItem(effectItem))
+                if (CleanFxItem(effectItem))
                     {
                     itemsRemoved++;
                     }
@@ -5954,7 +6085,7 @@
     return itemsRemoved;
     }
 
-void CAlfBridge::RemoveAllTemporaryPresenterVisuals()
+void CAlfBridge::CleanAllFxVisuals()
     {
     CHuiControl& effectControlGroup =  iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0);
     CHuiLayout* effectControlGroupLayout = (CHuiLayout*) &effectControlGroup.Visual(0);
@@ -5963,7 +6094,7 @@
     while(iEffectCleanupStack.Count())
         {
         TEffectCleanupStruct& effectItem = iEffectCleanupStack[0];
-        RemoveTemporaryPresenterItem(effectItem);
+        CleanFxItem(effectItem);
         iEffectCleanupStack.Remove(0);
         }
     
@@ -5989,30 +6120,29 @@
     // iFinishedCleanupStackEffects.Append(aHandle);
     
 	// check if the first part of application start effect finished
-    if (iFullScreenEffectData 
-            && iFullScreenEffectData->iHandle == aHandle
-            && iFullScreenEffectData->iLongAppStartTimeout && iSecondaryFullScreenEffectData)
-        {
-        delete iFullScreenEffectData;
-        iFullScreenEffectData = iSecondaryFullScreenEffectData;
-        iSecondaryFullScreenEffectData = NULL;
-        iFullScreenEffectData->iTwoPhaseEffect = CFullScreenEffectState::ESecondPartActive;
-        if (iFullScreenEffectData->State() == EEndFullscreenReceived)
+    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.");
-            iFullScreenEffectData->SetState(ESecondPhaseSetupActive); // effect setup will be skipped in HandleGfxEvent
-            GfxTriggerEndFullScreen(iFullScreenEffectData);
-            iFullScreenEffectData->SetState(EFinalEffectActive);
+            GfxTriggerEndFullScreen(iFSFxData);
+            iFSFxData->SetState(EFinalEffectActive);
 			// skip cleanup. It will be run, when this effect finishes
             return;
             }
         else
             {
-            iFullScreenEffectData->SetState(EWaitEndFullScreen);
+            iFSFxData->SetState(EWaitEndFullScreen);
             }
         
-        iFullScreenEffectData->iEffectType = CFullScreenEffectState::EStartEffect;
+        iFSFxData->iEffectType = CFullScreenEffectState::EStartEffect;
         
         CHuiControlGroup* toGroup = FindControlGroupByFullScreenToEffect();
         GfxTriggerEffectWhenFullScreenDrawn(toGroup);
@@ -6053,21 +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 iSecondaryFullScreenEffectData;
-        iSecondaryFullScreenEffectData = NULL;
+        delete iFSFXDataPart2;
+        iFSFXDataPart2 = NULL;
         }
     }
     
@@ -6739,46 +6869,41 @@
     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() == EHuiFpsIndicatorContainer)
             {
             // FPS container doesn't contain canvas visuals
@@ -6786,22 +6911,19 @@
             }
 
         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
+        // ALF applications are handled by checking if their visuals cover the whole screen.
         if (control.Role() == EHuiSessionContainer)
             {
             CHuiLayout* hostContainer = control.ContainerLayout( NULL );
@@ -6830,29 +6952,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)
@@ -7054,6 +7443,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.
         }
     }
 
--- a/uiacceltk/hitchcock/ServerCore/Src/alfeffectutils.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfeffectutils.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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,13 +880,6 @@
 
 CFullScreenEffectState::~CFullScreenEffectState()
     {
-    iPaintedRegion.Close();
-    if (iDrawingCompleteTimer)
-        {
-        iDrawingCompleteTimer->Cancel();
-        delete iDrawingCompleteTimer;
-        iDrawingCompleteTimer = NULL;
-        }
     }
 
 void CFullScreenEffectState::ConstructL(const CFullScreenEffectState& aEffectState)
@@ -872,6 +942,7 @@
     {
     if (aState >= iState)
         {
+        __ALFFXLOGSTRING2("CFullScreenEffectState::SetState - Set %d -> %d", iState, aState);
         iState = aState;
         }
     else
@@ -882,6 +953,7 @@
         
 TEffectState CFullScreenEffectState::State()
     {
+    __ALFFXLOGSTRING1("CFullScreenEffectState::State - %d", iState);
     return iState;
     }
       
--- a/uiacceltk/hitchcock/ServerCore/Src/alfhierarchymodel.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfhierarchymodel.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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();
     }
 
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/ServerCore/Src/alfstreamerserver.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfstreamerserver.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -739,7 +739,7 @@
     
     for ( TInt i = 0; i<count; i++ ) 
         {
-        __ALFLOGSTRING1("CAlfStreamerServer::GetListOfWGsHavingInactiveSurfacesL adding %d", arrayPtr[i].iWindowGroup);
+        __ALFLOGSTRING1("CAlfStreamerServer::GetListOfWGsHavingInactiveSurfacesL adding %d", arrayRef[i].iWindowGroup);
         *array = arrayRef[i].iWindowGroup;
         array++;
         if (optionalOnly)
--- a/uiacceltk/hitchcock/ServerCore/Src/alfvisualhandlers.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfvisualhandlers.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -777,7 +777,10 @@
                 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;
@@ -798,7 +801,10 @@
                 // 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;
@@ -806,6 +812,7 @@
         case EAlfVisualRemoveEffect:
             {
             iVisual->SetEffect(NULL);
+            iVisual->SetFreezeState(EFalse); // Note: alf effects do not support freezing.
             break;
             }
 
--- a/uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/eabi/hitchcocku.DEF	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/group/huitk_base.mmp	Tue Jun 08 13:16:48 2010 +0300
@@ -76,6 +76,8 @@
 SOURCE          HuiImageLoaderUtil.cpp
 SOURCE          huifixmath.cpp
 
+SOURCE		appiconcache.cpp
+
 // Toolkit Core
 SOURCE          HuiTimedValue.cpp
 SOURCE          HuiTimedPoint.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/coretoolkit/inc/appiconcache.h	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huicanvasdebugwsgc.h	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h	Tue Jun 08 13:16:48 2010 +0300
@@ -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
@@ -391,7 +395,7 @@
     mutable RRegionBuf<KHuiCanvasWsPainterRegionGranularity> iTempIntersectingRegion;
 
 #ifdef HUI_DEBUG_TRACK_DRAWING
-    CAlfCommandDebug* iCommandDebugger;
+    CHuiCanvasDebugWsGc* iCanvasDebugWsGc; 
 #endif
     
     // Boolean flag indicating if render buffer ought to be used.
--- a/uiacceltk/hitchcock/coretoolkit/inc/huistatictlsdata.h	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huistatictlsdata.h	Tue Jun 08 13:16:48 2010 +0300
@@ -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/inc/HuiVg10Texture.h	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Texture.h	Tue Jun 08 13:16:48 2010 +0300
@@ -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/HuiVg10RenderSurface.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10RenderSurface.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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,35 @@
             else
                 aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), size, NULL, NULL);
             }
+        // 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;
+                }
+            }
         }
 
     // restore the old surface before restoring original modes
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -69,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 */
@@ -2940,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;
 
@@ -2957,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)
             {
@@ -3156,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();        
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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.
@@ -872,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
 
@@ -893,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);    
     }
 
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiDisplay.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiDisplay.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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());
     }
 
@@ -884,7 +890,7 @@
         // Set up the clipping rectangle.
         TRect dirtyRect = iTempDirtyRegions[iCurrentDirtyIndx];
         ClipDirtyRect(dirtyRect, VisibleAreaClippingRect());
-        
+        iCurrentDirtyRect = dirtyRect;
         iGc->PushClip();
         iGc->Clip(dirtyRect);        
         
@@ -914,7 +920,7 @@
             iForegroundBitmapGc->SetPenColor(clearColor);
             iForegroundBitmapGc->SetBrushColor(clearColor);
             iForegroundBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
-  	        iForegroundBitmapGc->Clear();
+  	        iForegroundBitmapGc->Clear(dirtyRect);
   	        iForegroundBitmapGc->Reset();
             }
         		
@@ -975,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)
@@ -1633,6 +1612,18 @@
     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))
@@ -1671,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));
         }
     }
@@ -1822,3 +1822,7 @@
         }
     }
 
+TRect CHuiDisplay::CurrentDirtyRect()
+    {
+    return iCurrentDirtyRect;
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiEnv.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiEnv.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -612,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/HuiRosterImpl.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiRosterImpl.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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"
@@ -801,6 +802,12 @@
             
             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;
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiS60Skin.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiS60Skin.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiStatic.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiVisual.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -2167,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	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvasdebugwsgc.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaspainter.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -254,10 +254,22 @@
         {        
         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();
             }
         }    
+    
+    if (iCanvasVisual)
+        {
+        TRect displayRect(iCanvasVisual->DisplayRect());
+        tempRegion.ClipRect(TRect(displayRect.Size()));
+        tempRegion.Offset(displayRect.iTl);
+        }
+
     TRect result = tempRegion.BoundingRect();
     tempRegion.Close();
     return result;
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvaswsbitgc.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswsbitgc.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswshwgc.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -1906,8 +1906,8 @@
     if (aUpdateDisplay && renderbuffer && iCanvasGc->Gc())
         {
         THuiRealRect updatedRect = aUpdateRegion.BoundingRect();
-				  TInt w; 
-				  TInt h ;
+        TInt w = 0; 
+		TInt h = 0;
         // Handle relative rotation
         if (iVisual->Display())
             {
@@ -2136,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
@@ -2158,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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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>
@@ -126,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
     }
 
 
@@ -157,7 +161,7 @@
     iTempCurrentSubRegion.Close();
     iTempIntersectingRegion.Close();
 #ifdef HUI_DEBUG_TRACK_DRAWING
-    delete iCommandDebugger;
+    delete iCanvasDebugWsGc;
 #endif
     iFullUpdateRegion.Close();
     iShapeRegion.Close();
@@ -566,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
@@ -761,7 +771,7 @@
             }
         }
 
-    iCommandDebugger->StartFrame();
+    TTlsData::CommandDebugger()->StartFrame();
     if ( commandBuffer->iProcessName )
         {
         // UNCOMMENT THIS IF YOU WANT TO PRINT EVERYTHING
@@ -797,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
@@ -1286,7 +1296,7 @@
        	
         } while( offset < bufLength );
 #ifdef HUI_DEBUG_TRACK_DRAWING
-    iCommandDebugger->EndFrame();
+    TTlsData::CommandDebugger()->EndFrame();
 #endif    
     }
     
@@ -2140,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();                    
@@ -2752,8 +2762,16 @@
         }
 
     #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();
--- a/uiacceltk/hitchcock/group/bld.inf	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/group/bld.inf	Tue Jun 08 13:16:48 2010 +0300
@@ -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/plugins/alftranseffect/alfgfxtransadapter/inc/gfxtransenginetfx.h	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/inc/gfxtransenginetfx.h	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -295,6 +295,8 @@
 CGfxTransAdapterTfx::~CGfxTransAdapterTfx()
 	{
 	
+    
+    iControlEffects.Close();
 	__ALFFXLOGSTRING("CGfxTransAdapterTfx for HWA transitionn effects, destructor ");
 //	iIgnoredWOChildControls.Close();
 	//iControlInfo.ResetAndDestroy();
@@ -462,6 +464,16 @@
 	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;
@@ -470,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:
@@ -777,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;
@@ -872,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;
     }
 
 
@@ -1264,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,
@@ -1298,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/alfgfxeffects.h	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/inc/alfgfxeffects.h	Tue Jun 08 13:16:48 2010 +0300
@@ -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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/inc/alfserverdrawer.h	Tue Jun 08 13:16:48 2010 +0300
@@ -102,6 +102,11 @@
 
 	TInt SendBeginFullscreen(TInt aHandle, TUint aAction, const TUid& aUid, 
 							 const TUid& aPreviousUid, const TRect& aEffectRect);
+	/**
+	 *  SendEndFullscreen
+	 *  
+	 *  @return    1, If longer app start effect was triggered. Otherwise returns 0.
+	 */
 	TInt SendEndFullscreen(TBool aTimeout = EFalse);
 	TInt SendAbortFullscreen();
 	TInt SendAbortControlTransition();
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfgfxeffects.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfgfxeffects.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -223,7 +223,7 @@
 		    else
 		        {
 	            action = inStream.ReadUint32L();
-#ifdef _DEBUG    
+#ifdef _ALF_FXLOGGING    
     PrintRequestInfo( op, action);
 #endif    
 	            TRect effectRect( inStream.ReadInt32L(),
@@ -247,13 +247,13 @@
 		        }
             break;
         case MAlfGfxEffectPlugin::EEndFullscreen:
-#ifdef _DEBUG    
+#ifdef _ALF_FXLOGGING    
     PrintRequestInfo( op, action);
 #endif    
             iEngine->EndFullscreen(EFalse); // not timeout, but official endfullscreen
             break;
         case MAlfGfxEffectPlugin::EAbortFullscreen:
-#ifdef _DEBUG    
+#ifdef _ALF_FXLOGGING
     PrintRequestInfo( op, action);
 #endif    
 
@@ -272,7 +272,7 @@
                 // we have enough information.
                 {
                 action = inStream.ReadUint32L();
-#ifdef _DEBUG    
+#ifdef _ALF_FXLOGGING    
     PrintRequestInfo( op, action);
 #endif    
                 
@@ -298,7 +298,7 @@
         case MAlfGfxEffectPlugin::ETfxServerOpAddFullscreenKMLEx:
             {
             action = inStream.ReadUint32L();
-#ifdef _DEBUG    
+#ifdef _ALF_FXLOGGING    
     PrintRequestInfo( op, action);
 #endif    
 
@@ -873,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	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -944,9 +944,10 @@
 
     iFullScreenFinished = EFalse;
     iFullScreenTimeout->iIsStartEffect = EFalse;
+ 	
     if (triggerStartEffectTimeout)
         {
-        return KErrNone;
+        //return KErrNone;  // even long app start effects need some hardcore timeout
         }
     if ( iAction == AknTransEffect::EApplicationExit /*||
         iAction == 1001*/  ) 
@@ -958,7 +959,7 @@
         {
         iFinishFullScreen->Start( KAlfLongEffectTimeout, TCallBack( FinishFullScreenTimeout, this ) );
         }
-    return KErrNone;
+    return triggerStartEffectTimeout;
     }
 
 // ---------------------------------------------------------------------------
@@ -975,7 +976,8 @@
         }
 
     iFullScreenTransitionEndObserver->Cancel();
-    
+    iFinishFullScreen->Cancel();
+    iFullScreenTimeout->Cancel();
     iFullScreenFxSent = EFalse;
     iFullScreenEndSent = ETrue;
     
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/states.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/states.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -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())) 
 				{
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/wsserverdrawercontroller.cpp	Wed May 26 16:47:36 2010 +0300
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/wsserverdrawercontroller.cpp	Tue Jun 08 13:16:48 2010 +0300
@@ -744,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);
 			}
 		}
@@ -915,6 +921,7 @@
     // Convert 
 
     // Signal statemachine
+    SaveLastActionAndUid();
     iStates->Signal(CStateBase::EBeginFullscreen);
 	// Start end checker always.
 	if(flags & AknTransEffect::TParameter::EEndCheck)