Revision: 201007 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 12 Mar 2010 15:47:04 +0200
branchRCL_3
changeset 7 433cbbb6a04b
parent 3 d8a3531bc6b8
child 8 10534483575f
Revision: 201007 Kit: 201008
rom/alfred.iby
uiaccelerator_plat/alf_client_server_api/inc/alf/alfappui.h
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiCanvasVisual.h
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiControlGroup.h
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiDisplay.h
uiacceltk/hitchcock/AlfDecoderServerClient/src/alfdecoderserverclient.cpp
uiacceltk/hitchcock/AlfRenderStage/inc/alfrenderstage.h
uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstage.cpp
uiacceltk/hitchcock/CommonInc/alflogger.h
uiacceltk/hitchcock/CommonInc/alfmoduletest.h
uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h
uiacceltk/hitchcock/ServerCore/Inc/alfeffectutils.h
uiacceltk/hitchcock/ServerCore/Inc/alfhierarchymodel.h
uiacceltk/hitchcock/ServerCore/Inc/alfnodes.h
uiacceltk/hitchcock/ServerCore/Src/alfappservercore.mmp
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/alfnodes.cpp
uiacceltk/hitchcock/ServerCore/Src/alfsrvdisplaysubsession.cpp
uiacceltk/hitchcock/backgroundanim/refplugin/group/refplugin.mmp
uiacceltk/hitchcock/backgroundanim/refplugin/src/shader.c
uiacceltk/hitchcock/backgroundanim/src/bganimhost.cpp
uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF
uiacceltk/hitchcock/coretoolkit/inc/HuiFxConstants.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffect.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffectCache.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxLayer.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxParameter.h
uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h
uiacceltk/hitchcock/coretoolkit/inc/huiextension.h
uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Texture.h
uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiControlGroup.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiDisplay.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiEnv.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxEffectParser.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxEngine.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxGroupLayer.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxLayer.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxParameterManager.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiFxVisualLayer.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiStatic.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvasgc.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvaswshwgc.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp
uiacceltk/hitchcock/goommonitor/data/goomconfig.xml
uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h
uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp
uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp
uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp
uiacceltk/hitchcock/group/core_exports.inc
uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp
--- a/rom/alfred.iby	Mon Feb 22 17:57:49 2010 +0200
+++ b/rom/alfred.iby	Fri Mar 12 15:47:04 2010 +0200
@@ -116,6 +116,10 @@
 data=DATAZ_/RESOURCE_FILES_DIR/effects/musicplayer_popup_disappear.fxml RESOURCE_FILES_DIR/effects/musicplayer_popup_disappear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/musicplayer_viewswitch_in.fxml RESOURCE_FILES_DIR/effects/musicplayer_viewswitch_in.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/musicplayer_viewswitch_out.fxml RESOURCE_FILES_DIR/effects/musicplayer_viewswitch_out.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/notificationwidget_appear.fxml RESOURCE_FILES_DIR/effects/notificationwidget_appear.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/notificationwidget_dd_appear.fxml RESOURCE_FILES_DIR/effects/notificationwidget_dd_appear.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/notificationwidget_dd_disappear.fxml RESOURCE_FILES_DIR/effects/notificationwidget_dd_disappear.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/notificationwidget_disappear.fxml RESOURCE_FILES_DIR/effects/notificationwidget_disappear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/optionsmenu_appear.fxml RESOURCE_FILES_DIR/effects/optionsmenu_appear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/optionsmenu_cascade_appear.fxml RESOURCE_FILES_DIR/effects/optionsmenu_cascade_appear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/optionsmenu_cascade_disappear.fxml RESOURCE_FILES_DIR/effects/optionsmenu_cascade_disappear.fxml
@@ -127,6 +131,7 @@
 data=DATAZ_/RESOURCE_FILES_DIR/effects/preview_popup_disappear.fxml RESOURCE_FILES_DIR/effects/preview_popup_disappear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/screensaver_activate.fxml RESOURCE_FILES_DIR/effects/screensaver_activate.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/screensaver_deactivate.fxml RESOURCE_FILES_DIR/effects/screensaver_deactivate.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/skinchange.fxml RESOURCE_FILES_DIR/effects/skinchange.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/systemnotify_appear.fxml RESOURCE_FILES_DIR/effects/systemnotify_appear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/systemnotify_disappear.fxml RESOURCE_FILES_DIR/effects/systemnotify_disappear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/tab_effect.fxml RESOURCE_FILES_DIR/effects/tab_effect.fxml
--- a/uiaccelerator_plat/alf_client_server_api/inc/alf/alfappui.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiaccelerator_plat/alf_client_server_api/inc/alf/alfappui.h	Fri Mar 12 15:47:04 2010 +0200
@@ -196,6 +196,7 @@
     void SetAlfWindowGroupId(TInt aWgId);
     void NotifyLowMemory(TInt aAmountOfFreeMemRequested);
     TInt ForceSwRendering(TBool aEnabled);
+    void SetAlfAppWindowGroup( TInt aID );
     
 private:
 
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiCanvasVisual.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiCanvasVisual.h	Fri Mar 12 15:47:04 2010 +0200
@@ -418,6 +418,11 @@
     static TBool RecursiveIsExternalContentDrawingEnabled(CHuiVisual* aVisual);
     static TBool RecursiveHasCommandBuffers(CHuiVisual* aVisual);
     
+    void CollectPaintedRegion(TRegion& aRecursivePaintRegion, TInt aExcludeCanvasFlags) const;
+    void CollectRecursivePaintedRegion(TRegion& aRecursivePaintRegion, TInt aExcludeCanvasFlags) const;
+    
+    TBool CanSkipDrawing() const;
+
 private: 
 
     struct THuiCanvasVisualData;
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiControlGroup.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiControlGroup.h	Fri Mar 12 15:47:04 2010 +0200
@@ -247,7 +247,8 @@
      *              elements. 
      */
     THuiTimedValue iOpacity;
-
+    TBool iAlfApp;
+  
 	};
 
 #endif  // __HUICONTROLGROUP_H__
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiDisplay.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiDisplay.h	Fri Mar 12 15:47:04 2010 +0200
@@ -805,9 +805,20 @@
      */
     IMPORT_C CFbsBitmap* ForegroundBitmap() const;
     
+    
 private:
 
     /**
+     * Uploads foreground bitmap to texture.
+     */
+    void UpdateForegroundTexture(const TRect& aRect);
+    
+    /**
+     * Actual upload foreground bitmap to texture.
+     */
+    void DoUpdateForegroundTextureL(const TRect& aRect);
+    
+    /**
      * Draws foreground texture.
      */     
     void DrawForegroundTexture();
--- a/uiacceltk/hitchcock/AlfDecoderServerClient/src/alfdecoderserverclient.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/AlfDecoderServerClient/src/alfdecoderserverclient.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -44,7 +44,9 @@
         {
         return err;
         }
-        
+    
+    User::SetCritical(User::ESystemCritical); // reset the device if we die
+
     // create CCleanup
     CTrapCleanup * cleanup = CTrapCleanup::New();
     if (cleanup)
--- a/uiacceltk/hitchcock/AlfRenderStage/inc/alfrenderstage.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/inc/alfrenderstage.h	Fri Mar 12 15:47:04 2010 +0200
@@ -20,6 +20,9 @@
 #ifndef __ALFRENDERSTAGE_H__
 #define __ALFRENDERSTAGE_H__
 
+#define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
+#include "alfmoduletest.h"
+
 #include <graphics/wsrenderstage.h>
 #include <graphics/wscursor.h>
 #include "alfrsgc.h"
--- a/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstage.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstage.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -71,7 +71,15 @@
 	delete iWsGraphicsContext;
 	delete iGoomSession;
 	
-	// Used just as a temporary holding place, do not delete!
+    #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    if (Dll::Tls()!=NULL) 
+        {
+        delete AMT_CONTROL();
+        Dll::FreeTls();
+        }
+    #endif
+
+    // Used just as a temporary holding place, do not delete!
 	iWindowDrawingNode = NULL;	
 	}
 
@@ -109,6 +117,15 @@
       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         
+    
     __ALFLOGSTRING("CAlfRenderStage: ready to rock");
     }
 
@@ -348,17 +365,46 @@
     drawRegion.AddRect( aExtent );
     TRegionFix<1> clipRegion;
     clipRegion.AddRect( aClipRect );
-            
+
+    TRgb penColor = TRgb(0x555555); 
+    TRgb brushColor = TRgb(0x555555); 
+    TRgb dotColor = TRgb(0xBBBBBB); 
+    
     WindowRedrawStart( aWindowTreeNode, drawRegion );
     iWsGraphicsContext->Reset();
     iWsGraphicsContext->SetDrawMode( MWsGraphicsContext::EDrawModePEN );
     iWsGraphicsContext->SetBrushStyle( MWsGraphicsContext::ESolidBrush );
     iWsGraphicsContext->SetPenStyle( MWsGraphicsContext::ESolidPen );
-    iWsGraphicsContext->SetBrushColor( KRgbBlack ); // color from interface is white, so temporirily putting black
-    //const TRect clipRect = cursor->ClipRect();
-    //const TRect cursorRect = cursor->Rect();
-    iWsGraphicsContext->SetClippingRegion( clipRegion );
+    iWsGraphicsContext->SetBrushColor( brushColor ); 
+    iWsGraphicsContext->SetPenColor( penColor );
+    iWsGraphicsContext->SetClippingRegion( clipRegion );    
     iWsGraphicsContext->DrawRect( aCursorRect );    
+
+    // Draw pattern to cursor so that it is visible in any color backgrounds.
+    iWsGraphicsContext->SetPenColor( dotColor );    
+    TPoint start = aCursorRect.iTl;
+    TPoint end = TPoint(aCursorRect.iTl.iX, aCursorRect.iBr.iY);
+    
+    for (TInt i=0; i<aCursorRect.Width();i++)
+        {    
+        TPoint point = start;
+        for (TInt j=0; j<aCursorRect.Height();j++)
+            {
+            if ((i % 2))
+                {
+                if (j % 2)
+                    iWsGraphicsContext->Plot(point);            
+                }
+            else
+                {
+                if (!(j % 2))
+                    iWsGraphicsContext->Plot(point);                        
+                }                
+            point.iY++;
+            }
+        start.iX++;
+        }
+        
     WindowRedrawEnd( aWindowTreeNode );
     }
 
@@ -544,6 +590,10 @@
         }
 #endif    
 	iAlfSendBuffer->CommitL();
+	
+    AMT_INC_COUNTER_IF(nodeType==MWsWindowTreeNode::EWinTreeNodeClient, iRsWindowNodeCount ); 
+    AMT_INC_COUNTER_IF(nodeType==MWsWindowTreeNode::EWinTreeNodeGroup,  iRsWindowGroupNodeCount ); 
+    AMT_INC_COUNTER(iRsWindowGroupNodeCount ); 
     }
 
 // ---------------------------------------------------------------------------
@@ -584,6 +634,9 @@
 	    __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(iRsWindowGroupNodeCount ); 
     }
 
 // ---------------------------------------------------------------------------
@@ -601,6 +654,8 @@
 
 	iAlfSendBuffer->CommitL();
     __ALFLOGSTRING("CAlfRenderStage::NodeActivated <<");
+   
+    AMT_INC_COUNTER_IF(nodeType==MWsWindowTreeNode::EWinTreeNodeClient, iRsWindowNodeActivatedCount ); 
     }
 
 // ---------------------------------------------------------------------------
@@ -637,6 +692,9 @@
             );    
         }
 	iAlfSendBuffer->CommitL();
+
+    AMT_INC_COUNTER( iRsNodeExtentChangedCount );
+    AMT_SET_VALUE( iRsLatestNodeExtentRect, aRect );
     }
 
 // ---------------------------------------------------------------------------
@@ -669,6 +727,8 @@
             aNewValue,
             &aWindowTreeNode   );
 	iAlfSendBuffer->CommitL();
+
+    AMT_INC_COUNTER( iRsTotalNodeFlagChangedCount );
     }
 
 // ---------------------------------------------------------------------------
@@ -731,7 +791,9 @@
                 }
             }
         iAlfSendBuffer->CommitL();
-        } 
+        
+        AMT_INC_COUNTER( iRsTotalNodeAttributeChangedCount );
+        }    
     }
 
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/CommonInc/alflogger.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/CommonInc/alflogger.h	Fri Mar 12 15:47:04 2010 +0200
@@ -56,18 +56,21 @@
     #define __ALFLOGSTRING1(C, X)
     #define __ALFLOGSTRING2(C, X, Y)
     #define __ALFLOGSTRING3(C, X, Y, Z)
+    #define __ALFLOGSTRING4(C, X, Y, Z, W)
 #endif
 #if (ALF_LOGGING_METHOD==1)
     #define __ALFLOGSTRING(C)            RDebug::Print(_L(C));
     #define __ALFLOGSTRING1(C, X)        RDebug::Print(_L(C),X);
     #define __ALFLOGSTRING2(C, X, Y)     RDebug::Print(_L(C),X, Y);
     #define __ALFLOGSTRING3(C, X, Y, Z)  RDebug::Print(_L(C),X, Y, Z);
+    #define __ALFLOGSTRING4(C,X,Y,Z,W)   RDebug::Print(_L(C),X, Y, Z, W);
 #endif
 #if (ALF_LOGGING_METHOD==2)
     #define __ALFLOGSTRING(C)            {_LIT(tempLogDes,C);RFileLogger::WriteFormat(KLogsDir(),KLogFileName(), EFileLoggingModeAppend, tempLogDes());}
     #define __ALFLOGSTRING1(C, X)        {_LIT(tempLogDes,C);RFileLogger::WriteFormat(KLogsDir(),KLogFileName(), EFileLoggingModeAppend, TRefByValue<const TDesC>(tempLogDes()),X);}
     #define __ALFLOGSTRING2(C, X, Y)     {_LIT(tempLogDes,C);RFileLogger::WriteFormat(KLogsDir(),KLogFileName(), EFileLoggingModeAppend, TRefByValue<const TDesC>(tempLogDes()),X,Y);}
     #define __ALFLOGSTRING3(C, X, Y, Z)  {_LIT(tempLogDes,C);RFileLogger::WriteFormat(KLogsDir(),KLogFileName(), EFileLoggingModeAppend, TRefByValue<const TDesC>(tempLogDes()),X,Y,Z);}
+    #define __ALFLOGSTRING4(C,X,Y,Z,W)   {_LIT(tempLogDes,C);RFileLogger::WriteFormat(KLogsDir(),KLogFileName(), EFileLoggingModeAppend, TRefByValue<const TDesC>(tempLogDes()),X,Y,Z,W);}
 #endif
 
 // Logging for effects components
@@ -86,18 +89,22 @@
     #define __ALFFXLOGSTRING1(C, X)
     #define __ALFFXLOGSTRING2(C, X, Y)
     #define __ALFFXLOGSTRING3(C, X, Y, Z)
+    #define __ALFFXLOGSTRING4(C, X, Y, W)
+
 #endif
 #if (ALF_FXLOGGING_METHOD==1)
     #define __ALFFXLOGSTRING(C)            RDebug::Print(_L(C));
     #define __ALFFXLOGSTRING1(C, X)        RDebug::Print(_L(C),X);
     #define __ALFFXLOGSTRING2(C, X, Y)     RDebug::Print(_L(C),X, Y);
     #define __ALFFXLOGSTRING3(C, X, Y, Z)  RDebug::Print(_L(C),X, Y, Z);
+    #define __ALFFXLOGSTRING4(C,X,Y,Z,W)   RDebug::Print(_L(C),X, Y, Z, W);
 #endif
 #if (ALF_FXLOGGING_METHOD==2)
     #define __ALFFXLOGSTRING(C)            {_LIT(tempLogDes,C);RFileLogger::WriteFormat(KLogsDir(),KLogFileName(), EFileLoggingModeAppend, tempLogDes());}
     #define __ALFFXLOGSTRING1(C, X)        {_LIT(tempLogDes,C);RFileLogger::WriteFormat(KLogsDir(),KLogFileName(), EFileLoggingModeAppend, TRefByValue<const TDesC>(tempLogDes()),X);}
     #define __ALFFXLOGSTRING2(C, X, Y)     {_LIT(tempLogDes,C);RFileLogger::WriteFormat(KLogsDir(),KLogFileName(), EFileLoggingModeAppend, TRefByValue<const TDesC>(tempLogDes()),X,Y);}
     #define __ALFFXLOGSTRING3(C, X, Y, Z)  {_LIT(tempLogDes,C);RFileLogger::WriteFormat(KLogsDir(),KLogFileName(), EFileLoggingModeAppend, TRefByValue<const TDesC>(tempLogDes()),X,Y,Z);}
+    #define __ALFFXLOGSTRING4(C,X,Y,Z,W)   {_LIT(tempLogDes,C);RFileLogger::WriteFormat(KLogsDir(),KLogFileName(), EFileLoggingModeAppend, TRefByValue<const TDesC>(tempLogDes()),X,Y,Z,W);}
 #endif
 
 #endif // ALFLOGGER_H
--- a/uiacceltk/hitchcock/CommonInc/alfmoduletest.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletest.h	Fri Mar 12 15:47:04 2010 +0200
@@ -5,24 +5,30 @@
 #define ALFMODULETEST_H
 
 // Define this to build module testing enchanced version of ALF
-//#define USE_MODULE_TEST_HOOKS_FOR_ALF
+// #define USE_MODULE_TEST_HOOKS_FOR_ALF 
 
 #if !defined(USE_MODULE_TEST_HOOKS_FOR_ALF) || !defined(AMT_CONTROL)
 
 #define AMT_FUNC(func)                                
 #define AMT_FUNC_EXC(func)    
+#define AMT_FUNC_EXC_IF(cond, func)    
 #define AMT_INC_COUNTER(member)
 #define AMT_DEC_COUNTER(member)
 #define AMT_SET_VALUE(member, val)
 #define AMT_GET_VALUE(x, member)
+#define AMT_INC_COUNTER_IF(cond, member)
+#define AMT_DEC_COUNTER_IF(cond, member)
+#define AMT_SET_VALUE_IF(cond, member, val)
+#define AMT_GET_VALUE_IF(cond, x, member)
 #define AMT_PRINT_STATE()
 
 #ifndef AMT_CONTROL
 #error "Error: you need to define AMT_CONTROL macro in your code to be able to use ALF module test system!"
 // The user have to define AMT_CONTROL, e.g. like this:
-// #define AMT_CONTROL()                static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
+// #define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
 // or
-// #define AMT_CONTROL()                iMyModuleTestDataControl
+// #define AMT_CONTROL() iMyModuleTestDataControl
+// etc.
 #endif
 
 #else
@@ -41,6 +47,7 @@
 #define AMT_DATA()                  AMT_CONTROL()->iModuleTestData
 #define AMT_FUNC(func)              if (AMT_DATA()->iIsEnabled) {func;}                                         
 #define AMT_FUNC_EXC(func)          {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled) {func;} AMT_CONTROL()->Unlock();}        
+#define AMT_FUNC_EXC_IF(cond, func) {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled && (cond)) {func;} AMT_CONTROL()->Unlock();}        
 
 // Single operation macros, that will do lock/unlock.
 #define AMT_INC_COUNTER(member)     AMT_FUNC_EXC(AMT_DATA()->member++)
@@ -49,6 +56,13 @@
 #define AMT_GET_VALUE(x, member)    AMT_FUNC_EXC((x) = AMT_DATA()->member)
 #define AMT_PRINT_STATE()           AMT_FUNC_EXC(AMT_DATA()->PrintState())
 
+// Conditional single operation macros, that will do lock/unlock.
+#define AMT_INC_COUNTER_IF(cond, member)    AMT_FUNC_EXC_IF((cond), AMT_DATA()->member++)
+#define AMT_DEC_COUNTER_IF(cond, member)    AMT_FUNC_EXC_IF((cond), AMT_DATA()->member--)
+#define AMT_SET_VALUE_IF(cond, member, val) AMT_FUNC_EXC_IF((cond), AMT_DATA()->member=(val))
+#define AMT_GET_VALUE_IF(cond, x, member)   AMT_FUNC_EXC_IF((cond), (x) = AMT_DATA()->member)
+
+
 // *** Global object names
 _LIT(KAlfModuleTestChunkName, "ALF_MODULE_TEST_CHUNK");
 _LIT(KAlfModuleTestMutexName, "ALF_MODULE_TEST_MUTEX");
@@ -66,16 +80,42 @@
         RDebug::Print(_L("iTotalLayerCount[0]=%d"), iTotalLayerCount[0]);
         RDebug::Print(_L("iTotalLayerCount[1]=%d"), iTotalLayerCount[1]);
         RDebug::Print(_L("iCloneLayerCount=%d"), iCloneLayerCount);
+        RDebug::Print(_L("iRsTotalNodeCount=%d"), iRsTotalNodeCount);
+        RDebug::Print(_L("iRsWindowGroupNodeCount=%d"), iRsWindowGroupNodeCount);
+        RDebug::Print(_L("iRsWindowNodeCount=%d"), iRsWindowNodeCount);
+        RDebug::Print(_L("iRsAnimNodeCount=%d"), iRsAnimNodeCount);
+        RDebug::Print(_L("iRsWindowNodeActivatedCount=%d"), iRsWindowNodeActivatedCount);
+        RDebug::Print(_L("iRsNodeExtentChangedCount=%d"), iRsNodeExtentChangedCount);
+        RDebug::Print(_L("iRsLatestNodeExtentRect= x:%d, y:%d, width=%d, height=%d"), 
+                         iRsLatestNodeExtentRect.iTl.iX, iRsLatestNodeExtentRect.iTl.iY, 
+                         iRsLatestNodeExtentRect.Width(), iRsLatestNodeExtentRect.Height());
+        RDebug::Print(_L("iRsTotalNodeFlagChangedCount=%d"), iRsTotalNodeFlagChangedCount);
+        RDebug::Print(_L("iRsTotalNodeAttributeChangedCount=%d"), iRsTotalNodeAttributeChangedCount);
         RDebug::Print(_L("iTotalNodeCount=%d"), iTotalNodeCount);
         RDebug::Print(_L("iWindowGroupNodeCount=%d"), iWindowGroupNodeCount);
         RDebug::Print(_L("iWindowNodeCount=%d"), iWindowNodeCount);
         RDebug::Print(_L("iAnimNodeCount=%d"), iAnimNodeCount);
+        RDebug::Print(_L("iWindowNodeActivatedCount=%d"), iWindowNodeActivatedCount);
+        RDebug::Print(_L("iNodeExtentChangedCount=%d"), iNodeExtentChangedCount);
+        RDebug::Print(_L("iLatestNodeExtentRect= x:%d, y:%d, width=%d, height=%d"), 
+                         iLatestNodeExtentRect.iTl.iX, iLatestNodeExtentRect.iTl.iY, 
+                         iLatestNodeExtentRect.Width(), iLatestNodeExtentRect.Height());
+        RDebug::Print(_L("iTotalNodeFlagChangedCount=%d"), iTotalNodeFlagChangedCount);
+        RDebug::Print(_L("iTotalNodeAttributeChangedCount=%d"), iTotalNodeAttributeChangedCount);        
         RDebug::Print(_L("iTotalVisualCount=%d"), iTotalVisualCount);
         RDebug::Print(_L("iVisibleVisualCount=%d"), iVisibleVisualCount);
         RDebug::Print(_L("iActiveVisualCount=%d"), iActiveVisualCount);
         RDebug::Print(_L("iPassiveVisualCount=%d"), iPassiveVisualCount);
         RDebug::Print(_L("iTextureCount=%d"), iTextureCount);
         RDebug::Print(_L("iRenderBufferCount=%d"), iRenderBufferCount);
+        RDebug::Print(_L("iTotalControlGroupCount=%d"), iTotalControlGroupCount);        
+        RDebug::Print(_L("iVisualSizeChangedCount=%d"), iVisualSizeChangedCount);        
+        RDebug::Print(_L("iVisualPositionChangedCount=%d"), iVisualPositionChangedCount);
+        RDebug::Print(_L("iLatestVisualExtentRect= x:%d, y:%d, width=%d, height=%d"), 
+                         iLatestVisualExtentRect.iTl.iX, iLatestVisualExtentRect.iTl.iY, 
+                         iLatestVisualExtentRect.Width(), iLatestVisualExtentRect.Height());
+        RDebug::Print(_L("iTotalVisualFlagChangedCount=%d"), iTotalVisualFlagChangedCount);
+        RDebug::Print(_L("iTotalVisualAttributeChangedCount=%d"), iTotalVisualAttributeChangedCount);        
         RDebug::Print(_L("*** ALF INTERNAL STATE ***"));
         }
     
@@ -87,20 +127,56 @@
     TInt iScreenCount;          // *** not yet implemented
     TInt iTotalLayerCount[10];  // For each screen
     TInt iCloneLayerCount;      // ** not yet implemented
-    
+    TInt iRsTotalNodeCount;
+    TInt iRsWindowGroupNodeCount;
+    TInt iRsWindowNodeCount;
+    TInt iRsAnimNodeCount;
+    TInt iRsWindowNodeActivatedCount;    
+    TInt iRsNodeExtentChangedCount;
+    TRect iRsLatestNodeExtentRect;
+    TInt iRsTotalNodeFlagChangedCount;
+    TInt iRsTotalNodeAttributeChangedCount;
+    // These are temporary variables for Alf Render Stage thread internal use only!
+    TInt iARS_Temp1;
+    TInt iARS_Temp2;
+    TInt iARS_Temp3;
+    TInt iARS_Temp4;
+   
     // Alf Streamer
-    TInt iTotalNodeCount;       // *** not yet implemented
-    TInt iWindowGroupNodeCount; // *** not yet implemented
-    TInt iWindowNodeCount;      // *** not yet implemented
-    TInt iAnimNodeCount;        // *** not yet implemented
-    
+    TInt iTotalNodeCount;
+    TInt iWindowGroupNodeCount;
+    TInt iWindowNodeCount;
+    TInt iAnimNodeCount;
+    TInt iWindowNodeActivatedCount;
+    TInt iNodeExtentChangedCount;
+    TRect iLatestNodeExtentRect;
+    TInt iTotalNodeFlagChangedCount;
+    TInt iTotalNodeAttributeChangedCount;
+    // These are temporary variables for Alf Streamer thread internal use only!
+    TInt iAST_Temp1;
+    TInt iAST_Temp2;
+    TInt iAST_Temp3;
+    TInt iAST_Temp4;
+   
     // Alf Server
-    TInt iTotalVisualCount;     // *** not yet implemented
-    TInt iVisibleVisualCount;   // *** not yet implemented
-    TInt iActiveVisualCount;    // Active visual count
-    TInt iPassiveVisualCount;   // Passive visual count
+    TInt iTotalVisualCount;
+    TInt iVisibleVisualCount;
+    TInt iActiveVisualCount;
+    TInt iPassiveVisualCount;
     TInt iTextureCount;         // *** not yet implemented
     TInt iRenderBufferCount;    // *** not yet implemented
+    TInt iTotalControlGroupCount;
+    TInt iVisualSizeChangedCount;
+    TInt iVisualPositionChangedCount;
+    TRect iLatestVisualExtentRect;
+    TInt iTotalVisualFlagChangedCount;
+    TInt iTotalVisualAttributeChangedCount;
+    TInt iOrdinalChange;
+    // These are temporary variables for Alf Server thread internal use only!
+    TInt iASE_Temp1;
+    TInt iASE_Temp2;
+    TInt iASE_Temp3;
+    TInt iASE_Temp4;
     };
 
 
@@ -124,6 +200,7 @@
      */
     TInt OpenGlobalObjects()
         {
+        RDebug::Print(_L("CAlfModuleTestDataControl::OpenGlobalObjects()."));
         // Open global module testing chunk
         TBool isReadOnly = EFalse;
         TInt err = iModuleTestChunk.OpenGlobal(KAlfModuleTestChunkName, isReadOnly);
@@ -136,7 +213,7 @@
                 iModuleTestData = reinterpret_cast<CAlfModuleTestData*>(iModuleTestChunk.Base());
                 }
             }
-        RDebug::Print(_L("CAlfModuleTestDataControl::OpenGlobalObjects. err=%d"), err);
+        RDebug::Print(_L("CAlfModuleTestDataControl::OpenGlobalObjects. ret=%d"), err);
         return err;
         }
 
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h	Fri Mar 12 15:47:04 2010 +0200
@@ -22,7 +22,7 @@
 
 #include <e32hashtab.h>
 
-#define AMT_CONTROL()                static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
+#define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
 #include "alfmoduletest.h" 
 
 #include "alfscreen.h"
@@ -40,7 +40,10 @@
 class CAlfCommandDebug;
 class CAlfLayoutSwitchEffectCoordinator;
 class RMemReadStream;
-
+class CHuiCanvasVisual;
+class CFullScreenEffectState;
+class CControlEffectState;
+    
 const TInt KAlfBridgeRegionGranularity = 10;
 
 NONSHARABLE_CLASS(CAlfBridge): 
@@ -49,7 +52,6 @@
     public MHuiDisplayRefreshObserver, 
     public MHuiBitmapProvider,
     public MAlfGfxEffectObserver,
-    public MHuiRosterObserver,
     public MHuiSynchronizationObserver
     {
 	// Helper class for keeping ongoing effects in order. Kept in iEffectCleanupStack
@@ -192,7 +194,6 @@
     void HandleGfxStopEvent( TBool aClientRequest );
     
     void EnableSwRenderingL(TBool aEnable = ETrue);
-    void UploadSwRenderingTargetL( CAlfScreen* aScreen );
     TBool PrepareSwRenderingTarget( CAlfScreen* aScreen );
 
     /**
@@ -224,19 +225,29 @@
      * Cancels all effects due to low memory.
      */
     void LowMemoryCancelAllEffects();
-    
-    // From MHuiRosterObserver
-    void NotifyRosterDrawStart(CHuiDisplay& aDisplay);
-    void NotifyRosterDrawEnd(CHuiDisplay& aDisplay);
+
+    /**
+      * Sets HuiControlGroup as Alf application window group
+      */
+    void SetWindowGroupAsAlfApp(TInt aId);
     
     // From MHuiSynchronizationObserver
     void Synchronized(TInt aId);
     
+    /*
+     * HandleGfxEndFullScreenTimeout
+     * 
+     * GfxTransEffect API gives EndFullScreen events too late. Thus there is a two stage process for triggering 
+     * the EndFullScreen effect after BeginFullScreen event arrived.
+     * 
+     * For application start effects we give N milliseconds timeout for application to finish drawing after
+     * the first drawing has arrived. If after N milliseconds application has not drawn 75% of the screen, it
+     * gets another N milliseconds. Most cases, the first N milliseconds is enough.
+     */
+    void HandleGfxEndFullScreenTimeout(CFullScreenEffectState* aFullScreenEffectData);
+        
 private:    
     
-    class CFullScreenEffectState;
-    
-    class CControlEffectState;
     
     CAlfBridge( CAlfStreamerBridge** aHost );
     
@@ -289,6 +300,23 @@
      */
     TBool HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout *aFromLayout);
     
+    
+    /*
+     * ResolveAfterEffectAppearingApplicationL
+     * 
+     * In case of an exit effect the appearing application is not notifed to alf
+     * by the GfxTransEffect API. In such case it is being resolved from Roster by
+     * taking the application directly under the application that is being moved
+     * to the background (when called by HandleReorderWindow) or being destroyed
+     * (called by DeleteControlGroupL).
+     * 
+     * In some situation Alf may end up with wrong appearing application uid. In such
+     * case the worst that can happen, is that we must wait the frameworks
+     * EndFullScreen event to arrive.
+     */
+    void ResolveAfterEffectAppearingApplicationL(CHuiControlGroup* aGroup);
+
+    
 	/**
 	*	FreezeLayoutUntilEffectDestroyedL
 	*
@@ -663,17 +691,18 @@
     TBool LoadFadeEffectsL( CHuiCanvasVisual& aVisual );        
 
     // Fading related utility methods
-    static TBool CanFadeChildren( CHuiCanvasVisual& aParent );
-    static TInt RecursiveChildCount( CHuiCanvasVisual& aParent, TInt aCanvasFlags );
-    static TBool IsFadedByParent( CHuiCanvasVisual& aVisual );
-    static TBool IsNearestParentEffectFade( CHuiCanvasVisual& aVisual );
-    static TBool HasActivePaintedAreas( CHuiCanvasVisual& aVisual, TBool aIncludeChildren );
-    static TBool HasActiveFadedChildren( CHuiCanvasVisual& aVisual );
+    TBool CanFadeChildren( CHuiCanvasVisual& aParent );
+    TInt RecursiveChildCount( CHuiCanvasVisual& aParent, TInt aCanvasFlags );
+    TBool IsFadedByParent( CHuiCanvasVisual& aVisual );
+    TBool IsNearestParentEffectFade( CHuiCanvasVisual& aVisual );
+    TBool HasActivePaintedAreas( CHuiCanvasVisual& aVisual, TBool aIncludeChildren );
+    TBool HasActiveFadedChildren( CHuiCanvasVisual& aVisual );
 
 private:
 
     RPointerArray<CAlfScreen> iAlfScreens;
     void SetCursorTimerL(TUint aTime = 0, CHuiVisual* aCursor = 0);
+    TBool IsAlfOriginatedWindow(CHuiCanvasVisual& aVisual);
 
 NONSHARABLE_CLASS ( TDeadControlGroup )
     {
@@ -744,77 +773,7 @@
     // See method RemoveTemporaryPresenterVisuals.
     RArray<TInt> iFinishedCleanupStackEffects;
     
-	// Effects states are used for effects request that arrive before the effected 
-	// window has been created. This is very common with fullscreen effects and 
-	// occational with control effects.
-	//
-	// NOTE: control effects support currently only one "delayed" effect. This is propably
-	// not sufficient for all sitations.
-    NONSHARABLE_CLASS(CEffectState) : public CBase
-        {
-    public:    
-        
-        CEffectState();
-         ~CEffectState();
-         
-    protected:
-	   /**
-		* ResolveFileNameL
-		*
-		* Reads filename from stream and composes it to iEffectName variable.
-		*/
-         void ResolveFileNameL(RMemReadStream& aStream);
-         
-    public:
-         
-         TInt iAction;
-         TInt iHandle;
-            
-         HBufC* iEffectName;
-         // Handle using which client should be informed of completion.
-         TInt iCompletionHandle;
-         // State information
-         TInt iOperation;
-         
-        };
-    
-    NONSHARABLE_CLASS( CControlEffectState ) : public CEffectState
-        {
-    public:
-
-        TUint32 iClientHandle;
-        TUint32 iClientGroupHandle;
-    
-        void ConstructL(TInt aAction, RMemReadStream& aStream);
-        };
-
-    NONSHARABLE_CLASS( CFullScreenEffectState ) : public CEffectState
-        {
-    public:
-       // CFullScreenEffectState();
-       // ~CFullScreenEffectState();
-        
-        void ConstructL(TInt aAction, RMemReadStream& aStream);
-
-        // Information from BeginFullScreen
-        TInt iType;
-        TInt iWg1;
-        TInt iWg2;
-        TInt iToAppId;
-        TInt iFromAppId;
-        TRect iRect;
-        
-        // ETrue if waiting for window group to appear
-        TBool iWaitingWindowGroup;
-        // ETrue if end fullscreen has been performed
-        TBool iEndFullScreen;
-        // ETrue if setup effect container has been done
-        TBool iSetupDone;
-
-        // used for resolving the iCleanupStackItem that holds the frozen app layout underneath the starting application
-        TInt iAppStartScreenshotItemHandle;
-        };
-
+	
     /**
      * Full screen effect state.
      * Own.
@@ -868,6 +827,7 @@
         };
     
     RHashMap<TUint32,THashVisualStruct> iWindowHashArray;
+    CHuiControl* iOrphanStorage; // owned. holds the visuals which are orphaned from their control group
     class TRegisteredEffectsStruct
         {
     public:
@@ -923,6 +883,10 @@
     TInt iTempTotalActiveVisualCount;
     TInt iTempTotalPassiveVisualCount;
     #endif
+    #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
+    TInt activevisualcount;
+    TInt passivevisualcount;
+    #endif
     };    
 
 #endif // __ALF_BRIDGE_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfeffectutils.h	Fri Mar 12 15:47:04 2010 +0200
@@ -0,0 +1,198 @@
+/*
+* Copyright (c) 2008 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:   internal for Nokia
+*
+*/
+
+#include <s32mem.h>
+#include <akntranseffect.h>
+#include "alfbridge.h"
+
+// Timer to send finish full screen effect
+// ---------------------------------------------------------
+// CAlfFinishTimer
+// ---------------------------------------------------------
+//
+NONSHARABLE_CLASS( CAlfRosterFreezeEndTimer ):public CTimer
+    {
+    public:  // Constructors and destructor
+        static CAlfRosterFreezeEndTimer* NewL( CAlfBridge& aBridge );
+        virtual ~CAlfRosterFreezeEndTimer();
+
+    public: // New functions
+        void Start( TTimeIntervalMicroSeconds32 aPeriod );
+        
+    protected:  // Functions from base classes
+        void DoCancel();
+
+    private:
+        CAlfRosterFreezeEndTimer( CAlfBridge& aBridge );
+        void ConstructL();
+        void RunL();
+      
+    private:    // Data
+        CAlfBridge& iBridge;
+                
+    };
+
+
+
+// Timer to send finish full screen effect
+// ---------------------------------------------------------
+// CAlfFinishTimer
+// ---------------------------------------------------------
+//
+NONSHARABLE_CLASS( CAlfEffectEndTimer ):public CTimer
+    {
+    public:  // Constructors and destructor
+        static CAlfEffectEndTimer* NewL( CAlfBridge& aBridge );
+        virtual ~CAlfEffectEndTimer();
+
+    public: // New functions
+        void Start( TTimeIntervalMicroSeconds32 aPeriod, TInt aHandle );
+        
+    protected:  // Functions from base classes
+        void DoCancel();
+
+    private:
+        CAlfEffectEndTimer( CAlfBridge& aBridge );
+        void ConstructL();
+        void RunL();
+      
+    private:    // Data
+        CAlfBridge& iBridge;
+        TInt iHandle;
+                
+    };
+
+// ---------------------------------------------------------
+// CAlfLayoutSwitchEffectcoordinator
+// ---------------------------------------------------------
+//
+NONSHARABLE_CLASS( CAlfLayoutSwitchEffectCoordinator ) : public CBase, public MAlfGfxEffectObserver
+    {
+    public:  // Constructors and destructor
+        CAlfLayoutSwitchEffectCoordinator( CAlfBridge& aBridge );
+        virtual ~CAlfLayoutSwitchEffectCoordinator();
+    
+    public: // MAlfGfxEffectObserver           
+        void AlfGfxEffectEndCallBack( TInt aHandle );
+    
+    public:
+        void BeginLayoutSwitch();
+        void Cancel();
+        
+    private:
+        AknTransEffect::TContext NextLayoutSwitchContext();
+        void SetLayoutSwitchEffect(AknTransEffect::TContext aContext);
+        TBool LayoutSwitchEffectsExist();
+        
+    private: // Data
+        
+        CAlfBridge& iBridge;
+        AknTransEffect::TContext iLayoutSwitchEffectContext;
+        TThreadPriority iOriginalPriority;
+        CAlfRosterFreezeEndTimer* iRosterFreezeEndTimer;
+    };
+
+// ---------------------------------------------------------
+// Effects states are used for effects request that arrive before the effected 
+// window has been created. This is very common with fullscreen effects and 
+// occational with control effects.
+//
+// NOTE: control effects support currently only one "delayed" effect. This is propably
+//       not sufficient for all sitations.
+// ---------------------------------------------------------
+//
+NONSHARABLE_CLASS(CEffectState) : public CBase
+        {
+    public:    
+        
+        CEffectState();
+        virtual ~CEffectState();
+         
+    protected:
+       /**
+        * ResolveFileNameL
+        *
+        * Reads filename from stream and composes it to iEffectName variable.
+        */
+         void ResolveFileNameL(RMemReadStream& aStream);
+         
+    public:
+         
+         TInt iAction;
+         TInt iHandle;
+            
+         HBufC* iEffectName;
+         // Handle using which client should be informed of completion.
+         TInt iCompletionHandle;
+         // State information
+         TInt iOperation;
+         
+        };
+    
+    NONSHARABLE_CLASS(CControlEffectState ) : public CEffectState
+        {
+    public:
+
+        TUint32 iClientHandle;
+        TUint32 iClientGroupHandle;
+    
+        void ConstructL(TInt aAction, RMemReadStream& aStream);
+        };
+
+    NONSHARABLE_CLASS(CFullScreenEffectState ) : public CEffectState
+        {
+    public:
+        ~CFullScreenEffectState();
+        
+        void ConstructL(TInt aAction, RMemReadStream& aStream);
+        
+        TBool ResetTimerL(CAlfBridge* aBridge);
+        
+        void NotifyDrawingTimeout();
+
+        // Information from BeginFullScreen
+        TInt iType;
+        TInt iWg1;
+        TInt iWg2;
+        TInt iToAppId;
+        TInt iFromAppId;
+        TRect iRect;
+        
+        // ETrue if waiting for window group to appear
+        TBool iWaitingWindowGroup;
+        // ETrue if end fullscreen has been performed
+        TBool iEndFullScreen;
+        // ETrue if setup effect container has been done
+        TBool iSetupDone;
+
+        // used for resolving the iCleanupStackItem that holds the frozen app layout underneath the starting application
+        TInt iAppStartScreenshotItemHandle;
+        
+        RRegion iPaintedRegion;
+        enum TEffectType
+        {
+            ENotDefinedEffect = 0,
+            EStartEffect,
+            EExitEffect
+        };
+        
+        TEffectType iEffectType;
+        TSize iDisplaySize;
+        CAlfBridge* iBridge; // for callback. not own.
+        
+        CPeriodic* iDrawingCompleteTimer;
+        };
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfhierarchymodel.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfhierarchymodel.h	Fri Mar 12 15:47:04 2010 +0200
@@ -23,6 +23,10 @@
 #include <e32base.h>
 #include <e32hashtab.h>
 #include <gdi.h>
+
+#define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
+#include "alfmoduletest.h" 
+
 #include <alfwindowstructs.h>
 #include "alfstreamerbridge.h"
 #include <uiacceltk/HuiUtil.h>  // USER_INVARIANT
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfnodes.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfnodes.h	Fri Mar 12 15:47:04 2010 +0200
@@ -104,7 +104,7 @@
     
     void SetFirstSprite();
     
-    CAlfNode* OrphonMe();
+    CAlfNode* OrphanMe();
     
     CAlfNode* FindPreviousChild();
     
--- a/uiacceltk/hitchcock/ServerCore/Src/alfappservercore.mmp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappservercore.mmp	Fri Mar 12 15:47:04 2010 +0200
@@ -82,8 +82,11 @@
 SOURCE                  alfnodes.cpp
 SOURCE                  alfbridge.cpp
 SOURCE                  alfscreen.cpp
+SOURCE                  alfeffectutils.cpp
 #endif
 
+SOURCE themerepositorylistener.cpp
+
 USERINCLUDE             ../Inc
 USERINCLUDE				../../coretoolkit/inc
 SYSTEMINCLUDE           ../../CommonInc
@@ -130,4 +133,3 @@
 #ifdef HUI_DEBUG_TRACK_DRAWING
 LIBRARY					alfcommanddebug.lib
 #endif
-SOURCE themerepositorylistener.cpp
--- a/uiacceltk/hitchcock/ServerCore/Src/alfappui.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappui.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -667,6 +667,7 @@
     {
     #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
     delete AMT_CONTROL();
+    Dll::FreeTls();
     #endif
     
     delete iData;
@@ -769,15 +770,11 @@
     __ALFLOGSTRING( "CAlfAppUi::ConstructL start" )
     
     #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
-    __ALFLOGSTRING( "CAlfAppUi::ConstructL. Open and initialize ALF module test chunk. " )
-    // Initiliaze global data in TLS. 
+    // Initiliaze global data in TLS and open global module testing chunk and mutex
     User::LeaveIfError(Dll::SetTls(new(ELeave) CAlfModuleTestDataControl()));
-    // Open global module testing chunk and mutex
     User::LeaveIfError(AMT_CONTROL()->OpenGlobalObjects());
-    __ALFLOGSTRING( "CAlfAppUi::ConstructL. ALF module test chunk ready. " )
     #endif
-     
-  
+      
     TInt flags = EStandardApp|ENoScreenFurniture|ENonStandardResourceFile|EAknEnableSkin;
     CCoeEnv* coe = CCoeEnv::Static();
     iData =  new (ELeave) CAlfAppUiData();
@@ -1461,4 +1458,8 @@
     return iData->iBridgeObj->ForceSwRendering( aEnabled );
     }
     
+void CAlfAppUi::SetAlfAppWindowGroup( TInt aID )
+    {
+    iData->iBridgeObj->SetWindowGroupAsAlfApp( aID );
+    }
 // end of file
--- a/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -23,7 +23,6 @@
 #include <uiacceltk/HuiEnv.h>
 #include <aknenv.h>
 #include <AknsConstants.h>
-#include <s32mem.h>
 #include <uiacceltk/HuiSkin.h>
 #include <uiacceltk/HuiDisplay.h>
 #include <uiacceltk/HuiControl.h>
@@ -69,7 +68,7 @@
 #include "HuiRenderPlugin.h"
 #include "huicanvasgc.h"
 #include "huicanvasrenderbuffer.h"
-
+#include "alfeffectutils.h"
 #include "alfrenderstageutils.h" // for KAlfPSUidSynchronizer & KAlfPSKeySynchronizer
 
 #ifdef HUI_DEBUG_TRACK_DRAWING
@@ -91,466 +90,13 @@
 
 _LIT8(KAlfWindowGroupContainerControlTag, "WGROUP");
 
-// This debug option prints window group order with __ALFLOGSTRING
-//#define ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
-
+// #define USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
 // This debug option shows window groups in a grid
 //#define ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
 
 
 const TInt KFadeAction = 6000;
 
-const TInt KRosterFreezeEndTimeoutInMs = 400;
-
-// Timer to send finish full screen effect
-// ---------------------------------------------------------
-// CAlfFinishTimer
-// ---------------------------------------------------------
-//
-NONSHARABLE_CLASS( CAlfRosterFreezeEndTimer ):public CTimer
-    {
-    public:  // Constructors and destructor
-        static CAlfRosterFreezeEndTimer* NewL( CAlfBridge& aBridge );
-        virtual ~CAlfRosterFreezeEndTimer();
-
-    public: // New functions
-        void Start( TTimeIntervalMicroSeconds32 aPeriod );
-        
-    protected:  // Functions from base classes
-        void DoCancel();
-
-    private:
-        CAlfRosterFreezeEndTimer( CAlfBridge& aBridge );
-        void ConstructL();
-        void RunL();
-      
-    private:    // Data
-        CAlfBridge& iBridge;
-                
-    };
-
-
-// ---------------------------------------------------------
-// CAlfRosterFreezeEndTimer
-// ---------------------------------------------------------
-//
-CAlfRosterFreezeEndTimer::CAlfRosterFreezeEndTimer( CAlfBridge& aBridge )
-    :CTimer ( EPriorityStandard ),
-    iBridge( aBridge )
-    {   
-    }
-
-void CAlfRosterFreezeEndTimer::ConstructL()
-    {
-    CTimer::ConstructL();
-    CActiveScheduler::Add( this );
-    }
-
-CAlfRosterFreezeEndTimer* CAlfRosterFreezeEndTimer::NewL( CAlfBridge& aBridge )
-    {
-    CAlfRosterFreezeEndTimer* self = new ( ELeave ) CAlfRosterFreezeEndTimer( aBridge );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-CAlfRosterFreezeEndTimer::~CAlfRosterFreezeEndTimer()
-    {
-    Cancel();        
-    }
-
-void CAlfRosterFreezeEndTimer::Start( TTimeIntervalMicroSeconds32 aPeriod )
-    {
-    if (!IsActive())
-        {
-        After( aPeriod );
-        }
-    }
-
-void CAlfRosterFreezeEndTimer::RunL()
-    {
-    iBridge.iHuiEnv->Display(0).SetDirty();
-    TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
-    iBridge.SetVisualTreeVisibilityChanged(ETrue);    
-    }
-
-void CAlfRosterFreezeEndTimer::DoCancel()
-    {
-    CTimer::DoCancel();
-    }
-
-// ---------------------------------------------------------
-// CAlfLayoutSwitchEffectcoordinator
-// ---------------------------------------------------------
-//
-NONSHARABLE_CLASS( CAlfLayoutSwitchEffectCoordinator ) : public CBase, public MAlfGfxEffectObserver
-    {
-    public:  // Constructors and destructor
-        CAlfLayoutSwitchEffectCoordinator( CAlfBridge& aBridge );
-        virtual ~CAlfLayoutSwitchEffectCoordinator();
-    
-    public: // MAlfGfxEffectObserver           
-        void AlfGfxEffectEndCallBack( TInt aHandle );
-    
-    public:
-        void BeginLayoutSwitch();
-        void Cancel();
-        
-    private:
-        AknTransEffect::TContext NextLayoutSwitchContext();
-        void SetLayoutSwitchEffect(AknTransEffect::TContext aContext);
-        TBool LayoutSwitchEffectsExist();
-        
-    private: // Data
-        
-        CAlfBridge& iBridge;
-        AknTransEffect::TContext iLayoutSwitchEffectContext;
-        TThreadPriority iOriginalPriority;
-        CAlfRosterFreezeEndTimer* iRosterFreezeEndTimer;
-    };
-
-CAlfLayoutSwitchEffectCoordinator::CAlfLayoutSwitchEffectCoordinator( CAlfBridge& aBridge ) :
-    iBridge( aBridge ),
-    iLayoutSwitchEffectContext(AknTransEffect::ENone)    
-    {
-    RThread me = RThread();
-    iOriginalPriority = me.Priority();    
-    me.Close();
-    }
-
-CAlfLayoutSwitchEffectCoordinator::~CAlfLayoutSwitchEffectCoordinator()
-    {   
-    }
-
-// ---------------------------------------------------------
-// CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack
-//
-// This method is callback which gets called when layout 
-// switch effect has ended.
-// ---------------------------------------------------------
-//
-void CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack( TInt aHandle )
-    {
-    //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack"));
-    if (iLayoutSwitchEffectContext == aHandle)
-        {
-        AknTransEffect::TContext nextContext = NextLayoutSwitchContext();
-
-        // Unfreeze visible content. This reveals real roster content (in new orientation).
-        if (nextContext == AknTransEffect::ELayoutSwitchExit)
-            {
-            #ifdef HUI_DEBUG_TRACK_DRAWING
-            RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack unfreezing roster content"));
-            #endif
-            iBridge.iHuiEnv->Display(0).SetDirty();
-            TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
-            iBridge.SetVisualTreeVisibilityChanged(ETrue);
-            }
-        
-        // Set next effect
-        SetLayoutSwitchEffect(nextContext);
-        
-        if (nextContext == AknTransEffect::ENone)
-            {
-            // Restore normal priority
-            RThread me = RThread();
-            me.SetPriority(iOriginalPriority);    
-            me.Close();
-
-            // Just in case refresh everything
-            iBridge.iHuiEnv->Display(0).SetDirty();
-            }        
-        }
-    else
-        {
-        //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack - got different handle (normal, dont worry...) - %i"), aHandle);        
-        }
-    }
-
-// ---------------------------------------------------------
-// CAlfLayoutSwitchEffectCoordinator::Cancel
-// ---------------------------------------------------------
-//
-void CAlfLayoutSwitchEffectCoordinator::Cancel()
-    {
-    // Disable effect
-    SetLayoutSwitchEffect( AknTransEffect::ENone );
-
-    // Unfreeze visible content
-    if ( iRosterFreezeEndTimer )
-        {
-		iRosterFreezeEndTimer->Cancel();
-    	}
-
-    iBridge.iHuiEnv->Display(0).SetDirty();
-    TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
-    iBridge.SetVisualTreeVisibilityChanged(ETrue);
-    
-    // Restore normal priority
-    RThread me = RThread();
-    me.SetPriority(iOriginalPriority);    
-    me.Close();
-	}
-
-// ---------------------------------------------------------
-// CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch
-//
-// This method starts the layout switch effect procedure.
-// ---------------------------------------------------------
-//
-void CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch()
-    {
-    // Hm. what to do if earlier is already in progress ?
-    //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch"));
-    if ( iBridge.iHuiEnv->MemoryLevel() <= EHuiMemoryLevelLowest )
-        {
-        // No effects in low memory mode
-        return;
-        }
-    
-    if (!iLayoutSwitchEffectContext)
-        {
-        TBool tfxOn = CAknTransitionUtils::TransitionsEnabled(AknTransEffect::ELayoutswitchTransitionsOff );
-        TBool tfxExists = LayoutSwitchEffectsExist();
-        if (tfxOn && tfxExists)
-            {
-            // Boost priority so that we are able to draw more frames for the effect
-            RThread me = RThread();
-            me.SetPriority(EPriorityAbsoluteHigh);    
-            me.Close();
-            
-            // Freeze visual content
-            //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch freezing roster content"));
-            iBridge.iHuiEnv->Display(0).SetDirty();
-            TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(ETrue));
-            
-            // Remove all other effects
-            iBridge.HandleGfxStopEvent( EFalse );
-            iBridge.RemoveAllTemporaryPresenterVisuals();
-            
-            // Set first layout switch effect 
-            SetLayoutSwitchEffect(AknTransEffect::ELayoutSwitchStart);
-            }
-        else
-            {
-            if (!iRosterFreezeEndTimer)
-                {
-                TRAP_IGNORE(iRosterFreezeEndTimer = CAlfRosterFreezeEndTimer::NewL(iBridge));
-                }
-            
-            if (iRosterFreezeEndTimer)
-                {
-                iBridge.iHuiEnv->Display(0).SetDirty();
-                TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(ETrue));
-                
-                // Remove all other effects
-                iBridge.HandleGfxStopEvent( EFalse );
-                iBridge.RemoveAllTemporaryPresenterVisuals();
-
-                // Set remove freeze timer
-                iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000); 
-                }            
-            //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch - tfx are set OFF -> I am not starting effect."));                        
-            }
-        }
-    else
-        {
-        //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch - old effect exists - %i"), iLayoutSwitchEffectContext);
-        }
-    }
-
-// ---------------------------------------------------------
-// CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchContext
-//
-// This method automatically selects the next context in the 
-// layout switch procedure.
-//
-// Contextes change in the following order during layout switch:
-//
-// 1. AknTransEffect::ENone
-// 2. AknTransEffect::ELayoutSwitchStart
-// 3. AknTransEffect::ELayoutSwitchExit
-// 4. AknTransEffect::ENone
-//
-// After new context is selected, appropriate effect is set 
-// (and/or removed) from the roster.
-//
-// ---------------------------------------------------------
-//
-AknTransEffect::TContext CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchContext()
-    {
-    // Resolve next context based on current context
-    AknTransEffect::TContext newContext = AknTransEffect::ENone;    
-    switch (iLayoutSwitchEffectContext)
-        {
-        case AknTransEffect::ENone:
-            {
-            newContext = AknTransEffect::ELayoutSwitchStart;            
-            break;
-            }
-        case AknTransEffect::ELayoutSwitchStart:
-            {
-            newContext = AknTransEffect::ELayoutSwitchExit;                    
-            break;
-            }
-        case AknTransEffect::ELayoutSwitchExit: // fallthrough
-        default:
-            {
-            newContext = AknTransEffect::ENone;            
-            break;
-            }              
-        }
-
-    //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchEffectL old ctx = %i, new ctx = %i"), iLayoutSwitchEffectContext, newContext);
-    return newContext;
-    }
-
-// ---------------------------------------------------------
-// CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffectL
-//
-// This method sets correct effect based on the given 
-// layout switch context.
-//
-// ---------------------------------------------------------
-//
-void CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffect(AknTransEffect::TContext aContext)
-    {
-    MHuiEffectable* effectable = iBridge.iHuiEnv->Display(0).Roster().Effectable();
-    CHuiFxEffect* effect = NULL;
-    CHuiFxEngine* engine = iBridge.iHuiEnv->EffectsEngine();
-    
-    if (!effectable || !engine)
-        {
-        return;
-        }    
-            
-    // Update current context
-    iLayoutSwitchEffectContext = aContext;           
-    
-    if (aContext == AknTransEffect::ENone)
-        {
-        // Just remove effect
-        //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchEffectL - removing effect"));
-        effectable->EffectSetEffect(NULL); // This calls AlfGfxEffectEndCallBack         
-        }
-    else
-        {    
-        // Load correct effect
-        for ( TInt i = 0; i<iBridge.iAlfRegisteredEffects.Count(); i++ )
-            {             
-            if ( iBridge.iAlfRegisteredEffects[i].iAction == aContext)
-                {
-                //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffectL - loading effect"));
-                TRAP_IGNORE(engine->LoadEffectL(*iBridge.iAlfRegisteredEffects[i].iEffectFile, effect, effectable, NULL, this, iLayoutSwitchEffectContext, 0 ) );                    
-                break;
-                }
-            }
-        }    
-    }
-
-TBool CAlfLayoutSwitchEffectCoordinator::LayoutSwitchEffectsExist()
-    {
-    TBool appearExists = EFalse;
-    TBool disAppearExists = EFalse;
-    
-    for ( TInt i = 0; i<iBridge.iAlfRegisteredEffects.Count(); i++ )
-        {             
-        if ( iBridge.iAlfRegisteredEffects[i].iAction == AknTransEffect::ELayoutSwitchStart)
-            {
-            disAppearExists = ETrue;
-            break;
-            }
-        else if ( iBridge.iAlfRegisteredEffects[i].iAction == AknTransEffect::ELayoutSwitchExit)
-            {
-            appearExists = ETrue;
-            break;
-            }
-        }
-    
-    return (appearExists || disAppearExists);    
-    }
-
-// Timer to send finish full screen effect
-// ---------------------------------------------------------
-// CAlfFinishTimer
-// ---------------------------------------------------------
-//
-NONSHARABLE_CLASS( CAlfEffectEndTimer ):public CTimer
-    {
-    public:  // Constructors and destructor
-        static CAlfEffectEndTimer* NewL( CAlfBridge& aBridge );
-        virtual ~CAlfEffectEndTimer();
-
-    public: // New functions
-        void Start( TTimeIntervalMicroSeconds32 aPeriod, TInt aHandle );
-        
-    protected:  // Functions from base classes
-        void DoCancel();
-
-    private:
-        CAlfEffectEndTimer( CAlfBridge& aBridge );
-        void ConstructL();
-        void RunL();
-      
-    private:    // Data
-        CAlfBridge& iBridge;
-        TInt iHandle;
-                
-    };
-
-
-// ---------------------------------------------------------
-// CAlfFinishTimer
-// ---------------------------------------------------------
-//
-CAlfEffectEndTimer::CAlfEffectEndTimer( CAlfBridge& aBridge )
-    :CTimer(EPriorityHigh), 
-	iBridge(aBridge)
-    {   
-    }
-
-void CAlfEffectEndTimer::ConstructL()
-    {
-    CTimer::ConstructL();
-    CActiveScheduler::Add( this );
-    }
-
-CAlfEffectEndTimer* CAlfEffectEndTimer::NewL( CAlfBridge& aBridge )
-    {
-    CAlfEffectEndTimer* self = new ( ELeave ) CAlfEffectEndTimer( aBridge );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-CAlfEffectEndTimer::~CAlfEffectEndTimer()
-    {
-    Cancel();        
-    }
-
-void CAlfEffectEndTimer::Start( TTimeIntervalMicroSeconds32 aPeriod, TInt aHandle )
-    {
-    iHandle = aHandle;
-    After( aPeriod );
-    }
-
-void CAlfEffectEndTimer::RunL()
-    {
-    //
-    // timer completes and control is returned to caller
-    //
-    iBridge.TransitionFinishedHandlerL( iHandle );
-    // We don't become active unless we are explicitly restarted
-    }
-
-void CAlfEffectEndTimer::DoCancel()
-    {
-    CTimer::DoCancel();
-    }
-
-
 // ======== MEMBER FUNCTIONS ========
 
 // ======== MEMBER FUNCTIONS ========
@@ -592,6 +138,7 @@
 // 
 CAlfBridge::~CAlfBridge()
 	{
+	delete iOrphanStorage;
 	delete iFadeEffectFile;
 	iWindowHashArray.Close();
 	for( TInt i = 0; i< iAlfRegisteredEffects.Count(); i++ )
@@ -655,6 +202,11 @@
     
     iLayoutSwitchEffectCoordinator = new (ELeave) CAlfLayoutSwitchEffectCoordinator(*this);
     iAlfSecureId = RThread().SecureId();
+	
+	// Create control for the orphaned windows, which control group id deleted before them
+    iOrphanStorage = new (ELeave) CHuiControl(*iHuiEnv);
+    iOrphanStorage->ConstructL();
+	
     RegisterFadeEffectL();
     }
 
@@ -792,6 +344,8 @@
     iWindowHashArray.Insert( aWindowNodeId, visualStruct );
     iPreviouslySearchedVisualId = aWindowNodeId;
     iPreviouslySearchedVisual = aVisual;
+
+    AMT_INC_COUNTER( iTotalVisualCount );
     }
 
 // ---------------------------------------------------------------------------
@@ -803,6 +357,8 @@
     __ALFFXLOGSTRING1("CAlfBridge::RemoveVisual 0x%x", aWindowNodeId);
     iWindowHashArray.Remove( aWindowNodeId );
     iPreviouslySearchedVisualId = 0;
+    
+    AMT_DEC_COUNTER( iTotalVisualCount );    
     }
     
 // ---------------------------------------------------------------------------
@@ -950,6 +506,48 @@
     }
 
 // ---------------------------------------------------------------------------
+// ResolveAfterEffectAppearingApplicationL
+// ---------------------------------------------------------------------------
+// 
+void CAlfBridge::ResolveAfterEffectAppearingApplicationL(CHuiControlGroup* aGroup)
+    {
+#ifdef USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
+    if (iFullScreenEffectData && iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
+        {
+        CHuiControlGroup *exitingGroupInEffect = FindControlGroupByAppId(iFullScreenEffectData->iToAppId);
+        if (exitingGroupInEffect == aGroup)
+            {
+            CHuiRoster& roster = iAlfScreens[0]->iDisplay->Roster();
+            CHuiControlGroup* nextToBecomeVisible = NULL;
+            // resolve who is under this application in roster
+            for (TInt i = 0 ; i < roster.Count() ; i++)
+                {
+                if (&roster.ControlGroup(i) == exitingGroupInEffect && i > 1)
+                    {
+                    __ALFFXLOGSTRING("CAlfBridge::ResolveAfterEffectAppearingApplicationL - Found underneath control group");
+                    nextToBecomeVisible = &roster.ControlGroup(i-1);
+                    break;
+                    }
+                }
+                // resolve, to which application this maps to
+            if (nextToBecomeVisible)
+                {
+                for(TInt j = 0 ; j < iAlfScreens[0]->iControlGroups.Count() - 1 ; j++)
+                    {
+                    if (iAlfScreens[0]->iControlGroups[j].iControlGroup == nextToBecomeVisible)
+                        {
+                        iFullScreenEffectData->iFromAppId = iAlfScreens[0]->iControlGroups[j].iSecureId;
+                        __ALFFXLOGSTRING1("CAlfBridge::ResolveAfterEffectAppearingApplicationL - Found underneath application uid: 0x%x. Start track drawing for exit effect.", iFullScreenEffectData->iFromAppId );
+                        break;
+                        }
+                    }
+                }
+            }
+        }
+#endif    
+    }
+
+// ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // 
 void CAlfBridge::DeleteControlGroupL(TInt aWindowGroupNodeId, TInt aScreenNumber )
@@ -960,8 +558,10 @@
             {
             if (iAlfScreens[aScreenNumber]->iDisplay)
                 {
-                CHuiControl& control = iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup->Control(0);
+                CHuiControlGroup* controlGroup = iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup;
+                CHuiControl& control = controlGroup->Control(0);
                 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
+                ResolveAfterEffectAppearingApplicationL(controlGroup);
                 // wserv has notifed that this control group and its layout should be destroyed. However, we might be
                 // have effect on the layout itself or layout is being drawn as external content. This indicates that
                 // we should not delete the control group at this point, but add it to iDeadControlGroup list, which 
@@ -1011,7 +611,21 @@
                     // in this case, the child window effects WILL BE REMOVED.
                      for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++)
                          {
-                         RemoveTemporaryPresenterVisual(familyTree[familyIndex]);
+                         CHuiLayout* removedVisual = familyTree[familyIndex];
+                         RemoveTemporaryPresenterVisual(removedVisual);
+          
+                         if ( removedVisual != layout ) // let control group delete the layout
+					         {
+					         control.Remove(removedVisual); // remove ownership from the original control (group)
+					         if ( removedVisual->Layout() == layout ) 
+					             {
+					             iOrphanStorage->AppendL( removedVisual );
+					             } 
+					         else 
+					             {
+                                 removedVisual->SetOwner(*iOrphanStorage);
+					             }
+                             }
                          }
                     }
                 familyTree.Close();
@@ -1021,6 +635,9 @@
                 iHuiEnv->DeleteControlGroup(aWindowGroupNodeId);
                 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group done");
                 }
+            
+            AMT_DEC_COUNTER( iTotalControlGroupCount );            
+            
             break;
             }
         }        
@@ -1097,6 +714,8 @@
 
         if (iAlfScreens[aScreenNumber]->iDisplay)
             ShowControlGroupL(iAlfScreens[aScreenNumber]->iDisplay->Roster(), *group, KHuiRosterShowAtTop, aScreenNumber); 
+        
+        AMT_INC_COUNTER( iTotalControlGroupCount );
         }
     
 
@@ -1268,8 +887,20 @@
             {
             if (index == aWhere)
                 {
-                aRoster.ShowL(aGroup, i);        
+                TBool lSyncAlfAppAndAlfEventGroup = EFalse;
+                if ( i>0 &&  aRoster.ControlGroup(i).iAlfApp && aRoster.ControlGroup(i-1).ResourceId() == iAlfWindowGroupNodeId  && &aRoster.ControlGroup(i) != &aGroup)
+                    {
+                    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;
                 }
 
@@ -1650,8 +1281,8 @@
     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
         {                
 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
-        TInt activevisualcount = 0;
-        TInt passivevisualcount = 0;
+        activevisualcount = 0;
+        passivevisualcount = 0;
 #endif
 
         CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
@@ -1785,9 +1416,19 @@
                 if (firstFadedWindowGroupFound)
                     {
                     TInt flags = layout->Effect()->EffectFlags();
-                    flags |= KHuiFxAlwaysBlend;
+                    flags |= KHuiFxAlwaysBlend; // Workaround for opaque layout canvasvisual.
                     layout->Effect()->SetEffectFlags(flags);
                     }
+                
+                if ((controlgroup.ResourceId() == iAlfWindowGroupNodeId))
+                    {
+                    // Special handling for ALF fading...fading happens via empty alf originated event window group
+                    TInt flags = layout->Effect()->EffectFlags();
+                    flags |= KHuiFxEnableBackgroundInAllLayers; // This forces effect to happen to background pixels that are read from surface. 
+                    flags |= KHuiFxFrozenBackground; // To get optimal UI performance, we ignore changes in ALF scene when it is faded.
+                    layout->Effect()->SetEffectFlags(flags);                            
+                    }
+                
                 firstFadedWindowGroupFound = ETrue;
                 }
             }
@@ -1927,9 +1568,9 @@
             iTempTotalPassiveVisualCount++;
             #endif
             
-    #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
-            passivevisualcount++;
-    #endif
+            #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
+                    passivevisualcount++;
+            #endif
             }
         else
             {
@@ -1978,9 +1619,13 @@
                 {
                 canvasVisual->SetChanged();
                 }
-    #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
+            #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+            iTempTotalActiveVisualCount++;
+            #endif
+
+            #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
             activevisualcount++;
-    #endif
+            #endif
             }
             
         // Finally check the area that this visual covers and add it to covered region
@@ -2607,7 +2252,6 @@
             if (aVisual == effectItem.iEffectedVisual)
                 {
                 iEffectCleanupStack.Remove(i);
-                AMT_DEC_COUNTER(iAlfBridgeEffectCleanupStackCount);
                 break;
                 }
             }
@@ -2654,9 +2298,12 @@
 		     // Sprite is in its own group, and can be deleted normally.
 			if ( !controlGroup  && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite )
 			    {
-			    __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.!");
-			    // the group containing this visual has been destroyed. Thus the visual itself has been destroyed by 
-			    // the group. Ignore this.
+			    __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.");
+			    // the group containing this visual has been destroyed. 
+                if ( viz ) 
+				    {
+				    DestroyWindow(viz);
+					}
 			    }
 			else
 			    {
@@ -2717,6 +2364,9 @@
 		{
 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowPosL, EAlfDSSetWindowPos: Visual not found!");    
 		}   
+
+    AMT_INC_COUNTER_IF( viz, iVisualPositionChangedCount );
+    AMT_SET_VALUE_IF( viz, iLatestVisualExtentRect, TRect( windowAttributes->iPosition, windowAttributes->iSize ) );
 	}
 
 // ---------------------------------------------------------------------------
@@ -2745,6 +2395,9 @@
 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!");    
 		}   
     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
+    
+    AMT_INC_COUNTER_IF(viz, iVisualSizeChangedCount );
+    AMT_SET_VALUE_IF(viz, iLatestVisualExtentRect, TRect( windowAttributes->iPosition, windowAttributes->iSize ) );        
 	}
 
 // ---------------------------------------------------------------------------
@@ -2834,11 +2487,11 @@
 
 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
 			
-                        if (!controlGroup)
-                            {
-                            User::Leave(KErrNotFound);
-                            }
-
+            if (!controlGroup)
+                {
+                User::Leave(KErrNotFound);
+                }
+            ResolveAfterEffectAppearingApplicationL(controlGroup); // does nothing, if effect is not active on this control group
 			// Window server nodes are in inverted Z-order, we switch it here.
 			iAlfScreens[screenNumber]->iDisplay->Roster().Hide(*controlGroup);                            
 			TInt wsWindowGroupCount = 0;
@@ -3009,9 +2662,87 @@
 		{
 		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
 		}    
+#ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
+	    if (iFullScreenEffectData 
+	            && iFullScreenEffectData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
+	            && !iFullScreenEffectData->iEndFullScreen)
+	        {
+            TInt toAppUid; 
+            if (iFullScreenEffectData->iEffectType == CFullScreenEffectState::EExitEffect)
+                {
+                toAppUid = iFullScreenEffectData->iFromAppId;
+                }
+            else
+                {
+                toAppUid = iFullScreenEffectData->iToAppId;
+                }
+            
+            CHuiControlGroup *to_group = FindControlGroupByAppId(toAppUid);
+	    
+	        // 1. if we get drawing commands after BeginFullScreen, we need to generate EndFullScreen call.
+	        // 2. only the first drawing commands will trigger EndFullScreen
+	        // (this mechanism is here because we want to remove delay from fullscreen effects - and EndFullScreens are coming from application too late)
+	        
+	        if (viz->Owner().ControlGroup() == to_group)
+	            {
+                iFullScreenEffectData->ResetTimerL(this);
+                iFullScreenEffectData->iDisplaySize = iAlfScreens[0]->Size(); 
+                THuiCanvasPaintedArea p = viz->PaintedArea(0);
+	            iFullScreenEffectData->iPaintedRegion.AddRect( p.iPaintedRect.Round() );
+	            TRect b = iFullScreenEffectData->iPaintedRegion.BoundingRect();
+	            __ALFFXLOGSTRING3(
+	                    "CAlfBridge::HandlePostCanvasBufferL : Effect to visual 0x%x, Covered rect: iTl.iX: %d , iTl.iY: %d",
+	                    viz, 
+	                    b.iTl.iX, 
+	                    b.iTl.iY);
+	            __ALFFXLOGSTRING2("CAlfBridge::HandlePostCanvasBufferL : iBr.iX: %d, iBr.iY: %d", b.iBr.iX, b.iBr.iY);
+	                        }
+	        }
+	        // END TP HACK
+#endif
 	}
 
 // ---------------------------------------------------------------------------
+// HandleGfxEndFullScreenTimeout
+// ---------------------------------------------------------------------------
+// 
+void CAlfBridge::HandleGfxEndFullScreenTimeout(CFullScreenEffectState* aFullScreenEffectData)
+    {
+    if (aFullScreenEffectData->iEndFullScreen)
+        {
+        return;
+        }
+    CHuiControlGroup *to_group = FindControlGroupByAppId(aFullScreenEffectData->iToAppId);
+    CHuiControlGroup *from_group = FindControlGroupByAppId( aFullScreenEffectData->iFromAppId );
+    CHuiLayout *to_layout = NULL;
+    CHuiLayout *from_layout = NULL;
+    if (!to_group) // group has been destroyed and moved to effectControlGroup for waiting the application exit effect EndFullScreen trigger 
+         {
+        to_layout = FindLayoutByEffectHandle(aFullScreenEffectData->iHandle);
+         }
+     else
+         {
+         CHuiControl& control = to_group->Control(0);
+         to_layout = (CHuiLayout*)&control.Visual(0);
+         }
+        
+    if (from_group)
+        {
+        CHuiControl& control = from_group->Control(0);
+        from_layout = (CHuiLayout*)&control.Visual(0);
+        }
+    aFullScreenEffectData->iOperation = MAlfGfxEffectPlugin::EEndFullscreen;
+    if (to_layout)
+        {
+        // from layout may be undefined
+        __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEndFullScreenTimeout : Enough app drawing. Trigger EndFullScreen for layout 0x%x", to_layout);    
+        HandleGfxEventL( *aFullScreenEffectData, to_layout, from_layout );
+        }
+
+    aFullScreenEffectData->iEndFullScreen = ETrue;
+    }
+
+// ---------------------------------------------------------------------------
 // SetWindowActiveL
 // ---------------------------------------------------------------------------
 // 
@@ -3672,6 +3403,8 @@
 TBool CAlfBridge::HasActiveFadedChildren( CHuiCanvasVisual& aVisual )
     {
     TBool has = EFalse;
+    has |= IsAlfOriginatedWindow(aVisual);
+    
     TInt count = aVisual.Count();        
     for (TInt i=0; i<count; i++)
         {
@@ -3679,7 +3412,7 @@
         TBool active = !(child->Flags() & EHuiVisualFlagInactive);            
         TBool faded = child->CanvasFlags() & EHuiCanvasFlagExternalFade; 
         
-        if (active && faded && child->PaintedAreaCount())
+        if (active && faded && (child->PaintedAreaCount() || IsAlfOriginatedWindow(*child)))
             {
             has = ETrue;
             break;
@@ -3719,7 +3452,7 @@
         TBool otherEffectActive = aVisual.Effect() && !(aVisual.Effect()->EffectFlags() & KHuiFadeEffectFlag);
 
         // Check if we really need to fade. Note the order of if-conditions, fastest checks first to optimize performance.
-        if (visualIsActive && !alreadyFaded && !otherEffectActive && !IsFadedByParent(aVisual) && HasActivePaintedAreas(aVisual, fadesChildren))
+        if (visualIsActive && !alreadyFaded && !otherEffectActive && !IsFadedByParent(aVisual) && (HasActivePaintedAreas(aVisual, fadesChildren) || IsAlfOriginatedWindow(aVisual)))
         	{        
         	CHuiFxEffect* effect = NULL;
         	CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
@@ -3892,6 +3625,8 @@
         {
         __ALFLOGSTRING1("CAlfBridge::HandleSetCursorDataL - WARNING! Cursor node 0x%x not found!", windowNodeId);
         }
+    
+    AMT_INC_COUNTER_IF(viz, iTotalVisualAttributeChangedCount);   
     }
 
 // ---------------------------------------------------------------------------
@@ -3975,9 +3710,11 @@
                 {
                 aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
                 TBool needStoredBuffers = NeedsStoredBuffers(engine, *aEvent.iEffectName);
+                __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - EBeginFullScreen: %d, Take screenhot: %d", aEvent.iHandle, needStoredBuffers);
                 if (needStoredBuffers)
                     {
                     TRAP(err,StoreRenderBufferStartL(aToLayout));
+                    __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - EBeginFullScreen: Screenshot result: KErrNone == %d", err);
                     if (err == KErrNone)
                         {
                         aToLayout->SetFreezeState(ETrue);
@@ -3995,6 +3732,7 @@
                         {
                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that yet dont have anything to show
                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
+                        aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
                         break;
                         }
                     case AknTransEffect::EApplicationStartSwitch:
@@ -4002,11 +3740,13 @@
                         {
                         aToLayout->iOpacity.Set(0.0f);    // this is meant for applications that are in the background.
                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
+                        aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
                         break;
                         }
 
                     case AknTransEffect::EApplicationExit:
                         {
+                        aEvent.iEffectType = CFullScreenEffectState::EExitEffect;
                         // The effect should start when the new view is ready,
                         // but we have no signal telling us that, so we just have to do our best
 
@@ -4022,16 +3762,18 @@
                             __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Found effect on layout 0x%x. Removing effect 0x%x", aToLayout, aToLayout->Effect());
                             aToLayout->SetEffect(NULL);
                             }
-                        if (!(aToLayout->Flags() & EHuiVisualFlagInactive))
+                        if ( aEvent.iAction == AknTransEffect::EApplicationExit && !(aToLayout->Flags() & EHuiVisualFlagInactive)) 
                             {
                             // this will tag the visual, that they cannot be hidden by HandleVisualVisibility
                             // Initialize layout for the exit effect  
                             iLayoutInitializedForExitEffect = SetupEffectLayoutContainerL(aEvent.iHandle, aToLayout, ETrue);
+                            __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - EBeginFullscreen - iLayoutInitializedForExitEffect: %d", iLayoutInitializedForExitEffect);
                             aEvent.iSetupDone = iLayoutInitializedForExitEffect; 
                             }
                         else
                             {
                             iLayoutInitializedForExitEffect = EFalse;
+                            aEvent.iSetupDone = EFalse;
                             }
                          return failed;
                          }
@@ -4053,11 +3795,12 @@
                     if (aToLayout)
                         {
                         aToLayout->iOpacity.Set(1.0f);
-                        __ALFFXLOGSTRING1("HandleGfxEventL - loading effect, handle %d", aEvent.iHandle );
+                        __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - loading effect, handle %d", aEvent.iHandle );
                         if (aEvent.iAction == AknTransEffect::EApplicationExit)
                             {
-                        	// Exit effect was initialized earlier with EBeginFullscreen event
-						    layoutEffectable = iLayoutInitializedForExitEffect;
+                            // Exit effect was initialized earlier with EBeginFullscreen event
+						    layoutEffectable = aEvent.iSetupDone;
+						    __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - EEndFullScreen: %d", layoutEffectable);
                             }
                         else
                         	{
@@ -4069,14 +3812,21 @@
                             }
 
                         if (layoutEffectable)
-                            {
+                            {                        
+                            TInt effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
+                            if (NeedsStoredBuffers(iHuiEnv->EffectsEngine(), *aEvent.iEffectName))
+                                {
+                                // Performance improvement, but this would be better to be a special hint param in the fxml
+                                effectFlags |= KHuiFxOpaqueHint;
+                                }
+                            
                             if (aEvent.iRect != TRect())
                                 {
-                                TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), &aEvent.iRect, this, aEvent.iHandle, KHuiFxDelayRunUntilFirstFrameHasBeenDrawn ));
+                                TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), &aEvent.iRect, this, aEvent.iHandle, effectFlags ));
                                 }
                             else
                                 {
-                                TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle, KHuiFxDelayRunUntilFirstFrameHasBeenDrawn ) );
+                                TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle, effectFlags ) );
                                 }
                             effect = NULL;
                             // only use the effect if the effect file was correctly parsed
@@ -4113,6 +3863,7 @@
     if (aLayout)
         {
 		TRAPD(err, StoreRenderBufferStartL(aLayout));
+		__ALFFXLOGSTRING2("CAlfBridge::FreezeLayoutUntilEffectDestroyed - StoreRenderBufferStartL call returned: %d for layout 0x%x", err, aLayout);
 		if (err == KErrNone)
 			{
             // Freeze only, if buffer was reserved succesfully 
@@ -4188,78 +3939,6 @@
         }
     }
 
-CAlfBridge::CEffectState::CEffectState()
-    {
-    // CBase clears all variables
-    }
-
-CAlfBridge::CEffectState::~CEffectState()
-    {
-    delete iEffectName;
-    }
-
-void CAlfBridge::CEffectState::ResolveFileNameL(RMemReadStream& aStream)
-    {
-    HBufC* effectDirectory = HBufC::NewLC(aStream, 256);
-    HBufC* effectFile = HBufC::NewLC(aStream, 256);
-
-    // Add one extra because we want to be able to append a number to the filename
-    HBufC* effectFullName = HBufC::NewL(effectDirectory->Des().Length()
-            + effectFile->Des().Length() + 1);
-    CleanupStack::PushL(effectFullName);
-
-    effectFullName->Des().Copy(*(effectDirectory));
-    effectFullName->Des().Append(*(effectFile));
-    delete iEffectName;
-    iEffectName = effectFullName; // ownership transferred
-    CleanupStack::Pop(effectFullName);
-    CleanupStack::PopAndDestroy(2, effectDirectory);
-    }
-
-void CAlfBridge::CFullScreenEffectState::ConstructL(
-        TInt aAction,
-        RMemReadStream& aStream)
-    {
-    iAction = aAction;
-
-    iHandle = aStream.ReadInt32L();
-
-    iType = aStream.ReadInt32L();
-    iWg1 = aStream.ReadInt32L();
-    iWg2 = aStream.ReadInt32L();
-    iToAppId = aStream.ReadInt32L();
-    iFromAppId = aStream.ReadInt32L();
-
-    if (iType == AknTransEffect::EParameterType)
-        {
-        /*screen1 =*/aStream.ReadInt32L();
-        /*screen2 =*/aStream.ReadInt32L();
-        }
-    /*TInt flags =*/
-    aStream.ReadInt32L();
-    iRect.iTl.iX = aStream.ReadInt32L();
-    iRect.iTl.iY = aStream.ReadInt32L();
-    iRect.iBr.iX = aStream.ReadInt32L();
-    iRect.iBr.iY = aStream.ReadInt32L();
-
-    ResolveFileNameL(aStream);
-
-    iCompletionHandle = iHandle;
-    }
-
-void CAlfBridge::CControlEffectState::ConstructL(TInt aAction,
-        RMemReadStream& aStream)
-    {
-    iAction = aAction;
-    TInt operation = aStream.ReadInt32L();
-    iHandle = aStream.ReadInt32L();
-    iClientHandle = aStream.ReadInt32L();
-    iClientGroupHandle = aStream.ReadInt32L();
-    TInt screenNumber = aStream.ReadInt32L(); // this has always value 0 
-    // Are Symbian full filename+directory combinations still max 256 characters long?
-    ResolveFileNameL(aStream);
-    }
-
 // ---------------------------------------------------------------------------
 // HandleGfxEffectsL
 // ---------------------------------------------------------------------------
@@ -4354,6 +4033,13 @@
 
         __ALFFXLOGSTRING("HandleGfxEffectsL - process end");
         iFullScreenEffectData->iEndFullScreen = ETrue;
+
+#ifdef USE_APPLICATION_ENDFULLSCREEN_TIMEOUT		
+        if (iFullScreenEffectData->iDrawingCompleteTimer)
+            {
+            iFullScreenEffectData->iDrawingCompleteTimer->Cancel();
+            }
+#endif			
         }
 
     CFullScreenEffectState* fxData = iFullScreenEffectData;
@@ -4648,6 +4334,8 @@
 
 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect)
     {
+    __ALFFXLOGSTRING3("CAlfBridge::SetupEffectLayoutContainerL - aHandle: %d, aSourceLayout: 0x%x, aIsExitEffect: % d >>", aHandle, aSourceLayout, aIsExitEffect );
+    
     if (aSourceLayout->Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)
         {
         // the requested visual is already having an effect. 
@@ -5205,6 +4893,8 @@
                 {
 #ifdef  HUI_DEBUG_TRACK_DRAWING
                 __ALFLOGSTRING2(">> %d WINDOW GROUP (ALF), %d", i, clientWindowGroupId);                                    
+#else
+                __ALFLOGSTRING1(">> %d WINDOW GROUP (ALF)", i);                                                    
 #endif         
                 }
             else
@@ -5220,6 +4910,8 @@
             {
 #ifdef  HUI_DEBUG_TRACK_DRAWING
             __ALFLOGSTRING2(">> %d ALF GROUP, %d", i, clientWindowGroupId);                        
+#else
+            __ALFLOGSTRING1(">> %d ALF GROUP", i);                                    
 #endif
             }
         else if (indexedGroup.Control(0).Role() == EAlfWindowFloatingSpriteContainer)
@@ -5250,6 +4942,8 @@
             {
 #ifdef  HUI_DEBUG_TRACK_DRAWING
             __ALFLOGSTRING3(">> %d UNKNOWN GROUP ?!!? %S, %d", i, &processName, clientWindowGroupId );
+#else
+            __ALFLOGSTRING1(">> %d UNKNOWN GROUP ?!!?", i);                                                                            
 #endif
             }                                                
 
@@ -5486,13 +5180,11 @@
             iAlfScreens[i]->iDisplay->SetForegroundBitmapL( iAlfScreens[i]->iSwRenderingTarget );
             CleanupStack::Pop(texture);
             iAlfScreens[i]->iDisplay->SetForegroundTexture(texture);
-            iAlfScreens[i]->iDisplay->iRosterObservers.AppendL(*this);
             }
         else
             {
             iAlfScreens[i]->iDisplay->SetForegroundBitmapL(NULL);            
             iAlfScreens[i]->iDisplay->SetForegroundTexture(NULL);
-            iAlfScreens[i]->iDisplay->iRosterObservers.Remove(*this);            
             }
             
         // SetCapturingBufferL is called from HandleVisualVisibility.
@@ -5503,21 +5195,6 @@
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // 
-void CAlfBridge::UploadSwRenderingTargetL(CAlfScreen* aScreen)
-    {
-    if (iSwRenderingEnabled)
-        {
-        CHuiTexture* texture = aScreen->iDisplay->ForegroundTexture();                        
-        if (texture && aScreen->iSwRenderingTarget)
-            {
-            texture->UploadL(*aScreen->iSwRenderingTarget, NULL);                
-            }           
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-// 
 TBool CAlfBridge::PrepareSwRenderingTarget( CAlfScreen* aScreen )
     {
     TBool modified = EFalse;
@@ -5638,27 +5315,39 @@
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // 
-void CAlfBridge::NotifyRosterDrawStart(CHuiDisplay& /*aDisplay*/)
+void CAlfBridge::Synchronized(TInt aId)
+    {
+    // Use P&S for now.
+    RProperty::Set( KAlfPSUidSynchronizer, KAlfPSKeySynchronizer, aId );
+    }
+
+void CAlfBridge::SetWindowGroupAsAlfApp(TInt aId)
     {
-    // Do nothing
+   TBool lBreak = EFalse;
+    
+    for ( TInt j = 0; j < iAlfScreens.Count(); j++ )
+            {
+            for ( TInt i = 0; i < iAlfScreens[j]->iControlGroups.Count(); i++ )
+                {
+                if ( iAlfScreens[j]->iControlGroups[i].iClientWindowGroupId == aId )
+                    {
+                    iAlfScreens[j]->iControlGroups[i].iControlGroup->iAlfApp = ETrue;
+                    lBreak = ETrue;
+                    break;
+                    }
+                }   
+            if ( lBreak )
+               break;
+            }
+            
     }
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // 
-void CAlfBridge::NotifyRosterDrawEnd(CHuiDisplay& aDisplay)
+TBool CAlfBridge::IsAlfOriginatedWindow(CHuiCanvasVisual& aVisual)
     {
-    TInt screenNumber = ResolveScreenNumber(aDisplay);    
-    TRAP_IGNORE(UploadSwRenderingTargetL(iAlfScreens[screenNumber]));
-    }
-
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-// 
-void CAlfBridge::Synchronized(TInt aId)
-    {
-    // Use P&S for now.
-    RProperty::Set( KAlfPSUidSynchronizer, KAlfPSKeySynchronizer, aId );
+    return (aVisual.Owner().ControlGroup()->ResourceId() == iAlfWindowGroupNodeId);
     }
 
 // end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfeffectutils.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -0,0 +1,505 @@
+/*
+* Copyright (c) 2008 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:   AlfEffectUtils contains small classes that enable layout switch and transition effects.
+*
+*/
+#include <e32cmn.h>
+#include <s32mem.h>
+#include "alfeffectutils.h"
+#include <akntransitionutils.h>
+
+
+const TInt KRosterFreezeEndTimeoutInMs = 400;
+const TInt KFirstTimeoutForApplicationEndFullScreenInMs = 50;
+
+// ---------------------------------------------------------
+// CAlfRosterFreezeEndTimer
+// ---------------------------------------------------------
+//
+CAlfRosterFreezeEndTimer::CAlfRosterFreezeEndTimer( CAlfBridge& aBridge )
+    :CTimer ( EPriorityStandard ),
+    iBridge( aBridge )
+    {   
+    }
+
+void CAlfRosterFreezeEndTimer::ConstructL()
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add( this );
+    }
+
+CAlfRosterFreezeEndTimer* CAlfRosterFreezeEndTimer::NewL( CAlfBridge& aBridge )
+    {
+    CAlfRosterFreezeEndTimer* self = new ( ELeave ) CAlfRosterFreezeEndTimer( aBridge );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CAlfRosterFreezeEndTimer::~CAlfRosterFreezeEndTimer()
+    {
+    Cancel();        
+    }
+
+void CAlfRosterFreezeEndTimer::Start( TTimeIntervalMicroSeconds32 aPeriod )
+    {
+    if (!IsActive())
+        {
+        After( aPeriod );
+        }
+    }
+
+void CAlfRosterFreezeEndTimer::RunL()
+    {
+    iBridge.iHuiEnv->Display(0).SetDirty();
+    TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
+    iBridge.SetVisualTreeVisibilityChanged(ETrue);    
+    }
+
+void CAlfRosterFreezeEndTimer::DoCancel()
+    {
+    CTimer::DoCancel();
+    }
+
+
+
+CAlfLayoutSwitchEffectCoordinator::CAlfLayoutSwitchEffectCoordinator( CAlfBridge& aBridge ) :
+    iBridge( aBridge ),
+    iLayoutSwitchEffectContext(AknTransEffect::ENone)    
+    {
+    RThread me = RThread();
+    iOriginalPriority = me.Priority();    
+    me.Close();
+    }
+
+CAlfLayoutSwitchEffectCoordinator::~CAlfLayoutSwitchEffectCoordinator()
+    {   
+    }
+
+// ---------------------------------------------------------
+// CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack
+//
+// This method is callback which gets called when layout 
+// switch effect has ended.
+// ---------------------------------------------------------
+//
+void CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack( TInt aHandle )
+    {
+    //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack"));
+    if (iLayoutSwitchEffectContext == aHandle)
+        {
+        AknTransEffect::TContext nextContext = NextLayoutSwitchContext();
+
+        // Unfreeze visible content. This reveals real roster content (in new orientation).
+        if (nextContext == AknTransEffect::ELayoutSwitchExit)
+            {
+            #ifdef HUI_DEBUG_TRACK_DRAWING
+            RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack unfreezing roster content"));
+            #endif
+            iBridge.iHuiEnv->Display(0).SetDirty();
+            TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
+            iBridge.SetVisualTreeVisibilityChanged(ETrue);
+            }
+        
+        // Set next effect
+        SetLayoutSwitchEffect(nextContext);
+        
+        if (nextContext == AknTransEffect::ENone)
+            {
+            // Restore normal priority
+            RThread me = RThread();
+            me.SetPriority(iOriginalPriority);    
+            me.Close();
+
+            // Just in case refresh everything
+            iBridge.iHuiEnv->Display(0).SetDirty();
+            }        
+        }
+    else
+        {
+        //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack - got different handle (normal, dont worry...) - %i"), aHandle);        
+        }
+    }
+
+// ---------------------------------------------------------
+// CAlfLayoutSwitchEffectCoordinator::Cancel
+// ---------------------------------------------------------
+//
+void CAlfLayoutSwitchEffectCoordinator::Cancel()
+    {
+    // Disable effect
+    SetLayoutSwitchEffect( AknTransEffect::ENone );
+
+    // Unfreeze visible content
+    if ( iRosterFreezeEndTimer )
+        {
+        iRosterFreezeEndTimer->Cancel();
+        }
+
+    iBridge.iHuiEnv->Display(0).SetDirty();
+    TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse));
+    iBridge.SetVisualTreeVisibilityChanged(ETrue);
+    
+    // Restore normal priority
+    RThread me = RThread();
+    me.SetPriority(iOriginalPriority);    
+    me.Close();
+    }
+
+// ---------------------------------------------------------
+// CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch
+//
+// This method starts the layout switch effect procedure.
+// ---------------------------------------------------------
+//
+void CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch()
+    {
+    // Hm. what to do if earlier is already in progress ?
+    //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch"));
+    if ( iBridge.iHuiEnv->MemoryLevel() <= EHuiMemoryLevelLowest )
+        {
+        // No effects in low memory mode
+        return;
+        }
+    
+    if (!iLayoutSwitchEffectContext)
+        {
+        TBool tfxOn = CAknTransitionUtils::TransitionsEnabled(AknTransEffect::ELayoutswitchTransitionsOff );
+        TBool tfxExists = LayoutSwitchEffectsExist();
+        if (tfxOn && tfxExists)
+            {
+            // Boost priority so that we are able to draw more frames for the effect
+            RThread me = RThread();
+            me.SetPriority(EPriorityAbsoluteHigh);    
+            me.Close();
+            
+            // Freeze visual content
+            //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch freezing roster content"));
+            iBridge.iHuiEnv->Display(0).SetDirty();
+            TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(ETrue));
+            
+            // Remove all other effects
+            iBridge.HandleGfxStopEvent( EFalse );
+            iBridge.RemoveAllTemporaryPresenterVisuals();
+            
+            // Set first layout switch effect 
+            SetLayoutSwitchEffect(AknTransEffect::ELayoutSwitchStart);
+            }
+        else
+            {
+            if (!iRosterFreezeEndTimer)
+                {
+                TRAP_IGNORE(iRosterFreezeEndTimer = CAlfRosterFreezeEndTimer::NewL(iBridge));
+                }
+            
+            if (iRosterFreezeEndTimer)
+                {
+                iBridge.iHuiEnv->Display(0).SetDirty();
+                TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(ETrue));
+                
+                // Remove all other effects
+                iBridge.HandleGfxStopEvent( EFalse );
+                iBridge.RemoveAllTemporaryPresenterVisuals();
+
+                // Set remove freeze timer
+                iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000); 
+                }            
+            //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch - tfx are set OFF -> I am not starting effect."));                        
+            }
+        }
+    else
+        {
+        //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch - old effect exists - %i"), iLayoutSwitchEffectContext);
+        }
+    }
+
+// ---------------------------------------------------------
+// CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchContext
+//
+// This method automatically selects the next context in the 
+// layout switch procedure.
+//
+// Contextes change in the following order during layout switch:
+//
+// 1. AknTransEffect::ENone
+// 2. AknTransEffect::ELayoutSwitchStart
+// 3. AknTransEffect::ELayoutSwitchExit
+// 4. AknTransEffect::ENone
+//
+// After new context is selected, appropriate effect is set 
+// (and/or removed) from the roster.
+//
+// ---------------------------------------------------------
+//
+AknTransEffect::TContext CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchContext()
+    {
+    // Resolve next context based on current context
+    AknTransEffect::TContext newContext = AknTransEffect::ENone;    
+    switch (iLayoutSwitchEffectContext)
+        {
+        case AknTransEffect::ENone:
+            {
+            newContext = AknTransEffect::ELayoutSwitchStart;            
+            break;
+            }
+        case AknTransEffect::ELayoutSwitchStart:
+            {
+            newContext = AknTransEffect::ELayoutSwitchExit;                    
+            break;
+            }
+        case AknTransEffect::ELayoutSwitchExit: // fallthrough
+        default:
+            {
+            newContext = AknTransEffect::ENone;            
+            break;
+            }              
+        }
+
+    //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchEffectL old ctx = %i, new ctx = %i"), iLayoutSwitchEffectContext, newContext);
+    return newContext;
+    }
+
+// ---------------------------------------------------------
+// CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffectL
+//
+// This method sets correct effect based on the given 
+// layout switch context.
+//
+// ---------------------------------------------------------
+//
+void CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffect(AknTransEffect::TContext aContext)
+    {
+    MHuiEffectable* effectable = iBridge.iHuiEnv->Display(0).Roster().Effectable();
+    CHuiFxEffect* effect = NULL;
+    CHuiFxEngine* engine = iBridge.iHuiEnv->EffectsEngine();
+    
+    if (!effectable || !engine)
+        {
+        return;
+        }    
+            
+    // Update current context
+    iLayoutSwitchEffectContext = aContext;           
+    
+    if (aContext == AknTransEffect::ENone)
+        {
+        // Just remove effect
+        //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchEffectL - removing effect"));
+        effectable->EffectSetEffect(NULL); // This calls AlfGfxEffectEndCallBack         
+        }
+    else
+        {    
+        // Load correct effect
+        for ( TInt i = 0; i<iBridge.iAlfRegisteredEffects.Count(); i++ )
+            {             
+            if ( iBridge.iAlfRegisteredEffects[i].iAction == aContext)
+                {
+                //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffectL - loading effect"));
+                TRAP_IGNORE(engine->LoadEffectL(*iBridge.iAlfRegisteredEffects[i].iEffectFile, effect, effectable, NULL, this, iLayoutSwitchEffectContext, 0 ) );                    
+                break;
+                }
+            }
+        }    
+    }
+
+TBool CAlfLayoutSwitchEffectCoordinator::LayoutSwitchEffectsExist()
+    {
+    TBool appearExists = EFalse;
+    TBool disAppearExists = EFalse;
+    
+    for ( TInt i = 0; i<iBridge.iAlfRegisteredEffects.Count(); i++ )
+        {             
+        if ( iBridge.iAlfRegisteredEffects[i].iAction == AknTransEffect::ELayoutSwitchStart)
+            {
+            disAppearExists = ETrue;
+            break;
+            }
+        else if ( iBridge.iAlfRegisteredEffects[i].iAction == AknTransEffect::ELayoutSwitchExit)
+            {
+            appearExists = ETrue;
+            break;
+            }
+        }
+    
+    return (appearExists || disAppearExists);    
+    }
+
+// ---------------------------------------------------------
+// CAlfFinishTimer
+// ---------------------------------------------------------
+//
+CAlfEffectEndTimer::CAlfEffectEndTimer( CAlfBridge& aBridge )
+    :CTimer(EPriorityHigh), 
+    iBridge(aBridge)
+    {   
+    }
+
+void CAlfEffectEndTimer::ConstructL()
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add( this );
+    }
+
+CAlfEffectEndTimer* CAlfEffectEndTimer::NewL( CAlfBridge& aBridge )
+    {
+    CAlfEffectEndTimer* self = new ( ELeave ) CAlfEffectEndTimer( aBridge );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CAlfEffectEndTimer::~CAlfEffectEndTimer()
+    {
+    Cancel();        
+    }
+
+void CAlfEffectEndTimer::Start( TTimeIntervalMicroSeconds32 aPeriod, TInt aHandle )
+    {
+    iHandle = aHandle;
+    After( aPeriod );
+    }
+
+void CAlfEffectEndTimer::RunL()
+    {
+    //
+    // timer completes and control is returned to caller
+    //
+    iBridge.TransitionFinishedHandlerL( iHandle );
+    // We don't become active unless we are explicitly restarted
+    }
+
+void CAlfEffectEndTimer::DoCancel()
+    {
+    CTimer::DoCancel();
+    }
+
+
+CEffectState::CEffectState()
+    {
+    // CBase clears all variables
+    }
+
+CEffectState::~CEffectState()
+    {
+    delete iEffectName;
+    }
+
+void CEffectState::ResolveFileNameL(RMemReadStream& aStream)
+    {
+    HBufC* effectDirectory = HBufC::NewLC(aStream, 256);
+    HBufC* effectFile = HBufC::NewLC(aStream, 256);
+
+    // Add one extra because we want to be able to append a number to the filename
+    HBufC* effectFullName = HBufC::NewL(effectDirectory->Des().Length()
+            + effectFile->Des().Length() + 1);
+    CleanupStack::PushL(effectFullName);
+
+    effectFullName->Des().Copy(*(effectDirectory));
+    effectFullName->Des().Append(*(effectFile));
+    delete iEffectName;
+    iEffectName = effectFullName; // ownership transferred
+    CleanupStack::Pop(effectFullName);
+    CleanupStack::PopAndDestroy(2, effectDirectory);
+    }
+
+
+CFullScreenEffectState::~CFullScreenEffectState()
+    {
+    iPaintedRegion.Close();
+    if (iDrawingCompleteTimer)
+        {
+        iDrawingCompleteTimer->Cancel();
+        delete iDrawingCompleteTimer;
+        iDrawingCompleteTimer = NULL;
+        }
+    }
+
+
+void CFullScreenEffectState::ConstructL(
+        TInt aAction,
+        RMemReadStream& aStream)
+    {
+    iAction = aAction;
+
+    iHandle = aStream.ReadInt32L();
+
+    iType = aStream.ReadInt32L();
+    iWg1 = aStream.ReadInt32L();
+    iWg2 = aStream.ReadInt32L();
+    iToAppId = aStream.ReadInt32L();
+    iFromAppId = aStream.ReadInt32L();
+
+    if (iType == AknTransEffect::EParameterType)
+        {
+        /*screen1 =*/aStream.ReadInt32L();
+        /*screen2 =*/aStream.ReadInt32L();
+        }
+    /*TInt flags =*/
+    aStream.ReadInt32L();
+    iRect.iTl.iX = aStream.ReadInt32L();
+    iRect.iTl.iY = aStream.ReadInt32L();
+    iRect.iBr.iX = aStream.ReadInt32L();
+    iRect.iBr.iY = aStream.ReadInt32L();
+
+    ResolveFileNameL(aStream);
+
+    iCompletionHandle = iHandle;
+    }
+
+TInt doNotifyDrawingTimeout( TAny* aPtr )
+    {
+    ((CFullScreenEffectState*)aPtr)->NotifyDrawingTimeout();
+    return 0; // must return something
+    }
+
+TBool CFullScreenEffectState::ResetTimerL(CAlfBridge* aBridge)
+    {
+    iBridge = aBridge;
+    if (!iDrawingCompleteTimer)
+        {
+        iDrawingCompleteTimer = CPeriodic::NewL( EPriorityNormal );
+        iDrawingCompleteTimer->Start( 
+                KFirstTimeoutForApplicationEndFullScreenInMs * 1000 , 
+                KFirstTimeoutForApplicationEndFullScreenInMs * 1000 , TCallBack( doNotifyDrawingTimeout, this ));
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+void CFullScreenEffectState::NotifyDrawingTimeout()
+    {
+    TRect b = iPaintedRegion.BoundingRect();
+    if ( (b.Width() * b.Height()) > 0.75 * (iDisplaySize.iWidth * iDisplaySize.iHeight))
+        {
+        iBridge->HandleGfxEndFullScreenTimeout(this);
+        delete iDrawingCompleteTimer;
+        iDrawingCompleteTimer = NULL;
+        }
+    }
+
+void CControlEffectState::ConstructL(TInt aAction,
+        RMemReadStream& aStream)
+    {
+    iAction = aAction;
+    TInt operation = aStream.ReadInt32L();
+    iHandle = aStream.ReadInt32L();
+    iClientHandle = aStream.ReadInt32L();
+    iClientGroupHandle = aStream.ReadInt32L();
+    TInt screenNumber = aStream.ReadInt32L(); // this has always value 0 
+    // Are Symbian full filename+directory combinations still max 256 characters long?
+    ResolveFileNameL(aStream);
+    }
+
--- a/uiacceltk/hitchcock/ServerCore/Src/alfhierarchymodel.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfhierarchymodel.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -70,9 +70,16 @@
         {
         iServer.Bridge()->SetBatchObserver(this);
         }                
-#ifdef ALF_DEBUG_TRACK_DRAWING 
+    #ifdef ALF_DEBUG_TRACK_DRAWING 
     iCommandDebugger = CAlfCommandDebug::NewL();
-#endif
+    #endif
+
+    #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    // Initiliaze global data in TLS and Open global module testing chunk and mutex
+    User::LeaveIfError(Dll::SetTls(new(ELeave) CAlfModuleTestDataControl()));
+    User::LeaveIfError(AMT_CONTROL()->OpenGlobalObjects());
+    #endif
+    
 	}
 
 // ---------------------------------------------------------------------------
@@ -132,6 +139,11 @@
 #ifdef ALF_DEBUG_TRACK_DRAWING 
     delete iCommandDebugger;
 #endif
+    
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    delete AMT_CONTROL();
+    Dll::FreeTls();
+#endif
     }
 
 // ---------------------------------------------------------------------------
@@ -775,6 +787,10 @@
         //CAlfNode::PrintInfo( 0, (CAlfNodeVisual*)node, TPtrC(KText) , iSearchNode);
         }
 #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 );         
     }
 
 // ---------------------------------------------------------------------------
@@ -804,6 +820,10 @@
         {
         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 );     
     }
 
 // ---------------------------------------------------------------------------
@@ -823,6 +843,8 @@
         {
         USER_INVARIANT();
         }
+    
+    AMT_INC_COUNTER_IF( node && (nodeType==MWsWindowTreeNode::EWinTreeNodeClient), iWindowNodeActivatedCount ); 
     }
 
 // ---------------------------------------------------------------------------
@@ -853,6 +875,8 @@
         }
 #endif
 
+    AMT_INC_COUNTER_IF(node, iNodeExtentChangedCount );
+    AMT_SET_VALUE_IF(node, iLatestNodeExtentRect, rect );        
     }
 
 // ---------------------------------------------------------------------------
@@ -867,7 +891,11 @@
     CAlfNode* node = FindNode( nodeId );
     if ( node )
         {
+        AMT_SET_VALUE(iAST_Temp1, node->OrdinalPosition());
+        
         node->SiblingOrderChanged( newPos );
+        
+        AMT_SET_VALUE(iOrdinalChange, node->OrdinalPosition() - AMT_DATA()->iAST_Temp1);
         }
     else
         {
@@ -908,6 +936,8 @@
         {
         USER_INVARIANT();
         }
+
+    AMT_INC_COUNTER_IF(node, iTotalNodeFlagChangedCount );    
     }
 
 // ---------------------------------------------------------------------------
@@ -1094,6 +1124,8 @@
         {
         USER_INVARIANT(); // attribute change for unexpected node type. new code needed!
         }
+
+    AMT_INC_COUNTER_IF(node, iTotalNodeAttributeChangedCount );    
     }
 // ---------------------------------------------------------------------------
 // DoNodeWindowGroupChainBrokenAfterL
--- a/uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -61,20 +61,14 @@
         }
     }
 // ---------------------------------------------------------------------------
-// OrphonMe
+// OrphanMe
 // ---------------------------------------------------------------------------
 //
-CAlfNode* CAlfNode::OrphonMe()
+CAlfNode* CAlfNode::OrphanMe()
+
     {
-    __ALFLOGSTRING1("CAlfNode::OrphonMe %d", iId);
-	// this window will not be used anymore by wserv and cannot be drawn into. Thus destroying the
-	// visual representing this node is safe.
-    if ( iWindow && iModel )
-        {
-        iModel->Server().WindowMgr()->DestroyWindow( *iWindow );
-        iWindow = NULL;
-        }
-
+    __ALFLOGSTRING1("CAlfNode::OrphanMe %d", iId);
+    // Parent node has been deleted. Orphan the node: remove the parent/sibling relationship.
     CAlfNode* sibling = iSibling;
     iSibling = NULL;
     iParent = NULL;
@@ -1174,6 +1168,11 @@
 CAlfNode::~CAlfNode()
     {
     __ALFLOGSTRING1("CAlfNode::~CAlfNode %d", iId);
+	if ( iWindow && iModel ) // just in case: the window should be deleted already
+        {
+        iModel->Server().WindowMgr()->DestroyWindow( *iWindow );
+        iWindow = NULL;
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -1233,11 +1232,11 @@
         __ALFLOGSTRING1("My parent says, that I'm not his child :..( or no parent %d ", iParent );
         }
     
-    // Orphon all the children
+    // Orphan all the children
     CAlfNode* child = iChild; 
     while( child )
         {
-        child = child->OrphonMe();
+        child = child->OrphanMe();
         }
     iChild = NULL;
     if ( iModel )
@@ -1680,6 +1679,7 @@
     if ( iWindow && iModel )
         {
         iModel->Server().WindowMgr()->DestroyWindow( *iWindow );
+		iWindow = NULL; // make sure there is no double deletion
         }
     }
 
@@ -1944,7 +1944,8 @@
         iModel->Server().Bridge()->AddData( EAlfDSDestroyWindow, 
                 iGroupId, 
                 iId, 
-                (TAny*)offset );                
+                (TAny*)offset );
+        iWindow = 0; // just in case
         }
     RemoveDependencies( iParent->iChild );
     };
--- a/uiacceltk/hitchcock/ServerCore/Src/alfsrvdisplaysubsession.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfsrvdisplaysubsession.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -62,7 +62,8 @@
         // according to the last display. Also the new area is left there even if  ConstructL() 
         // fails(!).
         static_cast<CAlfAppSrvSession&>(Session()).SetClientDrawingArea( aRect );
-        aSession.SetClientWindowGroupId( aWindowGroupId );            
+        aSession.SetClientWindowGroupId( aWindowGroupId );           
+        Session().AlfAppUi()->SetAlfAppWindowGroup(aWindowGroupId);
         }    
     }
 
--- a/uiacceltk/hitchcock/backgroundanim/refplugin/group/refplugin.mmp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/backgroundanim/refplugin/group/refplugin.mmp	Fri Mar 12 15:47:04 2010 +0200
@@ -39,7 +39,6 @@
 MW_LAYER_SYSTEMINCLUDE
 OS_LAYER_LIBC_SYSTEMINCLUDE
 APP_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE 					/epoc32/include/platform/GLES2
 
 SOURCEPATH          ../src
 SOURCE              plugin.c
--- a/uiacceltk/hitchcock/backgroundanim/refplugin/src/shader.c	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/backgroundanim/refplugin/src/shader.c	Fri Mar 12 15:47:04 2010 +0200
@@ -46,7 +46,11 @@
     fseek (file, 0, SEEK_END);
     len = ftell (file);
     fseek(file, 0, SEEK_SET);
-
+    if (len<0)
+        {
+        fclose(file);
+        return 0;
+        }
     shaderdata = (char*)malloc(len+1);
     if (!shaderdata)
         {
--- a/uiacceltk/hitchcock/backgroundanim/src/bganimhost.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/backgroundanim/src/bganimhost.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -26,7 +26,7 @@
 
 typedef void* (*plugingetinterfacefunc)(int);
 
-const TInt KRefreshTarget = 15;
+const TInt KRefreshTarget = 99;
 _LIT(KExeCaption,"BG anim host");
 
 static const TUint KMaxGPUMemUsage = 1024*1024*4;
@@ -370,7 +370,6 @@
 	
 	eglMakeCurrent( iEGLDisplay, iEGLSurface, iEGLSurface, iEGLContext );        
 
-
     free(configList);
     free(preferredConfig);
 	
--- a/uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF	Fri Mar 12 15:47:04 2010 +0200
@@ -1508,7 +1508,7 @@
 	?SetEngine@CHuiFxEffect@@QAEXPAVCHuiFxEngine@@@Z @ 1507 NONAME ; void CHuiFxEffect::SetEngine(class CHuiFxEngine *)
 	?SetExtRect@CHuiFxVisualLayer@@UAEXPAVTRect@@@Z @ 1508 NONAME ; void CHuiFxVisualLayer::SetExtRect(class TRect *)
 	?SetExtRect@CHuiFxGroupLayer@@UAEXPAVTRect@@@Z @ 1509 NONAME ; void CHuiFxGroupLayer::SetExtRect(class TRect *)
-	??0CHuiFxEffectCacheEffectNode@@QAE@ABVTDesC16@@AAPAVCHuiFxEffect@@PAVMHuiEffectable@@PAVTRect@@PAVCHuiFxEngine@@@Z @ 1510 NONAME ; CHuiFxEffectCacheEffectNode::CHuiFxEffectCacheEffectNode(class TDesC16 const &, class CHuiFxEffect * &, class CHuiVisual *, class TRect *, class CHuiFxEngine *)
+	??0CHuiFxEffectCacheEffectNode@@QAE@ABVTDesC16@@AAPAVCHuiFxEffect@@PAVMHuiEffectable@@PAVTRect@@PAVCHuiFxEngine@@@Z @ 1510 NONAME ABSENT; CHuiFxEffectCacheEffectNode::CHuiFxEffectCacheEffectNode(class TDesC16 const &, class CHuiFxEffect * &, class CHuiVisual *, class TRect *, class CHuiFxEngine *)
 	?SetExtRect@CHuiFxEffect@@QAEXPAVTRect@@@Z @ 1511 NONAME ; void CHuiFxEffect::SetExtRect(class TRect *)
 	?CopyParameterL@CHuiFxFilter@@IAEXABVTDesC16@@PAMPBV1@@Z @ 1512 NONAME ; void CHuiFxFilter::CopyParameterL(class TDesC16 const &, float *, class CHuiFxFilter const *)
 	?CopyParameterL@CHuiFxFilter@@IAEXABVTDesC16@@PAVTRgb@@PBV1@@Z @ 1513 NONAME ; void CHuiFxFilter::CopyParameterL(class TDesC16 const &, class TRgb *, class CHuiFxFilter const *)
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxConstants.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxConstants.h	Fri Mar 12 15:47:04 2010 +0200
@@ -146,6 +146,7 @@
 _LIT(KLitVisualBottom, "visual.bottom" ); // bottom y coordinate
 _LIT(KLitVisualLeft, "visual.left" ); // left x coordinate
 _LIT(KLitVisualRight, "visual.right" ); // right x coordinate
+_LIT(KLitDisplayHeightMinusVisualTop, "visual.top.reversed");
 
 _LIT(KLitDisplayWidth, "screen.width" );
 _LIT(KLitDisplayHeight, "screen.height" );
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffect.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffect.h	Fri Mar 12 15:47:04 2010 +0200
@@ -29,16 +29,38 @@
 class MHuiEffectable;
 // Hui Effect Flags
 // The flags must be 1 bit flags to allow several to be set simultaneously (if needed)
-const TInt KHuiFlagsNone = 0x00000000;
-const TInt KHuiFadeEffectFlag = 0x00000001;
+const TInt KHuiFlagsNone = 0x0;
+
+/** Effect is system fade effect */
+const TInt KHuiFadeEffectFlag = 0x1;
+
+/** Effect does not use margins. It is clipped inside its area. */
 const TInt KHuiFxEffectDisableMarginsFlag = 0x2;
+
+/** Effect is not applied to children visuals. */
 const TInt KHuiFxEffectExcludeChildrenFlag = 0x4;
+
+/** Effect is grouped and syncronized with other effect(s)*/
 const TInt KHuiFxWaitGroupSyncronization = 0x8;
+
+/** Effect duration is started after it has first time been drawn. */
 const TInt KHuiFxDelayRunUntilFirstFrameHasBeenDrawn = 0x10;
+
+/** Background pixels are not read even if effect would be applied to background. */
 const TInt KHuiFxDisableBackground = 0x20;
+
+/** Effect content is composited using blending even if normally it would require other mode */ 
 const TInt KHuiFxAlwaysBlend = 0x40;
+
+/** Effect content is marked to produce opaque content on the screen. This can be used to avoid drawing unnecessarely under the effect area. */
 const TInt KHuiFxOpaqueHint = 0x80;
 
+/** Background pixels are read for every layer. This is used for fading legacy ALF content only. */
+const TInt KHuiFxEnableBackgroundInAllLayers = 0x100;
+
+/** Background pixels are not read for every frame (only once in a while), thus background content looks frozen if it is visible. */
+const TInt KHuiFxFrozenBackground = 0x200;
+
 class MAlfGfxEffectObserver
     {
     public:
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffectCache.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffectCache.h	Fri Mar 12 15:47:04 2010 +0200
@@ -86,7 +86,7 @@
 class CHuiFxEffectCacheEffectNode : public CBase, public MHuiFxEffectCacheNode
 {
 public:
-     IMPORT_C CHuiFxEffectCacheEffectNode(const TDesC &aFileName, CHuiFxEffect *&aEffect, MHuiEffectable *aVisual, TRect *extRect, CHuiFxEngine *aEngine) 
+     CHuiFxEffectCacheEffectNode(const TDesC &aFileName, CHuiFxEffect *&aEffect, MHuiEffectable *aVisual, TRect *extRect, CHuiFxEngine *aEngine) 
 	: iFileName(aFileName.AllocL()), iEffect(aEffect), iVisual(aVisual), iExtRect(extRect), iEffectCached(0), iEngine(aEngine), iRefCount(0), iParser(0) { }
      IMPORT_C ~CHuiFxEffectCacheEffectNode();
      void SetEffectEndObserver( MAlfGfxEffectObserver* aEffectEndObserver, TInt aHandle );
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h	Fri Mar 12 15:47:04 2010 +0200
@@ -52,6 +52,8 @@
     CHuiFxLayer& Layer(TInt aIndex) const;
     void FxmlVisualInputs(RArray<THuiFxVisualSrcType> &aArray);
     virtual void EnableMarginApplyChildren(TBool aEnable);
+    virtual void SetAlwaysReadSurfacePixels(TBool aAlwaysReadSurfacePixels);
+
 protected:
     IMPORT_C CHuiFxGroupLayer();
     IMPORT_C void ConstructL(TBool aIsRoot);
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxLayer.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxLayer.h	Fri Mar 12 15:47:04 2010 +0200
@@ -79,6 +79,10 @@
     virtual TBool IsSemitransparent() const;
     
     virtual void FxmlVisualInputs(RArray<THuiFxVisualSrcType> &aArray) { }
+    
+    TBool AlwaysReadSurfacePixels() const;
+    virtual void SetAlwaysReadSurfacePixels(TBool aAlwaysReadSurfacePixels);
+    
 protected:
     IMPORT_C CHuiFxLayer();
     IMPORT_C void ConstructL( THuiFxLayerType aType );
@@ -95,6 +99,7 @@
     TBool               iAnimated;
     TBool               iTransformed;
     TBool               iMarginEnabled;
+    TBool               iAlwaysReadSurfacePixels;
     };
 
 #endif /*HUIFXLAYER_*/
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxParameter.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxParameter.h	Fri Mar 12 15:47:04 2010 +0200
@@ -51,7 +51,7 @@
     EReferencePointExtRectBottom,
     EReferencePointExtRectLeft,
     EReferencePointExtRectRight,
-   
+    EReferencePointDisplayHeightMinusVisualTop
     };
 
 class MHuiFxParameter
--- a/uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h	Fri Mar 12 15:47:04 2010 +0200
@@ -196,6 +196,9 @@
     void DestroyBuffer(TInt aIndex);
     void UpdateBufferUpdateRegions(TPoint aPos);
     
+    void RemoveBuffersWithMovedDisplayRect();
+    void ModifyBuffersWithChangedDisplayRect();
+    
 public:    
     void EnableRenderBufferIfNeeded(TBool aEnable);
 private:
--- a/uiacceltk/hitchcock/coretoolkit/inc/huiextension.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huiextension.h	Fri Mar 12 15:47:04 2010 +0200
@@ -23,6 +23,25 @@
 
 #include <e32std.h>
 
+class CFbsBitmap;
+
+// Uid for Partial Bitmap Upload extension
+// THuiTexturePartialBitmapUploadParams used as parameter.
+const TUid KHuiTexturePartialBitmapUploadUid = { 0x2002C359 };
+
+// Parameter structure for Partial Bitmap Upload extension
+struct THuiTexturePartialBitmapUploadParams
+    {
+    // Input parameters
+    
+    TRect iRect;
+    CFbsBitmap* iBitmap;
+    
+    // Output parameters
+    
+    TInt iErrorCode;
+    };
+
 // Uid for Query visual extension
 const TUid KHuiVisualQueryUid = { 0x2002C36B };
 
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Texture.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Texture.h	Fri Mar 12 15:47:04 2010 +0200
@@ -31,6 +31,7 @@
 #include "uiacceltk/HuiTextureHandle.h"
 #include "HuiVg10RenderPlugin.h"
 
+struct THuiTexturePartialBitmapUploadParams;
 #ifdef __NVG
     #include <AknIconHeader.h>
     class CNvgEngine;
@@ -236,6 +237,11 @@
      *  Make sure the shadow texture is of the proper dimensions.
      */
     void UpdateShadowSizeL(const TSize& aSize);
+
+    /**
+     * Partial bitmap upload.
+     */
+    void PartialBitmapUpload(THuiTexturePartialBitmapUploadParams* aParams);
     
     /** The render plugin that created this texture. */
     CHuiVg10RenderPlugin& iRenderPlugin;
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -30,6 +30,8 @@
 #include "uiacceltk/HuiUtil.h"
 #include "uiacceltk/HuiPanic.h"
 
+#include "huiextension.h"
+
 // temporary hack until the openvg headers are fixed..
 #ifndef OPENVG_VERSION_1_0_1
     #warning using temporary hack to define OPENVG_VERSION_1_0_1, see TSW: SKYA-7QQB8
@@ -878,7 +880,17 @@
     
 void CHuiVg10Texture::TextureExtension(const TUid& aExtensionUid, TAny** aExtensionParameters)
     {
-	CHuiTexture::TextureExtension(aExtensionUid, aExtensionParameters);    	
+    if ( aExtensionUid == KHuiTexturePartialBitmapUploadUid && 
+         aExtensionParameters && *aExtensionParameters )
+        {
+        THuiTexturePartialBitmapUploadParams* params = 
+            static_cast<THuiTexturePartialBitmapUploadParams*>(*aExtensionParameters);
+        PartialBitmapUpload(params);
+        }
+    else
+        {
+	    CHuiTexture::TextureExtension(aExtensionUid, aExtensionParameters);    	
+	    }
     }
 
 void CHuiVg10Texture::EnableShadow(TBool aEnable)
@@ -1003,6 +1015,70 @@
     HUI_VG_INVARIANT();
     }
 
+void CHuiVg10Texture::PartialBitmapUpload(THuiTexturePartialBitmapUploadParams* aParams)
+    {
+    if ( !aParams->iBitmap || !aParams->iBitmap->Handle() ||
+         aParams->iBitmap->DisplayMode() != EColor16MAP )
+        {
+        // Only specific format supported.
+        aParams->iErrorCode = KErrArgument;
+        return;
+        }
+        
+    if ( SegmentCount() != 1 || ((VGImage)SegmentName(0)) == VG_INVALID_HANDLE || 
+         Size() != aParams->iBitmap->SizeInPixels() )
+        {
+        // You must perform initial upload using normal methods.
+        aParams->iErrorCode = KErrNotReady;
+        return;
+        }
+    
+    //TRect segmentRect(SegmentSize(0));
+    TRect segmentRect(Size());
+    TRect rect(aParams->iRect);
+    rect.Intersection(segmentRect);
+    
+    if ( rect != aParams->iRect )
+        {
+        // Rect must be fully within segment rect
+        aParams->iErrorCode = KErrArgument;
+        return;        
+        }
+
+    aParams->iErrorCode = KErrNone;
+    
+    if ( rect.IsEmpty() )
+        {
+        // Nothing to upload.
+        return;
+        }
+
+    PushEGLContext();
+    aParams->iBitmap->BeginDataAccess();
+
+    const TInt scanLineLength = CFbsBitmap::ScanLineLength(
+        aParams->iBitmap->SizeInPixels().iWidth, EColor16MAP);
+    const TInt bytesPerPixel = 4;
+    
+    TUint8* dataAddress = (TUint8*)aParams->iBitmap->DataAddress();
+    dataAddress += rect.iTl.iX * bytesPerPixel;
+    dataAddress += rect.iTl.iY * scanLineLength;
+        
+    vgImageSubData(
+        (VGImage)SegmentName(0), // image
+        dataAddress,             // data
+        scanLineLength,          // dataStride
+        VG_sARGB_8888_PRE,       // dataFormat
+        rect.iTl.iX,             // x
+        rect.iTl.iY,             // y
+        rect.Width(),            // width
+        rect.Height()            // height
+        );
+    
+    aParams->iBitmap->EndDataAccess( ETrue );
+    PopEGLContext();
+    }
+
 #ifdef __NVG
 HBufC8* CHuiVg10Texture::ReadNVGDataL(const CFbsBitmap& aBitmap)
     {
@@ -1436,7 +1512,13 @@
 TSize CHuiVg10Texture::ApplyMargin(VGImage aImage, TSize aSize, EGLDisplay aDisplay, EGLSurface aSurface, EGLContext aContext)
     {
     HUI_VG_INVARIANT();
-        
+    #ifdef __WINSCW__
+        if ( eglMakeCurrent( aDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ) == EGL_FALSE )
+           {
+           HUI_DEBUG1(_L("CHuiVg10Texture::ApplyMargin() - EGL NO_Surface could not be made current, eglErr: %04x"), eglGetError());
+           return aSize;
+           }
+    #endif      
 #ifndef __WINS__ // Should possibly query the supported mode instead?
     VGImageFormat imageInternalFormat = VG_sARGB_8888_PRE;
 #else
@@ -1485,7 +1567,14 @@
         }
     delete buf;
     HUI_VG_INVARIANT();
-    
+    #ifdef __WINSCW__    
+    // Make the PBuffer surface current again 
+     if ( eglMakeCurrent(aDisplay, aSurface, aSurface, aContext) == EGL_FALSE )
+         {
+         HUI_DEBUG1(_L("CHuiVg10Texture::ApplyMargin() - EGL aSurface could not be made current, eglErr: %04x"), eglGetError());
+         return aSize;
+         }
+    #endif     
     // If icon size has to be changed, clear out old area for new DrawNVG round!
     if(aSize.iHeight > HaN)
         {
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -1101,8 +1101,6 @@
     TBool volatileBitmapOrMask = ETrue;
 #endif
 
-    TBool originalMaskUsed = ETrue;
-
 
     TInt bitmapHandle = aImage.iBitmapHandle;
     TInt maskHandle = aImage.iMaskHandle;
@@ -1201,7 +1199,6 @@
                 
                 mask = invertedMask;
                 CleanupStack::PushL(mask);    
-                originalMaskUsed = EFalse;
                 }
             
             // Upload expects mask to begin always at TPoint(0,0), so if mask
@@ -1220,7 +1217,6 @@
                     }
                 mask = movedMask;
                 CleanupStack::PushL(mask);                            
-                originalMaskUsed = EFalse;
                 }
 #ifdef __NVG
             }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -312,6 +312,31 @@
     }
     
     
+TBool CHuiCanvasVisual::CanSkipDrawing() const
+    {
+    TBool semiTranparentEffectActive = (Effect() && Effect()->IsSemitransparent());
+    TBool childWindowEffectActive = (Effect() && EffectIsAppliedToChildren());
+    TBool invisible = (iOpacity.Now() <= EPSILON && !semiTranparentEffectActive);
+    TBool effectAppliedToSurfacePixels = (Effect() && (Effect()->EffectFlags() & KHuiFxEnableBackgroundInAllLayers));
+    
+    if( invisible || 
+        (!HasCommandBuffers(ETrue /*include children*/) && 
+         !childWindowEffectActive &&
+         !IsBackgroundDrawingEnabled() && 
+         !IsExternalContentDrawingEnabled()&&
+         !IsExternalContentDrawingEnabled(ETrue /*include children*/) &&
+         !effectAppliedToSurfacePixels
+         
+        ))
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
 void CHuiCanvasVisual::Draw(CHuiGc& aGc) const
     {
     if (Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)
@@ -324,22 +349,9 @@
     		}
     	}
     
-    TBool semiTranparentEffectActive = (Effect() && Effect()->IsSemitransparent());
-    TBool childWindowEffectActive = (Effect() && EffectIsAppliedToChildren());
-    TBool invisible = (iOpacity.Now() <= EPSILON && !semiTranparentEffectActive);
-    
-    if( invisible || 
-        (!HasCommandBuffers(ETrue /*include children*/) && 
-         !childWindowEffectActive &&
-         !IsBackgroundDrawingEnabled() && 
-         !IsExternalContentDrawingEnabled()&&
-         !IsExternalContentDrawingEnabled(ETrue /*include children*/)
-         
-        ))
+    // Optimization
+    if (CanSkipDrawing())
         {
-        // This will not be visible due to being completely transparent, or the visual does not actually draw anything
-    
-        // However, the draw should continue, if the effect is possibly manipulating the opacity of the visual. See CHuiFxVisualLayer::Draw.
         return;
         }
 
@@ -399,26 +411,25 @@
         TBool transparent = EFalse; 
         transparent |= (!(Flags() & EHuiVisualFlagOpaqueHint)); // Does not have opaque hint -> always transparent
         transparent |= iOpacity.Now() < 1.0f; // Opacity less than 1.0f -> always transparent
-        
+                
         TBool refreshCache = EFalse;        
         if (EffectIsAppliedToChildren())
             {
             refreshCache |= ChildTreeChanged(EHuiCanvasFlagExcludeFromParentEffect);
+
+            iCanvasVisualData->iPaintedRegion.Clear();
+            CollectRecursivePaintedRegion(iCanvasVisualData->iPaintedRegion, EHuiCanvasFlagExcludeFromParentEffect);
             }
         else
             {
-            refreshCache |= Changed();
-            }
-        
-        // TODO: We could update this somewhere else, not here everytime
-        iCanvasVisualData->iPaintedRegion.Clear();
-        TInt paintedAreaCount = PaintedAreaCount();  
-        for (TInt i=0; i<paintedAreaCount; i++ )
-            {
-            iCanvasVisualData->iPaintedRegion.AddRect( CanvasPaintedArea(i).iPaintedRect.Round() );
+            refreshCache |= Changed();            
+
+            iCanvasVisualData->iPaintedRegion.Clear();
+            CollectPaintedRegion(iCanvasVisualData->iPaintedRegion, 0);
             }
         
         didDrawEffect = Effect()->CachedDraw(aGc, area, refreshCache, !transparent, iCanvasVisualData->iPaintedRegion);
+        
         }
     
     if ( !didDrawEffect )
@@ -506,7 +517,7 @@
             }
         }
 
-    if ((IsDelayedEffectSource() || Freezed()))
+    if (IsContentDrawingEnabled() && (IsDelayedEffectSource() || Freezed()))
         {
         // Select right draw mode
         THuiCanvasDrawMode drawMode = (Flags() & EHuiVisualFlagOpaqueHint) ? EHuiCanvasDrawModeNormal : EHuiCanvasDrawModeBlend;
@@ -1126,6 +1137,7 @@
     if (aEnabled == KWindowIsDSAHost)
         {
         iCanvasVisualData->iCanvasFlags |= EHuiCanvasFlagDisableCanvasContent;        
+        ClearCommandSet();
         return;    
         }    
     iCanvasVisualData->iLayerUsesAlphaFlag = aEnabled;
@@ -1417,7 +1429,7 @@
             params->iResult = KErrNone;
             break;
         case THuiVisualQueryParams::EQueryHasDrawableContent:
-            params->iValue = HasCommandBuffers(EFalse);
+            params->iValue = HasCommandBuffers(EFalse) || IsBackgroundDrawingEnabled();
             params->iResult = KErrNone;
             break;
         default:
@@ -1429,3 +1441,46 @@
 		CHuiVisual::VisualExtension(aExtensionUid, aExtensionParams);
 		}
     }
+
+void CHuiCanvasVisual::CollectPaintedRegion(TRegion& aPaintRegion, TInt aExcludeCanvasFlags) const
+    {
+    // Only our own painted areas.
+    TInt paintedAreaCount = PaintedAreaCount();  
+    for (TInt i=0; i<paintedAreaCount; i++ )
+        {
+        aPaintRegion.AddRect( CanvasPaintedArea(i).iPaintedRect.Round() );
+        }
+    aPaintRegion.Tidy();
+    }
+
+void CHuiCanvasVisual::CollectRecursivePaintedRegion(TRegion& aRecursivePaintRegion, TInt aExcludeCanvasFlags) const
+    {
+    // First our own painted areas...
+    CollectPaintedRegion(aRecursivePaintRegion, aExcludeCanvasFlags);
+            
+    // ...then children (and their children).
+    const TInt count = Count();
+    for(TInt i = 0; i < count; ++i)
+        {
+        // Check wheter we should include this child visual or ignore it.
+        if (aExcludeCanvasFlags)
+            {
+            CHuiVisual* visual = (CHuiCanvasVisual*)&Visual(i);
+            if ( !(visual->Flags() & EHuiVisualFlagInactive) )
+                {
+                TInt canvasFlags = visual->QueryCanvasFlags();
+                    
+                if ( !(canvasFlags & aExcludeCanvasFlags) )
+                    {
+                    // If this is marked as Wserv visual, it should be safe to cast.
+                    if (visual->Flags() & EHuiVisualFlagWserv)
+                        {
+                        CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)visual;
+                        canvasVisual->CollectRecursivePaintedRegion(aRecursivePaintRegion, aExcludeCanvasFlags);
+                        }
+                    }
+                }        
+            }
+        }    
+    aRecursivePaintRegion.Tidy();
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiControlGroup.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiControlGroup.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -29,7 +29,7 @@
 #include "uiacceltk/HuiEnv.h"
 
 CHuiControlGroup::CHuiControlGroup(TInt aResourceId, CHuiEnv& aEnv)
-        : iResourceId(aResourceId), iEnv(aEnv), iAcceptInput(ETrue), iOpacity( 1.f )
+        : iResourceId(aResourceId), iEnv(aEnv), iAcceptInput(ETrue), iOpacity( 1.f ),iAlfApp(EFalse)
     {
     HUI_PROBE_ASSOCIATE_WITH_CURRENT_SESSION
     HUI_PROBE_REPORT_CONSTRUCTED
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiDisplay.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiDisplay.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -48,6 +48,7 @@
 #include <uiacceltk/huidisplaybackgrounditem.h>
 #include "huiskinbackroundlayout.h"
 #include "HuiFxEngine.h"
+#include "huiextension.h"
 
 const TUid KHuiInternalFbsBitmapBufferGcUid = {0x2000e5a3}; 
 
@@ -932,6 +933,7 @@
 		
 		if (iForegroundTexture)
 		    {
+		    UpdateForegroundTexture(dirtyRect);
 		    DrawForegroundTexture();
 		    }
 		
@@ -1620,6 +1622,30 @@
     return iForegroundTexture;
     }
 
+void CHuiDisplay::UpdateForegroundTexture(const TRect& aRect)
+    {
+    if (iForegroundTexture && iForegroundBitmap && !aRect.IsEmpty())
+        {
+        TRAP_IGNORE(DoUpdateForegroundTextureL(aRect));
+        }
+    }
+
+void CHuiDisplay::DoUpdateForegroundTextureL(const TRect& aRect)
+    {
+    // First try to upload with faster mechanism
+    THuiTexturePartialBitmapUploadParams params;
+    params.iErrorCode = KErrNotSupported;
+    params.iRect = aRect;
+    params.iBitmap = iForegroundBitmap;
+    TAny* ptr = &params;
+    
+    MHuiTexture* texture = iForegroundTexture;
+    texture->TextureExtension(KHuiTexturePartialBitmapUploadUid, &ptr);
+    if ( params.iErrorCode != KErrNone )
+        {    
+        iForegroundTexture->UploadL(*iForegroundBitmap, NULL);
+        }
+    }
 
 void CHuiDisplay::DrawForegroundTexture()
     {
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiEnv.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiEnv.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -1825,6 +1825,5 @@
             
             }
         }
+    }
 
-   
-    }
\ No newline at end of file
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -238,6 +238,12 @@
         {
         iRoot->EnableMargin(EFalse);
         }
+
+    // Check if surface pixels are to be used for this effect in all layers.
+    if (EffectFlags() & KHuiFxEnableBackgroundInAllLayers)
+        {
+        iRoot->SetAlwaysReadSurfacePixels(ETrue);
+        }
     
     iRoot->SetTargetRect(targetArea);
     iRoot->SetSourceRect(targetArea);        
@@ -257,8 +263,15 @@
         // Background has not been disabled with a effect specific flag
         TBool enableBackground = IsAppliedToBackground() && (!aOpaque || iRoot->IsMarginEnabled()) && !(EffectFlags() & KHuiFxDisableBackground);
         
+        if (EffectFlags() & KHuiFxEnableBackgroundInAllLayers)
+            {
+            enableBackground = ETrue;
+            }
+        
+        TBool useFrozenBackground = (EffectFlags() & KHuiFxFrozenBackground);
+        
         // Check if cache is up-to date or does it need to be refreshed
-        TBool cachedRenderTargetNeedsRefresh = (iRoot->Changed() || aRefreshCachedRenderTarget || enableBackground);
+        TBool cachedRenderTargetNeedsRefresh = (iRoot->Changed() || aRefreshCachedRenderTarget || (enableBackground && !useFrozenBackground));
 
         // Try to apply also margins, we cannot just use aDisplayRect directly
         TRect targetRect = iRoot->VisualRect();
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffectParser.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffectParser.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -1075,6 +1075,10 @@
         {
         ref = EReferencePointDisplayHeight;
         }
+    else if ( paramRef.Compare( KLitDisplayHeightMinusVisualTop ) == 0 )
+        {
+        ref = EReferencePointDisplayHeightMinusVisualTop;
+        }
     else if ( paramRef.Compare( KLitDisplayTop ) == 0 )
         {
         ref = EReferencePointDisplayTop;
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxEngine.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEngine.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -332,14 +332,6 @@
 #endif // #ifdef HUIFX_TRACE    
 
     iActiveEffects.AppendL(aEffect);
-
-    // Performance improvement, but this would be better to be a special hint param in the fxml
-    if (aEffect && FxmlUsesInput1(*aEffect))
-        {
-        TInt flags = aEffect->EffectFlags();
-        flags |= KHuiFxOpaqueHint;
-        aEffect->SetEffectFlags(flags);        
-        }
     }
 
 EXPORT_C void CHuiFxEngine::RemoveEffect(CHuiFxEffect* aEffect)
@@ -373,6 +365,12 @@
             CHuiDisplay* display = &CHuiStatic::Env().PrimaryDisplay(); 
             return display->VisibleArea().Size().iHeight; // was DefaultRenderbuffer()->Size().iHeight
             }
+        case EReferencePointDisplayHeightMinusVisualTop:
+            {
+            CHuiDisplay* display = &CHuiStatic::Env().PrimaryDisplay(); 
+            TReal32 height = display->VisibleArea().Size().iHeight; // was DefaultRenderbuffer()->Size().iHeight
+            return height;
+            }
         default:
             break;
         }
@@ -592,6 +590,11 @@
 
 TBool CHuiFxEngine::HasActiveEffects() const
     {
+	// Don't report active effects if in SW-rendering mode
+    if(iLowGraphicsMemoryMode) // != Normal
+        {
+        return EFalse;
+        }
     return iActiveEffects.Count() > 0;
     }
 
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxGroupLayer.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxGroupLayer.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -190,6 +190,14 @@
             {
             return;
             }
+
+        // Make sure background is enabled if needed.
+        if (AlwaysReadSurfacePixels())
+            {
+            backBuffer->EnableBackground(ETrue);
+            backBuffer->PrepareForReuse(backBuffer->Size());
+            }
+        
         sourceBuffer = backBuffer;
         
         // Translate the graphics context so that the content appears in the correct place
@@ -447,3 +455,12 @@
         iLayers[i]->FxmlVisualInputs(aArray);
         }
     }
+
+void CHuiFxGroupLayer::SetAlwaysReadSurfacePixels(TBool aAlwaysReadSurfacePixels)
+    {
+    CHuiFxLayer::SetAlwaysReadSurfacePixels(aAlwaysReadSurfacePixels);
+    for( TInt i=0 ; i < iLayers.Count() ; i++ )
+        {
+        iLayers[i]->SetAlwaysReadSurfacePixels(aAlwaysReadSurfacePixels);
+        }
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxLayer.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxLayer.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -188,3 +188,13 @@
     {
     return EFalse;
     }
+
+TBool CHuiFxLayer::AlwaysReadSurfacePixels() const
+    {
+    return iAlwaysReadSurfacePixels;
+    }    
+
+void CHuiFxLayer::SetAlwaysReadSurfacePixels(TBool aAlwaysReadSurfacePixels)
+    {
+    iAlwaysReadSurfacePixels = aAlwaysReadSurfacePixels;
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxParameterManager.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxParameterManager.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -216,6 +216,13 @@
             // the bottom right corner of a rect is actually outside the rect
             aDefaultValue = aVisualRect.iBr.iX;
             break;
+        case EReferencePointDisplayHeightMinusVisualTop:
+            {
+            TReal32 height = aEngine.GetReferenceValue( aRef ); // this will be display.height
+            height -= aVisualRect.iTl.iY;
+            aDefaultValue = height;
+            break;
+            }
         default:
             // This will return reference points that depend on display size
             aDefaultValue = aEngine.GetReferenceValue( aRef );
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxVisualLayer.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxVisualLayer.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -300,10 +300,29 @@
     // if seems wiser to do the translation first, otherwise the results seem to be unpredictable.
     
     // Translation
-    if (iTranslationX != 0.0f || iTranslationY != 0.0f || iTranslationZ != 0.0f)
+	TReal32 translationX = 0.0f;
+	TReal32 translationY = 0.0f;
+	TReal32 translationZ = 0.0f;
+
+    if (iTranslationX != 0.0f)
+		{
+		translationX = iTranslationX - iVisual->EffectDisplayRect().iTl.iX;
+		}
+	if (iTranslationY != 0.0f)
         {
-        aGc.Translate(EHuiGcMatrixModel, iTranslationX, iTranslationY, iTranslationZ);
+        translationY = iTranslationY - iVisual->EffectDisplayRect().iTl.iY;
         }    
+
+	if (iTranslationZ != 0.0f)
+        {
+		// Z translation not supported by the model
+        translationZ = iTranslationZ;
+        }    
+
+	  if (translationX != 0.0f || translationY != 0.0f || translationZ != 0.0f)
+	  	{
+        aGc.Translate(EHuiGcMatrixModel, translationX, translationY, translationZ);
+		}
         
     // Scaling
     if (iScaleX != 1.0f || iScaleY != 1.0f || iScaleZ != 1.0f)
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiStatic.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiStatic.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -61,6 +61,102 @@
 NONSHARABLE_CLASS(CAppFwProxy): public CBase
     {
 public:
+    class CAlfGuardedSynchCall: public CActive
+        {
+        public:
+        CAlfGuardedSynchCall(const TAlfCommandParams& aParams):CActive(CActive::EPriorityStandard), iPckg(aParams), iPtr(0,0)
+            {
+            CActiveScheduler::Add(this);
+            iStatus = KErrNotFound;
+            }
+
+        static void DoGuardedOpL(const TAlfCommandParams& aInParams, 
+                                  TDes8& aOutParams,
+                                  RNotifier& aNotifier,
+                                  const TDesC8* aInParams2 = 0 // ugly extension, really
+                                  )
+            {
+            CAlfGuardedSynchCall* me = new (ELeave) CAlfGuardedSynchCall(aInParams);
+
+            CleanupStack::PushL(me);
+            User::LeaveIfError(me->iTimer.CreateLocal());
+            me->iRetBuf = aOutParams.AllocL();
+            me->iPtr.Set((TUint8*)me->iRetBuf->Ptr(),0,aOutParams.MaxSize());
+            if (aInParams2)
+                {
+                me->iAltInBuf = aInParams2->AllocL();
+                }
+            CleanupStack::Pop(); // me
+             
+            if (aInParams2)
+                {
+                aNotifier.StartNotifierAndGetResponse(me->iStatus, 
+                                                      TUid::Uid(KAlfAppFwProxyUid), 
+                                                      *me->iAltInBuf, me->iPtr);
+                }
+            else
+                {
+                aNotifier.StartNotifierAndGetResponse(me->iStatus, 
+                                                      TUid::Uid(KAlfAppFwProxyUid), 
+                                                      me->iPckg, me->iPtr);
+                }                        
+            
+            me->iTimer.After(me->iTimerStatus, 100000); // 100ms
+            User::WaitForRequest(me->iStatus, me->iTimerStatus);
+            TBool timedOut = (me->iStatus == KRequestPending);
+            
+            me->iTimer.Cancel(); // Cancel timer anyway
+                        
+            if (!timedOut)
+                {
+                TInt err = me->iStatus.Int();  
+                User::WaitForRequest(me->iTimerStatus);
+                aOutParams.Copy(*me->iRetBuf);    
+                delete me;
+                User::LeaveIfError(err);
+                }
+            else 
+                {
+                me->SetActive(); 
+                User::Leave( KErrTimedOut );
+                }
+            }
+
+        static TInt DoGuardedOp(const TAlfCommandParams& aInParams, 
+                                  TDes8& aOutParams,
+                                  RNotifier& aNotifier)
+            {
+            TInt ret = KErrNone;    
+            TRAP(ret, DoGuardedOpL(aInParams, aOutParams, aNotifier);)
+            return ret;
+            }    
+
+        ~CAlfGuardedSynchCall()
+            {
+            Cancel();
+            delete iRetBuf;
+            delete iAltInBuf;
+            iTimer.Close(); 
+            }
+            
+        void RunL()
+            {           
+            delete this;
+            }
+            
+        void DoCancel()
+            {
+            // Cancel will call User::WaitForRequest for iStatus (if this ao is active)
+            }
+                
+        TPckgC<TAlfCommandParams> iPckg;
+        HBufC8* iRetBuf;
+        HBufC8* iAltInBuf;
+        TPtr8 iPtr;
+        RTimer iTimer;
+        TRequestStatus iTimerStatus;
+        };
+
     class CAlfLayoutListener: public CActive
         {
         public:
@@ -82,7 +178,8 @@
             TAlfCommandParams params={EAlfIsMirrorred,0,0,0};
             TPckgC<TAlfCommandParams> pkg(params);
             TBuf8<1> awkwardApiDummy;
-            iNotif.iNotif.StartNotifierAndGetResponse(iStatus,TUid::Uid(KAlfAppFwProxyUid), pkg, awkwardApiDummy);            }
+            iNotif.iNotif.StartNotifierAndGetResponse(iStatus,TUid::Uid(KAlfAppFwProxyUid), pkg, awkwardApiDummy);            
+            }
     
         void DoCancel()
             {
@@ -111,6 +208,7 @@
         if (!iConnected)
             {
             // perhaps should check also whether eikon server / notifier server exists..
+            // This is currently unsafe (synch) call to a process that may be blocked by window server, keep fingers crossed
             iConnected = (iNotif.Connect() == KErrNone);
             }
         return iConnected;
@@ -121,11 +219,10 @@
         if ( Connect() && iLayoutMirrored == KErrNotFound)
             {
             TRequestStatus status;
-            TAlfCommandParams params={EAlfIsMirrorred,0,0,0};
-            TPckgC<TAlfCommandParams> pkg(params);
-            TBuf8<1> awkwardApiDummy;
-            iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, awkwardApiDummy);
-            User::WaitForRequest(status);
+            TAlfCommandParams inParams={EAlfIsMirrorred,0,0,0};
+            TBuf8<1> outParams;
+            TInt ret = CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif );
+
             // order updates
             iLayoutUpdateAo = new CAlfLayoutListener(*this);
             if (iLayoutUpdateAo)
@@ -133,7 +230,7 @@
                 TRAP_IGNORE(iLayoutUpdateAo->RunL());
                 }
             
-            iLayoutMirrored = (status.Int() > 0);
+            iLayoutMirrored = ret > 0;
             }
      
         return iLayoutMirrored==KErrNotFound?EFalse:iLayoutMirrored;    
@@ -144,13 +241,9 @@
         TInt ret = 0;
         if ( Connect() )
             {
-            TRequestStatus status;
-            TAlfCommandParams params={EAlfCbaLocation,0,0,0};
-            TPckgC<TAlfCommandParams> pkg(params);
-            TBuf8<1> awkwardApiDummy;
-            iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, awkwardApiDummy);
-            User::WaitForRequest(status);
-            ret = status.Int();
+            TAlfCommandParams inParams={EAlfCbaLocation,0,0,0};
+            TBuf8<1> outParams;
+            ret = CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif );
             }
         
         return ret;    
@@ -161,13 +254,9 @@
         TRect ret=TRect(0,0,0,0);
         if ( Connect() )
             {
-            TRequestStatus status;
-            TAlfCommandParams params={EAlfLayoutMetricsRect,aType,0,0};
-            TPckgC<TAlfCommandParams> pkg(params);
-            TPckg<TRect> retpkg(ret);
-                        
-            iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, retpkg);
-            User::WaitForRequest(status);
+            TAlfCommandParams inParams={EAlfLayoutMetricsRect,aType,0,0};
+            TPckg<TRect> outParams(ret);
+            CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif );
             }
         
         return ret;    
@@ -178,14 +267,9 @@
         {
         if ( Connect() )
             {
-            TRequestStatus status;
-            TAlfCommandParams params={EAlfGetCachedColor,aID.iMajor,aID.iMinor,aIndex};
-            TPckgC<TAlfCommandParams> pkg(params);
-            TPckg<TRgb> retpkg(aRgb);
-                    
-            iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, retpkg);
-            User::WaitForRequest(status);
-            return status.Int();
+            TAlfCommandParams inParams={EAlfGetCachedColor,aID.iMajor,aID.iMinor,aIndex};
+            TPckg<TRgb> outParams(aRgb);
+            return CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif);
             }
     
         return KErrCouldNotConnect;    
@@ -196,15 +280,12 @@
         {
         if ( Connect() )
             {
-            TRequestStatus status;
-            TAlfCommandParams2 params={EAlfGetSkinBitmap,aID.iMajor,aID.iMinor,aBitmapId,aMaskId,aFileName, aSize, aScaleMode};
-            TPckgC<TAlfCommandParams2> pkg(params);
+            TAlfCommandParams fakeParams={0,0,0,0};    
+            TAlfCommandParams2 inParams={EAlfGetSkinBitmap,aID.iMajor,aID.iMinor,aBitmapId,aMaskId,aFileName, aSize, aScaleMode};
+            TPckgC<TAlfCommandParams2> inBuf(inParams);
             TInt2 handles = {0,0};
-            TPckg<TInt2> retpkg(handles);
-                    
-            iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, retpkg);
-            User::WaitForRequest(status);
-            User::LeaveIfError(status.Int());
+            TPckg<TInt2> outParams(handles);
+            CAlfGuardedSynchCall::DoGuardedOpL( fakeParams, outParams , iNotif, &inBuf );
             if (!handles.iInt1)
                 {
                 User::Leave(KErrNotFound); 
@@ -221,15 +302,10 @@
         {
         if ( Connect() )
             {
-            TRequestStatus status;
-            TAlfCommandParams params={EAlfGetSkinBackgroundBitmap,aID.iMajor,aID.iMinor,0};
-            TPckgC<TAlfCommandParams> pkg(params);
+            TAlfCommandParams inParams={EAlfGetSkinBackgroundBitmap,aID.iMajor,aID.iMinor,0};
             TInt handle = 0;
-            TPckg<TInt> retpkg(handle);
-                    
-            iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, retpkg);
-            User::WaitForRequest(status);
-            User::LeaveIfError(status.Int());
+            TPckg<TInt> outParams(handle);
+            CAlfGuardedSynchCall::DoGuardedOpL( inParams, outParams , iNotif );
             User::LeaveIfError(aBitmap->Duplicate(handle));
             }
         }
@@ -238,26 +314,12 @@
         {
         if ( Connect() )
             {
-            TRequestStatus status;
-            TAlfCommandParams params={EGetCachedSkinItemData,aID.iMajor,aID.iMinor,aType};
-            TPckgC<TAlfCommandParams> pkg(params);
-            TPckg<TAlfCachedSkinItemArray> retpkg(aArray);
-                    
-            iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, retpkg);
-            User::WaitForRequest(status);
-            User::LeaveIfError(status.Int());
+            TAlfCommandParams inParams={EGetCachedSkinItemData,aID.iMajor,aID.iMinor,aType};
+            TPckg<TAlfCachedSkinItemArray> outParams(aArray);
+            CAlfGuardedSynchCall::DoGuardedOpL( inParams, outParams , iNotif );
             }
         }
         
-    void GetListOfWindowGroupsL(TRequestStatus& aStatus, TPtr8& aPtr)
-        {
-        if ( Connect() )
-            {
-            TAlfCommandParams params={EGetListOfWindowGroups,0,0,0};
-            TPckgC<TAlfCommandParams> pkg(params);
-            iNotif.StartNotifierAndGetResponse(aStatus,TUid::Uid(KAlfAppFwProxyUid), pkg, aPtr);
-            }        
-        }    
     public: 
         TBool iLayoutMirrored;
         RNotifier iNotif;
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvasgc.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvasgc.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -1223,6 +1223,13 @@
     
 EXPORT_C TBool CHuiCanvasGc::ClipNext()
     {
+    if (iDelayedClipVisibility == EFullyOutside)
+        {
+        // If drawing would fall completely outside the clipping region, we are done. 
+        return EFalse;
+        }
+
+    const TBool clipOneByOne = iDelayedClipRegion.Count() > MaxNumberOfClipRects();
     if (iDelayedClipVisibility != EFullyOutside && 
         iDelayedClipRegion.Count() && 
         iDelayedClipCount < iDelayedClipRegion.Count())        
@@ -1236,7 +1243,7 @@
       	iGc->PushClip();
         iDelayedClipRectPushed = ETrue;
         
-        if (MaxNumberOfClipRects() == 1)
+        if (clipOneByOne)
             {
             iGc->Clip(iDelayedClipRegion[iDelayedClipCount]);                            
             }
@@ -1246,18 +1253,21 @@
             }                            
         }    
 
-    iDelayedClipCount += MaxNumberOfClipRects();
-    
-    if (iDelayedClipVisibility == EFullyOutside)
+    TBool continueDrawing = EFalse;
+    if (clipOneByOne)
         {
-        // If drawing would fall completely outside the clipping region, we are done. 
-        return EFalse;
+        // Clip one by one.            
+        iDelayedClipCount++;
+        continueDrawing = iDelayedClipCount <= iDelayedClipRegion.Count();
         }
     else
         {
-        // Check how many times we must do the operation in case rederer does not support many clip rects at once 
-        return (iDelayedClipCount <= iDelayedClipRegion.Count() || iDelayedClipCount == MaxNumberOfClipRects());
+        // Drawing once is sufficient - all clipping can be done.
+        continueDrawing = !iDelayedClipCount;
+        iDelayedClipCount++;
         }
+
+    return continueDrawing;    
     }
 
 EXPORT_C void CHuiCanvasGc::DisableDelayedClippingIfNeeded()
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvaswshwgc.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswshwgc.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -657,16 +657,30 @@
            }
         UseWsState();
         
-        if ( aFillRule == MWsGraphicsContext::EAlternate )
+        if (iWsBrushStyle == MWsGraphicsContext::ENullBrush)
             {
-            iCanvasGc->SetPolygonDrawMode( EHuiFillEvenOdd );
+            // nullbrush, but pen style set
+            // -> draw non filled polygon and 
+            // use pencolor
+            iCanvasGc->SetPolygonDrawMode( EHuiNoFill );
+            iCanvasGc->SetPenColor(iWsPenColor);            
+            iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));       
+
             }
-        if ( aFillRule == MWsGraphicsContext::EWinding )
-            {        
-            iCanvasGc->SetPolygonDrawMode( EHuiFillNonZero );
+        else
+            {
+            if ( aFillRule == MWsGraphicsContext::EAlternate )
+                {
+                iCanvasGc->SetPolygonDrawMode( EHuiFillEvenOdd );
+                }
+            if ( aFillRule == MWsGraphicsContext::EWinding )
+                {        
+                iCanvasGc->SetPolygonDrawMode( EHuiFillNonZero );
+                }
+            iCanvasGc->SetPenColor(iWsBrushColor);            
+            iCanvasGc->SetOpacity(TReal32(iWsBrushColor.Alpha() / 255.f));       
             }
-        iCanvasGc->SetPenColor(iWsPenColor);            
-        iCanvasGc->SetOpacity(TReal32(iWsPenColor.Alpha() / 255.f));       
+            
         iCanvasGc->SetDrawMode(SelectCanvasDrawMode(iWsDrawMode));        
             
         iCanvasGc->DrawPolygon( points );
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -62,10 +62,6 @@
 const TInt KHuiCanvasDisableRenderBufferHandleInterval = 100; // Milliseconds 
 const TInt KHuiCanvasEnableRenderBufferHandleInterval = 500;  // Milliseconds
 
-/** Internal constant to identify complex command buffers */
-const TInt KPossiblePerformanceProblemInWindow = 64;
-
-
 /** ETrue - use SelectGcL to select gc implementation, 
     EFalse - use KHuiDefaultCanvasWsGc. */
 const TBool KHuiUseSelectGc = ETrue;
@@ -302,23 +298,13 @@
             
             /* If window shape region has been changed, we should clear the window to get rid of old content. 
              * We also set all command buffers to "not drawn" state so that everything will be redrawn.
+             * Actual clearing is done after BeginActionL, because drawing phase will start only after calling it.
              */
-            TBool isFullUpdateRegionCleared = EFalse;
             if(iShapeRegionClearingPending)
                 {
-                #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
-                RDebug::Print(_L(">> CHuiCanvasWsPainter::HandleBufferL - Clearing fullupdateregion"));    
-                #endif
-                // Clear the window update region area
-                TBool doClear = ETrue;
-                iCanvasWsGc->EnableUpdateRegion(iFullUpdateRegion, doClear);
-                iCanvasWsGc->DisableUpdateRegion(); 
-                isFullUpdateRegionCleared = ETrue;
-                
                 // Cause a full redraw for the canvas visual
                 SetAllBuffersChanged(ETrue);    
                 ClearAllBufferStatusFlags(EHuiCanvasBufferStatusDrawn);
-                iShapeRegionClearingPending = EFalse;
                 }
             
             
@@ -328,6 +314,20 @@
             /* Begin draw. If render buffer is used this sets up the render buffer if needed */
             iCanvasWsGc->BeginActionL(aAction,aDisplayRect,aUser,cachePrepared,iFullUpdateRegion);                   
 
+            TBool isFullUpdateRegionCleared = EFalse;
+            if(iShapeRegionClearingPending)
+                {
+                #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
+                    RDebug::Print(_L(">> CHuiCanvasWsPainter::HandleBufferL - Clearing fullupdateregion"));    
+                #endif
+                // Clear the window update region area
+                TBool doClear = ETrue;
+                iCanvasWsGc->EnableUpdateRegion(iFullUpdateRegion, doClear);
+                iCanvasWsGc->DisableUpdateRegion(); 
+                isFullUpdateRegionCleared = ETrue;
+                iShapeRegionClearingPending = EFalse;
+                }
+
             #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
             if (iCanvasWsGc->IsRenderBufferEnabled())
                 {
@@ -2245,7 +2245,13 @@
     TInt originalBufferCount = iCommandBuffers.Count();
     
     RemoveBuffersWithoutRealDrawing();
-    RemoveBuffersWithOldDisplayRect();
+
+    // Remove buffers only with moved display rect and modify the clip region
+    // of buffers with changed size instead of completely removing all. 
+    RemoveBuffersWithMovedDisplayRect();
+    ModifyBuffersWithChangedDisplayRect();
+    //RemoveBuffersWithOldDisplayRect();
+    
     RemoveBuffersWithEmptyUpdateRegion();
     RemoveBuffersWithOverlappingUpdateRegion();         
     
@@ -2253,6 +2259,44 @@
     return didRemoveBuffers;
     }
 
+void CHuiCanvasWsPainter::RemoveBuffersWithMovedDisplayRect()
+    {
+    TInt bufferCount = iCommandBuffers.Count();
+    
+    TRect canvas = iCanvasVisual->DisplayRect().Round();
+    for (TInt cb = bufferCount - 1; cb >= 0; cb--)
+        {
+        CHuiCanvasCommandBuffer* buffer = iCommandBuffers[cb];
+        TRect bufRect = buffer->iOriginalDisplayRect.Round();
+        
+        // If the visual has moved, delete the old buffer
+        if (bufRect.iTl != canvas.iTl)
+            {
+            DestroyBuffer(cb);
+            }
+        }
+    }
+
+void CHuiCanvasWsPainter::ModifyBuffersWithChangedDisplayRect()
+    {
+    TInt bufferCount = iCommandBuffers.Count();
+    TRect canvasRect = iCanvasVisual->DisplayRect().Round();
+    TRegionFix<1> region(canvasRect);
+    
+    // If the buffers have different update region than CanvasVisual, clip
+    // the drawing to canvas visual's & cmdbuffer's updateregions' intersection.
+    for (TInt cb = 0; cb < bufferCount; cb++)
+        {
+        CHuiCanvasCommandBuffer* cmdbuffer = iCommandBuffers[cb];
+        if (cmdbuffer->iOriginalDisplayRect.Round() != canvasRect)
+            {
+            cmdbuffer->iUpdateRegion.Copy(cmdbuffer->iOriginalUpdateRegion);
+            cmdbuffer->iUpdateRegion.Intersect(region);
+            cmdbuffer->iUpdateRegion.Tidy();
+            }
+        }
+    }
+
 void CHuiCanvasWsPainter::RemoveBuffersWithoutRealDrawing()
     {
     TInt bufferCount = iCommandBuffers.Count();
--- a/uiacceltk/hitchcock/goommonitor/data/goomconfig.xml	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/data/goomconfig.xml	Fri Mar 12 15:47:04 2010 +0200
@@ -18,7 +18,7 @@
 	actions are needed. This value is meaningful only when "check" or "estimate" sync mode is
 	used with plugins.
 -->
-	<global_settings low_ram_threshold="3637" good_ram_threshold="10000" max_app_close_batch="3" default_wait_after_plugin="300">
+	<global_settings low_ram_threshold="3637" good_ram_threshold="10000" max_app_close_batch="3" default_wait_after_plugin="200">
 	</global_settings>
 
 <!--	Application specific low RAM and good RAM thresholds are defined here. The higher values of
@@ -27,7 +27,7 @@
 -->
 	<app_specific_thresholds>
 
-  <app uid="101F857A" low_ram_threshold="26000" good_ram_threshold="28000" target_free_on_startup="26000" skip_plugin="2002B3AE"></app> <!-- Camera --> 
+  <app uid="101F857A" low_ram_threshold="28000" good_ram_threshold="30000" target_free_on_startup="22000" skip_plugin="2002B3AE"></app> <!-- Camera --> 
   <app uid="200159B2" low_ram_threshold="5000" good_ram_threshold="10000" target_free_on_startup="26000" skip_plugin="2002B3AE"></app> <!-- MPlayer -->
   <app uid="102824CD" low_ram_threshold="26000" good_ram_threshold="28000" skip_plugin="2002B3AE"></app> <!-- Embedded mplayer -->
   <app uid="200009EE" low_ram_threshold="3637" good_ram_threshold="10000" target_free_on_startup="15000"></app> <!-- Photos -->
--- a/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h	Fri Mar 12 15:47:04 2010 +0200
@@ -51,23 +51,23 @@
     
     enum TGOomTrigger   //How free memory operation was triggered
             {
-            EGOomFocusChanged = 0,
-            EGOomRequestMemory,
-            EGOomThresholdCrossed
+            EGOomTriggerNone = 0,
+            EGOomTriggerFocusChanged,
+            EGOomTriggerRequestMemory,
+            EGOomTriggerThresholdCrossed
             };
 
 public: // event handlers
     void FreeMemThresholdCrossedL(TInt aAction = 0, TInt aThreshold = 0);
     void AppNotExiting(TInt aWgId);
     void StartFreeSomeRamL(TInt aTargetFree, TGOomTrigger aTrigger);
-    void FreeOptionalRamL(TInt aTargetFree, TInt aPluginId, TBool aUseAbsolute = EFalse); // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation
-    void RequestFreeMemoryL(TInt aTargetFree, TBool aUseAbsolute = EFalse);
+    void FreeOptionalRamL(TInt aTargetFree, TInt aPluginId, TBool aUseAbsolute = ETrue); // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation
+    void RequestFreeMemoryL(TInt aTargetFree, TBool aUseAbsolute = ETrue);
     void HandleFocusedWgChangeL(TInt aForegroundAppUid = KErrNotFound);
     static const CGOomGlobalConfig& GlobalConfig();
     void SetPriorityBusy(TInt aWgId);
     void SetPriorityNormal(TInt aWgId);
     void SetPriorityHigh(TInt aWgId);
-    void ResetTargets(TInt aTarget = 0);
     TInt GetFreeMemory();
     void RunCloseAppActions(TInt aMaxPriority);
     CGOomWindowGroupList * GetWindowGroupList() const;
@@ -141,7 +141,7 @@
     void RefreshThresholds(TInt aForegroundAppUid = KErrNotFound);
     void StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority, TGOomTrigger aTrigger);
     void AppClosePriorityChanged(TInt aWgId, TInt aPriority);
-    
+    void ResetTargets(TInt aTarget = 0);
     
 public:
     // All members are owned
--- a/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -408,10 +408,10 @@
         {
         // No usable memory freeing action has been found, so we give up
         TRACES("CGOomActionList::FreeMemory: No usable memory freeing action has been found");
-        iMonitor.ResetTargets();
         TInt freeMemory;
         FreeMemoryAboveTarget(freeMemory);
         iServer.CloseAppsFinished(freeMemory, EFalse);
+        iMonitor.WaitAndSynchroniseMemoryState();
         }
     }
 
@@ -441,7 +441,7 @@
 
     aFreeMemory = iMonitor.GetFreeMemory();
 
-    TRACES1("CGOomActionList::FreeMemoryAboveTarget: Free RAM now %d",aFreeMemory);
+    TRACES2("CGOomActionList::FreeMemoryAboveTarget: Free RAM now %d, currentTarget %d",aFreeMemory, iCurrentTarget);
 
     return (aFreeMemory >= iCurrentTarget);
     }
@@ -600,7 +600,7 @@
                     iRunningKillAppActions = EFalse;
                     // There are no more actions to try, so we give up
                     TRACES1("CGOomActionList::StateChanged: All current actions complete, below good threshold with no more actions available. freeMemory=%d", freeMemory);
-                    iMonitor.ResetTargets();
+                    
                     /* Do not call memory good immidiately after freeing memory for some app
                     if (freeMemory >= iCurrentTarget && !iMonitor.NeedToPostponeMemGood())
                     {                    
@@ -608,6 +608,7 @@
                     }
                      */
                     iServer.CloseAppsFinished(freeMemory, EFalse);
+                    iMonitor.WaitAndSynchroniseMemoryState();
                     }
                 else
                     {
@@ -615,7 +616,7 @@
                     iRunningKillAppActions = ETrue;
                     iMonitor.RunCloseAppActions(iMaxPriority);
                     }
-                iMonitor.WaitAndSynchroniseMemoryState();
+                
                 }
             else
                 {
@@ -634,7 +635,6 @@
                 }
             */
             iRunningKillAppActions = EFalse;
-            iMonitor.ResetTargets();
             iServer.CloseAppsFinished(freeMemory, ETrue);
             iMonitor.WaitAndSynchroniseMemoryState();
             }
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -236,7 +236,8 @@
         TRACES1("FreeMemThresholdCrossedL : crossed low threshold %d", iLowThreshold);
         iMemAllocationsGrowing->Stop();
         iMemAllocationsGoingDown->Continue();
-        StartFreeSomeRamL(iGoodThreshold, EGOomThresholdCrossed);
+        if(iTrigger == EGOomTriggerNone)
+            StartFreeSomeRamL(iGoodThreshold, EGOomTriggerThresholdCrossed);
         }
 #endif
     }
@@ -257,7 +258,7 @@
     RefreshThresholds(aForegroundAppUid);
     // Not very elegant, now we poll on each window group change
     // Should have better trigger e.g. from window server 
-	StartFreeSomeRamL(iCurrentTarget, EGOomFocusChanged);
+	StartFreeSomeRamL(iCurrentTarget, EGOomTriggerFocusChanged);
      }
 
 void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority, TGOomTrigger aTrigger) // The maximum priority of action to run
@@ -333,7 +334,7 @@
     {
     FUNC_LOG;
 
-    StartFreeSomeRamL(aUseAbsolute?aTargetFree:(aTargetFree + iLowThreshold), KGOomPriorityInfinate - 1, EGOomRequestMemory);
+    StartFreeSomeRamL(aUseAbsolute?aTargetFree:(aTargetFree + iLowThreshold), KGOomPriorityInfinate - 1, EGOomTriggerRequestMemory);
     }
 
 void CMemoryMonitor::FreeOptionalRamL(TInt aTargetFree, TInt aPluginId, TBool aUseAbsolute) // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation
@@ -342,7 +343,7 @@
 
     // Calculate the priority of the allocation (the priority of the plugin that will clear it up - 1)
     TInt priorityOfAllocation = iConfig->GetPluginConfig(aPluginId).CalculatePluginPriority(*iGOomWindowGroupList) - 1;
-    StartFreeSomeRamL(aUseAbsolute?aTargetFree:(aTargetFree + iGoodThreshold), priorityOfAllocation, EGOomRequestMemory);
+    StartFreeSomeRamL(aUseAbsolute?aTargetFree:(aTargetFree + iGoodThreshold), priorityOfAllocation, EGOomTriggerRequestMemory);
     }
 
 // Does the EGL extension return the amount of memory in bits?
@@ -383,7 +384,8 @@
     // Calculate the desired good threshold, this could be the globally configured value...
     iGoodThreshold = CMemoryMonitor::GlobalConfig().iGoodRamThreshold;
     iLowThreshold = CMemoryMonitor::GlobalConfig().iLowRamThreshold;
-    iCurrentTarget = iGoodThreshold;
+    if(iCurrentTarget < iLowThreshold)
+        iCurrentTarget = iLowThreshold;
         
     TRACES2("CMemoryMonitor::RefreshThresholds: Global Good Threshold = %d, Global Low Threshold = %d", iGoodThreshold, iLowThreshold);
 
@@ -469,6 +471,8 @@
     //where the operation was initiated with a target larger than the current good threshold
     iCurrentTarget = aTarget;
     iGOomActionList->SetCurrentTarget(iCurrentTarget);
+    if(!aTarget)
+        iTrigger = EGOomTriggerNone;    //reset the trigger condition
     }
 
 void CMemoryMonitor::SetPriorityBusy(TInt aWgId)
@@ -621,7 +625,7 @@
         {
         if(!NeedToPostponeMemGood())
             {
-            TRACES("DoPostponedMemoryGood calling MemoryGOOD");
+            TRACES2("DoPostponedMemoryGood calling MemoryGOOD current %d, iGoodThreshold %d",current, iGoodThreshold);
             iGOomActionList->MemoryGood();
             }
         else
@@ -717,26 +721,28 @@
     
     switch (iTrigger)
         {
-        case EGOomThresholdCrossed:
+        case EGOomTriggerThresholdCrossed:
             {
             //Call memory good if we are good.
             DoPostponedMemoryGood();
             break;
             }
-        case EGOomFocusChanged:
-        case EGOomRequestMemory:
+        case EGOomTriggerFocusChanged:
+        case EGOomTriggerRequestMemory:
             {
             //start timer
-            //cancel timer if end critical allocations request
-            //end critical allocations when timer expires
+            //cancel timer if end critical allocations request -TODO
+            //end critical allocations when timer expires -TODO
             if ( iSynchTimer && //exists
                  !iSynchTimer->IsActive() ) // keep it simple
-                {                
-	        iSynchTimer->After(KGoomWaitTimeToSynch);
+                {        
+                iSynchTimer->Cancel();
+                iSynchTimer->After(KGoomWaitTimeToSynch);
                 }
             break;
             }
         }
+    ResetTargets();
     }
 
 void CMemoryMonitor::SynchroniseMemoryState()
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -90,7 +90,7 @@
 
                 Server().Monitor().SessionInCriticalAllocation(1, clientId);
                 
-                TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0(), iUseAbsoluteTargets));
+                TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0()));
                 if (err)
                     {
                     // completes the message if that was left to pending
@@ -135,7 +135,7 @@
             // message will be completed when CloseAppsFinished() is called.
             iRequestFreeRam = aMessage;
             iMinimumMemoryRequested = aMessage.Int1();
-            Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2(), iUseAbsoluteTargets);
+            Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2());
             break;
             
         case EGOomMonitorSetPriorityBusy:
--- a/uiacceltk/hitchcock/group/core_exports.inc	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/group/core_exports.inc	Fri Mar 12 15:47:04 2010 +0200
@@ -3,7 +3,7 @@
 *  Name        : core_exports.inc
 *  Part of     : Alfred UI Toolkit
 *  Description : Exported header files.
-*  Version     : %version: tr1sido#8.1.25 %
+*  Version     : %version: tr1sido#8.1.26 %
 *
 *  Copyright © 2006-2007 Nokia.  All rights reserved.
 *  This material, including documentation and any related computer
@@ -64,6 +64,10 @@
 ../coretoolkit/data/musicplayer_popup_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/musicplayer_popup_disappear.fxml
 ../coretoolkit/data/musicplayer_viewswitch_in.fxml /epoc32/release/winscw/urel/z/resource/effects/musicplayer_viewswitch_in.fxml
 ../coretoolkit/data/musicplayer_viewswitch_out.fxml /epoc32/release/winscw/urel/z/resource/effects/musicplayer_viewswitch_out.fxml
+../coretoolkit/data/notificationwidget_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/notificationwidget_appear.fxml
+../coretoolkit/data/notificationwidget_dd_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/notificationwidget_dd_appear.fxml
+../coretoolkit/data/notificationwidget_dd_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/notificationwidget_dd_disappear.fxml
+../coretoolkit/data/notificationwidget_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/notificationwidget_disappear.fxml
 ../coretoolkit/data/optionsmenu_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/optionsmenu_appear.fxml
 ../coretoolkit/data/optionsmenu_cascade_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/optionsmenu_cascade_appear.fxml
 ../coretoolkit/data/optionsmenu_cascade_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/optionsmenu_cascade_disappear.fxml
@@ -75,6 +79,7 @@
 ../coretoolkit/data/preview_popup_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/preview_popup_disappear.fxml
 ../coretoolkit/data/screensaver_activate.fxml /epoc32/release/winscw/urel/z/resource/effects/screensaver_activate.fxml
 ../coretoolkit/data/screensaver_deactivate.fxml /epoc32/release/winscw/urel/z/resource/effects/screensaver_deactivate.fxml
+../coretoolkit/data/skinchange.fxml /epoc32/release/winscw/urel/z/resource/effects/skinchange.fxml
 ../coretoolkit/data/systemnotify_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/systemnotify_appear.fxml
 ../coretoolkit/data/systemnotify_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/systemnotify_disappear.fxml
 ../coretoolkit/data/tab_effect.fxml /epoc32/release/winscw/urel/z/resource/effects/tab_effect.fxml
@@ -128,6 +133,10 @@
 ../coretoolkit/data/musicplayer_popup_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/musicplayer_popup_disappear.fxml
 ../coretoolkit/data/musicplayer_viewswitch_in.fxml /epoc32/release/winscw/udeb/z/resource/effects/musicplayer_viewswitch_in.fxml
 ../coretoolkit/data/musicplayer_viewswitch_out.fxml /epoc32/release/winscw/udeb/z/resource/effects/musicplayer_viewswitch_out.fxml
+../coretoolkit/data/notificationwidget_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/notificationwidget_appear.fxml
+../coretoolkit/data/notificationwidget_dd_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/notificationwidget_dd_appear.fxml
+../coretoolkit/data/notificationwidget_dd_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/notificationwidget_dd_disappear.fxml
+../coretoolkit/data/notificationwidget_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/notificationwidget_disappear.fxml
 ../coretoolkit/data/optionsmenu_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/optionsmenu_appear.fxml
 ../coretoolkit/data/optionsmenu_cascade_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/optionsmenu_cascade_appear.fxml
 ../coretoolkit/data/optionsmenu_cascade_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/optionsmenu_cascade_disappear.fxml
@@ -139,6 +148,7 @@
 ../coretoolkit/data/preview_popup_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/preview_popup_disappear.fxml
 ../coretoolkit/data/screensaver_activate.fxml /epoc32/release/winscw/udeb/z/resource/effects/screensaver_activate.fxml
 ../coretoolkit/data/screensaver_deactivate.fxml /epoc32/release/winscw/udeb/z/resource/effects/screensaver_deactivate.fxml
+../coretoolkit/data/skinchange.fxml /epoc32/release/winscw/udeb/z/resource/effects/skinchange.fxml
 ../coretoolkit/data/systemnotify_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/systemnotify_appear.fxml
 ../coretoolkit/data/systemnotify_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/systemnotify_disappear.fxml
 ../coretoolkit/data/tab_effect.fxml /epoc32/release/winscw/udeb/z/resource/effects/tab_effect.fxml
@@ -192,6 +202,10 @@
 ../coretoolkit/data/musicplayer_popup_disappear.fxml /epoc32/data/z/resource/effects/musicplayer_popup_disappear.fxml
 ../coretoolkit/data/musicplayer_viewswitch_in.fxml /epoc32/data/z/resource/effects/musicplayer_viewswitch_in.fxml
 ../coretoolkit/data/musicplayer_viewswitch_out.fxml /epoc32/data/z/resource/effects/musicplayer_viewswitch_out.fxml
+../coretoolkit/data/notificationwidget_appear.fxml /epoc32/data/z/resource/effects/notificationwidget_appear.fxml
+../coretoolkit/data/notificationwidget_dd_appear.fxml /epoc32/data/z/resource/effects/notificationwidget_dd_appear.fxml
+../coretoolkit/data/notificationwidget_dd_disappear.fxml /epoc32/data/z/resource/effects/notificationwidget_dd_disappear.fxml
+../coretoolkit/data/notificationwidget_disappear.fxml /epoc32/data/z/resource/effects/notificationwidget_disappear.fxml
 ../coretoolkit/data/optionsmenu_appear.fxml /epoc32/data/z/resource/effects/optionsmenu_appear.fxml
 ../coretoolkit/data/optionsmenu_cascade_appear.fxml /epoc32/data/z/resource/effects/optionsmenu_cascade_appear.fxml
 ../coretoolkit/data/optionsmenu_cascade_disappear.fxml /epoc32/data/z/resource/effects/optionsmenu_cascade_disappear.fxml
@@ -203,6 +217,7 @@
 ../coretoolkit/data/preview_popup_disappear.fxml /epoc32/data/z/resource/effects/preview_popup_disappear.fxml
 ../coretoolkit/data/screensaver_activate.fxml /epoc32/data/z/resource/effects/screensaver_activate.fxml
 ../coretoolkit/data/screensaver_deactivate.fxml /epoc32/data/z/resource/effects/screensaver_deactivate.fxml
+../coretoolkit/data/skinchange.fxml /epoc32/data/z/resource/effects/skinchange.fxml
 ../coretoolkit/data/systemnotify_appear.fxml /epoc32/data/z/resource/effects/systemnotify_appear.fxml
 ../coretoolkit/data/systemnotify_disappear.fxml /epoc32/data/z/resource/effects/systemnotify_disappear.fxml
 ../coretoolkit/data/tab_effect.fxml /epoc32/data/z/resource/effects/tab_effect.fxml
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -680,7 +680,7 @@
 // calls to GfxTransEffect::NotifyExternalState comes through here.
 // ---------------------------------------------------------------------------
 //
-void CGfxTransAdapterTfx::NotifyExternalState( TInt aState, const TDesC8* /*aArg*/ )
+void CGfxTransAdapterTfx::NotifyExternalState( TInt aState, const TDesC8* aArg )
 	{
 	switch(aState)
 		{
@@ -710,7 +710,14 @@
 	    case ELastPopupInSequence:
 	    case EEndPopupSequence:
 		case EInternalHandleSequence:
+		    break;
 		case EGetRegistrationType:
+		    {
+		    // Not supported
+	        TUid* t = (TUid*)(aArg);
+	        *t = KNullUid;
+	        break;
+		    }
         case EAddIgnoreWOChildComponent:
         case ERemoveIgnoreWOChildComponent:
         default:
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp	Mon Feb 22 17:57:49 2010 +0200
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp	Fri Mar 12 15:47:04 2010 +0200
@@ -1103,10 +1103,6 @@
 
     TInt index = 0;
 
-    TInt nodeHandle = KErrNotFound;
-    TInt nodeGroup = KErrNotFound;
-    TInt screenNumber = KErrNotFound;
-      
     IncreaseHandle();
     iTransitionEndObserver->Cancel();
     iFinishFullScreen->Cancel();