Revision: 201007
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Mar 2010 09:43:21 +0200
changeset 13 8f67d927ea57
parent 0 15bf7259bb7c
child 14 83d2d132aa58
Revision: 201007 Kit: 201011
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
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiEnv.h
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiGc.h
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiS60Skin.h
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiTimedValue.h
uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiVisual.h
uiaccelerator_plat/alf_visual_api/group/bld.inf
uiaccelerator_plat/alf_visual_api/inc/alf/alfdrawer.h
uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorsession.h
uiacceltk/hitchcock/AlfDecoderServerClient/src/alfdecoderserverclient.cpp
uiacceltk/hitchcock/AlfRenderStage/group/alfnonsupportedwscommands.rss
uiacceltk/hitchcock/AlfRenderStage/group/alfrenderstage.rss
uiacceltk/hitchcock/AlfRenderStage/group/alfrenderstageplugin.mmp
uiacceltk/hitchcock/AlfRenderStage/group/bld.inf
uiacceltk/hitchcock/AlfRenderStage/inc/alfasynchgoomsession.h
uiacceltk/hitchcock/AlfRenderStage/inc/alfrenderstage.h
uiacceltk/hitchcock/AlfRenderStage/inc/alfrenderstagefactory.h
uiacceltk/hitchcock/AlfRenderStage/inc/alfrsgc.h
uiacceltk/hitchcock/AlfRenderStage/inc/alfrssendbuffer.h
uiacceltk/hitchcock/AlfRenderStage/src/alfasynchgoomsession.cpp
uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstage.cpp
uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstagefactory.cpp
uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstageplugin.cpp
uiacceltk/hitchcock/AlfRenderStage/src/alfrsgc.cpp
uiacceltk/hitchcock/AlfRenderStage/src/alfrssendbuffer.cpp
uiacceltk/hitchcock/Client/BWINS/alfclientu.DEF
uiacceltk/hitchcock/Client/eabi/alfclientu.DEF
uiacceltk/hitchcock/Client/inc/alfcrppluginclient.h
uiacceltk/hitchcock/Client/src/alfclient.mmp
uiacceltk/hitchcock/Client/src/alfcrppluginclient.cpp
uiacceltk/hitchcock/Client/src/alfdrawer.cpp
uiacceltk/hitchcock/Client/src/alfenv.cpp
uiacceltk/hitchcock/Client/src/alfmappingfunctions.cpp
uiacceltk/hitchcock/Client/src/alftextstylemanager.cpp
uiacceltk/hitchcock/Client/src/alftexturegroup.cpp
uiacceltk/hitchcock/Client/src/alftextvisual.cpp
uiacceltk/hitchcock/CommonInc/alfbridgecommands.h
uiacceltk/hitchcock/CommonInc/alflogger.h
uiacceltk/hitchcock/CommonInc/alfmoduletest.h
uiacceltk/hitchcock/CommonInc/alfrenderstageutils.h
uiacceltk/hitchcock/CommonInc/huisynchronizationobserver.h
uiacceltk/hitchcock/CommonInc/huiwscanvascommands.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/Inc/alfscreen.h
uiacceltk/hitchcock/ServerCore/Inc/alfstreamerconsts.h
uiacceltk/hitchcock/ServerCore/Src/alfappservercore.mmp
uiacceltk/hitchcock/ServerCore/Src/alfappsrvsessionBase.cpp
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/alfscreen.cpp
uiacceltk/hitchcock/ServerCore/Src/alfsrvdisplaysubsession.cpp
uiacceltk/hitchcock/ServerCore/Src/alfstreamerserver.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/eabi/hitchcocku.DEF
uiacceltk/hitchcock/coretoolkit/inc/HuiFxConstants.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffect.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffectCache.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxEngine.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxLayer.h
uiacceltk/hitchcock/coretoolkit/inc/HuiFxParameter.h
uiacceltk/hitchcock/coretoolkit/inc/HuiRenderSurface.h
uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h
uiacceltk/hitchcock/coretoolkit/inc/huiextension.h
uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Gc.h
uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10PBufferSurface.h
uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10RenderSurface.h
uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Texture.h
uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Gc.cpp
uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10PBufferSurface.cpp
uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10RenderSurface.cpp
uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiAnchorLayout.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiAnimatedTexture.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiCmdBufferBrush.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/HuiFxEffectCache.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/HuiLayout.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiRosterImpl.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiS60Skin.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiStatic.cpp
uiacceltk/hitchcock/coretoolkit/src/HuiVisual.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvasgc.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvaswshwgc.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp
uiacceltk/hitchcock/coretoolkit/src/huicanvaswsswgc.cpp
uiacceltk/hitchcock/coretoolkit/src/huigifanimationtexture.cpp
uiacceltk/hitchcock/goommonitor/bwins/goommonitoru.DEF
uiacceltk/hitchcock/goommonitor/data/goomconfig.xml
uiacceltk/hitchcock/goommonitor/eabi/goommonitoru.DEF
uiacceltk/hitchcock/goommonitor/inc/goomactionlist.h
uiacceltk/hitchcock/goommonitor/inc/goomactionref.h
uiacceltk/hitchcock/goommonitor/inc/goomapplicationconfig.h
uiacceltk/hitchcock/goommonitor/inc/goomcloseapp.h
uiacceltk/hitchcock/goommonitor/inc/goomcloseappconfig.h
uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h
uiacceltk/hitchcock/goommonitor/inc/goommonitorclientserver.h
uiacceltk/hitchcock/goommonitor/inc/goomrunplugin.h
uiacceltk/hitchcock/goommonitor/inc/goomwindowgrouplist.h
uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp
uiacceltk/hitchcock/goommonitor/src/goomactionref.cpp
uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp
uiacceltk/hitchcock/goommonitor/src/goomconfigparser.cpp
uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp
uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp
uiacceltk/hitchcock/goommonitor/src/goommonitorsession.cpp
uiacceltk/hitchcock/goommonitor/src/goomrunplugin.cpp
uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp
uiacceltk/hitchcock/group/bld.inf
uiacceltk/hitchcock/group/core_exports.inc
uiacceltk/hitchcock/plugins/alfcrpplugin/group/alfcrpplugin.mmp
uiacceltk/hitchcock/plugins/alfcrpplugin/group/bld.inf
uiacceltk/hitchcock/plugins/alfcrpplugin/inc/alfcrpplugin.h
uiacceltk/hitchcock/plugins/alfcrpplugin/inc/alfsynchronizer.h
uiacceltk/hitchcock/plugins/alfcrpplugin/src/alfcrpplugin.cpp
uiacceltk/hitchcock/plugins/alfcrpplugin/src/alfcrpplugin.rss
uiacceltk/hitchcock/plugins/alfcrpplugin/src/alfsynchronizer.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfpolicyhandler.cpp
uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp
--- a/rom/alfred.iby	Tue Feb 02 07:56:43 2010 +0200
+++ b/rom/alfred.iby	Fri Mar 19 09:43:21 2010 +0200
@@ -51,6 +51,7 @@
 file=ABI_DIR\BUILD_DIR\alfhintplugin.dll               	SHARED_LIB_DIR\alfhintplugin.dll
 
 ECOM_PLUGIN(alfoogmplugin.dll, alfoogmplugin.RSC)
+ECOM_PLUGIN(alfcrpplugin.dll, alfcrpplugin.RSC)
 
 data=DATAZ_\ECOM_RESOURCE_DIR\alfnonsupportedwscommands.rsc     ECOM_RESOURCE_DIR\alfnonsupportedwscommands.rsc
 
@@ -115,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
@@ -126,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
@@ -133,6 +139,8 @@
 data=DATAZ_/RESOURCE_FILES_DIR/effects/taskswapper_app_start_rect.fxml RESOURCE_FILES_DIR/effects/taskswapper_app_start_rect.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/taskswapper_appear.fxml RESOURCE_FILES_DIR/effects/taskswapper_appear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/taskswapper_disappear.fxml RESOURCE_FILES_DIR/effects/taskswapper_disappear.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/toolbar_ext_appear.fxml RESOURCE_FILES_DIR/effects/toolbar_ext_appear.fxml
+data=DATAZ_/RESOURCE_FILES_DIR/effects/toolbar_ext_disappear.fxml RESOURCE_FILES_DIR/effects/toolbar_ext_disappear.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/touchinput_close.fxml RESOURCE_FILES_DIR/effects/touchinput_close.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/touchinput_open.fxml RESOURCE_FILES_DIR/effects/touchinput_open.fxml
 data=DATAZ_/RESOURCE_FILES_DIR/effects/waitnote_appear.fxml RESOURCE_FILES_DIR/effects/waitnote_appear.fxml
--- a/uiaccelerator_plat/alf_client_server_api/inc/alf/alfappui.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_client_server_api/inc/alf/alfappui.h	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiCanvasVisual.h	Fri Mar 19 09:43:21 2010 +0200
@@ -399,10 +399,13 @@
 
 public:    
     IMPORT_C void StoreRenderBufferL();
-    void DrawStoredVisualRenderBuffer() const;
-    void DrawStoredFullScreenRenderBuffer(CHuiGc& aGc) const;
+    void DrawStoredVisualRenderBuffer(TInt aCanvasDrawMode) const;
+    void DrawStoredFullScreenRenderBuffer(TInt aCanvasDrawMode, CHuiGc& aGc) const;
     IMPORT_C void FreeRenderBuffer();
-        
+
+protected:
+    virtual void VisualExtension(const TUid& aExtensionUid, TAny** aExtensionParams);
+
 private:
        
     THuiCanvasPaintedArea CanvasPaintedArea(TInt aIndex) const;
@@ -411,6 +414,15 @@
     void DrawCanvasChildren(CHuiGc& aGc, TInt aIncludeCanvasFlags, TInt aExcludeCanvasFlags) const;
     TBool ChildTreeChanged(TInt aExcludeCanvasFlags) const;
     
+    static TBool RecursiveChildTreeChanged(CHuiVisual* aVisual, TInt aExcludeCanvasFlags);
+    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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiControlGroup.h	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiDisplay.h	Fri Mar 19 09:43:21 2010 +0200
@@ -677,7 +677,7 @@
      *
      * @return  Pointer to native window, or <code>NULL</code>.
      */
-    RDrawableWindow* NativeWindow();
+    IMPORT_C RDrawableWindow* NativeWindow();
 
     /**
      * Returns the rendering surface of the display.
@@ -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/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiEnv.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiEnv.h	Fri Mar 19 09:43:21 2010 +0200
@@ -51,6 +51,7 @@
 class CHuiThemeManager;
 class CHuiCanvasTextureCache;
 class CHuiFxEngine;
+class MHuiSynchronizationObserver;
 
 class CHighResTimer;
 const TInt KHuiEnvReleasedActionId = 0x200100F8;
@@ -759,6 +760,20 @@
 
     CHuiCanvasTextureCache& CanvasTextureCache() const;
 
+    /**
+	 * Performs drawing synchronization.
+	 * @internal
+	 * @param aId identifier.
+	 * @param aObserver observer to be informed of completion.
+	 */
+    IMPORT_C void Synchronize(TInt aId, MHuiSynchronizationObserver* aObserver);
+
+     /**
+     	 * Removes the controlgroup
+	 * @param aId identifier.
+
+     */	   	
+     void RemoveTheControlGroup(TInt aId); 		
 public:
 
     /* Implementaton of MHuiTextureLoadingCompletedObserver: */
@@ -988,6 +1003,10 @@
     IMPORT_C void NotifyMemoryLevel(THuiMemoryLevel aMemoryLevel);
     IMPORT_C THuiMemoryLevel MemoryLevel();
     
+    void DoSynchronize();
+private:
+    MHuiSynchronizationObserver* iSynchObserver;
+    TInt iSynchId;
     };
 
 #endif  // __HUIENV_H__
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiGc.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiGc.h	Fri Mar 19 09:43:21 2010 +0200
@@ -421,6 +421,11 @@
     IMPORT_C virtual void SetDimmingFog(const TRgb& aColor, TReal32 aAmount) __SOFTFP = 0;
 
     /**
+     * Clear rect using the current pen color
+     */
+    IMPORT_C virtual void Clear(const TRect& aRect) = 0;
+    
+    /**
      * Clear using the current pen color.
      */
     IMPORT_C virtual void Clear() = 0;
@@ -938,12 +943,12 @@
     IMPORT_C CHuiGc();
 
     /* Methods. */
-
+    
     /**
      * Determines the projection viewport.
      */
     IMPORT_C TRect ProjectionViewport() const;
-
+    
     /**
      * Determines the display area not affected by orientation.
      */
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiS60Skin.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiS60Skin.h	Fri Mar 19 09:43:21 2010 +0200
@@ -57,12 +57,12 @@
 
 
 	/* Methods from MAknsSkinChangeObserver */
-	  void SkinContentChanged();
+	IMPORT_C void SkinContentChanged();
 
-	  void SkinConfigurationChanged(
+	IMPORT_C void SkinConfigurationChanged(
 	          const TAknsSkinStatusConfigurationChangeReason aReason );
 	  
-	  void SkinPackageChanged(
+	IMPORT_C void SkinPackageChanged(
 	         const TAknsSkinStatusPackageChangeReason aReason );
 public:
 
@@ -127,6 +127,9 @@
 	}
     void UpdateBackgroundsL(const RArray<THuiDisplayBackgroundItem>& aItems);
     IMPORT_C CHuiTexture* BackgroundTexture(const TAknsItemID& aID);
+    
+    TRect SkinRect(const TAknsItemID& aID);
+    
 protected: // from CHuiSkin
     IMPORT_C void SkinExtension(const TUid& aExtensionUid, TAny** aExtensionParameters);
     void FreeBackgrounds();
@@ -143,6 +146,7 @@
      */
     void UpdateBackgroundL();
 
+
 private:
 
     /** Control context for the skin. */
@@ -150,6 +154,8 @@
 
     /** Background texture from S60. */
     CHuiTexture* iBackgroundTexture;
+    CFbsBitmap* iBackgroundBitmap;
+    TRect iBackgroundRect;
 
     /** To get CallBack from SkinServer when skin is changed */
     RAknsSrvSession iSkinSrvSession;
@@ -158,8 +164,29 @@
     /** Background should be reloaded the next time it is needed. */
     TBool iReloadBackground;
     TBool iSkinChanged;
-    CFbsBitmap* iBackgroundBitmap;
+
+    class CSkinItem : public CBase
+        {
+        public :
+        
+        ~CSkinItem()
+            {
+            delete iBitmap;
+            };
+        TAknsItemID iId;
+        TRect iSkinRect;
+        CFbsBitmap* iBitmap;
+        };
+    RPointerArray<CSkinItem> iCachedSkinItems;
+    
     TAny* iSpare;    
-    };
+
+private: // helpers
+    
+    TInt SearchCachedSkinItemIndex(const TAknsItemID& aId);
+    TRect SearchCachedSkinItemRect(const TAknsItemID& aId);
+    CFbsBitmap* SearchCachedSkinItemBitmap(const TAknsItemID& aId);
+	};
+
 
 #endif  // __HUIS60SKIN_H__
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiTimedValue.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiTimedValue.h	Fri Mar 19 09:43:21 2010 +0200
@@ -451,6 +451,7 @@
 private:
     TInt iTimeRemainingWhenSuspended;
     TInt iSpare2;
+    friend class CHuiVisual;
     };
 
 
--- a/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiVisual.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiVisual.h	Fri Mar 19 09:43:21 2010 +0200
@@ -195,7 +195,8 @@
     EHuiVisualFlagShouldBeUnderOpaqueHint = 0x20000000,
     
     EHuiVisualFlagShouldBeShown = 0x40000000,
-    
+    // visual that is used only by wserv
+    EHuiVisualFlagWserv = 0x80000000,
     EHuiVisualFlagLast = 0xFFFFFFFF
     };
 
@@ -1443,6 +1444,24 @@
         {
         iLoadingEffect = aLoading;
         };
+
+    /**
+     * Queries canvas flags of the visual, returns result
+     * @internal
+     */    
+    TInt QueryCanvasFlags();
+
+    /**
+     * Checks if external content drawing is enabled for this visual, returns result
+     * @internal
+     */    
+    TBool QueryExternalContentDrawingEnabled();
+    
+    /**
+     * Checks if visual has something to draw, returns result
+     * @internal
+     */    
+    TBool QueryHasDrawableContent();
     
 protected:
 
--- a/uiaccelerator_plat/alf_visual_api/group/bld.inf	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_visual_api/group/bld.inf	Fri Mar 19 09:43:21 2010 +0200
@@ -100,4 +100,6 @@
 ../inc/goommonitor/goommonitorplugin.hrh     MW_LAYER_PLATFORM_EXPORT_PATH(goommonitorplugin.hrh)
 
 ../inc/alf/alfcompositionclient.h	MW_LAYER_PLATFORM_EXPORT_PATH(alf/alfcompositionclient.h)
-../inc/alf/alfcompositionutility.h	MW_LAYER_PLATFORM_EXPORT_PATH(alf/alfcompositionutility.h)
\ No newline at end of file
+../inc/alf/alfcompositionutility.h	MW_LAYER_PLATFORM_EXPORT_PATH(alf/alfcompositionutility.h)
+
+../inc/alf/alfdrawer.h     MW_LAYER_PLATFORM_EXPORT_PATH(alf/alfdrawer.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiaccelerator_plat/alf_visual_api/inc/alf/alfdrawer.h	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   
+*
+*/
+#ifndef __ALFDRAWER_H__
+#define __ALFDRAWER_H__
+
+#include <e32base.h>
+
+/**
+ * This provides additional alf drawing synchronization.
+ * 
+ * This class requires application environment (CCoeEnv) to exist.
+ */
+NONSHARABLE_CLASS( CAlfDrawer ) : public CBase
+    {
+public:
+    /**
+     * Creates new CAlfDrawer instance.
+     * @return newly created instance.
+     */
+    IMPORT_C static CAlfDrawer* NewL();
+    
+    /**
+     * Destructor.
+     */
+    IMPORT_C ~CAlfDrawer();
+
+public:
+    /**
+     * Finishes drawing. 
+     * This will perform similar operation as RWsSession::Finish
+     * and then wait for all pending drawing to be finished.
+     * @return error code, KErrNone upon success.
+     */
+    IMPORT_C TInt Finish();
+
+private:
+    CAlfDrawer();
+    void ConstructL();
+
+private:
+    struct TAlfDrawerData;
+    TAlfDrawerData* iData;
+    };
+
+#endif // __ALFDRAWER_H__
--- a/uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorsession.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorsession.h	Fri Mar 19 09:43:21 2010 +0200
@@ -169,6 +169,11 @@
     * @param aAppUid application UID being started.
     */
     IMPORT_C void AppAboutToStart(TRequestStatus& aStatus, const TUid& aAppUid);
+    
+    /**
+    * Notify the GOOM monitor that this application has finished allocating memory.  
+    */
+    IMPORT_C void MemoryAllocationsComplete();
 
 private://data 
     TInt iFlags;
--- a/uiacceltk/hitchcock/AlfDecoderServerClient/src/alfdecoderserverclient.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfDecoderServerClient/src/alfdecoderserverclient.cpp	Fri Mar 19 09:43:21 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)
@@ -92,8 +94,8 @@
 	    	        KAlfServerThreadName,
 	    	        AlfThreadFucntion,
 	    	        16384, // magic
-	    	        20000, // uses own heap for now
-	    	        10000000,
+	    	        4*1024*1024, // uses own heap for now
+	    	        10*1024*1024,
 	    	        0,
 	    	        EOwnerThread));
 	    	    
--- a/uiacceltk/hitchcock/AlfRenderStage/group/alfnonsupportedwscommands.rss	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/group/alfnonsupportedwscommands.rss	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/group/alfrenderstage.rss	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/group/alfrenderstage.rss	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2001 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/group/alfrenderstageplugin.mmp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/group/alfrenderstageplugin.mmp	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/group/bld.inf	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/group/bld.inf	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/inc/alfasynchgoomsession.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/inc/alfasynchgoomsession.h	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/inc/alfrenderstage.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/inc/alfrenderstage.h	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
@@ -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"
@@ -55,7 +58,8 @@
     public MWsTextCursor,
     public MAlfCompositionAgnosticWindowTreeObserver,
     public MAlfHintObserver,
-    public MWsDrawAnnotationObserver
+    public MWsDrawAnnotationObserver,
+    public MAlfSynchronizationInterface
         {
 public:
 
@@ -146,6 +150,10 @@
 	void WindowGroupChainBrokenAfter(const MWsWindowTreeNode& aWindowGroupNode);
 	void FadeAllChildren(const MWsWindowTreeNode& aWindowTreeNode, TBool aFaded);
 	
+public: // from MAlfSynchronizationInterface
+    	
+	TInt Synchronize(TInt& aId);
+	
 public: // from MWsDrawAnnotationObserver
 	void WindowRedrawStart(const MWsWindowTreeNode& aWindowTreeNode, const TRegion& aRegion);
 	void WindowRedrawEnd(const MWsWindowTreeNode& aWindowTreeNode);
@@ -295,7 +303,9 @@
         };
     // Sprite flash setting for iSpriteRedraw
     TSpriteFlash iSpriteRedrawFlash;
-    
+
+    // Synchronization identifier.
+    TInt iSyncId;
 	};
 
 #endif //__ALFRENDERSTAGE_H__
--- a/uiacceltk/hitchcock/AlfRenderStage/inc/alfrenderstagefactory.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/inc/alfrenderstagefactory.h	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/inc/alfrsgc.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/inc/alfrsgc.h	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/inc/alfrssendbuffer.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/inc/alfrssendbuffer.h	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
@@ -374,6 +374,12 @@
          * @return Previous command
          */
         inline TInt PreviousCommand(){ return iPreviousCommand; } 
+      
+        /**
+         * Synchronize.
+         * @param aId id to pass forward.
+         */
+        void Synchronize(TInt aId);
         
     public: // From CActive
 
--- a/uiacceltk/hitchcock/AlfRenderStage/src/alfasynchgoomsession.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/src/alfasynchgoomsession.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstage.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstage.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
@@ -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");
     }
 
@@ -140,6 +157,8 @@
 			
     	case MWsDrawAnnotationObserver::EWsObjectInterfaceId:
     	    return static_cast<MWsDrawAnnotationObserver*>(this);
+        case KAlfSynchronizationInterfaceUid:
+            return static_cast<MAlfSynchronizationInterface*>(this);
     	default:
     	    return CWsRenderStage::ResolveObjectInterface(aTypeId);
 		}
@@ -164,6 +183,22 @@
 	}
 
 // ---------------------------------------------------------------------------
+// Synchronize
+// ---------------------------------------------------------------------------
+//
+TInt CAlfRenderStage::Synchronize(TInt& aId)
+    {
+    if ( iAlfSendBuffer )
+        {
+        ++iSyncId;
+        aId = iSyncId;
+        iAlfSendBuffer->Synchronize(iSyncId);
+        return KErrNone;
+        }
+    return KErrGeneral;
+    }
+
+// ---------------------------------------------------------------------------
 // End
 // ---------------------------------------------------------------------------
 //
@@ -330,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 );
     }
 
@@ -420,7 +484,8 @@
             if( iScreenNumber == 0 )
 		        {          
                 if ( secureId != 0x10207218 && // Capserver / AKA goom
-                     secureId != 0x10204c27 )  // Policy server 
+                     secureId != 0x10204c27 && // Policy server
+                     secureId != 0x2000f85a )  // IAD application updater
                     {
                     // Todo: Must actually check whether the configuration uses goom
                     // would create drastic performance hit in a system that does not need
@@ -525,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 ); 
     }
 
 // ---------------------------------------------------------------------------
@@ -565,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 ); 
     }
 
 // ---------------------------------------------------------------------------
@@ -582,6 +654,8 @@
 
 	iAlfSendBuffer->CommitL();
     __ALFLOGSTRING("CAlfRenderStage::NodeActivated <<");
+   
+    AMT_INC_COUNTER_IF(nodeType==MWsWindowTreeNode::EWinTreeNodeClient, iRsWindowNodeActivatedCount ); 
     }
 
 // ---------------------------------------------------------------------------
@@ -618,6 +692,9 @@
             );    
         }
 	iAlfSendBuffer->CommitL();
+
+    AMT_INC_COUNTER( iRsNodeExtentChangedCount );
+    AMT_SET_VALUE( iRsLatestNodeExtentRect, aRect );
     }
 
 // ---------------------------------------------------------------------------
@@ -650,6 +727,8 @@
             aNewValue,
             &aWindowTreeNode   );
 	iAlfSendBuffer->CommitL();
+
+    AMT_INC_COUNTER( iRsTotalNodeFlagChangedCount );
     }
 
 // ---------------------------------------------------------------------------
@@ -712,7 +791,9 @@
                 }
             }
         iAlfSendBuffer->CommitL();
-        } 
+        
+        AMT_INC_COUNTER( iRsTotalNodeAttributeChangedCount );
+        }    
     }
 
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstagefactory.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstagefactory.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstageplugin.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/src/alfrenderstageplugin.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/src/alfrsgc.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/src/alfrsgc.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
--- a/uiacceltk/hitchcock/AlfRenderStage/src/alfrssendbuffer.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/AlfRenderStage/src/alfrssendbuffer.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
@@ -862,6 +862,19 @@
     }
 
 // ---------------------------------------------------------------------------
+// Synchronize
+// ---------------------------------------------------------------------------
+//
+void CAlfRsSendBuffer::Synchronize(TInt aId)
+    {
+    if ( iAlfBridgerClient )
+        {
+        TIpcArgs args(aId);
+        iAlfBridgerClient->SendSynch(EAlfSynchronize, args); // error ignored
+        }
+    }
+
+// ---------------------------------------------------------------------------
 // ConnectL
 // ---------------------------------------------------------------------------
 //
--- a/uiacceltk/hitchcock/Client/BWINS/alfclientu.DEF	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/Client/BWINS/alfclientu.DEF	Fri Mar 19 09:43:21 2010 +0200
@@ -1105,4 +1105,7 @@
 	?EnableLowMemoryState@RAlfDirectClient@@QAEXH@Z @ 1104 NONAME ; void RAlfDirectClient::EnableLowMemoryState(int)
 	?SetGroupEffectL@CAlfVisual@@QAEXABVTDesC16@@H@Z @ 1105 NONAME ; void CAlfVisual::SetGroupEffectL(class TDesC16 const &, int)
 	?ForceSwRendering@RAlfDirectClient@@QAEHH@Z @ 1106 NONAME ; int RAlfDirectClient::ForceSwRendering(int)
+	?Finish@CAlfDrawer@@QAEHXZ @ 1107 NONAME ; int CAlfDrawer::Finish(void)
+	??1CAlfDrawer@@UAE@XZ @ 1108 NONAME ; CAlfDrawer::~CAlfDrawer(void)
+	?NewL@CAlfDrawer@@SAPAV1@XZ @ 1109 NONAME ; class CAlfDrawer * CAlfDrawer::NewL(void)
 
--- a/uiacceltk/hitchcock/Client/eabi/alfclientu.DEF	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/Client/eabi/alfclientu.DEF	Fri Mar 19 09:43:21 2010 +0200
@@ -1338,4 +1338,9 @@
 	_ZN16RAlfDirectClient20EnableLowMemoryStateEi @ 1337 NONAME
 	_ZN10CAlfVisual15SetGroupEffectLERK7TDesC16i @ 1338 NONAME
 	_ZN16RAlfDirectClient16ForceSwRenderingEi @ 1339 NONAME
+	_ZN10CAlfDrawer4NewLEv @ 1340 NONAME
+	_ZN10CAlfDrawer6FinishEv @ 1341 NONAME
+	_ZN10CAlfDrawerD0Ev @ 1342 NONAME
+	_ZN10CAlfDrawerD1Ev @ 1343 NONAME
+	_ZN10CAlfDrawerD2Ev @ 1344 NONAME
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/Client/inc/alfcrppluginclient.h	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*/
+
+#ifndef ALFCRPPLUGINCLIENT_H
+#define ALFCRPPLUGINCLIENT_H
+
+#include <e32base.h>
+#include <w32std.h>
+
+/**
+ * Client for ALF window server extension
+ */
+NONSHARABLE_CLASS( CAlfCrpPluginClient ) : public CWsGraphic
+    {
+public:
+    /**
+     * Constructor.
+     */
+    CAlfCrpPluginClient();
+    
+    /**
+     * 2nd phase constructor.
+     */
+    void ConstructL();
+    
+    /**
+     * Destructor.
+     */
+    virtual ~CAlfCrpPluginClient();
+    
+public:
+    
+    /**
+     * Synchronizes drawing.
+     */
+    void Synchronize();
+
+public: // from CWsGraphic
+    
+    virtual void HandleMessage(const TDesC8& aData);
+    virtual void OnReplace();
+        
+    };
+
+#endif // ALFCRPPLUGINCLIENT_H
+
+// End of file
--- a/uiacceltk/hitchcock/Client/src/alfclient.mmp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/Client/src/alfclient.mmp	Fri Mar 19 09:43:21 2010 +0200
@@ -105,6 +105,10 @@
 SOURCE                  alfcanvasvisual.cpp 
 SOURCE                  alfclientwindow.cpp
 SOURCE                  alfdirectclient.cpp
+
+SOURCE                  alfdrawer.cpp
+SOURCE                  alfcrppluginclient.cpp
+
 USERINCLUDE             ../inc
 USERINCLUDE             ../../CommonInc
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/Client/src/alfcrppluginclient.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   ALF window server client extension implementation.
+*
+*/
+
+#include "alfcrppluginclient.h"
+
+// --------------------------------------------------------------------------
+// CAlfCrpPluginClient::CAlfCrpPluginClient
+// --------------------------------------------------------------------------
+//
+CAlfCrpPluginClient::CAlfCrpPluginClient()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CAlfCrpPluginClient::~CAlfCrpPluginClient
+// --------------------------------------------------------------------------
+//
+CAlfCrpPluginClient::~CAlfCrpPluginClient()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CAlfCrpPluginClient::ConstructL
+// --------------------------------------------------------------------------
+//
+void CAlfCrpPluginClient::ConstructL()
+    {
+    const TUid id = { 0x2002C358 };
+    BaseConstructL( id, KNullDesC8 );
+    }    
+
+// --------------------------------------------------------------------------
+// CAlfCrpPluginClient::Synchronize
+// --------------------------------------------------------------------------
+//    
+void CAlfCrpPluginClient::Synchronize()
+    {
+    TPckgC<TInt> buf(0);
+    SendMessage(buf);
+    Flush();
+    }
+
+// --------------------------------------------------------------------------
+// CAlfCrpPluginClient::HandleMessage
+// --------------------------------------------------------------------------
+//    
+void CAlfCrpPluginClient::HandleMessage(const TDesC8& /*aData*/)
+    {
+    }
+    
+// --------------------------------------------------------------------------
+// CAlfCrpPluginClient::OnReplace
+// --------------------------------------------------------------------------
+//    
+void CAlfCrpPluginClient::OnReplace()
+    {
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/Client/src/alfdrawer.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CAlfDrawer implementation.
+*
+*/
+
+
+
+
+#include <alf/alfdrawer.h>
+#include "alfcrppluginclient.h"
+
+#include <coemain.h>
+#include <w32std.h>
+
+// Class to hold internal alf drawer data.
+NONSHARABLE_CLASS( CAlfDrawer::TAlfDrawerData )
+    {
+public:
+    TAlfDrawerData();
+        
+public:
+    CAlfCrpPluginClient* iClient;
+    };
+
+// Creates CAlfCrpPluginClient instance, returns error code.
+static TInt CreateAlfCrpClient(CAlfCrpPluginClient*& aClient);
+// Creates CAlfCrpPluginClient instance.
+static CAlfCrpPluginClient* CreateAlfCrpClientL();
+
+
+// ---------------------------------------------------------------------------
+// NewL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CAlfDrawer* CAlfDrawer::NewL()
+    {
+    CAlfDrawer* self = new (ELeave) CAlfDrawer;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );    
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CAlfDrawer::~CAlfDrawer()
+    {
+    if ( iData )
+        {
+        delete iData->iClient;
+        delete iData;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Finish
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CAlfDrawer::Finish()
+    {
+    // First perform RWsSession finish operation to ensure
+    // that all drawing commands have been issued to renderstage.
+    TInt err = CCoeEnv::Static()->WsSession().Finish();
+
+    // Then create CRP instance (if needed).
+    if ( err == KErrNone && !iData->iClient ) 
+        {
+        err = CreateAlfCrpClient( iData->iClient );
+        }
+
+    // Finally, wait until alf side has finished rendering.
+    if ( err == KErrNone && iData->iClient )
+        {
+        iData->iClient->Synchronize();
+        }
+        
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CAlfDrawer::CAlfDrawer()
+    {
+    }
+    
+// ---------------------------------------------------------------------------
+// ConstructL
+// ---------------------------------------------------------------------------
+//
+void CAlfDrawer::ConstructL()
+    {
+    iData = new (ELeave) TAlfDrawerData;
+    CreateAlfCrpClient( iData->iClient );
+    }
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CAlfDrawer::TAlfDrawerData::TAlfDrawerData()
+    : iClient( NULL )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CreateAlfCrpClient
+// ---------------------------------------------------------------------------
+//
+static TInt CreateAlfCrpClient(CAlfCrpPluginClient*& aClient)
+    {
+    TRAPD(err, aClient = CreateAlfCrpClientL());
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// CreateAlfCrpClientL
+// ---------------------------------------------------------------------------
+//
+static CAlfCrpPluginClient* CreateAlfCrpClientL()
+    {
+    CAlfCrpPluginClient* client = new (ELeave) CAlfCrpPluginClient;
+    CleanupStack::PushL( client );
+    client->ConstructL();
+    CleanupStack::Pop( client );
+    return client;
+    }
+
--- a/uiacceltk/hitchcock/Client/src/alfenv.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/Client/src/alfenv.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -953,6 +953,11 @@
 //   
 EXPORT_C void CAlfEnv::SetRefreshMode( TAlfRefreshMode aMode )
     {
+    if(aMode == EAlfRefreshModeAutomatic)
+        {
+        // syncronoushly rasterize all the changed text visuals
+        iData->iTextStyleManager->RefreshAllVisuals();
+        }
     Client().EnvSetRefreshMode( aMode );
     iData->iRefreshMode = TAlfRefreshMode(aMode);
     }
--- a/uiacceltk/hitchcock/Client/src/alfmappingfunctions.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/Client/src/alfmappingfunctions.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -663,7 +663,7 @@
     if (!inverted)
         {
         // Find closest pre-calculated value...
-        for (i=0; i<KAlfTableMappingNumberOfMappedValues;i++)
+        for (i=0; i<KAlfTableMappingNumberOfMappedValues-1;i++)
             {
             if ((!inverted && aValue < iData->iParams.iValues[i]) ||
                 inverted && (aValue > iData->iParams.iValues[i]))
--- a/uiacceltk/hitchcock/Client/src/alftextstylemanager.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/Client/src/alftextstylemanager.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -116,6 +116,11 @@
 
     void DoRefreshMesh()
         {
+        if( IsActive() )
+            {
+            Cancel();
+            }
+        
         for (TInt p = iVisuals.Count()-1; p >= 0; p--)
             {
             iVisuals[p]->PrepareForUpdateMesh();
@@ -337,7 +342,7 @@
 #ifdef ALF_RASTER_TEXT
     for(TInt i = 0 ; i < iData->iTextStyles.Count() ; i++ )
         {
-        iData->iTextStyles[i]->RefreshMesh();
+        iData->iTextStyles[i]->DoRefreshMesh();
         }
 #else
     return;
--- a/uiacceltk/hitchcock/Client/src/alftexturegroup.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/Client/src/alftexturegroup.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -109,23 +109,24 @@
 // ---------------------------------------------------------------------------
 //
 EXPORT_C CAlfTextureGroup::~CAlfTextureGroup()
-	{
-    while (Count())
+    {
+    if ( iData )
         {
-        RemoveTexture(Texture(Count()-1));
-        }
+        while (Count())
+            {
+            RemoveTexture(Texture(Count()-1));
+            }
+    
+        iData->iLoadObserverQueue.Close();	
+	iData->iTextures.Close();		    
+	    
+	delete iData->iTextureLoadObserver;
+	iData->iTextureLoadObserver = NULL;
+	}	
 
-	if ( iData )
-	    {
-	    iData->iLoadObserverQueue.Close();	
-	    iData->iTextures.Close();		    
-	    
-	    delete iData->iTextureLoadObserver;
-	    iData->iTextureLoadObserver = NULL;
-	    }	
+    delete iData;
+    }
 
-	delete iData;
-	}
 // ---------------------------------------------------------------------------
 // NewL
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/Client/src/alftextvisual.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/Client/src/alftextvisual.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -416,10 +416,12 @@
 
 void CAlfTextVisual::PrepareForUpdateMesh()
     {
+#ifdef ALF_RASTER_TEXT
     if(!iTextVisualData->iMeshUptoDate)
         {
         iTextVisualData->iMesh->PrepareForRasterize();
         }
+#endif // ALF_RASTER_TEXT    
     }
 
 void CAlfTextVisual::UpdateMesh(TBool aSynch)
@@ -458,6 +460,7 @@
     {
 #ifdef ALF_RASTER_TEXT
     iTextVisualData->iMesh->ResetLines(ETrue);
+    iTextVisualData->iMeshUptoDate = EFalse;
 #endif
     }
 	
--- a/uiacceltk/hitchcock/CommonInc/alfbridgecommands.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/CommonInc/alfbridgecommands.h	Fri Mar 19 09:43:21 2010 +0200
@@ -73,15 +73,14 @@
     EAlfEffectFxEndSyncronizedGroup,
     EAlfDSSetCapturingBitmap,
     EAlfDSSetCoveringBitmap,
+    
+    //140
     EAlfDSSetFadeEffect,
     EAlfReleaseTemporaryChunk,
-
-    // 140
     EAlfBridgeSetScreenRotation,
+    EAlfDSSynchronize,
 
     KUnInitialized
-    
-    
     };
 
 #endif /* ALFBRIDGECOMMANDS_H_ */
--- a/uiacceltk/hitchcock/CommonInc/alflogger.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/CommonInc/alflogger.h	Fri Mar 19 09:43:21 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletest.h	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,240 @@
+#include "e32base.h"
+#include "e32debug.h"
+
+#ifndef ALFMODULETEST_H
+#define ALFMODULETEST_H
+
+// Define this to build module testing enchanced version of 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())
+// or
+// #define AMT_CONTROL() iMyModuleTestDataControl
+// etc.
+#endif
+
+#else
+
+
+//  *** Use these macros to access global memory chunk
+
+
+// Note: If you read/write a large block of data members, it is advisable not use the AMT_FUNC_EXC() based macros below. 
+//       Use Lock() and Unlock() around the block explicitely, and use AMT_FUNC() macro.
+//       That is to avoid unnecessary nested lock-unlock sequences (even if nested locks are working ok).
+
+// Note: Be careful not to lock the the mutex for a long time as it will halt other processes if they are using the lock during that time!
+
+// Generic macros
+#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++)
+#define AMT_DEC_COUNTER(member)     AMT_FUNC_EXC(AMT_DATA()->member--)
+#define AMT_SET_VALUE(member, val)  AMT_FUNC_EXC(AMT_DATA()->member=(val))
+#define AMT_GET_VALUE(x, member)    AMT_FUNC_EXC((x) = AMT_DATA()->member)
+#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");
+
+/*
+ *  Class CAlfModuleTestData
+ */
+
+NONSHARABLE_CLASS(CAlfModuleTestData) : public CBase
+    {
+public:
+    void PrintState()
+        {
+        RDebug::Print(_L("*** ALF INTERNAL STATE ***"));
+        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 ***"));
+        }
+    
+    
+public:
+    TBool iIsEnabled;           // *** not yet implemented. For run-time enabling/disabling of the test system.  
+    
+    // Alf Render Stage
+    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;
+    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;
+    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;
+    };
+
+
+/*
+ *  Class CAlfModuleTestDataControl
+ */
+NONSHARABLE_CLASS(CAlfModuleTestDataControl) : public CBase
+    {
+public:
+    /*
+     * Destructor
+     */
+    ~CAlfModuleTestDataControl()
+        {
+        iModuleTestMutex.Close();
+        iModuleTestChunk.Close();
+        }
+
+    /*
+     * Open global chunk and mutex created elsewhere
+     */
+    TInt OpenGlobalObjects()
+        {
+        RDebug::Print(_L("CAlfModuleTestDataControl::OpenGlobalObjects()."));
+        // Open global module testing chunk
+        TBool isReadOnly = EFalse;
+        TInt err = iModuleTestChunk.OpenGlobal(KAlfModuleTestChunkName, isReadOnly);
+        if (!err)
+            {
+            // Create global module testing mutex
+            err = iModuleTestMutex.OpenGlobal(KAlfModuleTestMutexName);
+            if (!err)
+                {
+                iModuleTestData = reinterpret_cast<CAlfModuleTestData*>(iModuleTestChunk.Base());
+                }
+            }
+        RDebug::Print(_L("CAlfModuleTestDataControl::OpenGlobalObjects. ret=%d"), err);
+        return err;
+        }
+
+    /*
+     * Lock access to global memory
+     */
+    void Lock() {iModuleTestMutex.Wait();}
+ 
+    /*
+     * Unlock access to global memory
+     */
+    void Unlock() {iModuleTestMutex.Signal();}
+    
+public:
+    RChunk iModuleTestChunk;
+    RMutex iModuleTestMutex;
+    CAlfModuleTestData* iModuleTestData; // Not owned
+    };
+
+#endif
+
+#endif // ALFMODULETEST_H
+
+// End of File
--- a/uiacceltk/hitchcock/CommonInc/alfrenderstageutils.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/CommonInc/alfrenderstageutils.h	Fri Mar 19 09:43:21 2010 +0200
@@ -18,6 +18,10 @@
 #ifndef _ALFRSUAPI_H_
 #define _ALFRSUAPI_H_
 
+#include <e32std.h>
+
+class MWsWindowTreeNode;
+
 const TInt KAlfCompositionAgnosticWindowTreeObserverInterfaceId(0x2002BCFB);
     
 class MAlfCompositionAgnosticWindowTreeObserver
@@ -78,7 +82,7 @@
     virtual void MovedToWindowGroup(const MWsWindowTreeNode& aWindowTreeNode, const MWsWindowTreeNode& aNewWindowGroupNode) = 0;
     virtual void WindowGroupChained(const MWsWindowTreeNode& aParent, const MWsWindowTreeNode& aChild) = 0;
     virtual void WindowGroupChainBrokenAfter(const MWsWindowTreeNode& aWindowGroupNode) = 0;
-    virtual void FadeAllChildren(const MWsWindowTreeNode& aWindowTreeNode, TBool aFaded) = 0;
+    virtual void FadeAllChildren(const MWsWindowTreeNode& aWindowTreeNode, TBool aFaded) = 0;    
     };
 
 class RAlfBridgerClient;
@@ -99,4 +103,34 @@
     virtual RAlfBridgerClient* Client() = 0;
     };
 
+/**
+ * Synchronization interface
+ */
+class MAlfSynchronizationInterface
+    {
+public:
+    /**
+     * Start synchronization. 
+     * @param aId This will contain identifier for this synchronization.
+     * @return error code, KErrNone if synchronization is started.
+     */
+    virtual TInt Synchronize(TInt& aId) = 0;
+    };
+
+/**
+ * Use this UID as parameter when resolving MAlfSynchronizationInterface 
+ * interface.
+ */
+const TUint32 KAlfSynchronizationInterfaceUid = 0x2002C357;
+
+/**
+ * Category for P&S variable for synchronization finished indication.
+ */
+const TUid KAlfPSUidSynchronizer = { 0x10003B20 };
+
+/**
+ * Key for P&S variable for synchronization finished indication.
+ */
+const TUint32 KAlfPSKeySynchronizer = 0x2002C357;
+
 #endif // _ALFRSUAPI_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/CommonInc/huisynchronizationobserver.h	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,36 @@
+/*
+* 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:   
+*
+*/
+
+#ifndef HUISYNCHRONIZATIONOBSERVER_H
+#define HUISYNCHRONIZATIONOBSERVER_H
+
+#include <e32std.h>
+
+/**
+ * Synchronization observer interface
+ */
+class MHuiSynchronizationObserver
+    {
+public:
+    /**
+     * Informs of completion of synchronization. 
+     * @param aId Id of completed synchronization.
+     */
+    virtual void Synchronized(TInt aId) = 0;
+    };
+
+#endif // HUISYNCHRONIZATIONOBSERVER_H
--- a/uiacceltk/hitchcock/CommonInc/huiwscanvascommands.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/CommonInc/huiwscanvascommands.h	Fri Mar 19 09:43:21 2010 +0200
@@ -170,4 +170,7 @@
         EAlfTransparentContentFlush = 0x02
         };
 
+// drawing commands for the window should be ignored 
+#define KWindowIsDSAHost 2
+
 #endif /* HUIWSCANVASCOMMANDS_H_ */
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfbridge.h	Fri Mar 19 09:43:21 2010 +0200
@@ -22,6 +22,9 @@
 
 #include <e32hashtab.h>
 
+#define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
+#include "alfmoduletest.h" 
+
 #include "alfscreen.h"
 #include "alfstreamerbridge.h"
 #include "alfdecoderserverclient.h"
@@ -29,6 +32,7 @@
 #include <alf/alfconstants.h>
 
 #include "HuiFxEffect.h"
+#include "huisynchronizationobserver.h"
 #include <alf/AlfTransEffectPlugin.h>
 #include <uiacceltk/HuiDisplay.h>
 
@@ -36,7 +40,10 @@
 class CAlfCommandDebug;
 class CAlfLayoutSwitchEffectCoordinator;
 class RMemReadStream;
-
+class CHuiCanvasVisual;
+class CFullScreenEffectState;
+class CControlEffectState;
+    
 const TInt KAlfBridgeRegionGranularity = 10;
 
 NONSHARABLE_CLASS(CAlfBridge): 
@@ -45,7 +52,7 @@
     public MHuiDisplayRefreshObserver, 
     public MHuiBitmapProvider,
     public MAlfGfxEffectObserver,
-    public MHuiRosterObserver
+    public MHuiSynchronizationObserver
     {
 	// Helper class for keeping ongoing effects in order. Kept in iEffectCleanupStack
     private:
@@ -187,7 +194,6 @@
     void HandleGfxStopEvent( TBool aClientRequest );
     
     void EnableSwRenderingL(TBool aEnable = ETrue);
-    void UploadSwRenderingTargetL( CAlfScreen* aScreen );
     TBool PrepareSwRenderingTarget( CAlfScreen* aScreen );
 
     /**
@@ -219,16 +225,29 @@
      * Cancels all effects due to low memory.
      */
     void LowMemoryCancelAllEffects();
+
+    /**
+      * Sets HuiControlGroup as Alf application window group
+      */
+    void SetWindowGroupAsAlfApp(TInt aId);
     
-    // From MHuiRosterObserver
-    void NotifyRosterDrawStart(CHuiDisplay& aDisplay);
-    void NotifyRosterDrawEnd(CHuiDisplay& aDisplay);
+    // 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 );
     
@@ -281,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
 	*
@@ -384,10 +420,26 @@
      */
     CHuiLayout* FindLayoutByEffectHandle(TInt aHandle);
     
-    /*
+    /**
      * HasActiveEffect
+	 *
+	 *	Note. The visual might not have effect, but it is child for visual that has effect. 
+	 *	In both cases, this method returns ETrue. Otherwise EFalse.
+	 *
+	 *	@param	aVisual	Visual to be checked for effect participation.
      */
     TBool HasActiveEffect(CHuiVisual* aVisual);
+
+    /**
+     * HasActiveEffect
+	 *
+	 *	Note. The visual might not have effect, but it is child for visual that has effect. 
+	 *	In both cases, this method returns ETrue. Otherwise EFalse.
+	 *
+	 *	@param	aVisual	Visual to be checked for effect participation.
+	 *	@param  aIndex	Index of the effect item in iEffectCleanupStack, if found. Otherwise KErrNotFound
+     */    
+    TBool HasActiveEffect(CHuiVisual* aVisual, TInt& aIndex);
     
    /*
 	*	FindEffectHandle
@@ -627,6 +679,7 @@
             CHuiControlGroup& aGroup);
     
     void VisualizeControlGroupOrderL(
+            CAlfScreen& aScreen,
             CHuiRoster& aRoster, 
             CHuiControlGroup& aGroup);
     
@@ -638,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 )
     {
@@ -715,84 +769,11 @@
     // with visuals in iFullscreenEffectControlGroup
     RArray<TEffectCleanupStruct> iEffectCleanupStack;
     
-    // Effects that have finished by their own, or framework requested to end them
-    RArray<TInt> iFinishedEffects;
-    
     // Same as iEffectCleanupStack, but only the ones that can be now cleaned away.
     // 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.
@@ -846,6 +827,7 @@
         };
     
     RHashMap<TUint32,THashVisualStruct> iWindowHashArray;
+    CHuiControl* iOrphanStorage; // owned. holds the visuals which are orphaned from their control group
     class TRegisteredEffectsStruct
         {
     public:
@@ -896,6 +878,15 @@
     TBool iForcedSwRendering;
     TBool iLowMemoryMode;
     THuiMemoryLevel iCurrentMemoryLevel;
+    
+    #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    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 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfhierarchymodel.h	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfnodes.h	Fri Mar 19 09:43:21 2010 +0200
@@ -104,7 +104,7 @@
     
     void SetFirstSprite();
     
-    CAlfNode* OrphonMe();
+    CAlfNode* OrphanMe();
     
     CAlfNode* FindPreviousChild();
     
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfscreen.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfscreen.h	Fri Mar 19 09:43:21 2010 +0200
@@ -42,6 +42,9 @@
 
     /** Group for showing effects */
     EAlfFullScreenEffectContainer,
+    
+    /** Group for FPS indicator */
+    EAlfFpsIndicatorContainer
     };
 
 NONSHARABLE_CLASS( TAlfControlGroupEntry )  
@@ -107,6 +110,11 @@
          */
         TBool IsVisualTreeVisibilityChanged();
 
+        /**
+         * Returns amount of fixed control groups.
+         */
+        TInt FixedControlGroupCount() const;
+        
 	public:
 	        	   
 	    RArray<TAlfControlGroupEntry> iControlGroups;
@@ -115,6 +123,7 @@
 	   	CHuiDisplay* iDisplay; 
 	    CHuiControlGroup* iFloatingSpriteControlGroup; 
 	    CHuiControlGroup* iFullscreenEffectControlGroup; 
+	    CHuiControlGroup* iFpsControlGroup;
 	    
 	    TBool iVisualTreeVisibilityChanged;
 	    TInt iScreenNum;
--- a/uiacceltk/hitchcock/ServerCore/Inc/alfstreamerconsts.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Inc/alfstreamerconsts.h	Fri Mar 19 09:43:21 2010 +0200
@@ -37,7 +37,8 @@
     EDsNotifyNativeWindowData,
     EAlfBridgerBlindSend,
     EAlfSetScreenRotation, 
-    EAlfGetNativeWindowHandles
+    EAlfGetNativeWindowHandles,
+    EAlfSynchronize
     };
 
 enum TAlfCompOps{
--- a/uiacceltk/hitchcock/ServerCore/Src/alfappservercore.mmp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappservercore.mmp	Fri Mar 19 09:43:21 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/alfappsrvsessionBase.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappsrvsessionBase.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -940,16 +940,18 @@
 // 
 void CAlfAppSrvSessionBase::GetSystemEvents(const RMessage2* aMessage)
     {
-    if (aMessage && iData->iSystemEvent.IsNull())
+    __ASSERT_DEBUG(aMessage, USER_INVARIANT());
+    if (aMessage)
         {
-        iData->iSystemEvent = *aMessage;
+        if (iData->iSystemEvent.IsNull())
+            {
+            iData->iSystemEvent = *aMessage;
+            }
+        else 
+            {
+            aMessage->Complete(KErrInUse);
+            }
         }
-    else 
-        {
-	    __ASSERT_DEBUG(aMessage, USER_INVARIANT());
-        aMessage->Complete(KErrInUse);
-        }
-        
     }
 
 // ---------------------------------------------------------------------------
--- a/uiacceltk/hitchcock/ServerCore/Src/alfappui.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfappui.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -665,6 +665,11 @@
 //
 EXPORT_C CAlfAppUi::~CAlfAppUi()
     {
+    #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    delete AMT_CONTROL();
+    Dll::FreeTls();
+    #endif
+    
     delete iData;
     }
   
@@ -763,6 +768,13 @@
 EXPORT_C void CAlfAppUi::ConstructL()
     {
     __ALFLOGSTRING( "CAlfAppUi::ConstructL start" )
+    
+    #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
+      
     TInt flags = EStandardApp|ENoScreenFurniture|ENonStandardResourceFile|EAknEnableSkin;
     CCoeEnv* coe = CCoeEnv::Static();
     iData =  new (ELeave) CAlfAppUiData();
@@ -903,6 +915,10 @@
 	// Load Tfx server client API plugin, if exists
 	iData->iServer->CreateTfxServerPlugin();
     
+#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+    iData->iBridgeObj->ForceSwRendering(ETrue);
+#endif
+
     __ALFLOGSTRING( "CAlfAppUi::ConstructL end" )
     }
     
@@ -1442,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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Fri Mar 19 09:43:21 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,6 +68,8 @@
 #include "HuiRenderPlugin.h"
 #include "huicanvasgc.h"
 #include "huicanvasrenderbuffer.h"
+#include "alfeffectutils.h"
+#include "alfrenderstageutils.h" // for KAlfPSUidSynchronizer & KAlfPSKeySynchronizer
 
 #ifdef HUI_DEBUG_TRACK_DRAWING
 #include <alfcommanddebug.h>
@@ -88,468 +89,14 @@
 //const TReal32 KAlfVisualDefaultOpacity = 0.5f;
 
 _LIT8(KAlfWindowGroupContainerControlTag, "WGROUP");
-const TInt KAlfNumberOfFixedControlGroups = 2;
-
-// 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 ========
@@ -591,6 +138,7 @@
 // 
 CAlfBridge::~CAlfBridge()
 	{
+	delete iOrphanStorage;
 	delete iFadeEffectFile;
 	iWindowHashArray.Close();
 	for( TInt i = 0; i< iAlfRegisteredEffects.Count(); i++ )
@@ -598,7 +146,6 @@
 	    delete iAlfRegisteredEffects[i].iEffectFile;
 	    }
 	iAlfRegisteredEffects.Close();
-    iFinishedEffects.Close();
     delete iEffectEndTimer;
     iDeadControlGroups.Close();
     iEffectWindowGroups.Close();
@@ -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();
     }
 
@@ -739,9 +291,14 @@
 	ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFloatingSpriteControlGroup), KHuiRosterShowAtTop, screenNumber); 
 	ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFullscreenEffectControlGroup), KHuiRosterShowAtTop, screenNumber); 
     
-	
 	screen->iFloatingSpriteControlGroup->SetAcceptInput(EFalse);
 	screen->iFullscreenEffectControlGroup->SetAcceptInput(EFalse);
+	
+	if ( screen->iFpsControlGroup )
+	    {
+	    ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFpsControlGroup), KHuiRosterShowAtTop, screenNumber); 
+	    screen->iFpsControlGroup->SetAcceptInput(EFalse);
+	    }
     }
 
 //------------------------------------------------------------------------------
@@ -762,6 +319,12 @@
     
     screen->iFloatingSpriteControlGroup->SetAcceptInput(EFalse);
     screen->iFullscreenEffectControlGroup->SetAcceptInput(EFalse);
+    
+    if ( screen->iFpsControlGroup )
+	    {
+	    ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFpsControlGroup), KHuiRosterShowAtTop, screenNumber); 
+	    screen->iFpsControlGroup->SetAcceptInput(EFalse);
+	    }
     }
 
 
@@ -781,6 +344,8 @@
     iWindowHashArray.Insert( aWindowNodeId, visualStruct );
     iPreviouslySearchedVisualId = aWindowNodeId;
     iPreviouslySearchedVisual = aVisual;
+
+    AMT_INC_COUNTER( iTotalVisualCount );
     }
 
 // ---------------------------------------------------------------------------
@@ -792,6 +357,8 @@
     __ALFFXLOGSTRING1("CAlfBridge::RemoveVisual 0x%x", aWindowNodeId);
     iWindowHashArray.Remove( aWindowNodeId );
     iPreviouslySearchedVisualId = 0;
+    
+    AMT_DEC_COUNTER( iTotalVisualCount );    
     }
     
 // ---------------------------------------------------------------------------
@@ -939,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 )
@@ -949,16 +558,25 @@
             {
             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 
                 // is cleared when effect has finished.
                 RPointerArray<CHuiLayout> familyTree;
                 ListFamilyTreeL(familyTree, layout); // recursively dig the family tree
+                TBool anyVisualHasEffect(EFalse);
+                TInt familyIndex(0);
+                TInt familySize = familyTree.Count();
+                while(familyIndex < familySize && !anyVisualHasEffect)
+                    {
+                    anyVisualHasEffect = HasActiveEffect(familyTree[familyIndex++]);
+                    }
                 
-                if (HasActiveEffect(layout))
+                if (anyVisualHasEffect)
                     {
                     __ALFFXLOGSTRING1("Layout 0x%x has external content", layout);
                     // EHuiVisualFlagShouldDestroy destroy flag should have come for the windows in this layout already
@@ -993,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();
@@ -1003,6 +635,9 @@
                 iHuiEnv->DeleteControlGroup(aWindowGroupNodeId);
                 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group done");
                 }
+            
+            AMT_DEC_COUNTER( iTotalControlGroupCount );            
+            
             break;
             }
         }        
@@ -1079,6 +714,8 @@
 
         if (iAlfScreens[aScreenNumber]->iDisplay)
             ShowControlGroupL(iAlfScreens[aScreenNumber]->iDisplay->Roster(), *group, KHuiRosterShowAtTop, aScreenNumber); 
+        
+        AMT_INC_COUNTER( iTotalControlGroupCount );
         }
     
 
@@ -1120,7 +757,7 @@
             // has been solved by deleting the tag when window server wants to delete
             // the group. Window server no longer has it, but we keep it alive for a while
             // to show the effect. The group will be deleted when the effect ends.
-            aWhere = aRoster.Count() - KAlfNumberOfFixedControlGroups;
+            aWhere = aRoster.Count() - screen->FixedControlGroupCount();
             }
         }
 
@@ -1146,7 +783,7 @@
 #endif
 
 #ifdef ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
-        VisualizeControlGroupOrderL(aRoster, aGroup);
+        VisualizeControlGroupOrderL(*screen, aRoster, aGroup);
 #endif
     
     }
@@ -1240,18 +877,30 @@
     else if (aWhere == KHuiRosterShowAtTop)
         {
         // Topmost
-        aRoster.ShowL(aGroup, aRoster.Count() - KAlfNumberOfFixedControlGroups);
+        aRoster.ShowL(aGroup, aRoster.Count() - screen->FixedControlGroupCount());
         }
     else
         {
         TInt index = 0; // Index for Window group control groups
         TBool added = EFalse;
-        for (TInt i=0; i<aRoster.Count() - KAlfNumberOfFixedControlGroups; i++)
+        for (TInt i=0; i<aRoster.Count() - screen->FixedControlGroupCount(); i++)
             {
             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;
                 }
 
@@ -1266,7 +915,7 @@
         if (!added)
             {
             // Topmost
-            for (TInt i=aRoster.Count()-KAlfNumberOfFixedControlGroups; i >= 0; i--)
+            for (TInt i=aRoster.Count() - screen->FixedControlGroupCount(); i >= 0; i--)
                 {
                 if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer)
                     {
@@ -1455,10 +1104,25 @@
     }
 
 // ---------------------------------------------------------------------------
+// Check if effect has been flagged as opaque
+// ---------------------------------------------------------------------------
+// 
+static TBool IsOpaqueEffect(CHuiFxEffect* aEffect)
+    {
+    return aEffect && (aEffect->EffectFlags() & KHuiFxOpaqueHint);
+    }
+
+// ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // 
 TBool CAlfBridge::IsVisualOpaque(CHuiVisual& aVisual)
     {
+    // Effect with opaque hint overrides everything else.
+    if (IsOpaqueEffect( aVisual.Effect() ))
+        {
+        return ETrue; // Opaque
+        }    
+
     TBool transparent = EFalse;
     
     // TODO: We should check transformation too and perhaps parent transformations as well ?
@@ -1592,16 +1256,44 @@
     //iActiveVisualCount = 0;
     iBgSurfaceFound = EFalse;
     //iPaintedArea = 0;  
+    
+    // Check if effect group has an effect with opaque hint.
+    CHuiControlGroup& fxcontrolgroup = *(iAlfScreens[aScreenNumber]->iFullscreenEffectControlGroup);
+    CHuiControl& fxcontrol = fxcontrolgroup.Control(0);
+    CHuiCanvasVisual* fxlayout = (CHuiCanvasVisual*)&fxcontrol.Visual(0);
+    CHuiVisual* fxExternalContent = fxlayout->ExternalContent();
+    
+    if (fxlayout && IsOpaqueEffect(fxlayout->Effect()))
+        {
+        fullscreenCovered = ETrue;    
+        }
+    else if (fxExternalContent && IsOpaqueEffect(fxExternalContent->Effect()))
+        {
+        fullscreenCovered = ETrue;
+        }    
+    
+    #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+    iTempTotalActiveVisualCount = 0;
+    iTempTotalPassiveVisualCount = 0;
+    #endif
+	
     // skip the topmost (effect) layer, start from floating sprite group
-    for (TInt j=screen->iDisplay->Roster().Count() - 2; j>=0; j--)
+    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);
         CHuiControl& control = controlgroup.Control(0);
+
+        if (control.Role() == EAlfFpsIndicatorContainer)
+            {
+            // FPS container doesn't contain canvas visuals
+            continue;
+            }
+
         CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
 #ifdef HUI_DEBUG_TRACK_DRAWING	
         if ( layout->Tracking() )
@@ -1609,7 +1301,7 @@
             RDebug::Print(_L("CAlfBridge::HandleVisualVisibility: tracked visual 0x%x"), canvasVisual);
             }
 #endif            
-
+            
         // Dont mess with alf control group visuals, alf session handling does it for us
         // just add the rect to covered region because alf draws solid background.
         if (control.Role() == EAlfSessionContainer)
@@ -1641,6 +1333,12 @@
         TBool subTreeCovered = EFalse;
         TBool hasActiveVisualsInVisualTree = HandleLayoutVisualVisibility( layout, controlgroup, control, fullscreenCovered, fullscreen, screen, subTreeCovered, IsVisualOpaque(*layout)  );    
         TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
+
+        // If root visuals effect is marked as opaque, then add whole screen area as covered.
+        if (!fullscreenCovered)
+            {
+            fullscreenCovered = IsOpaqueEffect(layout->Effect());
+            }                    
         
 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
 		// flagged as containing fade effect, then run the setup as well so that effects which
@@ -1708,23 +1406,38 @@
     if (fadeEffectInScreen)
         {
         TBool firstFadedWindowGroupFound = EFalse;
-        for (TInt j=0; j<screen->iDisplay->Roster().Count() - 2; j++) // skip the topmost (effect) layer 
+        for (TInt j=0; j<screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j++) // skip the topmost (effect) layer 
             {                
             CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j);
             CHuiControl& control = controlgroup.Control(0);
-            CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0);
+            CHuiVisual* layout = &control.Visual(0);
             if (layout->Effect() && (layout->Effect()->EffectFlags() & KHuiFadeEffectFlag))
                 {
                 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;
                 }
             }
         }
+
+    AMT_FUNC_EXC(AMT_DATA()->iActiveVisualCount = iTempTotalActiveVisualCount;
+                 AMT_DATA()->iPassiveVisualCount = iTempTotalPassiveVisualCount;
+                 AMT_DATA()->PrintState()
+                 );
     }
 
 TBool CAlfBridge::HandleLayoutVisualVisibility(
@@ -1851,9 +1564,13 @@
                 aScreen->iDisplay->SetDirty();
                 }                
             
-    #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
-            passivevisualcount++;
-    #endif
+            #ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
+            iTempTotalPassiveVisualCount++;
+            #endif
+            
+            #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER
+                    passivevisualcount++;
+            #endif
             }
         else
             {
@@ -1902,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
@@ -1946,10 +1667,17 @@
                     iTempRegion.Tidy();                                    
                     }
                 }
+            
+            // If effect is marked as opaque, then add whole visual area as covered.
+            if (IsOpaqueEffect(canvasVisual->Effect()))
+                {
+                iTempRegion.AddRect(visualDisplayRect);
+                iTempRegion.Tidy();
+                }            
             }                                        
-        }
-    
-    visualTreeActive |= visualIsActive; 
+        visualTreeActive |= visualIsActive;
+        } // for loop end : children checking loop
+     
     return visualTreeActive;
     }
 
@@ -1963,17 +1691,18 @@
         return;
             
     CAlfScreen* screen = iAlfScreens[0]; // TODO  
-    for (TInt j=screen->iDisplay->Roster().Count() - 2; j>=0; j--) // skip the topmost (effect) layer 
+    for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--) // skip the topmost (effect) layer 
         {                
         CHuiControlGroup& controlgroup = iAlfScreens[0]->iDisplay->Roster().ControlGroup(j);
         CHuiControl& control = controlgroup.Control(0);
 
-        if ( control.Role() == EAlfSessionContainer )
+        if ( control.Role() == EAlfSessionContainer ||
+             control.Role() == EAlfFpsIndicatorContainer )
             {
             continue;
             }
         
-        CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
+        CHuiVisual* layout = &control.Visual(0);
         for (TInt i=layout->Count()-1; i >= 0; i--)
             {
             CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&layout->Visual(i));
@@ -2046,6 +1775,16 @@
 
         switch (data.iOp)
             {
+            case EAlfDSSynchronize:
+                {
+                TInt id = data.iInt1;
+                if ( iHuiEnv )
+                    {
+                    iHuiEnv->Synchronize( id, this );
+                    }
+                }
+                break;
+                
             case EAlfDSCreateNewDisplay:
                 {
                 AddNewScreenL(NULL);
@@ -2330,6 +2069,10 @@
     
     iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*(iAlfScreens[aScreenNumber]->iFloatingSpriteControlGroup)); 
     iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*(iAlfScreens[aScreenNumber]->iFullscreenEffectControlGroup));
+    if ( iAlfScreens[aScreenNumber]->iFpsControlGroup )
+        {
+        iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*(iAlfScreens[aScreenNumber]->iFpsControlGroup));
+        }
     delete iAlfScreens[aScreenNumber];
     iAlfScreens.Remove( aScreenNumber );
     }
@@ -2464,7 +2207,17 @@
 // 
 void CAlfBridge::DestroyWindow(CHuiVisual* aVisual, TBool aUseForce)
     {
-    if ( !aUseForce && HasActiveEffect(aVisual) )
+    TInt index;
+    TBool visualParticipatingInEffect = HasActiveEffect(aVisual, index);
+    
+    TBool effectIsExitEffect(ETrue);
+    if (index != KErrNotFound)
+        {
+        effectIsExitEffect = iEffectCleanupStack[index].iHideWhenFinished;
+        }
+    // effects inside application may need to destroy window to get the new content visible. 
+    // Even when there is effect on the layout, destruction of a child window must be allowed.
+    if ( !aUseForce && visualParticipatingInEffect && effectIsExitEffect )
         {
         // this visual will be destroyed on the effect call back.
         __ALFFXLOGSTRING1("CAlfBridge::DestroyWindow - not destroying 0x%x", aVisual);
@@ -2488,7 +2241,21 @@
     // check if visual is having an effect at the moment. This could occur, if options menu is exited (with effect) and then 
     // application is exited. EHuiVisualFlagDrawOnlyAsExternalContent is indication that
     // there might be effect on this visual. It is not guaranteen.
-
+    
+    if (!aUseForce)
+        {
+        // we can remove from iEffectCleanupStack only when this method was called from HandleDestroyWindow. Otherwise
+        // messing iEffectCleanupStack is likely to cause forever loop in some RemoveTemporaryPresenterVisuals method
+        for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
+            {
+            TEffectCleanupStruct& effectItem = iEffectCleanupStack[i];
+            if (aVisual == effectItem.iEffectedVisual)
+                {
+                iEffectCleanupStack.Remove(i);
+                break;
+                }
+            }
+        }
     delete aVisual;
     }
 // ---------------------------------------------------------------------------
@@ -2531,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
 			    {
@@ -2594,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 ) );
 	}
 
 // ---------------------------------------------------------------------------
@@ -2622,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 ) );        
 	}
 
 // ---------------------------------------------------------------------------
@@ -2711,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;
@@ -2886,15 +2662,94 @@
 		{
 		__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
 // ---------------------------------------------------------------------------
 // 
 void CAlfBridge::SetWindowActiveL(CHuiVisual* aVisual, TBool aActive)
     {
-    if (!HasActiveEffect(aVisual))
+    TInt effectIndex;
+    if (!HasActiveEffect(aVisual, effectIndex))
         {
         // Does not have effect
         if (aActive)
@@ -2915,7 +2770,15 @@
         if (aActive)
             {
 			// this prevents windows appearing before their "effected" time
-            aVisual->SetFlag(EHuiVisualFlagShouldBeShown);
+            if (!iEffectCleanupStack[effectIndex].iHideWhenFinished)
+                {
+                // this is appear effect. Lets show it
+                aVisual->iOpacity.Set(KAlfVisualDefaultOpacity);
+                }
+            else
+                {
+                aVisual->SetFlag(EHuiVisualFlagShouldBeShown);
+                }
             aVisual->ClearFlag(EHuiVisualFlagShouldBeHidden);
             }
         else
@@ -3540,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++)
         {
@@ -3547,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;
@@ -3587,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();
@@ -3661,11 +3526,14 @@
     {
     TInt windowNodeId = aData.iInt1;  
     TBool faded = aData.iInt2;
-
-    CHuiVisual* viz = (CHuiVisual*)FindVisual(windowNodeId);    
-    if (!viz)
+    MWsWindowTreeNode::TType type = (MWsWindowTreeNode::TType)(TInt)aData.iPtr;
+    CHuiVisual* viz = NULL;
+    if (type != MWsWindowTreeNode::EWinTreeNodeGroup)
         {
-        // Visual not found, it could be window group. It must be searched with other method.
+        viz = (CHuiVisual*)FindVisual(windowNodeId);
+        }
+    else
+        {
         CHuiControlGroup* cg = FindControlGroup(windowNodeId, 0); // TODO: Screen            
         if (cg) 
             {
@@ -3757,6 +3625,8 @@
         {
         __ALFLOGSTRING1("CAlfBridge::HandleSetCursorDataL - WARNING! Cursor node 0x%x not found!", windowNodeId);
         }
+    
+    AMT_INC_COUNTER_IF(viz, iTotalVisualAttributeChangedCount);   
     }
 
 // ---------------------------------------------------------------------------
@@ -3840,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);
@@ -3860,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:
@@ -3867,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
 
@@ -3887,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;
                          }
@@ -3913,18 +3790,17 @@
                     if ( aEvent.iAction != AknTransEffect::EApplicationExit && aToLayout->Flags() & EHuiVisualFlagInactive)
                         {
                         aToLayout->iOpacity.Set(1.0f);
-                        failed = ETrue;
-                        return failed;
                         }
                         
                     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
                         	{
@@ -3936,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 ) );
+                                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 ) );
+                                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
@@ -3980,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 
@@ -4055,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
 // ---------------------------------------------------------------------------
@@ -4221,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;
@@ -4424,6 +4243,11 @@
     CHuiCanvasVisual* temporaryPresenterVisual = NULL;
     TInt enableEffect = ETrue;
     
+    if (aSourceVisual->iOpacity.Now() >= 0.01)
+        {
+        aSourceVisual->SetFlag(EHuiVisualFlagShouldBeShown);
+        }
+    
     aSourceVisual->ClearFlags(EHuiVisualFlagShouldBeInactive | EHuiVisualFlagShouldBeUnderOpaqueHint);
     if (aIsExitEffect) 
         {
@@ -4463,7 +4287,7 @@
                     aSourceVisual, 
                     temporaryPresenterVisual,
                     ETrue,
-                    EFalse);
+                    aIsExitEffect);
             iEffectCleanupStack.AppendL(item);
             }
         else
@@ -4472,7 +4296,7 @@
             // aSourceVisual->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
             TEffectCleanupStruct item = TEffectCleanupStruct(aEffectHandle,
                         aSourceVisual, NULL, EFalse,
-                        EFalse);
+                        aIsExitEffect);
             iEffectCleanupStack.AppendL(item);
             }
      }
@@ -4510,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. 
@@ -4533,7 +4359,7 @@
         }
     else
         {
-        AddEffectItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, ETrue, itemsDestroyed, EFalse);
+        AddEffectItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, EFalse, itemsDestroyed, EFalse);
         __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout), NO presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout);
         }
     iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue;
@@ -4573,7 +4399,6 @@
 
 void CAlfBridge::HandleGfxControlEffectsL( TAlfBridgerData data )
     {
-    TInt err = KErrNone;
     TInt action = data.iInt1;
     TInt length = data.iInt2;
     __ALFFXLOGSTRING1("HandleGfxControlEffectsL - Reading bridge data %d", (TInt)data.iPtr);
@@ -4612,16 +4437,8 @@
         return;
         }
     iAlfScreens[0]->iDisplay->SetDirty();
-
     iHuiEnv->ContinueRefresh();
 
-    if (visual && err != KErrNone)
-        {
-        // if the effect loading failed too soon, we must call our callback ourselves
-        //        RDebug::Print(_L("HandleGfxControlEffectsL - effect not set - going directly to callback"));
-        AlfGfxEffectEndCallBack(fxData->iHandle);
-        }
-
     delete iControlEffectData;
     iControlEffectData = NULL;
 
@@ -4675,7 +4492,7 @@
             }
         if (layoutEffectable)
             {
-            TRAP( err, engine->LoadGroupEffectL(*aEvent.iEffectName, effect, aCanvasVisual->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle ) );
+            TRAP( err, engine->LoadGroupEffectL(*aEvent.iEffectName, effect, aCanvasVisual->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle, KHuiFxDelayRunUntilFirstFrameHasBeenDrawn ) );
             }
         else
             {
@@ -4731,11 +4548,7 @@
         sourceViz->iOpacity.Set(0.0f);
         sourceViz->ClearFlag(EHuiVisualFlagShouldBeHidden); // it is now hidden
         }
-	else
-		{
-        // visual may be transparent after manipulation of the effect
-	   	sourceViz->iOpacity.Set(KAlfVisualDefaultOpacity); 
-		}
+	
     if (showVisual)
         {
         sourceViz->iOpacity.Set(KAlfVisualDefaultOpacity);
@@ -4875,10 +4688,18 @@
 
 TBool CAlfBridge::HasActiveEffect(CHuiVisual* aVisual)
     {
+    TInt dummy;
+    return HasActiveEffect(aVisual, dummy);
+    }
+
+TBool CAlfBridge::HasActiveEffect(CHuiVisual* aVisual, TInt& aIndex)
+    {
+    aIndex = KErrNotFound;
     for (TInt i = 0; i < iEffectCleanupStack.Count(); i++)
         {
         if (aVisual == iEffectCleanupStack[i].iEffectedVisual)
             {
+            aIndex = i;
             return ETrue;
             }
         }
@@ -4935,7 +4756,10 @@
                     {
                     itemsRemoved++;
                     }
-                iEffectCleanupStack.Remove(i);
+                if (iEffectCleanupStack.Count() > i)
+                    {
+                    iEffectCleanupStack.Remove(i);
+                    }
                 iFinishedCleanupStackEffects.Remove(0);
                 i--;
                 }
@@ -4970,7 +4794,7 @@
     {
     // We need a delay to prevent the refresh from being messed up
     // We try a short delay before clearing everything up.
-    __ALFFXLOGSTRING1("AlfGfxEffectEndCallBack, append handle %d", aHandle );
+    __ALFFXLOGSTRING1("AlfGfxEffectEndCallBack, handle %d", aHandle );
     //    RDebug::Print(_L("AlfGfxEffectEndCallBack, append handle %d"), aHandle );
     // If the handle cannot be appended, the function returns an error.
     // However, if the memory is low, there is nothing we can do about it.
@@ -4978,10 +4802,7 @@
     // If there are already other handles in the queue, the handler will not
     // be called for this handle, but all handles that have been left hanging
     // around will be cleared when HandleGfxStopEffectsL is called
-  
-    
-    iFinishedEffects.Append(aHandle);
-    	
+
     // iFinishedCleanupStackEffects.Append(aHandle);
     if (!iEffectEndTimer->IsActive())
         {
@@ -5072,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
@@ -5087,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)
@@ -5105,10 +4930,20 @@
             __ALFLOGSTRING1(">> %d EFFECT GROUP", i);                                                                
 #endif
             }
+        else if (indexedGroup.Control(0).Role() == EAlfFpsIndicatorContainer)
+            {
+#ifdef  HUI_DEBUG_TRACK_DRAWING
+            __ALFLOGSTRING3(">> %d FPS GROUP %S, %d", i, &processName, clientWindowGroupId );                                                                
+#else
+            __ALFLOGSTRING1(">> %d FPS GROUP", i);                                                                
+#endif
+            }
         else 
             {
 #ifdef  HUI_DEBUG_TRACK_DRAWING
             __ALFLOGSTRING3(">> %d UNKNOWN GROUP ?!!? %S, %d", i, &processName, clientWindowGroupId );
+#else
+            __ALFLOGSTRING1(">> %d UNKNOWN GROUP ?!!?", i);                                                                            
 #endif
             }                                                
 
@@ -5146,15 +4981,16 @@
 #endif        
 
 #ifdef ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
-void CAlfBridge::VisualizeControlGroupOrderL(CHuiRoster& aRoster, CHuiControlGroup& /*aGroup*/)
+void CAlfBridge::VisualizeControlGroupOrderL(CAlfScreen& aScreen, CHuiRoster& aRoster, CHuiControlGroup& /*aGroup*/)
     {       
     TInt nbrofcolums = 3;
     TInt nbrofrows = 3;
     TInt gridIndex = 0;
     TBool skipEmpty = EFalse;
-    if (aRoster.Count() > 3)
+    TInt skipCount = aScreen.FixedControlGroupCount() + 1;
+    if (aRoster.Count() > skipCount)
         {
-        for (TInt i=aRoster.Count() - 3; i>0; i--)
+        for (TInt i=aRoster.Count() - skipCount; i>0; i--)
             {
             CHuiControl& control = aRoster.ControlGroup(i).Control(0);
             if (skipEmpty)
@@ -5187,7 +5023,7 @@
     iAlfScreens[0]->iDisplay->SetClearBackgroundL(CHuiDisplay::EClearWithSkinBackground);            
     }
 #else
-void CAlfBridge::VisualizeControlGroupOrderL(CHuiRoster& /*aRoster*/, CHuiControlGroup& /*aGroup*/)
+void CAlfBridge::VisualizeControlGroupOrderL(CAlfScreen& /*aScreen*/, CHuiRoster& /*aRoster*/, CHuiControlGroup& /*aGroup*/)
     {       
     }
 #endif    
@@ -5344,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.
@@ -5361,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;
@@ -5389,7 +5208,7 @@
             aScreen->iSwRenderingTarget = new CFbsBitmap;
             if (aScreen->iSwRenderingTarget)
                 {
-                aScreen->iSwRenderingTarget->Create(aScreen->Size(), EColor16MA);
+                aScreen->iSwRenderingTarget->Create(aScreen->Size(), EColor16MAP); 
                 modified = ETrue;
                 }
             }
@@ -5496,18 +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]));
+    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 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfhierarchymodel.cpp	Fri Mar 19 09:43:21 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
     }
 
 // ---------------------------------------------------------------------------
@@ -233,6 +245,13 @@
 			aMessage.Complete( EAlfBridgerSendChunk );
             return;
             }
+        case EAlfSynchronize:
+            {
+            iServer.Bridge()->AddData( EAlfDSSynchronize, aMessage.Int0() );
+            aMessage.Complete( KErrNone );
+            }
+            break;
+            
         default:
             {
             doComplete= ETrue;
@@ -768,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 );         
     }
 
 // ---------------------------------------------------------------------------
@@ -797,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 );     
     }
 
 // ---------------------------------------------------------------------------
@@ -816,6 +843,8 @@
         {
         USER_INVARIANT();
         }
+    
+    AMT_INC_COUNTER_IF( node && (nodeType==MWsWindowTreeNode::EWinTreeNodeClient), iWindowNodeActivatedCount ); 
     }
 
 // ---------------------------------------------------------------------------
@@ -846,6 +875,8 @@
         }
 #endif
 
+    AMT_INC_COUNTER_IF(node, iNodeExtentChangedCount );
+    AMT_SET_VALUE_IF(node, iLatestNodeExtentRect, rect );        
     }
 
 // ---------------------------------------------------------------------------
@@ -860,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
         {
@@ -901,6 +936,8 @@
         {
         USER_INVARIANT();
         }
+
+    AMT_INC_COUNTER_IF(node, iTotalNodeFlagChangedCount );    
     }
 
 // ---------------------------------------------------------------------------
@@ -978,11 +1015,16 @@
     TUint32 nodeId = (TUint32)iStream->ReadUint32L();
     TRect extent = TRect(0,0,0,0);
     ReadRectL(extent, iStream); 
+    TBool isDSA = (TUint32)iStream->ReadUint32L();
     CAlfNodeVisual* node = (CAlfNodeVisual*)FindNode( nodeId );
     if ( node && node->Window() )
         {
         // SetSurfaceExtent is not supported for image visual
         node->Window()->SetSurfaceExtent( extent );
+        if (isDSA)
+            {
+            node->Window()->SetLayerUsesAplhaFlag(KWindowIsDSAHost);
+            }
         }
     else if( node ) // this would mean that node has being orphaneded but not yet deleted
         {
@@ -1082,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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp	Fri Mar 19 09:43:21 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;
@@ -255,7 +249,7 @@
             {
             CAlfNode* parentNode = iModel->FindNode( iParent->iId );
             __ASSERT_DEBUG(parentNode, USER_INVARIANT());
-            if (parentNode->HasChildren())
+            if (parentNode  && parentNode->HasChildren())
                 {
                 // parent node is not added to the list
                 // the anims, cursor and sprites directly in this parent are added to the list
@@ -838,7 +832,7 @@
         }
     // starting from the first child, loop until this one is found.
     
-    while( previousSibling->iSibling != this)
+    while( previousSibling && previousSibling->iSibling != this)
         {
         previousSibling = previousSibling->iSibling;
         }
@@ -879,7 +873,7 @@
         }
     if (iFadeState != iPostedFadeState)
         {
-        iModel->Server().Bridge()->AddData( EAlfDSSetFadeEffect, iId , iFadeState);
+        iModel->Server().Bridge()->AddData( EAlfDSSetFadeEffect, iId , iFadeState, (TAny*)iType);
         iPostedFadeState = iFadeState;
         }
     }
@@ -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/alfscreen.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfscreen.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -48,6 +48,7 @@
 _LIT8(KAlfFullScreenEffectContainerControlTag, "EFFECT");
 //_LIT8(KAlfWindowGroupTemporaryRemoveControlTag, "WGTEMP");
 
+const TInt KAlfNumberOfFixedControlGroups = 2;
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -163,8 +164,17 @@
     _LIT(KRDSupport, "c:\\resource\\errrd" );
     if (CHuiStatic::FsSession().Handle() && BaflUtils::FileExists( CHuiStatic::FsSession(), KRDSupport ))
         {
+        iFpsControlGroup = &aHuiEnv.NewControlGroupL(0xDEADBEEF + 20 + iScreenNum); // TODO
+    	
+    	CHuiControl* fpsCntrl = new (ELeave) CHuiControl(aHuiEnv);	    
+	    CleanupStack::PushL(fpsCntrl);
+	    fpsCntrl->ConstructL();
+	    fpsCntrl->SetRole(EAlfFpsIndicatorContainer);
+	    iFpsControlGroup->AppendL(fpsCntrl);
+	    CleanupStack::Pop(fpsCntrl);
+        
         // FPS Counter with hitchcock drawing
-        iFPSText = CHuiTextVisual::AddNewL(*effectCntrl, effectLayout);
+        iFPSText = CHuiTextVisual::AddNewL(*fpsCntrl, NULL);
         iFPSText->SetColor(KRgbBlue);
         iFPSText->SetFlag(EHuiVisualFlagManualLayout);
         iFPSText->SetPos(THuiRealPoint(300,20)); // could be adjusted
@@ -194,6 +204,8 @@
 	// this deletes also control and layout
 	delete iFloatingSpriteControlGroup;
 	
+	delete iFpsControlGroup;
+	
 	delete iDisplay;
 	iControlGroups.Close();
 	
@@ -222,3 +234,12 @@
     return iVisualTreeVisibilityChanged;    
     }
      
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// 
+TInt CAlfScreen::FixedControlGroupCount() const
+    {
+    return !iFpsControlGroup ? 
+        KAlfNumberOfFixedControlGroups :
+        KAlfNumberOfFixedControlGroups + 1;
+    }
--- a/uiacceltk/hitchcock/ServerCore/Src/alfsrvdisplaysubsession.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfsrvdisplaysubsession.cpp	Fri Mar 19 09:43:21 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/ServerCore/Src/alfstreamerserver.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfstreamerserver.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -610,6 +610,7 @@
         case EAlfBridgerRequestDataBlock:
         case EAlfBridgerAsyncronousData:
         case EDsNotifyNativeWindowData:
+        case EAlfSynchronize:
             {
             server->WindowTree()->HandleMessageL( aMessage );
             return;
--- a/uiacceltk/hitchcock/backgroundanim/refplugin/group/refplugin.mmp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/backgroundanim/refplugin/group/refplugin.mmp	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/backgroundanim/refplugin/src/shader.c	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/backgroundanim/src/bganimhost.cpp	Fri Mar 19 09:43:21 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);
 	
@@ -611,7 +610,7 @@
 
 void CBgAnimHost::DataReceived( CSensrvChannel& aChannel, TInt aCount, TInt aDataLost )
     {
-    if (iPlugin && iPlugin->receivesensordata);
+    if (iPlugin && iPlugin->receivesensordata)
         {
         iPlugin->receivesensordata((void*)&aChannel, aCount, aDataLost);
         }
--- a/uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/BWINS/hitchcocku.DEF	Fri Mar 19 09:43:21 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 *)
@@ -1581,4 +1581,8 @@
 	?SetForegroundBitmapL@CHuiDisplay@@QAEXPAVCFbsBitmap@@@Z @ 1580 NONAME ; void CHuiDisplay::SetForegroundBitmapL(class CFbsBitmap *)
 	?ForegroundBitmap@CHuiDisplay@@QBEPAVCFbsBitmap@@XZ @ 1581 NONAME ; class CFbsBitmap * CHuiDisplay::ForegroundBitmap(void) const
 	?HasCommandBuffers@CHuiCanvasVisual@@QBEHH@Z @ 1582 NONAME ; int CHuiCanvasVisual::HasCommandBuffers(int) const
+	?SkinContentChanged@CHuiS60Skin@@UAEXXZ @ 1583 NONAME ; void CHuiS60Skin::SkinContentChanged(void)
+	?SkinPackageChanged@CHuiS60Skin@@UAEXW4TAknsSkinStatusPackageChangeReason@@@Z @ 1584 NONAME ; void CHuiS60Skin::SkinPackageChanged(enum TAknsSkinStatusPackageChangeReason)
+	?SkinConfigurationChanged@CHuiS60Skin@@UAEXW4TAknsSkinStatusConfigurationChangeReason@@@Z @ 1585 NONAME ; void CHuiS60Skin::SkinConfigurationChanged(enum TAknsSkinStatusConfigurationChangeReason)
+	?Synchronize@CHuiEnv@@QAEXHPAVMHuiSynchronizationObserver@@@Z @ 1586 NONAME ; void CHuiEnv::Synchronize(int, class MHuiSynchronizationObserver *)
 
--- a/uiacceltk/hitchcock/coretoolkit/eabi/hitchcocku.DEF	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/eabi/hitchcocku.DEF	Fri Mar 19 09:43:21 2010 +0200
@@ -1979,4 +1979,11 @@
 	_ZTI15MHuiFxParameter @ 1978 NONAME
 	_ZTV15MHuiFxParameter @ 1979 NONAME
 	_ZNK16CHuiCanvasVisual17HasCommandBuffersEi @ 1980 NONAME
+	_ZN11CHuiS60Skin18SkinContentChangedEv @ 1981 NONAME
+	_ZN11CHuiS60Skin18SkinPackageChangedE34TAknsSkinStatusPackageChangeReason @ 1982 NONAME
+	_ZN11CHuiS60Skin24SkinConfigurationChangedE40TAknsSkinStatusConfigurationChangeReason @ 1983 NONAME
+	_ZThn28_N11CHuiS60Skin18SkinContentChangedEv @ 1984 NONAME
+	_ZThn28_N11CHuiS60Skin18SkinPackageChangedE34TAknsSkinStatusPackageChangeReason @ 1985 NONAME
+	_ZThn28_N11CHuiS60Skin24SkinConfigurationChangedE40TAknsSkinStatusConfigurationChangeReason @ 1986 NONAME
+	_ZN7CHuiEnv11SynchronizeEiP27MHuiSynchronizationObserver @ 1987 NONAME
 
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxConstants.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxConstants.h	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffect.h	Fri Mar 19 09:43:21 2010 +0200
@@ -29,15 +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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEffectCache.h	Fri Mar 19 09:43:21 2010 +0200
@@ -62,6 +62,7 @@
         };
     
     MHuiFxEffectCacheNode *Find(MHuiFxEffectCacheNode *aNode);
+    MHuiFxEffectCacheNode *FindDuplicate(MHuiFxEffectCacheNode *aNode);
     static bool Compare(MHuiFxEffectCacheNode *aNode1, MHuiFxEffectCacheNode *aNode2);
     void Remove(RPointerArray<MHuiFxEffectCacheNode> &aEffects, MHuiFxEffectCacheNode *aNode);
     void Remove(RHashMap<TInt, MHuiFxEffectCacheNode*> &aMap, MHuiFxEffectCacheNode *aNode);
@@ -85,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/HuiFxEngine.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxEngine.h	Fri Mar 19 09:43:21 2010 +0200
@@ -155,6 +155,10 @@
     TInt             iBuffersInUse;
     
 private:
+    
+    TBool FxmlUsesInput1(CHuiFxEffect& aEffect);
+    
+private:
     // Render buffer management --- native implementations
     virtual CHuiFxRenderbuffer* AcquireNativeRenderbuffer(const TSize& aDesiredSize) = 0;
     virtual void ReleaseNativeRenderbuffer(CHuiFxRenderbuffer* aBuffer) = 0;
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxGroupLayer.h	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxLayer.h	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiFxParameter.h	Fri Mar 19 09:43:21 2010 +0200
@@ -51,7 +51,7 @@
     EReferencePointExtRectBottom,
     EReferencePointExtRectLeft,
     EReferencePointExtRectRight,
-   
+    EReferencePointDisplayHeightMinusVisualTop
     };
 
 class MHuiFxParameter
--- a/uiacceltk/hitchcock/coretoolkit/inc/HuiRenderSurface.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/HuiRenderSurface.h	Fri Mar 19 09:43:21 2010 +0200
@@ -104,6 +104,12 @@
     virtual void SwapBuffers() = 0;
 
     /**
+     * Synchronizes the context. All rendering calls for the currently bound context are guaranteed 
+     * to be executed, when thsi method returns.
+     */
+    virtual void Finish() = 0;
+
+    /**
      * Binds a texture to the surface to be used during subsequent drawing
      * operations.
      *
--- a/uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h	Fri Mar 19 09:43:21 2010 +0200
@@ -196,6 +196,9 @@
     void DestroyBuffer(TInt aIndex);
     void UpdateBufferUpdateRegions(TPoint aPos);
     
+    void RemoveBuffersWithMovedDisplayRect();
+    void ModifyBuffersWithChangedDisplayRect();
+    
 public:    
     void EnableRenderBufferIfNeeded(TBool aEnable);
 private:
@@ -379,6 +382,9 @@
 #ifdef HUI_DEBUG_TRACK_DRAWING
     CAlfCommandDebug* iCommandDebugger;
 #endif
+    
+    // Boolean flag indicating if render buffer ought to be used.
+    TBool iEnableRenderBuffer;
   };
     
 #endif  // __HUICANVASWSPAINTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/coretoolkit/inc/huiextension.h	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Internal extensions
+*
+*/
+
+
+
+#ifndef __HUIEXTENSION_H__
+#define __HUIEXTENSION_H__
+
+
+#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 };
+
+// Parameter structure for Query visual extension
+struct THuiVisualQueryParams
+    {
+    enum TQueryType
+        {
+        // iResult contains canvas flags
+        EQueryCanvasFlags,
+        // iResult contains positive value if external content drawing enabled, 0 otherwise.
+        EQueryExternalContentDrawingEnabled,
+        // iResult contains positive value if this has something to draw, 0 otherwise.
+        EQueryHasDrawableContent
+        };
+
+    // Query type (in)
+    TQueryType iQueryType;
+        
+    // Result of query (out)
+    TInt iValue;
+    
+    // Error code (out). This should be filled with KErrNotSupported by caller and visual should modify to KErrNone.
+    TInt iResult;
+    };
+
+#endif // __HUIEXTENSION_H__
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Gc.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Gc.h	Fri Mar 19 09:43:21 2010 +0200
@@ -150,6 +150,11 @@
     void SetDimmingFog(const TRgb& aColor, TReal32 aAmount) __SOFTFP;
 
     /**
+     * Clear rect using the current pen color
+     */
+    void Clear(const TRect& aRect);
+    
+    /**
      * Clear using the current pen color.
      */
     void Clear();
@@ -553,7 +558,8 @@
     
     /** Default fill and stroke paint */
 	VGPaint iPaint;
-
+	TUint32 iPaintColor;
+	
     /** Gradient fill paint */
     VGPaint iGradientPaint;
     
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10PBufferSurface.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10PBufferSurface.h	Fri Mar 19 09:43:21 2010 +0200
@@ -118,6 +118,12 @@
     void SwapBuffers();
 
     /**
+     * Synchronizes the context. All rendering calls for the currently bound context are guaranteed 
+     * to be executed, when thsi method returns.
+     */
+    void Finish();
+
+    /**
      * Binds a texture to the surface to be used during subsequent drawing
      * operations.
      */
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10RenderSurface.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10RenderSurface.h	Fri Mar 19 09:43:21 2010 +0200
@@ -65,6 +65,8 @@
 
     virtual void SwapBuffers();
 
+    virtual void Finish();
+
     virtual void BindTexture(TInt aTextureUnit,
                              const MHuiSegmentedTexture& aTexture,
                              TInt aSegment);
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Texture.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10Texture.h	Fri Mar 19 09:43:21 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/HuiVg10Gc.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Gc.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -300,6 +300,8 @@
     iArcPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 
                             2, 7, VG_PATH_CAPABILITY_APPEND_TO);
     iPaint = vgCreatePaint();
+    iPaintColor = 0;
+    vgSetColor(iPaint, iPaintColor);
     iGradientPaint = vgCreatePaint();
     iBlendMode = VG_BLEND_SRC_OVER;
 
@@ -707,6 +709,42 @@
     // Fog not supported
     }
 
+void CHuiVg10Gc::Clear(const TRect& aRect)
+    {
+    HUI_VG_INVARIANT();
+    
+    UpdateClientMatrix();
+
+    THuiRealRect transformed = aRect;
+    iMatrixStack->Current().Multiply(transformed.iTl);
+    iMatrixStack->Current().Multiply(transformed.iBr);
+        
+    // Normalize the rectangle
+    if (transformed.iTl.iX > transformed.iBr.iX)
+        {
+        TReal32 tmp = transformed.iTl.iX;
+        transformed.iTl.iX = transformed.iBr.iX;
+        transformed.iBr.iX = tmp;
+        }
+    if (transformed.iTl.iY > transformed.iBr.iY)
+        {
+        TReal32 tmp = transformed.iTl.iY;
+        transformed.iTl.iY = transformed.iBr.iY;
+        transformed.iBr.iY = tmp;
+        }            
+    VGfloat scale = 1.0f / 255.0f;
+    VGfloat color[] = 
+        {
+        PenColor().Red()   * scale,
+        PenColor().Green() * scale,
+        PenColor().Blue()  * scale,
+        PenAlpha() * scale
+        };
+
+    vgSetfv(VG_CLEAR_COLOR, 4, color);
+    vgClear(transformed.iTl.iX, transformed.iTl.iY, transformed.Width(), transformed.Height());
+    HUI_VG_INVARIANT();
+    }
 
 void CHuiVg10Gc::Clear()
     {
@@ -941,7 +979,12 @@
 #endif
     
     // Update the color of the current paint
-    vgSetColor(iPaint, color);
+    // if required
+    if (iPaintColor != color)
+        {
+        vgSetColor(iPaint, color);
+        iPaintColor = color;
+        }
     
     // Detect white fully opaque color
     if (color == 0xffffffff)
@@ -1050,7 +1093,7 @@
     vgTranslate(-srcX, -srcY);
 
 #ifdef __NVG
-    if ( isExtended && texture.IsNvgContent())
+    if ( isExtended )
         {
         // Determine the size to which we want to draw the NVG icon paths
         TSize contentSize( HUI_ROUND_FLOAT_TO_INT(aDestRect.Width()),
@@ -1163,7 +1206,7 @@
     const CHuiVg10Texture& texture = static_cast<const CHuiVg10Texture&>( aTexture );
     TBool isExtended = texture.IsExtended();
     
-    if (isExtended && texture.IsNvgContent())
+    if (isExtended)
         {
         UpdateMatrix(VG_MATRIX_PATH_USER_TO_SURFACE);
         TSize contentSize(0, 0);
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10PBufferSurface.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10PBufferSurface.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -409,6 +409,10 @@
     // Pbuffers consist of a single buffer only (no front/back buffers to swap).
     }
 
+void CHuiVg10PBufferSurface::Finish()
+    {
+    vgFinish();
+    }
 
 void CHuiVg10PBufferSurface::BindTexture(TInt aTextureUnit,
                                            const MHuiSegmentedTexture& aTexture,
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10RenderSurface.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10RenderSurface.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -185,6 +185,9 @@
     EGLint attriblist[] = 
         {
         EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE,
+#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
+        EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER,
+#endif
         EGL_NONE
         };
     attriblistPtr = &attriblist[0];
@@ -296,6 +299,10 @@
     eglSwapBuffers(iEglDisplay, iEglSurface);
     }
 
+void CHuiVg10RenderSurface::Finish()
+    {
+    vgFinish();
+    }
 
 void CHuiVg10RenderSurface::BindTexture(TInt /*aTextureUnit*/,
                                         const MHuiSegmentedTexture& aTexture,
--- a/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/rendervg10/src/HuiVg10Texture.cpp	Fri Mar 19 09:43:21 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)
     {
@@ -1082,7 +1158,7 @@
         image = CreateRenderedImage(&nvgEngine, dataBuf, Size());
         
         // New functionality for checking the mask
-        if (header.GetBitmapId() != maskHeader.GetBitmapId() &&
+        if (header.GetBitmapId() != maskHeader.GetBitmapId() && maskDataBuf &&
             CompareNvgData(dataBuf, maskDataBuf) != 0)
             {
             VGImage maskImg = VG_INVALID_HANDLE;
@@ -1436,14 +1512,13 @@
 TSize CHuiVg10Texture::ApplyMargin(VGImage aImage, TSize aSize, EGLDisplay aDisplay, EGLSurface aSurface, EGLContext aContext)
     {
     HUI_VG_INVARIANT();
-    // If the icon is also a current EGL surface, the getImageSubData
-    // won't succeed and return "image in use" -error..
-    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;
-        }
-    
+    #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
@@ -1470,7 +1545,7 @@
     TReal R = 1.0;
     TInt HaN = Ha;
     
-    const TInt lastColumn = aSize.iHeight - 1;
+    const TInt lastColumn = aSize.iWidth - 1;
     for (TInt curRow = 0; curRow < lValidMargin; curRow++)
         {
         const TInt y = (aSize.iHeight - 1) - curRow; // h - 1 is the last line
@@ -1492,14 +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;
-        }
-    
+     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/HuiAnchorLayout.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiAnchorLayout.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -713,7 +713,9 @@
             Mem::FillZ(anchor, sizeof(*anchor));
             }
         }
-        
+    
+    ASSERT(anchor);
+    
     TEdgeAnchor* edge(NULL);
     TAxis& axis = anchor->Axis(axisId);
     error = axis.AddEdge(edgeProximity, edge);
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiAnimatedTexture.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiAnimatedTexture.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -56,7 +56,7 @@
     
 EXPORT_C MHuiSegmentedTexture* CHuiAnimatedTexture::SegmentedTexture()
     {
-    return this;
+    return iTexture;
     }
     
     
@@ -68,7 +68,7 @@
 
 EXPORT_C const MHuiSegmentedTexture* CHuiAnimatedTexture::SegmentedTexture() const
     {
-    return this;
+    return iTexture;
     }
     
     
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasTextureCache.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -285,6 +285,8 @@
 
 CHuiCanvasTextImage::~CHuiCanvasTextImage()
     {
+    delete iText;
+    iText = NULL;
     }
 
 TBool CHuiCanvasTextImage::UseColorModulation() const
@@ -1099,8 +1101,6 @@
     TBool volatileBitmapOrMask = ETrue;
 #endif
 
-    TBool originalMaskUsed = ETrue;
-
 
     TInt bitmapHandle = aImage.iBitmapHandle;
     TInt maskHandle = aImage.iMaskHandle;
@@ -1199,7 +1199,6 @@
                 
                 mask = invertedMask;
                 CleanupStack::PushL(mask);    
-                originalMaskUsed = EFalse;
                 }
             
             // Upload expects mask to begin always at TPoint(0,0), so if mask
@@ -1218,7 +1217,6 @@
                     }
                 mask = movedMask;
                 CleanupStack::PushL(mask);                            
-                originalMaskUsed = EFalse;
                 }
 #ifdef __NVG
             }
@@ -2191,6 +2189,7 @@
     iSearchedGraphicImageEntry->iBitmapTouchCount = KHuiInitialBitmapTouchCount;
     iSearchedGraphicImageEntry->iMaskTouchCount = KHuiInitialBitmapTouchCount;
     iSearchedGraphicImageEntry->iGcParams = aCachedImageParams.iGcParams;
+    iSearchedGraphicImageEntry->iCache = this;
     
     cachedEntry = iCachedImages.FindInOrder(iSearchedGraphicImageEntry, ImageOrderFunc);
     if (cachedEntry == KErrNotFound)
@@ -2219,6 +2218,7 @@
     iSearchedGraphicImageEntry->Reset();
     iSearchedGraphicImageEntry->iGcParams = aGcParams;
     iSearchedGraphicImageEntry->iImageSize = aImageSize;
+    iSearchedGraphicImageEntry->iCache = this;
     
     
     for (TInt i=0; i<aCachedImageParams.Count();i++)
@@ -2294,13 +2294,14 @@
     iSearchedGraphicImageEntry->iBitmapTouchCount = KHuiInitialBitmapTouchCount;
     iSearchedGraphicImageEntry->iMaskTouchCount = KHuiInitialBitmapTouchCount;
     iSearchedGraphicImageEntry->iGcParams = aCachedImageParams.iGcParams;
+    iSearchedGraphicImageEntry->iCache = this;
     
     cachedEntry = iCachedImages.FindInOrder(iSearchedGraphicImageEntry, ImageOrderFunc);
     if (cachedEntry == KErrNotFound)
         {
         // Create new entry object
         CHuiCanvasGraphicImage* newEntry = new (ELeave) CHuiCanvasGraphicImage; 
-        CleanupStack::PushL(newEntry);                    
+        CleanupStack::PushL(newEntry);
         
         newEntry->CopyAttributes(*iSearchedGraphicImageEntry);
         
@@ -2311,7 +2312,7 @@
         User::LeaveIfError(iCachedImages.InsertInOrder(newEntry, ImageOrderFunc));
         cachedEntry = iCachedImages.FindInOrder(newEntry, ImageOrderFunc);
         CleanupStack::Pop(newEntry);
-        needUpdate = ETrue;            
+        needUpdate = ETrue;
         }
     else
         {
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCanvasVisual.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -46,6 +46,9 @@
 
 #include "HuiFxEffect.h"
 #include "HuiCmdBufferBrush.h"
+#include "huiextension.h"
+
+#include "huiwscanvascommands.h"
 
 /** Flag to convienintly disable/enable canvas render buffer usage if needed */
 /* Turned to EFalse as DFS77 was having booting problems in wk26 */
@@ -93,7 +96,9 @@
 void CHuiCanvasVisual::ConstructL()
     {
     CHuiLayout::ConstructL();
-        
+
+    SetFlags(EHuiVisualFlagWserv);
+    
     iCanvasVisualData = new (ELeave) THuiCanvasVisualData;
     iCanvasVisualData->iCommandSetType = ECommandBufferWs;
     iCanvasVisualData->iCanvasFlags = 0;   
@@ -101,13 +106,13 @@
     iCanvasVisualData->iParentCanvas = NULL;
     iCanvasVisualData->iBackground = NULL;
     iCanvasVisualData->iCanvasPainter = NULL;
+    iCanvasVisualData->iStoredRenderBuffer = 0;
     
     iCanvasVisualData->iBackground = CHuiCanvasBackground::NewL();
     iCanvasVisualData->iBackground->SetVisual(this);
     
     iCanvasVisualData->iCanvasPainter = CHuiCanvasWsPainter::NewL();
     iCanvasVisualData->iCanvasPainter->SetVisual(this);
-    iCanvasVisualData->iStoredRenderBuffer = 0;
     
     TBool useCanvasRenderBuffer = CHuiStatic::Renderer().Allows(EHuiRenderPluginAllowVisualPBufferSurfaces);    
     iCanvasVisualData->iCanvasPainter->EnableRenderBuffer(useCanvasRenderBuffer); 
@@ -116,26 +121,34 @@
     iCanvasVisualData->iLayerExtent = TRect();
     
     // subwindow effects
-    EnableBrushesL(ETrue);
+    //EnableBrushesL(ETrue);
     }
 
 
 CHuiCanvasVisual::~CHuiCanvasVisual()
     {
-    FreeRenderBuffer();
-    if(iCanvasVisualData->iExternalContentVisual)
-    	{
-    	// Allow the external content visual to be drawn normally
-    	iCanvasVisualData->iExternalContentVisual->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
-    	}
-    	
+   
+    FreeRenderBuffer();	
     if (iCanvasVisualData)
         {
+        if(iCanvasVisualData->iExternalContentVisual)
+            {
+            // Allow the external content visual to be drawn normally
+            iCanvasVisualData->iExternalContentVisual->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent);
+            }
         ClearCommandSet();
-        delete iCanvasVisualData->iBackground;
-        iCanvasVisualData->iBackground = NULL;
-        delete iCanvasVisualData->iCanvasPainter;
-    	iCanvasVisualData->iCanvasPainter = NULL;
+        if ( iCanvasVisualData->iBackground )
+            {
+            delete iCanvasVisualData->iBackground;
+            iCanvasVisualData->iBackground = NULL;
+            }
+        if ( iCanvasVisualData->iCanvasPainter )
+            {
+            delete iCanvasVisualData->iCanvasPainter;
+            iCanvasVisualData->iCanvasPainter = NULL;
+            }
+        
+    	
     	iCanvasVisualData->iExternalContentVisual = NULL;
     	
     	// Tell parent that we are destructed
@@ -299,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)
@@ -311,35 +349,25 @@
     		}
     	}
     
-    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;
         }
 
     if ((IsDelayedEffectSource() || Freezed()))
         {
+        // Select right draw mode
+        THuiCanvasDrawMode drawMode = (Flags() & EHuiVisualFlagOpaqueHint) ? EHuiCanvasDrawModeNormal : EHuiCanvasDrawModeBlend;
+
         if (StoredRenderBuffer())
             {
-            DrawStoredFullScreenRenderBuffer(aGc);
+            DrawStoredFullScreenRenderBuffer(drawMode, aGc);
             return;
             }
         else if (iCanvasVisualData->iStoredRenderBuffer)
             {
-            DrawStoredVisualRenderBuffer();
+            DrawStoredVisualRenderBuffer(drawMode);
             return;
 			}
         }  
@@ -383,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 )
@@ -490,16 +517,19 @@
             }
         }
 
-    if ((IsDelayedEffectSource() || Freezed()))
+    if (IsContentDrawingEnabled() && (IsDelayedEffectSource() || Freezed()))
         {
+        // Select right draw mode
+        THuiCanvasDrawMode drawMode = (Flags() & EHuiVisualFlagOpaqueHint) ? EHuiCanvasDrawModeNormal : EHuiCanvasDrawModeBlend;
+        
         if (StoredRenderBuffer())
             {
-            DrawStoredFullScreenRenderBuffer(aGc);
+            DrawStoredFullScreenRenderBuffer(drawMode, aGc);
 			return;
             }
         else if (iCanvasVisualData->iStoredRenderBuffer)
             {
-            DrawStoredVisualRenderBuffer();
+            DrawStoredVisualRenderBuffer(drawMode);
             return;
             }
         }    
@@ -590,20 +620,26 @@
     const TInt count = Count();
     for(TInt i = 0; i < count; ++i)
         {
-        // This cast is not really safe, but dynamic cast is slow
-        CHuiCanvasVisual* visual = (CHuiCanvasVisual*) iHuiLayoutPrivateData->iChildren[i];
+        CHuiVisual* visual = iHuiLayoutPrivateData->iChildren[i];
+        
         //Ignore inactive child visuals
         if ((visual->Flags()& EHuiVisualFlagInactive))
             {
             continue;
             }
         
-        if (aIncludeCanvasFlags && !(visual->CanvasFlags()& aIncludeCanvasFlags))
+        TInt canvasFlags = 0;
+        if (aIncludeCanvasFlags || aExcludeCanvasFlags)
+            {
+            canvasFlags = visual->QueryCanvasFlags();
+            }
+        
+        if (aIncludeCanvasFlags && !(canvasFlags & aIncludeCanvasFlags))
             {
             continue;
             }
 
-        if (aExcludeCanvasFlags && (visual->CanvasFlags()& aExcludeCanvasFlags))
+        if (aExcludeCanvasFlags && (canvasFlags & aExcludeCanvasFlags))
             {
             continue;
             }
@@ -649,34 +685,50 @@
    	return hasChanged;
     }
 
-TBool CHuiCanvasVisual::ChildTreeChanged(TInt aExcludeCanvasFlags) const
+// Goes through visual hierarchy and checks if any visual has changed.
+// This method does not modify any visuals. Parameter is not const 
+// because of CanvasVisual method.
+TBool CHuiCanvasVisual::RecursiveChildTreeChanged(CHuiVisual* aVisual, TInt aExcludeCanvasFlags)
     {
-    // CHuiLayout::Changed() does not check children.  
-    // This utility method checks whole child tree below this visual.
     TBool changed = EFalse;
 
     // Check wheter we should include this visual or igonre it.
     if (aExcludeCanvasFlags)
         {
-        if (!(iCanvasVisualData->iCanvasFlags & aExcludeCanvasFlags))
+        if ( !(aVisual->Flags() & EHuiVisualFlagInactive) )
             {
-            changed |= Changed();
+            TInt canvasFlags = aVisual->QueryCanvasFlags();
+                
+            if ( !(canvasFlags & aExcludeCanvasFlags) )
+                {
+                changed |= aVisual->Changed();
+                }
             }        
         }
     
-    const TInt count = Count();
-    for(TInt i = 0; i < count; ++i)
+    if ( !changed )
         {
-        CHuiCanvasVisual* visual = (CHuiCanvasVisual*) iHuiLayoutPrivateData->iChildren[i];
-        changed |= visual->ChildTreeChanged(aExcludeCanvasFlags);        
-        if (changed)
+        const TInt count = aVisual->Count();
+        for(TInt i = 0; i < count; ++i)
             {
-            break;
+            CHuiVisual* visual = &aVisual->Visual(i);
+            changed |= RecursiveChildTreeChanged( visual, aExcludeCanvasFlags );
+            if ( changed )
+                {
+                break;
+                }
             }
         }
-    return changed;
+    return changed;    
     }
 
+TBool CHuiCanvasVisual::ChildTreeChanged(TInt aExcludeCanvasFlags) const
+    {
+    // CHuiLayout::Changed() does not check children.  
+    // This utility method checks whole child tree below this visual.
+    return RecursiveChildTreeChanged(
+        const_cast<CHuiCanvasVisual*>(this), aExcludeCanvasFlags);
+    }
 
 EXPORT_C void CHuiCanvasVisual::ClearChanged()
     {
@@ -747,8 +799,11 @@
 
 EXPORT_C void CHuiCanvasVisual::ClearCommandSet()
     {
-    iCanvasVisualData->iCanvasPainter->ClearCommandSet();
-    SetChanged();
+    if ( iCanvasVisualData->iCanvasPainter )
+        {
+        iCanvasVisualData->iCanvasPainter->ClearCommandSet();
+        SetChanged();
+        }
     }
 
 #ifdef HUI_DEBUG_TRACK_DRAWING  
@@ -815,6 +870,7 @@
     
    	if (aCommandType == ECommandBufferAlf)
    	   	{
+   	   	ClearFlags(EHuiVisualFlagWserv);
    	   	delete iCanvasVisualData->iCanvasPainter;
    	   	iCanvasVisualData->iCanvasPainter = NULL;
         iCanvasVisualData->iCommandSetType = ECommandBufferAlf;    
@@ -823,6 +879,7 @@
    		}	     
     else if (aCommandType == ECommandBufferWs)
     	{
+    	SetFlags(EHuiVisualFlagWserv);
     	delete iCanvasVisualData->iCanvasPainter;
    	   	iCanvasVisualData->iCanvasPainter = NULL;
         iCanvasVisualData->iCommandSetType = ECommandBufferWs;    
@@ -983,6 +1040,31 @@
     return drawContent;       
     }
 
+// Goes through visual hierarchy and checks if any visual has external content drawing enabled.
+TBool CHuiCanvasVisual::RecursiveIsExternalContentDrawingEnabled(CHuiVisual* aVisual)
+    {
+    TBool drawExternalContent = EFalse;
+    
+    const TInt count = aVisual->Count();
+    for(TInt i = 0; i < count; ++i)
+        {
+        CHuiVisual* visual = &aVisual->Visual(i);
+        drawExternalContent |= visual->QueryExternalContentDrawingEnabled();
+        if ( drawExternalContent )
+            {
+            break;
+            }
+        
+        drawExternalContent |= RecursiveIsExternalContentDrawingEnabled( visual );
+        if ( drawExternalContent )
+            {
+            break;
+            }
+        }
+    
+    return drawExternalContent;    
+    }
+
 TBool CHuiCanvasVisual::IsExternalContentDrawingEnabled(TBool aIncludeChildren) const
     {
     TBool drawExternalContent = EFalse;
@@ -990,13 +1072,10 @@
         {
         drawExternalContent = ETrue;    
         }
-    if (aIncludeChildren)
+    if (aIncludeChildren && !drawExternalContent)
         {
-        for (TInt i=0; !drawExternalContent && i<Count(); i++)
-             {
-             CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*) &Visual(i);
-             drawExternalContent |= canvasVisual->IsExternalContentDrawingEnabled(ETrue);
-             }
+        drawExternalContent |= RecursiveIsExternalContentDrawingEnabled(
+            const_cast<CHuiCanvasVisual*>(this));        
         }
     return drawExternalContent;       
     }
@@ -1055,6 +1134,12 @@
 
 EXPORT_C void CHuiCanvasVisual::SetLayerUsesAlphaFlag(TBool aEnabled)
     {
+    if (aEnabled == KWindowIsDSAHost)
+        {
+        iCanvasVisualData->iCanvasFlags |= EHuiCanvasFlagDisableCanvasContent;        
+        ClearCommandSet();
+        return;    
+        }    
     iCanvasVisualData->iLayerUsesAlphaFlag = aEnabled;
     }
 
@@ -1118,7 +1203,8 @@
         }
     else // background surface was removed
         {
-        EnableTransformationL(EFalse);
+        iCanvasVisualData->iCanvasFlags &= (~EHuiCanvasFlagDisableCanvasContent);    
+        //EnableTransformationL(EFalse);
         }
     }
 
@@ -1154,17 +1240,39 @@
         }
     }
 
-void CHuiCanvasVisual::DrawStoredVisualRenderBuffer() const
+void CHuiCanvasVisual::DrawStoredVisualRenderBuffer(TInt aCanvasDrawMode) const
     {
     CHuiCanvasGc& gc = CanvasGc();
+    CHuiCanvasVisual* visual = NULL; 
+    TBool transparent = EffectiveOpacity() < 1.0f;
+    gc.SetDrawMode((THuiCanvasDrawMode)aCanvasDrawMode);
+    if (transparent)
+        {
+        gc.EnableEffectiveOpacity(ETrue);  
+        visual = gc.Visual();
+        gc.SetVisual(*this);
+        gc.SetDrawMode(EHuiCanvasDrawModeBlend);
+        }
     THuiRealPoint dest_point = DisplayRect().iTl;
     CHuiCanvasRenderBuffer *stored = iCanvasVisualData->iStoredRenderBuffer;
+
     gc.DrawImage(*stored, dest_point);
+    if (transparent)
+        {
+        gc.SetVisual(*visual);
+        gc.EnableEffectiveOpacity(EFalse);
+        }
     }
 
-void CHuiCanvasVisual::DrawStoredFullScreenRenderBuffer(CHuiGc& aGc) const
+void CHuiCanvasVisual::DrawStoredFullScreenRenderBuffer(TInt aCanvasDrawMode, CHuiGc& aGc) const
     {
     if (!Display()) return;
+    if (!iHuiLayoutPrivateData->iGc)
+        {
+        CHuiRenderPlugin& renderplugin = CHuiStatic::Renderer();
+		// deleted in CHuiLayout destructor or CHuiCanvasVisual::FreeRenderBuffer when not needed anymore
+        iHuiLayoutPrivateData->iGc = renderplugin.CreateCanvasGcL();
+        }
     CHuiCanvasGc& gc = *iHuiLayoutPrivateData->iGc;
     gc.SetGc(aGc);
     gc.SetDefaults();
@@ -1182,8 +1290,23 @@
     
     THuiRealPoint dest_point = DisplayRect().iTl;
     CHuiCanvasRenderBuffer *stored = StoredRenderBuffer();
-    gc.DrawImage(*stored, dest_point); 
-
+    TBool transparent = EffectiveOpacity() < 1.0f;
+    CHuiCanvasVisual* visual = NULL; 
+	gc.SetDrawMode((THuiCanvasDrawMode)aCanvasDrawMode);
+    if (transparent)
+        {
+        
+        gc.EnableEffectiveOpacity(ETrue);  
+        visual = gc.Visual();
+        gc.SetVisual(*this);
+        gc.SetDrawMode(EHuiCanvasDrawModeBlend);
+        }
+    gc.DrawImage(*stored, dest_point);
+    if (transparent)
+        {
+        gc.SetVisual(*visual);
+        gc.EnableEffectiveOpacity(EFalse);
+        }
     gc.PopTransformationMatrix();
     }
 
@@ -1195,24 +1318,47 @@
             {
             delete iCanvasVisualData->iStoredRenderBuffer;
             iCanvasVisualData->iStoredRenderBuffer = NULL;
+            delete iHuiLayoutPrivateData->iGc;
+            iHuiLayoutPrivateData->iGc = NULL;
             }
         }
     }
 
+// Goes through visual hierarchy and checks if any visual has command buffers
+// or other drawable content.
+TBool CHuiCanvasVisual::RecursiveHasCommandBuffers(CHuiVisual* aVisual)
+    {
+    TBool hasCommandBuffers = EFalse;
+    
+    const TInt count = aVisual->Count();
+    for(TInt i = 0; i < count; ++i)
+        {
+        CHuiVisual* visual = &aVisual->Visual(i);
+        // If visual is a canvas one, then QueryHasDrawableContent returns 
+        // HasCommandBuffers(EFalse)
+        hasCommandBuffers |= visual->QueryHasDrawableContent();
+        if ( hasCommandBuffers )
+            {
+            break;
+            }
+        
+        hasCommandBuffers |= RecursiveHasCommandBuffers( visual );
+        if ( hasCommandBuffers )
+            {
+            break;
+            }
+        }
+    
+    return hasCommandBuffers;    
+    }
+
 EXPORT_C TBool CHuiCanvasVisual::HasCommandBuffers(TBool aIncludeChildren) const
     {
     TBool hasCommandBuffers = iCanvasVisualData->iCanvasPainter->HasCommandBuffers();
-    if (aIncludeChildren)
+    if (aIncludeChildren && !hasCommandBuffers)
         {
-        for (TInt i=0; i<Count(); i++)
-            {
-            CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*) &Visual(i); // Dynamic cast is too slow for us ;)
-            hasCommandBuffers |= canvasVisual->HasCommandBuffers(aIncludeChildren);
-            if (hasCommandBuffers)
-                {
-                break;
-                }
-            }
+        // Include children branch - just check if there is something to draw.
+        hasCommandBuffers |= RecursiveHasCommandBuffers(const_cast<CHuiCanvasVisual*>(this));
         }
     return hasCommandBuffers;
     }
@@ -1267,4 +1413,74 @@
     return THuiLayoutChildRectLayoutUpdateNeeded;
     }
 
+void CHuiCanvasVisual::VisualExtension(const TUid& aExtensionUid, TAny** aExtensionParams)
+    {
+    if (aExtensionUid == KHuiVisualQueryUid && aExtensionParams && *aExtensionParams)
+        {
+        THuiVisualQueryParams* params = static_cast<THuiVisualQueryParams*>(*aExtensionParams);
+        switch (params->iQueryType)
+            {
+        case THuiVisualQueryParams::EQueryCanvasFlags:
+            params->iValue = CanvasFlags();
+            params->iResult = KErrNone;
+            break;
+        case THuiVisualQueryParams::EQueryExternalContentDrawingEnabled:
+            params->iValue = IsExternalContentDrawingEnabled(EFalse);
+            params->iResult = KErrNone;
+            break;
+        case THuiVisualQueryParams::EQueryHasDrawableContent:
+            params->iValue = HasCommandBuffers(EFalse) || IsBackgroundDrawingEnabled();
+            params->iResult = KErrNone;
+            break;
+        default:
+            break;
+            }
+        }
+    else
+	    {
+		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/HuiCmdBufferBrush.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiCmdBufferBrush.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -167,7 +167,10 @@
 
     CHuiCanvasRenderBuffer* renderbuffer = NULL;
     renderbuffer = iVisual->Env().CanvasTextureCache().FindCachedRenderBuffer(*iVisual);
-    iCanvasGc.ClearRenderBuffer(*renderbuffer, aRectangle /*TRect(0,0,iVisual->DisplayRect().Size().iWidth, iVisual->DisplayRect().Size().iHeight)*/);
+    if (renderbuffer)
+        {
+        iCanvasGc.ClearRenderBuffer(*renderbuffer, aRectangle /*TRect(0,0,iVisual->DisplayRect().Size().iWidth, iVisual->DisplayRect().Size().iHeight)*/);
+        }
     }
 void CHuiCmdBufferBrush::DrawDrawingCommands(TInt aAction, CHuiGc &aGc, TRect aClippingRectangle, 
                                              TPtrC8 aCommands, CHuiCanvasCommandBuffer *buf, const TRegion &reg) const
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiControlGroup.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiControlGroup.cpp	Fri Mar 19 09:43:21 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
@@ -48,22 +48,29 @@
 
 	
 CHuiControlGroup::~CHuiControlGroup()
-    {    
-    iUnhandledEventObservers.Close();
+    {   
+    
+       
+        iEnv.RemoveTheControlGroup(iResourceId);
     
-    // The group owns the controls, so it must destroy them.
-    // Destroy in reverse order so that references will be removed in 
-    // natural order (children of a pane will be removed before the pane).
-    for(TInt i = iControls.Count() - 1; i >= 0; --i)
-        {
-        CHuiControl* c = iControls[i];
-        iControls.Remove(i);
-        delete c;
-        }
-    iControls.Reset();
+        iUnhandledEventObservers.Close();
+            
+            // The group owns the controls, so it must destroy them.
+            // Destroy in reverse order so that references will be removed in 
+            // natural order (children of a pane will be removed before the pane).
+            for(TInt i = iControls.Count() - 1; i >= 0; --i)
+                {
+                CHuiControl* c = iControls[i];
+                iControls.Remove(i);
+                delete c;
+                }
+            iControls.Reset();
+            
+            delete iTransform;
+            iTransform = NULL;
+            HUI_PROBE_REPORT_DESTRUCTED
+      
     
-    delete iTransform;
-    HUI_PROBE_REPORT_DESTRUCTED
     }
     
     
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiDisplay.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiDisplay.cpp	Fri Mar 19 09:43:21 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();
 		    }
 		
@@ -1525,10 +1527,8 @@
                     }
                 break;
             case EClearWithSkinBackground:
-                 TRect skinRect;
-                 TRect dummy;
-                 GetRectForItem(item.SkinBackground(), dummy, skinRect);
                  backgroundTexture = s60skin->BackgroundTexture(item.SkinBackground());
+                 TRect skinRect = s60skin->SkinRect(item.SkinBackground());
                  if (backgroundTexture)
                     {
                     THuiImage background(*backgroundTexture);
@@ -1622,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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiEnv.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -47,6 +47,8 @@
 #include "huicanvastexturecache.h"
 #include "HuiFxEngine.h"
 
+#include "huisynchronizationobserver.h"
+
 #define HUI_HIRES_TIMER
 
 
@@ -1069,6 +1071,8 @@
             }
         }
 
+    DoSynchronize();
+        
     iCurrentDisplay = NULL; // informs the egosystem that the drawing is done.
     CHuiStatic::ReportNewFrame();
     
@@ -1762,3 +1766,64 @@
     {
     return iMemoryLevel;
     }
+
+EXPORT_C void CHuiEnv::Synchronize(TInt aId, MHuiSynchronizationObserver* aObserver)
+    {
+    iSynchObserver = aObserver;
+    iSynchId = aId;
+    
+    if ( aObserver )
+        {
+        ContinueRefresh();
+        }
+    }
+
+void CHuiEnv::DoSynchronize()
+    {
+    if ( !iSynchObserver )
+        {
+        return;
+        }
+
+    // Synchronize commands before signalling through P&S
+    for(TInt i = 0; i < iDisplays.Count(); ++i)
+        {          
+        if ( ( iDisplays[i]->DisplayType() != CHuiDisplay::EDisplayOffScreenBuffer ) 
+             && ( iDisplays[i]->ScreenBufferObserver() == NULL ) )
+            {
+            MakeCurrent(*iDisplays[i]);
+            iDisplays[i]->RenderSurface().Finish();
+            }
+        }
+
+    iSynchObserver->Synchronized( iSynchId );
+    iSynchObserver = NULL;
+    }
+
+void CHuiEnv::RemoveTheControlGroup(TInt aId)
+    {
+    TInt i;
+
+    for(i = 0; i < iLoadedGroups.Count(); ++i)
+        {
+        if(iLoadedGroups[i]->ResourceId() == aId)
+            {
+            // This is control group to delete.
+            CHuiControlGroup* group = iLoadedGroups[i];
+            CancelCommands(group);
+
+            for (TInt ii = iDisplays.Count()-1; ii>=0; ii--)
+                {
+                TInt index = iDisplays[ii]->Roster().Find(group);
+                if (index != KErrNotFound)
+                    {
+                    iDisplays[ii]->Roster().Hide(iDisplays[ii]->Roster().ControlGroup(index));
+                    }
+                }
+            
+            iLoadedGroups.Remove(i);
+            
+            }
+        }
+    }
+
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffect.cpp	Fri Mar 19 09:43:21 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/HuiFxEffectCache.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffectCache.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -63,11 +63,17 @@
 void CHuiFxEffectCache::CreateL(MHuiFxEffectCacheNode *aNode)
     { // registration of fxml file
     MHuiFxEffectCacheNode *cachedNode = Find(aNode);
+    MHuiFxEffectCacheNode *dupNode = FindDuplicate(aNode);
     if (cachedNode)
        { // found in cache => duplicate registration => no need to do anything
        cachedNode->Ref(1);
        delete aNode;
        }
+    else if (dupNode)
+        { // found same file already being loaded
+        dupNode->Ref(1);
+        delete aNode;
+        }
     else
        { // not found in cache, so insert it and start parsing the effect.
        TInt id = UniqueId();
@@ -119,14 +125,14 @@
        TInt count = cachedNode->Ref(-1);
        if (count == 0)
            {
+           Remove(iCachedEffects, cachedNode);
            delete cachedNode;
-           Remove(iCachedEffects, cachedNode);
            }
        }
    if (cachedNode != aNode)
        { // this node was not found in iCachedEffects array, so it needs to be in iDuplicateEffects array
+       Remove(iDuplicateEffects, aNode);
        delete aNode;
-       Remove(iDuplicateEffects, aNode);
        }
    }
 
@@ -161,6 +167,19 @@
 	}
    return 0;
    }
+MHuiFxEffectCacheNode *CHuiFxEffectCache::FindDuplicate(MHuiFxEffectCacheNode *aNode)
+    {
+    TInt size = iDuplicateEffects.Count();
+    for(TInt i=0;i<size;i++)
+        {
+        MHuiFxEffectCacheNode *node = iDuplicateEffects[i].iNode;
+        if (Compare(node, aNode))
+            {
+            return node;
+            }
+        }
+    return 0;
+    }
 
 TInt CHuiFxEffectCache::FindById(TInt aId)
     {
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffectParser.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEffectParser.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -278,7 +278,7 @@
 #ifdef _HUI_FX_PARSER_LOGGING
             __ALFFXLOGSTRING("CHuiFxEffectParser::ParseNodeL - ENodeTypeUnknown");
 #endif
-            FAIL(KErrGeneral, _L("Unknown node type"));
+            __ALFFXLOGSTRING1("CHuiFxEffectParser::ParseNodeL : WARNING - Node tag <%S> is not supported.", &(aNode->NodeName()));
             break;
             }
             
@@ -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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxEngine.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -77,6 +77,26 @@
     return EFalse;
 #endif
     }
+
+TBool CHuiFxEngine::FxmlUsesInput1(CHuiFxEffect& aEffect)
+    {
+    RArray<THuiFxVisualSrcType> array;
+    aEffect.FxmlVisualInputs(array);
+ 
+    TInt c = array.Count();
+    for(TInt i = 0; i<c; i++)
+        {
+        THuiFxVisualSrcType val = array[i];
+        if (val == EVisualSrcInput1)
+            {
+            array.Close();
+            return ETrue;
+            }
+        }
+    array.Close();
+    return EFalse;    
+    }
+
     
 EXPORT_C void CHuiFxEngine::RegisterEffectL(const TDesC &aFileName)
     {
@@ -150,7 +170,6 @@
 #ifdef HUIFX_EFFECTCACHE_ENABLED
     CHuiFxEffectCacheEffectNode *node = new (ELeave) CHuiFxEffectCacheEffectNode(aFileName, aEffect, aVisual, &iExtRect, this);
     node->SetEffectEndObserver( aEffectEndObserver, aHandle );
-    aFlags |= KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
     node->SetEffectFlags( aFlags );
     CleanupStack::PushL(node);
     iCache->FindOrCreateL(node); // takes ownership
@@ -206,7 +225,6 @@
 		aFlags |= KHuiFxWaitGroupSyncronization;
 		node->SetEffectGroup(aGroup);
     	}
-    aFlags |= KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
     node->SetEffectFlags( aFlags );
     
     CleanupStack::PushL(node);
@@ -347,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;
         }
@@ -566,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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxGroupLayer.cpp	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxLayer.cpp	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxParameterManager.cpp	Fri Mar 19 09:43:21 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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiFxVisualLayer.cpp	Fri Mar 19 09:43:21 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/HuiLayout.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiLayout.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -56,8 +56,7 @@
     {
     CHuiVisual::ConstructL();
     iHuiLayoutPrivateData = new (ELeave) THuiLayoutPrivateData;
-    CHuiRenderPlugin& renderplugin = CHuiStatic::Renderer();
-    iHuiLayoutPrivateData->iGc = renderplugin.CreateCanvasGcL();
+    iHuiLayoutPrivateData->iGc = NULL;
     }
 
 
@@ -74,6 +73,7 @@
 	        }
 	    iHuiLayoutPrivateData->iChildren.Reset();
 	    delete iHuiLayoutPrivateData->iGc;
+	    iHuiLayoutPrivateData->iGc = NULL;
 	    delete iHuiLayoutPrivateData;
     	}
     }
@@ -311,12 +311,8 @@
     TInt count = Count();
     for(TInt i = 0; i < count; ++i)
         {
-        //Ignore inactive child visuals
-        if ( iHuiLayoutPrivateData->iChildren[i]->Flags() & EHuiVisualFlagInactive )
-        	{
-        	continue;
-        	}
-        UpdateChildLayout(i, aTransitionTime);
+        // size and positio changes must go also to inactive visuals
+        UpdateChildLayout(i, aTransitionTime); 
         }
 
     CHuiVisual::UpdateChildrenLayout(aTransitionTime);
@@ -687,7 +683,7 @@
     TInt count = Count();
     for(TInt i = 0; i < count; ++i)
         {
-        if (Flags() & EHuiVisualFlagInactive)
+        if (iHuiLayoutPrivateData->iChildren[i]->Flags() & EHuiVisualFlagInactive)
             {
             // No need to clear inactive children
             continue;
@@ -1120,6 +1116,13 @@
 void CHuiLayout::DrawStoredBitmap(CHuiGc &aGc) const
     {
     if (!Display()) return;
+    
+    if (!iHuiLayoutPrivateData->iGc)
+        {
+        CHuiRenderPlugin& renderplugin = CHuiStatic::Renderer();
+		// deleted in destructor or CHuiCanvasVisual::FreeRenderBuffer when not needed anymore
+        iHuiLayoutPrivateData->iGc = renderplugin.CreateCanvasGcL(); 
+        }
     CHuiCanvasGc& gc = *iHuiLayoutPrivateData->iGc;
     gc.SetGc(aGc);
     gc.SetDefaults();
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiRosterImpl.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiRosterImpl.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -527,10 +527,12 @@
     TInt j = 0;
 
     CHuiDisplay* display = aDisplay ? aDisplay : iDisplay;
+    
+    ASSERT(display!=NULL);
 
     if (iCanvasRenderBuffer && iCanvasGc)
         {
-        DrawSelfFrozen(aGc, aDisplay);
+        DrawSelfFrozen(aGc, display);
         return;
         }
 
@@ -1214,13 +1216,11 @@
         for(TInt i = 0; i < visualCount; ++i)
             {
             // Ignore inactive visuals
-            if ( entry.iRootVisuals[i]->Flags()& EHuiVisualFlagInactive )
+            if ( !(entry.iRootVisuals[i]->Flags()& EHuiVisualFlagInactive) )
                 {
-                continue; 
-                }
-            
-            // This will clear the change flags of the entire tree of visuals.
-            entry.iRootVisuals[i]->ClearChanged();
+                // This will clear the change flags of the entire tree of visuals.
+                entry.iRootVisuals[i]->ClearChanged(); 
+                }            
             }
         }
     }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiS60Skin.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiS60Skin.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -72,7 +72,9 @@
     if (iSkinSrvConnected)
         iSkinSrvSession.Close();
         
-   delete iBackgroundBitmap;
+    delete iBackgroundBitmap;
+    iCachedSkinItems.ResetAndDestroy();
+    iCachedSkinItems.Close();
     }
 
 
@@ -135,33 +137,45 @@
 
 void CHuiS60Skin::UpdateBackgroundL()
     {
-    if(iBackgroundTexture)
-         {
-         iBackgroundTexture->Reset();
-         delete iBackgroundTexture;
-         iBackgroundTexture = 0;
-         }
-
-    HUI_DEBUG1(_L("CHuiS60Skin::UpdateBackgroundL - Free memory in the beginning: %i"), HuiUtil::FreeMemory());
-    iBackgroundTexture = CreateSkinBackgroundL(KAknsIIDQsnBgScreen);
-    iBackgroundTexture->SetSkinContent(ETrue);
-    iBackgroundTexture->iContentObservers.AppendL(*this);
-
+    if(!iBackgroundTexture)
+        {
+        iBackgroundTexture = CreateSkinBackgroundL(KAknsIIDQsnBgScreen);
+        iBackgroundTexture->SetSkinContent(ETrue);
+        iBackgroundTexture->iContentObservers.AppendL(*this);
+        }
+    else if(iSkinChanged)
+        {
+        iBackgroundTexture->Reset();
+        delete iBackgroundBitmap;
+        iBackgroundBitmap = NULL;
+        iBackgroundBitmap = CHuiStatic::GetBgBitmapLC(KAknsIIDQsnBgScreen); 
+        CleanupStack::Pop(iBackgroundBitmap);
+        // update iBackgroundRect as well 
+        TRect dummy;
+        GetRectForItem(KAknsIIDQsnBgScreen, dummy, iBackgroundRect);
+        iBackgroundTexture->UploadL(*iBackgroundBitmap,NULL,EHuiTextureUploadFlagRetainResolution );                
+        iBackgroundTexture->SetSkinContent(ETrue);
+        }
+    else
+        {
+        // there should be already up-to-date background texture
+        }
     HUI_DEBUG1(_L("CHuiS60Skin::UpdateBackgroundL - Free memory at exit: %i"), HuiUtil::FreeMemory());
     }
 
 
-void CHuiS60Skin::SkinContentChanged()
+EXPORT_C void CHuiS60Skin::SkinContentChanged()
     {
     iSkinChanged = ETrue;
     }
 
-void CHuiS60Skin::SkinConfigurationChanged(
+EXPORT_C void CHuiS60Skin::SkinConfigurationChanged(
     const TAknsSkinStatusConfigurationChangeReason aReason )
     {
     
     }
-void CHuiS60Skin::SkinPackageChanged(
+
+EXPORT_C void CHuiS60Skin::SkinPackageChanged(
     const TAknsSkinStatusPackageChangeReason aReason )
     {
     
@@ -213,11 +227,12 @@
 EXPORT_C void CHuiS60Skin::NotifyDisplaySizeChangedL()
     {
     // The background is now different.
-    iReloadBackground = ETrue;
     SkinContentChanged(); // for changing the iSkinChanged flag
     Env().NotifySkinChangedL();
     Env().TextStyleManager().NotifyDisplaySizeChangedL();
     ReloadBgTexturesL();
+
+    iSkinChanged = EFalse;
     }
 
 
@@ -300,8 +315,9 @@
         delete bgTexture.iBackgroundTexture;
         bgTexture.iBackgroundTexture = NULL;
         }
-    ((TPrivData*)(iSpare))->iBackgrounds.Reset(); 
+    ((TPrivData*)(iSpare))->iBackgrounds.Reset();
     
+    iCachedSkinItems.ResetAndDestroy(); // reset cached bg images & rects
     }
     
     
@@ -317,47 +333,82 @@
     MAknsSkinInstance* skin = SkinInstance();
     CHuiTexture* texture = CHuiTexture::NewL();
     
-    CleanupStack::PushL(texture);            
-    if(iSkinChanged)
-         {
-     
-        delete iBackgroundBitmap; 
-        iBackgroundBitmap = NULL;
-        
-        if (skin)
-            {
-            TRect dummy;
-            TRect skinRect;
-            GetRectForItem(aID, dummy, skinRect);
-    
-            iBackgroundBitmap = new (ELeave) CFbsBitmap();
-            User::LeaveIfError( iBackgroundBitmap->Create(skinRect.Size(), EColor64K) );        
-    
-            CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(iBackgroundBitmap);
-            CleanupStack::PushL(device);
+    CleanupStack::PushL(texture);
     
-            CFbsBitGc* gc = 0;
-            User::LeaveIfError( device->CreateContext(gc) );
-            CleanupStack::PushL(gc);
-            iSkinControlContext->SetRect(skinRect);
-            iSkinControlContext->SetBitmap(aID);
-    
-            AknsDrawUtils::DrawBackground(skin, iSkinControlContext, NULL, *gc, TPoint(0,0), skinRect,
-                              KAknsDrawParamDefault);
-    
-            CleanupStack::PopAndDestroy(gc);
-            CleanupStack::PopAndDestroy(device);
+    if (skin)
+        {
+        TRect skinrect;
+        TRect dummy;
+        GetRectForItem(aID, dummy, skinrect);
+
+        CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
+        CleanupStack::PushL(bitmap);
+        User::LeaveIfError( bitmap->Create(skinrect.Size(), EColor64K) );        
+
+        CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(bitmap);
+        CleanupStack::PushL(device);
+
+        CFbsBitGc* gc = 0;
+        User::LeaveIfError( device->CreateContext(gc) );
+        CleanupStack::PushL(gc);
+        iSkinControlContext->SetRect(skinrect);
+        iSkinControlContext->SetBitmap(aID);
+
+        AknsDrawUtils::DrawBackground(skin, iSkinControlContext, NULL, *gc, TPoint(0,0), skinrect,
+                          KAknsDrawParamDefault);
+
+        CleanupStack::PopAndDestroy(gc);
+        CleanupStack::PopAndDestroy(device);
+
+        texture->UploadL(*bitmap,NULL,EHuiTextureUploadFlagRetainResolution );            
+        CleanupStack::PopAndDestroy(bitmap);
+        }
+    else
+        {
+        CFbsBitmap* bitmap = SearchCachedSkinItemBitmap(aID);
+        if(iSkinChanged || !bitmap)
+            {
+            TRect skinrect;
+            TRect dummy;
+            GetRectForItem(aID, dummy, skinrect);
+
+            if( aID == KAknsIIDQsnBgScreen) // handle normal background id differently
+                {
+                delete iBackgroundBitmap; 
+                iBackgroundBitmap = NULL;
+                bitmap = CHuiStatic::GetBgBitmapLC(aID);
+                CleanupStack::Pop(bitmap);
+                iBackgroundBitmap = bitmap;
+                iBackgroundRect = skinrect;
+                }
+            else // others are cached in skin item array
+                {
+                bitmap = CHuiStatic::GetBgBitmapLC(aID);
+                TInt index = SearchCachedSkinItemIndex(aID);
+                if( index == KErrNotFound ) // add new
+                    {
+                    CSkinItem* newSkinItem = new (ELeave) CHuiS60Skin::CSkinItem();
+                    CleanupStack::PushL(newSkinItem);
+                    newSkinItem->iId = aID;
+                    newSkinItem->iSkinRect = skinrect;
+                    newSkinItem->iBitmap = bitmap;
+                    User::LeaveIfError(iCachedSkinItems.Append(newSkinItem));
+                    CleanupStack::Pop(newSkinItem);
+                    }
+                else // modify existing
+                    {
+                    iCachedSkinItems[index]->iSkinRect = skinrect;
+                    delete iCachedSkinItems[index]->iBitmap;
+                    iCachedSkinItems[index]->iBitmap = NULL; 
+                    iCachedSkinItems[index]->iBitmap = bitmap;
+                    }
+                CleanupStack::Pop(bitmap);                
+                }
             }
-        else
-            {
-            iBackgroundBitmap = CHuiStatic::GetBgBitmapLC(aID);   
-            CleanupStack::Pop( iBackgroundBitmap );
-            }
-         }
-    texture->UploadL(*iBackgroundBitmap,NULL,EHuiTextureUploadFlagRetainResolution );            
-    
+        texture->UploadL(*bitmap,NULL,EHuiTextureUploadFlagRetainResolution );            
+        }
+
     CleanupStack::Pop(texture);
-    iSkinChanged = EFalse;
     return texture;
     }
 
@@ -368,6 +419,8 @@
         // no need to render the skin backgrounds separately on bitgdi
         return;
         }
+    iCachedSkinItems.ResetAndDestroy(); // reset cached bg images & rects
+    
     TBackgroundTexture bgTexture;
     TInt itemCount = ((TPrivData*)(iSpare))->iBackgrounds.Count(); 
     for (TInt index = 0; index < itemCount; index++)
@@ -425,3 +478,62 @@
         }
     return NULL;
     }
+
+
+TInt CHuiS60Skin::SearchCachedSkinItemIndex(const TAknsItemID& aId)
+    {
+    TInt cacheditemsCount = iCachedSkinItems.Count();
+    for(TInt i = 0; i < cacheditemsCount; i++ )
+        {
+        if( iCachedSkinItems[i]->iId == aId )
+            {
+            return i;
+            }
+        }
+
+    HUI_DEBUG2(_L("CHuiS60Skin::SeachCachedSkinItemIndex - cached TAknsItemID %i %i (iMajor, iMinor) not found"), aId.iMajor, aId.iMinor );
+
+    return KErrNotFound;
+    }
+
+TRect CHuiS60Skin::SearchCachedSkinItemRect(const TAknsItemID& aId)
+    {
+    TRect returnRect = TRect();
+    if(aId == KAknsIIDQsnBgScreen)
+        {
+        returnRect = iBackgroundRect;
+        }
+    else
+        {
+        TInt index = SearchCachedSkinItemIndex(aId);
+        if(index != KErrNotFound )
+            {
+            returnRect = iCachedSkinItems[index]->iSkinRect;
+            }
+        }   
+    return returnRect;
+    }
+
+CFbsBitmap* CHuiS60Skin::SearchCachedSkinItemBitmap(const TAknsItemID& aId)
+    {
+    CFbsBitmap* bitmap = NULL;
+    if(aId == KAknsIIDQsnBgScreen)
+        {
+        bitmap = iBackgroundBitmap;
+        }
+    else
+        {
+        TInt index = SearchCachedSkinItemIndex(aId);
+        if(index != KErrNotFound )
+            {
+            bitmap = iCachedSkinItems[index]->iBitmap;
+            }
+        }   
+    return bitmap;    
+    }
+
+
+TRect CHuiS60Skin::SkinRect(const TAknsItemID& aID)
+    {
+    return SearchCachedSkinItemRect(aID);
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/HuiStatic.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiStatic.cpp	Fri Mar 19 09:43:21 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/HuiVisual.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/HuiVisual.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -39,6 +39,8 @@
 #include "HuiCmdBufferBrush.h"
 #include "huicanvasrenderbuffer.h"
 
+#include "huiextension.h"
+
 struct CHuiVisual::THuiVisualPrivateData
     {
 public: // Functions
@@ -67,8 +69,7 @@
     
     // Data
     RArray<TTacticon> iTacticons;
-    CHuiDropShadow* iDropShadow;
-    TRect iPreviousDrawnTvOut; 
+    CHuiDropShadow* iDropShadow; 
     CHuiFxEffect* iEffect;
     CHuiFxEffectParser* iEffectParser;
     MHuiEffectable *iEffectable;
@@ -218,7 +219,7 @@
         	CHuiDisplay* display = &Env().Display(i);
         	if (&(display->Roster()) == &roster)
         		{
-				const TRect& previousDirtyRect = display->IsDisplayTypeTvOut() ? iVisualData->iPreviousDrawnTvOut : iPreviousDrawn;
+				const TRect& previousDirtyRect = iPreviousDrawn;
 				TRect empty;
         		display->CombineAndAddDirtyRegion(previousDirtyRect, empty);
         		}
@@ -690,6 +691,34 @@
 
 EXPORT_C THuiRealRect CHuiVisual::DisplayRect() const __SOFTFP
     {
+    // if this visual is wserv owned, we can take some shortcuts
+    // when calculating the displayrect (ie. none of the "advanced"
+    // functionality is used
+    if (iFlags & EHuiVisualFlagWserv)
+        {
+        TReal x = iPos.iX.iInterpolationStartValue;
+        TReal y = iPos.iY.iInterpolationStartValue;
+        TReal width = iSize.iX.iInterpolationStartValue;
+        TReal height = iSize.iY.iInterpolationStartValue;
+        
+        const CHuiVisual* iter = this;
+        while(iter)
+            {
+            // Move up in the tree.
+            iter = iter->iLayout;
+            if(iter)
+                {
+                x+=iter->iPos.iX.iInterpolationStartValue;
+                y+=iter->iPos.iY.iInterpolationStartValue;
+                }
+            }
+
+        iDisplayRect.iTl.iX = x;
+        iDisplayRect.iTl.iY = y;
+        iDisplayRect.iBr.iX = x+width;
+        iDisplayRect.iBr.iY = y+height;
+        return iDisplayRect;
+        }
     // Recalculate and cache as necessary. 
     TBool recalculationNeeded = ETrue;
     
@@ -1483,7 +1512,7 @@
             ExpandRectWithContent(dirty);
             }
 
-		TRect& previousDrawn = display->IsDisplayTypeTvOut() ? iVisualData->iPreviousDrawnTvOut : iPreviousDrawn;
+		TRect& previousDrawn = iPreviousDrawn;
         
         // CombineAndAddDirtyRegion modifies "dirty" param by transforming it.
         // "previousDrawn" is supposed to be already transformed. 
@@ -2153,3 +2182,50 @@
     delete iVisualData->iEffectParser;
     iVisualData->iEffectParser = aEffectParser;
     }
+
+TInt CHuiVisual::QueryCanvasFlags()
+    {
+    THuiVisualQueryParams p;
+    p.iQueryType = THuiVisualQueryParams::EQueryCanvasFlags;
+    p.iValue = 0;
+    p.iResult = KErrNotSupported;
+    TAny* ptr = &p;
+    
+    VisualExtension(KHuiVisualQueryUid, &ptr);
+    
+    // If visual does not support this extension, assume 0
+    
+    return ( p.iResult == KErrNone ) ? p.iValue : 0;
+    }
+    
+TBool CHuiVisual::QueryExternalContentDrawingEnabled()
+    {
+    THuiVisualQueryParams p;
+    p.iQueryType = THuiVisualQueryParams::EQueryExternalContentDrawingEnabled;
+    p.iValue = 0;
+    p.iResult = KErrNotSupported;
+    TAny* ptr = &p;
+    
+    VisualExtension(KHuiVisualQueryUid, &ptr);
+    
+    // If visual does not support this extension, assume
+    // that visual does not have external content drawing enabled.
+    
+    return ( p.iResult == KErrNone ) && p.iValue;
+    }
+    
+TBool CHuiVisual::QueryHasDrawableContent()
+    {
+    THuiVisualQueryParams p;
+    p.iQueryType = THuiVisualQueryParams::EQueryHasDrawableContent;
+    p.iValue = 0;
+    p.iResult = KErrNotSupported;
+    TAny* ptr = &p;
+    
+    VisualExtension(KHuiVisualQueryUid, &ptr);
+
+    // If visual does not support this extension, assume
+    // that it has something to draw.
+    
+    return p.iValue || ( p.iResult != KErrNone );
+    }
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvasgc.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvasgc.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -1193,7 +1193,19 @@
                 // Could copy only needed rects to avoid excessive clipping
                 iDelayedClipRegion.Copy(iClippingRegion);
                 break;
-                }                                
+                }
+
+		    // both points lie outside - but the line may still intersect the region, 
+            // so represent the line as a rect and try an intersection test...
+            TRect lineBoundingRect(start, end);
+            lineBoundingRect.Normalize();
+            lineBoundingRect.iBr += TPoint(1, 1);
+            if (IsClipped(lineBoundingRect, iClippingRegion) != EFullyOutside)
+                {
+                iDelayedClipRegion.Copy(iClippingRegion);
+                vis1 = EPartialOverlap;
+                break;
+                }                    
             }                    
         }        
     if (vis1 == EFullyOutside && vis2 == EFullyOutside)
@@ -1211,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())        
@@ -1224,7 +1243,7 @@
       	iGc->PushClip();
         iDelayedClipRectPushed = ETrue;
         
-        if (MaxNumberOfClipRects() == 1)
+        if (clipOneByOne)
             {
             iGc->Clip(iDelayedClipRegion[iDelayedClipCount]);                            
             }
@@ -1234,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	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswshwgc.cpp	Fri Mar 19 09:43:21 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 );
@@ -2067,7 +2081,8 @@
             TRgb oldColor = gc->PenColor();            
             gc->SetPenAlpha(0);
             gc->SetPenColor(KRgbBlue);
-            gc->Clear(); 
+            TRect rect = aUpdateRegion.BoundingRect();
+            gc->Clear(rect); 
             gc->SetPenAlpha(oldAlpha);
             gc->SetPenColor(oldColor);
             }
@@ -2106,6 +2121,7 @@
     // Set new clipping region which does not clip anything. 
     // We want always draw aUpdateRegion fully to the aRenderbuffer. 
     TRect displayArea = iCanvasGc->Gc()->DisplayArea(); 
+    
     iCanvasGc->Gc()->SetClip(displayArea); // this call does not transform region anymore
     
     // We use translation to get screen coordinates to match render buffer coordinates
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp	Fri Mar 19 09:43:21 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();
@@ -2488,7 +2532,9 @@
 
 TInt CHuiCanvasWsPainter::EnableRenderBuffer(TBool aEnable)
     {
-    if (aEnable != iCanvasWsGc->IsRenderBufferEnabled())
+    iEnableRenderBuffer = aEnable;
+    
+    if (iCanvasWsGc && ( aEnable != iCanvasWsGc->IsRenderBufferEnabled() ) )
         {
         if (aEnable)
             {
@@ -2604,6 +2650,11 @@
         {
         oldGc->ClearCache();
         }
+    if ( iCanvasWsGc )
+        {
+        // Forward 'enable render buffer' setting to new GC.
+        iCanvasWsGc->EnableRenderbuffer( iEnableRenderBuffer );
+        }
 
     #ifdef HUI_DEBUG_TRACK_DRAWING
     CHuiCanvasWsGc* realGc = iCanvasWsGc;
--- a/uiacceltk/hitchcock/coretoolkit/src/huicanvaswsswgc.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/huicanvaswsswgc.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -1325,8 +1325,8 @@
 	
 TDisplayMode CHuiCanvasWsSwGc::SelectDisplayMode()
     {
-    TDisplayMode mode = EColor16MA;
-        
+    TDisplayMode mode = EColor16MAP;
+    
     // Note 64K mode cannot be used until separate mask is supported. It might be
     // possible to generate according to dirty region ?
     
@@ -1477,6 +1477,8 @@
         return;
         }
     
+    iBitGc->Reset();
+    
     if (aClear)
         {
         if (iDefaultClipRegion.Count())
--- a/uiacceltk/hitchcock/coretoolkit/src/huigifanimationtexture.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/coretoolkit/src/huigifanimationtexture.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -149,7 +149,10 @@
     {
     if ((iAnimationState & EInitializing) && aTexture.iFrameCount > 1 && aTextureId == iTextureId1)
         {
+        delete iTexture;
         iTexture = iTexture1;
+        delete iTexture2;
+        iTexture2 = NULL;
         TRAP_IGNORE(iTexture2 = &iManager.LoadTextureL(*iFilename,EHuiTextureUploadFlagDefault, iTextureId2, 1))
         iFrameInterval = aTexture.iFrameInterval;
         iFrameCount = aTexture.iFrameCount;
--- a/uiacceltk/hitchcock/goommonitor/bwins/goommonitoru.DEF	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/bwins/goommonitoru.DEF	Fri Mar 19 09:43:21 2010 +0200
@@ -21,4 +21,5 @@
 	?UsesAbsoluteMemTargets@RGOomMonitorSession@@QAEXH@Z @ 20 NONAME ; void RGOomMonitorSession::UsesAbsoluteMemTargets(int)
 	?Connect@RGOomMonitorSession@@QAEHAAVTRequestStatus@@@Z @ 21 NONAME ; int RGOomMonitorSession::Connect(class TRequestStatus &)
 	?AppAboutToStart@RGOomMonitorSession@@QAEXAAVTRequestStatus@@ABVTUid@@@Z @ 22 NONAME ; void RGOomMonitorSession::AppAboutToStart(class TRequestStatus &, class TUid const &)
+	?MemoryAllocationsComplete@RGOomMonitorSession@@QAEXXZ @ 23 NONAME ; void RGOomMonitorSession::MemoryAllocationsComplete(void)
 
--- a/uiacceltk/hitchcock/goommonitor/data/goomconfig.xml	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/data/goomconfig.xml	Fri Mar 19 09:43:21 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="500">
+	<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,10 +27,11 @@
 -->
 	<app_specific_thresholds>
 
-  <app uid="101F857A" low_ram_threshold="26000" good_ram_threshold="28000" target_free_on_startup="26000"></app> <!-- Camera --> 
-  <app uid="200159B2" low_ram_threshold="5000" good_ram_threshold="10000" target_free_on_startup="26000"></app> <!-- MPlayer -->
-  <app uid="102824CD" low_ram_threshold="26000" good_ram_threshold="28000"></app> <!-- Embedded mplayer -->
+  <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 -->
+  <app uid="101FD693" low_ram_threshold="5000" good_ram_threshold="10000" target_free_on_startup="26000"></app> <!-- Flashlite -->
 
 	</app_specific_thresholds>
 
@@ -40,7 +41,7 @@
 <!--		The uid DEFAULT_APP refers to all applications, which priority is not specifically
 		defined in the conf file.
 -->
-		<close_app uid="DEFAULT_APP" priority="80" sync_mode="check">
+		<close_app uid="DEFAULT_APP" priority="80" sync_mode="check" close_timeout="1000" wait_after_close="2000">
 			<app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
 			<app_close_idle_priority idle_time="43200" priority="20"></app_close_idle_priority>
 		</close_app>
@@ -55,6 +56,11 @@
 		<close_app uid="HIGH_PRIORITY_APP" priority="90" sync_mode="check">
 			<app_close_idle_priority idle_time="43200" priority="20"></app_close_idle_priority>
 		</close_app>
+		
+<!-- policy server takes time to release resources aftr apps close
+		this line may be enabled for flashlite and other apps that allocate mem through policy server
+		close_app uid="101FD693" priority="80" sync_mode="check" close_timeout="3000" wait_after_close="5000"
+-->
 	</app_close_settings>
 	
 <!--	The priority of executing each system plugin is defined here.
--- a/uiacceltk/hitchcock/goommonitor/eabi/goommonitoru.DEF	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/eabi/goommonitoru.DEF	Fri Mar 19 09:43:21 2010 +0200
@@ -25,4 +25,5 @@
 	_ZN19RGOomMonitorSession22UsesAbsoluteMemTargetsEi @ 24 NONAME
 	_ZN19RGOomMonitorSession15AppAboutToStartER14TRequestStatusRK4TUid @ 25 NONAME
 	_ZN19RGOomMonitorSession7ConnectER14TRequestStatus @ 26 NONAME
+	_ZN19RGOomMonitorSession25MemoryAllocationsCompleteEv @ 27 NONAME
 
--- a/uiacceltk/hitchcock/goommonitor/inc/goomactionlist.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomactionlist.h	Fri Mar 19 09:43:21 2010 +0200
@@ -201,6 +201,10 @@
         }
     
     void SetPriority(TInt aWgId, TInt aPriority);
+    
+    TBool IsRunningKillAppActions();
+    
+    TUint CurrentPluginRun();
             
 private:
     
@@ -244,6 +248,8 @@
     RArray<TUint> iAppsProtectedByPlugins;
     
     TBool iRunningKillAppActions;
+    
+    TUint iCurrentPluginRun;
     };
 
 #include "goomactionlist.inl"
--- a/uiacceltk/hitchcock/goommonitor/inc/goomactionref.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomactionref.h	Fri Mar 19 09:43:21 2010 +0200
@@ -49,7 +49,7 @@
     TActionRef(TActionType aType, TInt aPriority, TGOomSyncMode aSyncMode, TInt aRamEstimate, CGOomRunPlugin& aRunPlugin, TUint aWgIndexOfTargetApp);
 
     //constructor for AppClose actions
-    TActionRef(TActionType aType, TInt aPriority, TGOomSyncMode aSyncMode, TInt aRamEstimate, TInt aWgId, TUint aWgIndex);
+    TActionRef(TActionType aType, TInt aPriority, TGOomSyncMode aSyncMode, TInt aRamEstimate, TInt aWgId, TUint aWgIndex, TInt aCloseTimeout = 0, TInt aWaitAfterClose = 0);
     
     TActionType Type() const;
     TUint Priority() const;
@@ -59,6 +59,8 @@
     TInt WgId() const;
     TInt WgIndex() const;
     CGOomRunPlugin& RunPlugin();
+    TInt CloseTimeout() const;
+    TInt WaitAfterClose() const;
 
 private: //data
     
@@ -69,6 +71,8 @@
     TInt iWgId; //For AppClose
     TInt iWgIndex;
     CGOomRunPlugin* iRunPlugin; //For Plugins. Not owned
+    TInt iCloseTimeout; //For AppClose
+    TInt iWaitAfterClose; //For AppClose
     };
 
 #endif /*GOOMACTIONREF_H_*/
--- a/uiacceltk/hitchcock/goommonitor/inc/goomapplicationconfig.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomapplicationconfig.h	Fri Mar 19 09:43:21 2010 +0200
@@ -72,6 +72,7 @@
     TUint iGoodRamThreshold;
     TUint iLowRamThreshold; 
     TUint iTargetFree;
+    TUint iSkipPluginId;
     
 private:
     
--- a/uiacceltk/hitchcock/goommonitor/inc/goomcloseapp.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomcloseapp.h	Fri Mar 19 09:43:21 2010 +0200
@@ -83,6 +83,8 @@
     void ConstructL();
     
     TUint iWgId;
+    TInt iCloseTimeout; 
+    TInt iWaitAfterClose; 
         
     TBool iAppCloserRunning;
     TApaTask iCurrentTask;
--- a/uiacceltk/hitchcock/goommonitor/inc/goomcloseappconfig.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomcloseappconfig.h	Fri Mar 19 09:43:21 2010 +0200
@@ -49,6 +49,9 @@
      */
     inline TUint CalculateCloseAppPriority(const CGOomWindowGroupList& aWindowGroupList, TUint aAppIndexInWindowGroup);
     
+    TInt iCloseTimeout;
+    TInt iWaitAfterClose;
+    
 private:
     
     CGOomCloseAppConfig(TInt32 aId);
--- a/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h	Fri Mar 19 09:43:21 2010 +0200
@@ -25,6 +25,7 @@
 #include <EGL/egl.h>
 #include "goomglobalconfig.h"
 #include "goomwindowgrouplist.h"
+#include "goomtraces.h"
 
 // ---------------------------------------------------------
 // CMemoryMonitor
@@ -40,27 +41,37 @@
 
 typedef EGLBoolean (*NOK_resource_profiling)(EGLDisplay, EGLint, EGLint*, EGLint, EGLint*);
 
+class CGOomSynchTimer;
+
 NONSHARABLE_CLASS(CMemoryMonitor) : public CBase
     {
 public:
     static CMemoryMonitor* NewL();
     ~CMemoryMonitor();
+    
+    enum TGOomTrigger   //How free memory operation was triggered
+            {
+            EGOomTriggerNone = 0,
+            EGOomTriggerFocusChanged,
+            EGOomTriggerRequestMemory,
+            EGOomTriggerThresholdCrossed
+            };
 
 public: // event handlers
     void FreeMemThresholdCrossedL(TInt aAction = 0, TInt aThreshold = 0);
     void AppNotExiting(TInt aWgId);
-    void StartFreeSomeRamL(TInt aTargetFree);
-    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 StartFreeSomeRamL(TInt aTargetFree, TGOomTrigger aTrigger);
+    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;
+    TBool IsSafeToProcessNewRequest(TUint aClientId);
         
     
     void SetActiveClient(TInt aClientId)
@@ -77,22 +88,34 @@
         {
         return iForegroundAppUid;
         } 
-    void SessionInCriticalAllocation(TBool aPostponeMemGood)
+    void SessionInCriticalAllocation(TBool aPostponeMemGood, TUint aClientId)
         {
+        FUNC_LOG;
         if (aPostponeMemGood)
             {
             iPostponeMemGood++;
+            if(iClientsRequestingMemory.Find(aClientId) == KErrNotFound)
+                iClientsRequestingMemory.Append(aClientId);
+            
+            TRACES2("SessionInCriticalAllocation : STARTING Critical Allocations for Client %x, ClientsRequestingMemory Count %d", aClientId, iClientsRequestingMemory.Count());
             }
         else
             {
             iPostponeMemGood--;
-            if(iPostponeMemGood<0)
+            TInt idx = iClientsRequestingMemory.Find(aClientId);
+            if(idx != KErrNotFound)
+                {
+                iClientsRequestingMemory.Remove(idx);
+                TRACES2("SessionInCriticalAllocation : ENDING Critical Allocations for Client %x, ClientsRequestingMemory Count %d", aClientId, iClientsRequestingMemory.Count());
+                }
+            
+             if(iPostponeMemGood<0)
                 {
                 iPostponeMemGood = 0;
                 }
             }
-                        
-        if (iPostponeMemGood == 0)
+        TRACES1("SessionInCriticalAllocation : ClientsRequestingMemory Count %d", iClientsRequestingMemory.Count());    
+        if (iClientsRequestingMemory.Count() == 0)
             {
             DoPostponedMemoryGood();
             }
@@ -103,17 +126,22 @@
     
     TBool NeedToPostponeMemGood()
         {
-        return (iPostponeMemGood != 0);
+        //return (iPostponeMemGood != 0);
+        return (iClientsRequestingMemory.Count() != 0);
         } 
     
+    void WaitAndSynchroniseMemoryState();
+    void SynchroniseMemoryState();
+    
 private:
     CMemoryMonitor();
     void ConstructL();
     TBool FreeGraphicsMemoryAboveThresholdL(TInt& aCurrentFreeMemory);
     void CloseNextApp();
     void RefreshThresholds(TInt aForegroundAppUid = KErrNotFound);
-    void StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority);
+    void StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority, TGOomTrigger aTrigger);
     void AppClosePriorityChanged(TInt aWgId, TInt aPriority);
+    void ResetTargets(TInt aTarget = 0);
     
 public:
     // All members are owned
@@ -174,6 +202,26 @@
     
     TInt iForegroundAppUid;
     TInt iPostponeMemGood;
+    
+    RArray<TUint> iClientsRequestingMemory;
+    
+    TGOomTrigger iTrigger;
+    
+    CGOomSynchTimer* iSynchTimer;
     };
 
+
+
+NONSHARABLE_CLASS(CGOomSynchTimer) : public CTimer
+    {
+    public:
+        static CGOomSynchTimer* NewL(CMemoryMonitor& aMonitor);
+        
+    private:
+        CMemoryMonitor& iMonitor;
+        CGOomSynchTimer(CMemoryMonitor& aMonitor);
+        void RunL();
+    };
+
+
 #endif /*GOOMMEMORYMONITOR_H*/
--- a/uiacceltk/hitchcock/goommonitor/inc/goommonitorclientserver.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/inc/goommonitorclientserver.h	Fri Mar 19 09:43:21 2010 +0200
@@ -34,6 +34,7 @@
 enum TGOomMonitorCmd
     {
     EGOomMonitorRequestFreeMemory,
+    EGOomMonitorMemoryAllocationsComplete,
     EGOomMonitorCancelRequestFreeMemory,
     EGOomMonitorThisAppIsNotExiting,
     EGOomMonitorRequestOptionalRam,
--- a/uiacceltk/hitchcock/goommonitor/inc/goomrunplugin.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomrunplugin.h	Fri Mar 19 09:43:21 2010 +0200
@@ -55,6 +55,8 @@
     // To be called by the CGOomPluginWaiter
     inline void WaitCompleted();
     
+    TUint Id();
+    
 protected:
     
     void ConstructL(CGOomRunPluginConfig& aPluginConfig);    
--- a/uiacceltk/hitchcock/goommonitor/inc/goomwindowgrouplist.h	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/inc/goomwindowgrouplist.h	Fri Mar 19 09:43:21 2010 +0200
@@ -72,6 +72,11 @@
     
     // Find the specificed application in the window group list and return the index
     TInt GetIndexFromAppId(TUint aAppId) const;
+    TInt GetIndexFromWgId(TInt aWgId) const;
+    
+    // Find all the windowgroups in the list that matches application id for this window group
+    void GetAllWgIdsMatchingAppId(TInt aWgId, RArray<TInt> & WgIdList) const;
+    
     
 private:    
 
--- a/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -177,9 +177,30 @@
         else
             actionType = TActionRef::ESystemPlugin;
 
+
+        //get skip plugin config for foreground app
+        TUint foregroundUid = iMonitor.ForegroundAppUid();
+        if(aConfig.GetApplicationConfig(foregroundUid).iSkipPluginId == iPluginList->Uid(pluginIndex))
+            {
+            TRACES2("Skiping plugin %x, configured for app %x", iPluginList->Uid(pluginIndex), foregroundUid);
+            actionsIndex++;
+            continue ; //skip this and continue with next plugin
+            }
+        
+        TUint activeClientId = iMonitor.ActiveClientId();
+        if(activeClientId!=0 && activeClientId!=foregroundUid)
+            {
+            if(aConfig.GetApplicationConfig(activeClientId).iSkipPluginId == iPluginList->Uid(pluginIndex))
+                        {
+                        TRACES2("Skiping plugin %x, configured for app %x", iPluginList->Uid(pluginIndex), foregroundUid);
+                        actionsIndex++;
+                        continue ; //skip this and continue with next plugin
+                        }
+            }
+        
         TActionRef ref = TActionRef(actionType, priority, syncMode, ramEstimate, *(iRunPluginActions[actionsIndex]), aWindowGroupList.GetIndexFromAppId(pluginConfig.TargetApp()));
         iAppsProtectedByPlugins.Append(pluginConfig.TargetApp());
-        TRACES1("Creating Plugin Action Item TargetAppId %x", pluginConfig.TargetApp());
+        TRACES2("Creating Plugin Action Item %x , TargetAppId %x", iPluginList->Uid(pluginIndex), pluginConfig.TargetApp());
         //It is valid to have plugins with equal priority
         User::LeaveIfError(iActionRefs.InsertInOrderAllowRepeats(ref, ComparePriorities));
 
@@ -193,8 +214,8 @@
     {
     FUNC_LOG;
     
-    iActionRefs.Reset();
-    iCurrentActionIndex = 0;
+//    iActionRefs.Reset();
+//    iCurrentActionIndex = 0;
     
     aWindowGroupList.RefreshL();
     
@@ -218,20 +239,23 @@
                 {
                 CGOomCloseAppConfig* appCloseConfig = NULL;
     
-                CApaWindowGroupName* wgName = aWindowGroupList.WgName();
-                __ASSERT_DEBUG(wgName, GOomMonitorPanic(KInvalidWgName));
-    
                 // Get the app ID for the wglist item
                 // This sets the window group name
                 TInt32 appId = aWindowGroupList.AppId(wgIndex, ETrue);
-     
-                if ( !appId  || foregroundUid.iUid ==appId || wgName->IsSystem() || wgName->Hidden() || (iAppsProtectedByPlugins.Find(appId) != KErrNotFound))
+                
+                CApaWindowGroupName* wgName = aWindowGroupList.WgName();
+                __ASSERT_DEBUG(wgName, GOomMonitorPanic(KInvalidWgName));
+
+                    
+                TBool skipped = EFalse;
+                if ( !appId  || foregroundUid.iUid ==appId || (iAppsProtectedByPlugins.Find(appId) != KErrNotFound))
                     {
                     //If the UID is NULL at this point, we assume the process is not an application
                     //and therefore is not a suitable candidate for closure.
                     //We also do not close system or hidden apps.
                     TRACES3("BuildActionListL: Not adding process to action list; UID = %x, wgIndex = %d, wgid = %d", appId, wgIndex, aWindowGroupList.WgId(wgIndex).iId);
-                    TRACES3("BuildActionListL: IsSystem = %d, Hidden = %d, Foregroundapp %x", wgName->IsSystem() ? 1 : 0, wgName->Hidden() ? 1 : 0, foregroundUid);
+                    TRACES1("BuildActionListL: Foregroundapp %x", foregroundUid);
+                    skipped = ETrue;
                     }
     
                 else if (aWindowGroupList.IsBusy(wgIndex) || wgName->IsBusy())
@@ -252,6 +276,11 @@
                     // Find the app close config for this app ID
                     appCloseConfig = aConfig.GetApplicationConfig(appId).GetAppCloseConfig();
                     }
+                
+                if(!appCloseConfig && !skipped)
+                    {
+                    appCloseConfig = aConfig.GetApplicationConfig(KGOomDefaultAppId).GetAppCloseConfig();
+                    }
     
                 // Create the app close action and add it to the action list
                 if (appCloseConfig)
@@ -260,7 +289,7 @@
                     TInt wgId = aWindowGroupList.WgId(wgIndex).iId;
                     TGOomSyncMode syncMode = appCloseConfig->iSyncMode;
                     TInt ramEstimate = appCloseConfig->iRamEstimate;
-                    TActionRef ref = TActionRef(TActionRef::EAppClose, priority, syncMode, ramEstimate, wgId, wgIndex);
+                    TActionRef ref = TActionRef(TActionRef::EAppClose, priority, syncMode, ramEstimate, wgId, wgIndex, appCloseConfig->iCloseTimeout, appCloseConfig->iWaitAfterClose);
     
                     //AppClose Actions should always have a unique prioirity determined by the application's z order.
                     TInt err = iActionRefs.InsertInOrder(ref, ComparePriorities);
@@ -320,7 +349,7 @@
             
             //Double checking again if this app is now in foreground, if yes then we dont kill
             CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(iWs, iWs.GetFocusWindowGroup());
-            RDebug::Print(wgName->WindowGroupName());
+            
             TInt32 fgApp = wgName->AppUid().iUid;
             TInt32 appId = iMonitor.GetWindowGroupList()->AppIdfromWgId(ref.WgId(), ETrue);
             if(appId == fgApp)
@@ -334,11 +363,13 @@
         else
             {
             action = &(ref.RunPlugin());
+            iCurrentPluginRun = ref.RunPlugin().Id();
             }
 
         iFreeingMemory = ETrue;
         TRACES2("CGOomActionList::FreeMemory: Running action %d which has priority %d", iCurrentActionIndex,ref.Priority());
         action->FreeMemory(iCurrentTarget - memoryEstimate);
+        iCurrentPluginRun = 0;
         memoryFreeingActionRun = ETrue;
 
         // Actions with EContinueIgnoreMaxBatchSize don't add to the tally of running actions
@@ -377,13 +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;
-        if (FreeMemoryAboveTarget(freeMemory) && !iMonitor.NeedToPostponeMemGood())
-            {
-            MemoryGood();
-            }
+        FreeMemoryAboveTarget(freeMemory);
         iServer.CloseAppsFinished(freeMemory, EFalse);
+        iMonitor.WaitAndSynchroniseMemoryState();
         }
     }
 
@@ -413,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);
     }
@@ -572,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())
                     {                    
@@ -580,6 +608,7 @@
                     }
                      */
                     iServer.CloseAppsFinished(freeMemory, EFalse);
+                    iMonitor.WaitAndSynchroniseMemoryState();
                     }
                 else
                     {
@@ -587,6 +616,7 @@
                     iRunningKillAppActions = ETrue;
                     iMonitor.RunCloseAppActions(iMaxPriority);
                     }
+                
                 }
             else
                 {
@@ -605,8 +635,8 @@
                 }
             */
             iRunningKillAppActions = EFalse;
-            iMonitor.ResetTargets();
             iServer.CloseAppsFinished(freeMemory, ETrue);
+            iMonitor.WaitAndSynchroniseMemoryState();
             }
         }
 
@@ -653,14 +683,15 @@
         }
     }
 
-void CGOomActionList::SetPriority(TInt aWgIndex, TInt aPriority)
+
+void CGOomActionList::SetPriority(TInt aWgId, TInt aPriority)
     {
     FUNC_LOG;
 
     TInt idx = iActionRefs.Count()-1;
     while(idx >= 0)
         {
-        if(iActionRefs[idx].WgIndex() == aWgIndex)
+        if(iActionRefs[idx].WgId() == aWgId)
             {
             break;
             }
@@ -669,15 +700,22 @@
     
     if(idx >= 0)
         {
-        TRACES2("CGOomActionList::SetPriority Setting app wgindex %d, index %d as busy", aWgIndex, idx);
+        TRACES2("CGOomActionList::SetPriority Setting app wgid %d, index %d as busy", aWgId, idx);
         iActionRefs[idx].SetPriority(aPriority);
-        if (!iFreeingMemory)
-            {
-            iActionRefs.Sort(ComparePriorities);
-            }
         }
     else
         {
-        TRACES1("CGOomActionList::SetPriority wgindex %d not in the hitlist", aWgIndex);
+        TRACES1("CGOomActionList::SetPriority wgd %d not in the hitlist", aWgId);
         }
     }
+
+
+TUint CGOomActionList::CurrentPluginRun()
+    {
+    return iCurrentPluginRun;
+    }
+
+TBool CGOomActionList::IsRunningKillAppActions()
+    {
+    return iRunningKillAppActions;
+    }
--- a/uiacceltk/hitchcock/goommonitor/src/goomactionref.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goomactionref.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -23,8 +23,8 @@
     {   
     }
 
-TActionRef::TActionRef(TActionType aType, TInt aPriority, TGOomSyncMode aSyncMode, TInt aRamEstimate, TInt aWgId, TUint aWgIndex)
-: iType(aType), iPriority(aPriority), iSyncMode(aSyncMode), iRamEstimate(aRamEstimate), iWgId(aWgId), iWgIndex(aWgIndex), iRunPlugin(NULL)
+TActionRef::TActionRef(TActionType aType, TInt aPriority, TGOomSyncMode aSyncMode, TInt aRamEstimate, TInt aWgId, TUint aWgIndex, TInt aCloseTimeout, TInt aWaitAfterClose)
+: iType(aType), iPriority(aPriority), iSyncMode(aSyncMode), iRamEstimate(aRamEstimate), iWgId(aWgId), iWgIndex(aWgIndex), iRunPlugin(NULL), iCloseTimeout(aCloseTimeout), iWaitAfterClose(aWaitAfterClose)
     {   
     }
 
@@ -59,6 +59,16 @@
     return iWgId;
     }
 
+TInt TActionRef::CloseTimeout() const
+    {
+    return iCloseTimeout;
+    }
+
+TInt TActionRef::WaitAfterClose() const
+    {
+    return iWaitAfterClose;
+    }
+
 TInt TActionRef::WgIndex() const
     {
     return iWgIndex;
--- a/uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -24,8 +24,6 @@
 #include "goomappclosewatcher.h"
 #include "goomactionref.h"
 
-const TInt KGOomMaxAppExitTime = 1000000;
-const TInt KGOomMaxAppAfterKillWaitTime = 1000000;
 
 CGOomCloseApp* CGOomCloseApp::NewL(MGOomActionObserver& aStateChangeObserver, RWsSession& aWs)
     {
@@ -51,10 +49,10 @@
     
     // Start a timer and the thread watcher 
     iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppClosing);
-    iAppCloseTimer->After(KGOomMaxAppExitTime);
+    iAppCloseTimer->After(iCloseTimeout * 1000);
     iAppCloseWatcher->Start(iCurrentTask);
     // Tell the app to close
-    TRACES1("CGOomCloseApp::FreeMemory: Closing app with window group id %d",iWgId);
+    TRACES2("CGOomCloseApp::FreeMemory: Closing app with window group id %d Timeout = %d",iWgId, iCloseTimeout);
     iCurrentTask.EndTask();
     }
 
@@ -81,12 +79,16 @@
     iAppCloserRunning = EFalse;
     
     if (iAppCloseTimer)
-        iAppCloseTimer->Cancel();
+        {
+            iAppCloseTimer->Cancel();
+            iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppKilled);
+            iAppCloseTimer->After(iWaitAfterClose * 1000);
+        }
+    
     if (iAppCloseWatcher)
         iAppCloseWatcher->Cancel(); 
     
-    iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppKilled);
-    iAppCloseTimer->After(KGOomMaxAppAfterKillWaitTime);
+    
     //MemoryFreed(KErrNone);
     }
 
@@ -95,6 +97,8 @@
     FUNC_LOG;
 
     iWgId = aRef.WgId();    
+    iCloseTimeout = aRef.CloseTimeout();
+    iWaitAfterClose = aRef.WaitAfterClose();
     }
 
 void CGOomCloseApp::ConstructL()
@@ -128,7 +132,7 @@
     iAppCloserRunning = EFalse;
     
     iAppCloseTimer->SetState(CGOomAppCloseTimer::EGOomAppKilled);
-    iAppCloseTimer->After(KGOomMaxAppAfterKillWaitTime);
+    iAppCloseTimer->After(iWaitAfterClose * 1000);
     //MemoryFreed(KErrNone);
     }
 
--- a/uiacceltk/hitchcock/goommonitor/src/goomconfigparser.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goomconfigparser.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -56,6 +56,7 @@
 KGOomErrBadLowThresholdValueForAppConfig,
 KGOomErrBadGoodThresholdValueForAppConfig,
 KGOomErrBadTargetFreeValueForAppConfig,
+KGOomErrBadSkipPluginValueForAppConfig,
 KGOomErrSystemPluginSettingsMustComeAfterAppCloseSettings,
 KGOomErrAppPluginSettingsMustComeAfterSystemPluginSettings,
 KGOomErrAppPluginIdleTimeRulesMustComeAfterAppPluginSettings,
@@ -109,6 +110,9 @@
 _LIT8(KGOomConfigAppCloseSettings, "app_close_settings");
 _LIT8(KGOomConfigCloseApp, "close_app");
 
+_LIT8(KGOomAttributeAppCloseTimeout, "close_timeout");
+_LIT8(KGOomAttributeAppWaitAfterClose, "wait_after_close");
+
 // App close idle time
 _LIT8(KGOomConfigAppCloseIdlePriority, "app_close_idle_priority");
 
@@ -122,6 +126,7 @@
 
 //App specific
 _LIT8(KGOomAttributeTargetFreeOnStartup, "target_free_on_startup");
+_LIT8(KGOomAttributeSkipPlugin, "skip_plugin");
 
 // System plugins 
 
@@ -478,6 +483,24 @@
             if (err != KErrNone)
                 ConfigError(KGOomErrBadTargetFreeValueForAppConfig);
             }
+        
+    // Get the app specific SkipPlugin
+        if (err == KErrNone)
+            {
+            TUint skipPlugin;
+            err = GetValueFromHexAttributeList(aAttributes, KGOomAttributeSkipPlugin, skipPlugin);
+            if (err == KErrNone)
+                {
+                TRACES2("SKIP PLUGIN %x configured for App %x", skipPlugin, uid); 
+                appConfig->iSkipPluginId = skipPlugin;
+                }
+            else if (err == KErrNotFound)
+                err = KErrNone;
+            
+            if (err != KErrNone)
+                ConfigError(KGOomErrBadSkipPluginValueForAppConfig);
+            }
+                
     
     // Add the applciation config to the main config
     if ((err == KErrNone) && (appConfig))
@@ -568,10 +591,46 @@
             ConfigError(KGOomErrMissingEstimateFromAppCloseConfig);
         else
             closeAppConfig->iRamEstimate = ramEstimate * 1024;
-           }
+        }
+    
+    if (err == KErrNone)
+        {
+        TInt closeTimeout;
+        err = GetValueFromDecimalAttributeList(aAttributes, KGOomAttributeAppCloseTimeout, closeTimeout);
+        if (err == KErrNone)
+            {
+            closeAppConfig->iCloseTimeout = closeTimeout;
+            }
+        else if (err == KErrNotFound)
+            {
+            closeAppConfig->iCloseTimeout=0;
+            err = KErrNone;
+            }
+        }
+     
+    if (err == KErrNone)
+        {
+        TInt waitAfterClose;
+        err = GetValueFromDecimalAttributeList(aAttributes, KGOomAttributeAppWaitAfterClose, waitAfterClose);
+        if (err == KErrNone)
+            {
+            closeAppConfig->iWaitAfterClose = waitAfterClose;
+            }
+        else if (err == KErrNotFound)
+            {
+            err = KErrNone;
+            closeAppConfig->iWaitAfterClose = 0;
+            }
+        }
 
     if (err == KErrNone)
-        iConfig.SetAppCloseConfigL(closeAppConfig);
+        {
+         iConfig.SetAppCloseConfigL(closeAppConfig);
+        }
+    else
+        {
+        TRACES2("ERROR Creating Appcloseconfig file for %x, err %d", uid,err);
+        }
     
     CleanupStack::Pop(closeAppConfig);
     }
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -48,6 +48,8 @@
 #include "goomthresholdcrossedao.inl"
 #endif
 
+const TInt KGoomWaitTimeToSynch = 1000000;
+
 // ======================================================================
 // class CMemoryMonitor
 // ======================================================================
@@ -81,6 +83,8 @@
 CMemoryMonitor::~CMemoryMonitor()
     {
     FUNC_LOG;
+    
+    delete iSynchTimer;
 
     delete iServer;
     delete iWservEventReceiver;
@@ -184,6 +188,8 @@
     
     iWservEventReceiver = new(ELeave) CWservEventReceiver(*this, iWs);
     iWservEventReceiver->ConstructL();
+    
+    iSynchTimer = CGOomSynchTimer::NewL(*this);
     }
 
 const CGOomGlobalConfig& CMemoryMonitor::GlobalConfig()
@@ -202,30 +208,38 @@
     FUNC_LOG;
     // keep only one notification active at a moment
 #ifdef USE_ASYNCYH_NOTIFICATIONS 
-    if (aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_GT_NOK)
-        {
-        TRACES("FreeMemThresholdCrossedL : EGL_PROF_TOTAL_MEMORY_USAGE_GT_NOK");
-        iMemAllocationsGrowing->Stop();
-        iMemAllocationsGoingDown->Continue();
-        }
-    else
-        {
-        TRACES("FreeMemThresholdCrossedL : EGL_PROF_TOTAL_MEMORY_USAGE_LT_NOK");
-        iMemAllocationsGrowing->Continue();
-        iMemAllocationsGoingDown->Stop();            
-        }    
-#endif
-
-    StartFreeSomeRamL(iGoodThreshold);
+   
     if (aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_LT_NOK)
         {
         TInt current = GetFreeMemory();
         if(current >= iGoodThreshold  && (!NeedToPostponeMemGood()))
             {
-            TRACES("FreeMemThresholdCrossedL : calling MemoryGOOD");
+            TRACES2("FreeMemThresholdCrossedL : crossed good threshold Free %d, GThresh %d, Calling MemoryGood",current, iGoodThreshold);
             iGOomActionList->MemoryGood();
+            iMemAllocationsGrowing->Continue();
+            iMemAllocationsGoingDown->Stop();
+            return;
+            }
+        else
+            {
+            TRACES3("FreeMemThresholdCrossedL : Not Calling MemoryGOOD. Free %d, GThresh %d, Handshakepending = %d",current, iGoodThreshold, NeedToPostponeMemGood()?1:0);
+            //if we remain in low mem mode, we have to wait for the same trigger i.e. free mem crossing good threshold
+            
+            if(NeedToPostponeMemGood()) //if handshake pending
+                iMemAllocationsGoingDown->Stop();   //Stop till handhsake is complete. It will be made to continue from DoPostponedMemoryGood
+            else
+                iMemAllocationsGoingDown->Continue();
             }
         }
+    else//if aThreshold == EGL_PROF_TOTAL_MEMORY_USAGE_GT_NOK
+        {
+        TRACES1("FreeMemThresholdCrossedL : crossed low threshold %d", iLowThreshold);
+        iMemAllocationsGrowing->Stop();
+        iMemAllocationsGoingDown->Continue();
+        if(iTrigger == EGOomTriggerNone)
+            StartFreeSomeRamL(iGoodThreshold, EGOomTriggerThresholdCrossed);
+        }
+#endif
     }
 
 void CMemoryMonitor::HandleFocusedWgChangeL(TInt aForegroundAppUid)
@@ -244,20 +258,10 @@
     RefreshThresholds(aForegroundAppUid);
     // Not very elegant, now we poll on each window group change
     // Should have better trigger e.g. from window server 
-#ifndef USE_ASYNCYH_NOTIFICATIONS  
-    TInt current = GetFreeMemory();
-    if (current < iLowThreshold)
-        {
-        StartFreeSomeRamL(iGoodThreshold);
-        }  
-    else if(current >= iGoodThreshold)
-        {
-        iGOomActionList->MemoryGood();
-        }
-#endif
+	StartFreeSomeRamL(iCurrentTarget, EGOomTriggerFocusChanged);
      }
 
-void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority) // The maximum priority of action to run
+void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority, TGOomTrigger aTrigger) // The maximum priority of action to run
     {
     FUNC_LOG;
 
@@ -299,8 +303,10 @@
     //iGOomActionList->SetCurrentTarget(aTargetFree);
     iGOomActionList->SetCurrentTarget(iCurrentTarget);
 
+    iTrigger = aTrigger;
     // Run the memory freeing actions
     iGOomActionList->FreeMemory(aMaxPriority);
+    
     }
 
 void CMemoryMonitor::RunCloseAppActions(TInt aMaxPriority)
@@ -317,18 +323,18 @@
 // of applications, and each will be given a timeout of KAPPEXITTIMEOUT.
 // ---------------------------------------------------------
 //
-void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree)
+void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree, TGOomTrigger aTrigger)
     {
     FUNC_LOG;
 
-    StartFreeSomeRamL(aTargetFree, KGOomPriorityInfinate - 1);
+    StartFreeSomeRamL(aTargetFree, KGOomPriorityInfinate - 1, aTrigger);
     }
 
 void CMemoryMonitor::RequestFreeMemoryL(TInt aTargetFree, TBool aUseAbsolute)
     {
     FUNC_LOG;
 
-    StartFreeSomeRamL(aUseAbsolute?aTargetFree:(aTargetFree + iLowThreshold), KGOomPriorityInfinate - 1);
+    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
@@ -337,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);
+    StartFreeSomeRamL(aUseAbsolute?aTargetFree:(aTargetFree + iGoodThreshold), priorityOfAllocation, EGOomTriggerRequestMemory);
     }
 
 // Does the EGL extension return the amount of memory in bits?
@@ -378,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);
 
@@ -464,31 +471,59 @@
     //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)
     {
     FUNC_LOG;
+    TRACES2("Received SetPriorityBusy for appid = %x, wgid = %d", iGOomWindowGroupList->AppIdfromWgId(aWgId, ETrue), aWgId);
     
-    TRACES2("Received SetPriorityBusy for appid = %x, wgid = %d", iGOomWindowGroupList->AppIdfromWgId(aWgId, ETrue), aWgId);
-    iGOomWindowGroupList->SetPriorityBusy(aWgId);
-    AppClosePriorityChanged(aWgId, RGOomMonitorSession::EGOomPriorityBusy);
+    RArray<TInt> WgIdList;
+    iGOomWindowGroupList->GetAllWgIdsMatchingAppId(aWgId, WgIdList);
+        
+    TInt i = WgIdList.Count();
+    while(i--)
+        {
+        iGOomWindowGroupList->SetPriorityBusy(WgIdList[i]);
+        if(iGOomActionList->IsRunningKillAppActions())  //this may be too late as killing of apps has already begun, but we might still be able to save the app 
+            AppClosePriorityChanged(WgIdList[i], RGOomMonitorSession::EGOomPriorityBusy);
+        }
     }
 
 void CMemoryMonitor::SetPriorityNormal(TInt aWgId)
     {
     FUNC_LOG;
-
-    iGOomWindowGroupList->SetPriorityNormal(aWgId);
-    AppClosePriorityChanged(aWgId, RGOomMonitorSession::EGOomPriorityNormal);
+    TRACES2("Received SetPriorityBusy for appid = %x, wgid = %d", iGOomWindowGroupList->AppIdfromWgId(aWgId, ETrue), aWgId);
+    
+    RArray<TInt> WgIdList;
+    iGOomWindowGroupList->GetAllWgIdsMatchingAppId(aWgId, WgIdList);
+        
+    TInt i = WgIdList.Count();
+    while(i--)
+        {
+        iGOomWindowGroupList->SetPriorityNormal(WgIdList[i]);
+        if(iGOomActionList->IsRunningKillAppActions())
+            AppClosePriorityChanged(WgIdList[i], RGOomMonitorSession::EGOomPriorityNormal);
+        }
     }
 
 void CMemoryMonitor::SetPriorityHigh(TInt aWgId)
     {
     FUNC_LOG;
+    TRACES2("Received SetPriorityBusy for appid = %x, wgid = %d", iGOomWindowGroupList->AppIdfromWgId(aWgId, ETrue), aWgId);
     
-    iGOomWindowGroupList->SetPriorityHigh(aWgId);
-    AppClosePriorityChanged(aWgId, RGOomMonitorSession::EGOomPriorityHigh);
+    RArray<TInt> WgIdList;
+    iGOomWindowGroupList->GetAllWgIdsMatchingAppId(aWgId, WgIdList);
+        
+    TInt i = WgIdList.Count();
+    while(i--)
+        {    
+        iGOomWindowGroupList->SetPriorityHigh(WgIdList[i]);
+        if(iGOomActionList->IsRunningKillAppActions())
+            AppClosePriorityChanged(WgIdList[i], RGOomMonitorSession::EGOomPriorityHigh);
+        }
     }
 
 TInt CMemoryMonitor::GetFreeMemory()
@@ -586,14 +621,24 @@
     {
     FUNC_LOG;
     TInt current = GetFreeMemory();
-    if(current >= iGoodThreshold  && (!NeedToPostponeMemGood()))
+    if(current >= iGoodThreshold)
         {
-        TRACES("DoPostponedMemoryGood calling MemoryGOOD");
-        iGOomActionList->MemoryGood();
+        if(!NeedToPostponeMemGood())
+            {
+            TRACES2("DoPostponedMemoryGood calling MemoryGOOD current %d, iGoodThreshold %d",current, iGoodThreshold);
+            iGOomActionList->MemoryGood();
+            }
+        else
+            {
+            iMemAllocationsGoingDown->Continue();
+            }
         }
+    else
+        {
+        iMemAllocationsGoingDown->Continue();
+        }   
     }    
 
-
 void CMemoryMonitor::AppClosePriorityChanged(TInt aWgId, TInt aPriority)
     {
     FUNC_LOG;
@@ -615,19 +660,21 @@
         appCloseConfig = iConfig->GetApplicationConfig(aWgId).GetAppCloseConfig();
         TRACES("CMemoryMonitor::AppClosePriorityChanged NORMAL");
     }
-        
+    
+    if(!appCloseConfig)
+        {
+        appCloseConfig = iConfig->GetApplicationConfig(KGOomDefaultAppId).GetAppCloseConfig();
+        }
+    
     if (appCloseConfig)
         {  
-        TInt32 appId = iGOomWindowGroupList->AppIdfromWgId(aWgId, ETrue);
-        TInt wgIndex=iGOomWindowGroupList->GetIndexFromAppId(appId);
-        
-        TRACES2("CMemoryMonitor::AppClosePriorityChanged wgindex %d, appid %x", wgIndex, appId);
+        TInt wgIndex=iGOomWindowGroupList->GetIndexFromWgId(aWgId);
         
         if(wgIndex>=0)
             {
-            TRACES2("CMemoryMonitor::AppClosePriorityChanged Setting Priority for app %x, wgid %d", appId, aWgId);
+            TRACES2("CMemoryMonitor::AppClosePriorityChanged Setting Priority for app %x, wgid %d", iGOomWindowGroupList->AppIdfromWgId(aWgId, ETrue), aWgId);
             TUint priority = appCloseConfig->CalculateCloseAppPriority(*iGOomWindowGroupList, wgIndex);
-            iGOomActionList->SetPriority(wgIndex, priority);
+            iGOomActionList->SetPriority(aWgId, priority);
             }
         else
             {
@@ -644,3 +691,107 @@
 {
     return iGOomWindowGroupList; 
 }
+
+TBool CMemoryMonitor::IsSafeToProcessNewRequest(TUint aClientId)
+    {
+    FUNC_LOG;
+    if(iActiveClientId == aClientId)
+        {
+        TRACES1("Repeated Request from %x", aClientId);
+        return EFalse;
+        }
+    
+    TUint currrentPluginRun = iGOomActionList->CurrentPluginRun();
+    if(currrentPluginRun)
+        {
+        if(iConfig->GetApplicationConfig(aClientId).iSkipPluginId == currrentPluginRun)
+            {
+            TRACES2("Request from %x cannot be served now as plugin %x is running", aClientId, currrentPluginRun);
+            return EFalse;
+            }
+        }
+    
+    TRACES1("Going to process new request %d",iPostponeMemGood);
+    return ETrue;
+    }
+
+void CMemoryMonitor::WaitAndSynchroniseMemoryState() //this will be called after freeing memory
+    {
+    FUNC_LOG;
+    
+    switch (iTrigger)
+        {
+        case EGOomTriggerThresholdCrossed:
+            {
+            //Call memory good if we are good.
+            DoPostponedMemoryGood();
+            break;
+            }
+        case EGOomTriggerFocusChanged:
+        case EGOomTriggerRequestMemory:
+            {
+            //start timer
+            //cancel timer if end critical allocations request -TODO
+            //end critical allocations when timer expires -TODO
+            if ( iSynchTimer && //exists
+                 !iSynchTimer->IsActive() ) // keep it simple
+                {        
+                iSynchTimer->Cancel();
+                iSynchTimer->After(KGoomWaitTimeToSynch);
+                }
+            break;
+            }
+        }
+    ResetTargets();
+    }
+
+void CMemoryMonitor::SynchroniseMemoryState()
+    {
+    FUNC_LOG;
+    TInt current = GetFreeMemory();
+    if(current >= iGoodThreshold)
+        {
+        if(!NeedToPostponeMemGood())
+            {
+            TRACES("SynchroniseMemoryState calling MemoryGOOD");
+            iGOomActionList->MemoryGood();
+            }
+        else
+            {
+            iMemAllocationsGoingDown->Continue();
+            }
+        }
+    else if(current < iLowThreshold)
+        {
+        iMemAllocationsGrowing->Stop();
+        iMemAllocationsGoingDown->Continue();
+        }
+    else
+        {
+        iMemAllocationsGrowing->Continue();
+        iMemAllocationsGoingDown->Continue();
+        }
+    }
+    
+    
+CGOomSynchTimer* CGOomSynchTimer::NewL(CMemoryMonitor& aMonitor)
+    {
+    CGOomSynchTimer* self = new (ELeave) CGOomSynchTimer(aMonitor);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CGOomSynchTimer::CGOomSynchTimer(CMemoryMonitor& aMonitor) : CTimer(EPriorityStandard), iMonitor(aMonitor)
+    {
+    CActiveScheduler::Add(this);
+    }
+    
+void CGOomSynchTimer::RunL()
+    {
+    FUNC_LOG;
+    iMonitor.SynchroniseMemoryState();
+    }
+
+
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -35,10 +35,12 @@
 CMemoryMonitorSession::~CMemoryMonitorSession()
     {
     FUNC_LOG;
+	/* TODO - need to add the right condition
     if (iUseAbsoluteTargets)
         { // se3ssion terminated while on critical allocation, release lock
         Server().Monitor().SessionInCriticalAllocation(0);
         }
+	*/
     CloseAppsFinished(0, EFalse);
     }
 
@@ -63,23 +65,32 @@
     iFunction = aMessage.Function();
     RThread t;
     aMessage.Client(t);
-    Server().Monitor().SetActiveClient(t.SecureId());
+    
+    TUint clientId = t.SecureId();
     t.Close();
     
+    TRACES1("NEW REQUEST from client %x", clientId);
     switch (aMessage.Function())
         {
         case EGOomMonitorRequestFreeMemory:
-            if (!iRequestFreeRam.IsNull())
+
+            //Do not take any more requests from the same client if previous request being served
+            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId))
                 {
+                TRACES1("CANNOT PROCESS NEW REQUEST from %x", clientId);
                 aMessage.Complete(KErrInUse);
                 return;
                 }
+            
+            Server().Monitor().SetActiveClient(clientId);
             // message will be completed when CloseAppsFinished() is called.
             if (aMessage.Int1() == 0)
                 {
                 iRequestFreeRam = aMessage;
 
-                TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0(), iUseAbsoluteTargets));
+                Server().Monitor().SessionInCriticalAllocation(1, clientId);
+                
+                TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0()));
                 if (err)
                     {
                     // completes the message if that was left to pending
@@ -94,12 +105,19 @@
                 TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid));
                 }
             break;
+            
+        case EGOomMonitorMemoryAllocationsComplete:
+            TRACES1("ServiceL : Memory Allocations complete from %x", clientId);
+            Server().Monitor().SessionInCriticalAllocation(0, clientId);
+            aMessage.Complete(KErrNone);
+            break;
 
         case EGOomMonitorCancelRequestFreeMemory:
             if (!iRequestFreeRam.IsNull())
                 {
                 iRequestFreeRam.Complete(KErrCancel);
                 }
+            Server().Monitor().SessionInCriticalAllocation(0, clientId);
             aMessage.Complete(KErrNone);
             break;
 
@@ -109,14 +127,15 @@
             break;
 
         case EGOomMonitorRequestOptionalRam:
-            if (!iRequestFreeRam.IsNull())
+            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId))
                 {
                 aMessage.Complete(KErrInUse);
                 }
+            Server().Monitor().SetActiveClient(clientId);
             // 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:
@@ -125,12 +144,12 @@
             break;
             
         case EGOomMonitorSetPriorityNormal:
-               Monitor().SetPriorityNormal(aMessage.Int0());
+            Monitor().SetPriorityNormal(aMessage.Int0());
             aMessage.Complete(KErrNone);
             break;
 
         case EGOomMonitorSetPriorityHigh:
-               Monitor().SetPriorityHigh(aMessage.Int0());
+            Monitor().SetPriorityHigh(aMessage.Int0());
             aMessage.Complete(KErrNone);
             break;
 
@@ -141,12 +160,13 @@
             TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid))
             break;
             }
+           
         case EGoomMonitorAppUsesAbsoluteMemTargets:
             {
             iUseAbsoluteTargets = aMessage.Int0();
-            TRACES2("EGoomMonitorAppUsesAbsoluteMemTargets this: 0x%x, use abs targets %d", this, iUseAbsoluteTargets);
+/*            TRACES2("EGoomMonitorAppUsesAbsoluteMemTargets this: 0x%x, use abs targets %d", this, iUseAbsoluteTargets);
             Server().Monitor().SessionInCriticalAllocation(iUseAbsoluteTargets);
-            aMessage.Complete(KErrNone);     
+*/           aMessage.Complete(KErrNone);     
             break;
             }    
             
--- a/uiacceltk/hitchcock/goommonitor/src/goommonitorsession.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goommonitorsession.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -59,6 +59,15 @@
     return KErrNone;    
     }
 
+EXPORT_C void RGOomMonitorSession::MemoryAllocationsComplete()
+    {
+    FUNC_LOG;
+    if (IsConnected())
+        {
+        SendReceive(EGOomMonitorMemoryAllocationsComplete);
+        }
+    }
+
 EXPORT_C TInt RGOomMonitorSession::RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable)
     {
     FUNC_LOG;
@@ -128,7 +137,7 @@
         }
     }
 
-
+//TODO should this be asynchronous - can be called from a goom plugin, which is called from goom - deadlock ?
 EXPORT_C void RGOomMonitorSession::SetGOomPriority(TGOomPriority aPriority)
     {
     FUNC_LOG;
--- a/uiacceltk/hitchcock/goommonitor/src/goomrunplugin.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goomrunplugin.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -94,3 +94,8 @@
 
     iPluginWaiter = CGOomPluginWaiter::NewL(waitDuration, *this);
     }
+
+TUint CGOomRunPlugin::Id()
+    {
+    return iPluginId;
+    }
--- a/uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -31,6 +31,8 @@
 _LIT(KDummyWgName, "20");
 const TInt KPreallocatedSpaceForAppList = 50;
 
+const TInt KAllowedMemUsageForApps = 50000;     //Allow upto 50K usage by app when killing apps
+
 const TUint KGOomTicksPerSecond = 1000;
 
 typedef EGLBoolean (*NOK_resource_profiling)(EGLDisplay, EGLint, EGLint*, EGLint, EGLint*);
@@ -78,7 +80,8 @@
     EGLint* prof_data;
     TInt i(0);
     RArray<TUint64> processIds;
-    //RArray<TUint> privMemUsed;
+    RArray<TUint> privMemUsed;
+    RArray<TUint64> systemProcessIds;
         
     EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
 
@@ -100,15 +103,14 @@
                                  &data_count);
     
     /* Iterate over the returned data */
+    TUint64 process_id;  
     while (i < data_count)
         {
         TRACES2("RefreshL EGL_NOK_resource_profiling - index: %d data: %x", i, prof_data[i]);
-            
         switch (prof_data[i++])
             {   
             case EGL_PROF_PROCESS_ID_NOK:
                 {
-                TUint64 process_id;
                 if (sizeof(EGLNativeProcessIdTypeNOK) == 8)
                     {
                     process_id = TUint64(prof_data[i]);
@@ -120,17 +122,29 @@
                     process_id = prof_data[i];
                     i++;
                     }
-                processIds.Append(process_id);
                 break;
                 }
             case EGL_PROF_PROCESS_USED_PRIVATE_MEMORY_NOK:
                 {
-                //TUint mem = prof_data[i];
-                //privMemUsed.Append(mem);
+                TUint mem = prof_data[i];
+                privMemUsed.Append(mem);
+
+                TRACES1("Memory Usage by app is %d", mem);
+                if(mem > KAllowedMemUsageForApps)
+                    processIds.Append(process_id);
+                
                 i++;
                 break;
                 }
             case EGL_PROF_PROCESS_USED_SHARED_MEMORY_NOK:
+                {
+                TUint mem = prof_data[i];
+                TRACES1("Shared Memory Usage by app is %d", mem);
+                if(mem > KAllowedMemUsageForApps)
+                    processIds.Append(process_id);
+                i++;
+                break;
+                }
             case EGL_PROF_USED_MEMORY_NOK:
             case EGL_PROF_TOTAL_MEMORY_NOK:
             default:
@@ -227,18 +241,49 @@
                 {
                 found = 1;
                 process.Close();
-                TRACES2("RefreshL Process id %x, wgindex %d, using gfx memory. Added to list", psecid, index);
+                TRACES3("RefreshL Process id %x, wgid %d, using gfx memory %d. Added to list", psecid, iWgIds[index].iId, privMemUsed[i]);
                 break;
                 }
             process.Close();
             }
-      
+        
         if(!found)
             {
             iWgIds.Remove(index);
             continue;
             }
       
+        //check if it is system app
+        if(iWgName->IsSystem() /*|| iWgName->Hidden()*/)
+            {
+            TRACES3("System/Hidden app found %x, ISystem %d, IsHidden %d",secureId, iWgName->IsSystem()?1:0, iWgName->Hidden()?1:0);  
+            systemProcessIds.Append(secureId);
+            }
+      
+        }
+       
+    processIds.Close();
+    privMemUsed.Close();      
+    
+    //check if any system apps are included
+    index = iWgIds.Count();
+    while (index--)
+        {
+        TBool skipped = EFalse;
+        for(i = 0; i < systemProcessIds.Count(); i++)
+            {
+            if(AppId(index,ETrue) == systemProcessIds[i])
+                {
+                TRACES2("WgId %d belongs to system app %x. Removing from Kill List",iWgIds[index].iId, systemProcessIds[i]);
+                iWgIds.Remove(index);
+                skipped = ETrue;
+                break;
+                }
+            }
+        
+        if(skipped)
+            continue;
+        
         // See if there is a tick count entry for each window in the list
         TGOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[index].iId);
         
@@ -250,9 +295,8 @@
             iWgToPropertiesMapping.InsertL(iWgIds[index].iId, wgProperties);
             }
         }
-       
-    processIds.Close();
-    //privMemUsed.Close();       
+    
+    systemProcessIds.Close();
     
     }
 
@@ -467,8 +511,6 @@
 void CGOomWindowGroupList::SetPriorityBusy(TInt aWgId)
     {
     FUNC_LOG;
-
-    //Refresh();
     
     TInt parentId;
     TRAPD(err, parentId = FindParentIdL(aWgId));
@@ -476,15 +518,15 @@
         {
         parentId = aWgId;
         }
-    
+        
     TRACES2("CGOomWindowGroupList::SetPriorityBusy aWgId = %d, parentId = %d", aWgId, parentId);
-    
+        
     TGOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(parentId);
     if (wgProperties)
         {
         wgProperties->iDynamicPriority = EGOomPriorityBusy;
         }
-    
+        
     // If we can't find the window group then ignore it
     }
 
@@ -533,6 +575,7 @@
 
 TBool CGOomWindowGroupList::IsBusy(TInt aWgIndex)
     {
+    FUNC_LOG;
     if (aWgIndex < 0 || aWgIndex >= iWgIds.Count())
         {
         return EFalse;
@@ -576,8 +619,6 @@
     {
     FUNC_LOG;
 
-    //Refresh();
-    
     TInt parentId;
     TRAPD(err, parentId = FindParentIdL(aWgId));
     if (err)
@@ -599,8 +640,6 @@
     {
     FUNC_LOG;
 
-    //Refresh();
-
     TInt parentId;
     TRAPD(err, parentId = FindParentIdL(aWgId));
     if (err)
@@ -639,3 +678,41 @@
 
     return indexInGroupList;
     }
+
+// Find the specificed application in the window group list and return the index
+TInt CGOomWindowGroupList::GetIndexFromWgId(TInt aWgId) const
+    {
+    FUNC_LOG;
+
+    TInt indexInGroupList = Count();
+    TBool appFoundInWindowGroupList = EFalse;
+    
+    while (indexInGroupList--)
+        {
+        if (iWgIds[indexInGroupList].iId == aWgId)
+            {
+            appFoundInWindowGroupList = ETrue;
+            break;
+            }
+        }
+    
+    if (!appFoundInWindowGroupList)
+        indexInGroupList = KAppNotInWindowGroupList;
+
+    return indexInGroupList;
+    }
+
+void CGOomWindowGroupList::GetAllWgIdsMatchingAppId(TInt aWgId, RArray<TInt> & WgIdList) const
+    {
+    TInt32 appId = AppIdfromWgId(aWgId, ETrue);
+    TInt indexInGroupList = Count();
+    WgIdList.Reset();
+    
+    while (indexInGroupList--)
+        {
+        if (AppIdfromWgId(iWgIds[indexInGroupList].iId, ETrue) == appId)
+            {
+            WgIdList.Append(iWgIds[indexInGroupList].iId);
+            }
+        }
+    }
--- a/uiacceltk/hitchcock/group/bld.inf	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/group/bld.inf	Fri Mar 19 09:43:21 2010 +0200
@@ -12,7 +12,7 @@
 * Contributors:
 *
 * Description:   Build information file for project alfappserver
-*  Version     : %version: tr1sido#128.1.7 %
+*  Version     : %version: tr1sido#128.1.9 %
 *
 */
 
@@ -88,6 +88,7 @@
 ../plugins/alftranseffect/alftfxserverplugin/group/AlfTfxSrvPlugin.mmp
 ../plugins/alftranseffect/alfgfxtransadapter/group/gfxtransenginetfx.mmp
 ../plugins/alfoogmplugin/group/alfoogmplugin.mmp
+../plugins/alfcrpplugin/group/alfcrpplugin.mmp
 
 // background animation host+reference plugin
 ../backgroundanim/group/bganimhost.mmp
@@ -111,10 +112,7 @@
 // waves plugin is not part of foundation content (differentiating SW)
 #include "../backgroundanim/wavesplugin/group/bld.inf"
 
-// yber hack, to be remover right after W02 build is out
-#ifndef FF_MEETING_REQUEST_UI
 #include "../plugins/mmfmediaclientplugin/group/bld.inf"
 #endif
-#endif
 
 PRJ_TESTMMPFILES
--- a/uiacceltk/hitchcock/group/core_exports.inc	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/group/core_exports.inc	Fri Mar 19 09:43:21 2010 +0200
@@ -3,7 +3,7 @@
 *  Name        : core_exports.inc
 *  Part of     : Alfred UI Toolkit
 *  Description : Exported header files.
-*  Version     : %version: tr1sido#8.1.24 %
+*  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
@@ -82,6 +87,8 @@
 ../coretoolkit/data/taskswapper_app_start_rect.fxml /epoc32/release/winscw/urel/z/resource/effects/taskswapper_app_start_rect.fxml
 ../coretoolkit/data/taskswapper_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/taskswapper_appear.fxml
 ../coretoolkit/data/taskswapper_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/taskswapper_disappear.fxml
+../coretoolkit/data/toolbar_ext_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/toolbar_ext_appear.fxml
+../coretoolkit/data/toolbar_ext_disappear.fxml /epoc32/release/winscw/urel/z/resource/effects/toolbar_ext_disappear.fxml
 ../coretoolkit/data/touchinput_close.fxml /epoc32/release/winscw/urel/z/resource/effects/touchinput_close.fxml
 ../coretoolkit/data/touchinput_open.fxml /epoc32/release/winscw/urel/z/resource/effects/touchinput_open.fxml
 ../coretoolkit/data/waitnote_appear.fxml /epoc32/release/winscw/urel/z/resource/effects/waitnote_appear.fxml
@@ -126,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
@@ -137,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
@@ -144,6 +156,8 @@
 ../coretoolkit/data/taskswapper_app_start_rect.fxml /epoc32/release/winscw/udeb/z/resource/effects/taskswapper_app_start_rect.fxml
 ../coretoolkit/data/taskswapper_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/taskswapper_appear.fxml
 ../coretoolkit/data/taskswapper_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/taskswapper_disappear.fxml
+../coretoolkit/data/toolbar_ext_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/toolbar_ext_appear.fxml
+../coretoolkit/data/toolbar_ext_disappear.fxml /epoc32/release/winscw/udeb/z/resource/effects/toolbar_ext_disappear.fxml
 ../coretoolkit/data/touchinput_close.fxml /epoc32/release/winscw/udeb/z/resource/effects/touchinput_close.fxml
 ../coretoolkit/data/touchinput_open.fxml /epoc32/release/winscw/udeb/z/resource/effects/touchinput_open.fxml
 ../coretoolkit/data/waitnote_appear.fxml /epoc32/release/winscw/udeb/z/resource/effects/waitnote_appear.fxml
@@ -166,7 +180,7 @@
 ../coretoolkit/data/app_start_rect.fxml /epoc32/data/z/resource/effects/app_start_rect.fxml
 ../coretoolkit/data/app_start_switch.fxml /epoc32/data/z/resource/effects/app_start_switch.fxml
 ../coretoolkit/data/app_start_switch_rect.fxml /epoc32/data/z/resource/effects/app_start_switch_rect.fxml
-../coretoolkit/data/appshell_exit.fxml /epoc32/data/z/resource/effects/effects/appshell_exit.fxml
+../coretoolkit/data/appshell_exit.fxml /epoc32/data/z/resource/effects/appshell_exit.fxml
 ../coretoolkit/data/confirmationnote_appear.fxml /epoc32/data/z/resource/effects/confirmationnote_appear.fxml
 ../coretoolkit/data/confirmationnote_disappear.fxml /epoc32/data/z/resource/effects/confirmationnote_disappear.fxml
 ../coretoolkit/data/dialer_close.fxml /epoc32/data/z/resource/effects/dialer_close.fxml
@@ -188,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
@@ -199,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
@@ -206,6 +225,8 @@
 ../coretoolkit/data/taskswapper_app_start_rect.fxml /epoc32/data/z/resource/effects/taskswapper_app_start_rect.fxml
 ../coretoolkit/data/taskswapper_appear.fxml /epoc32/data/z/resource/effects/taskswapper_appear.fxml
 ../coretoolkit/data/taskswapper_disappear.fxml /epoc32/data/z/resource/effects/taskswapper_disappear.fxml
+../coretoolkit/data/toolbar_ext_appear.fxml /epoc32/data/z/resource/effects/toolbar_ext_appear.fxml
+../coretoolkit/data/toolbar_ext_disappear.fxml /epoc32/data/z/resource/effects/toolbar_ext_disappear.fxml
 ../coretoolkit/data/touchinput_close.fxml /epoc32/data/z/resource/effects/touchinput_close.fxml
 ../coretoolkit/data/touchinput_open.fxml /epoc32/data/z/resource/effects/touchinput_open.fxml
 ../coretoolkit/data/waitnote_appear.fxml /epoc32/data/z/resource/effects/waitnote_appear.fxml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/plugins/alfcrpplugin/group/alfcrpplugin.mmp	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MMP file for alf crp ECOM plugin
+*
+*/
+
+#include <platform_paths.hrh>
+#include <defaultcaps.hrh>
+
+TARGET          alfcrpplugin.dll
+TARGETTYPE      PLUGIN 
+UID             0x10009D8D 0x2002C358
+CAPABILITY      CAP_ECOM_PLUGIN
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../CommonInc
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+SOURCE          alfcrpplugin.cpp
+SOURCE          alfsynchronizer.cpp
+
+START RESOURCE  alfcrpplugin.rss
+TARGET          alfcrpplugin.rsc
+END
+
+LIBRARY         ecom.lib
+LIBRARY         euser.lib
+LIBRARY         wsgraphicdrawer.lib
+LIBRARY         fbscli.lib
+LIBRARY         estor.lib
+LIBRARY         gdi.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/plugins/alfcrpplugin/group/bld.inf	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  bld.inf
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+alfcrpplugin.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/plugins/alfcrpplugin/inc/alfcrpplugin.h	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Alf CRP ECOM plugin
+*
+*/
+
+
+#ifndef AFLCRPPLUGIN_H
+#define AFLCRPPLUGIN_H
+
+// INCLUDES
+#include <w32std.h>
+#include <graphics/wsgraphicdrawerinterface.h>
+#include <graphics/wsgraphicdrawer.h>
+
+/**
+ * Alf window server ECOM plugin class.
+ */
+NONSHARABLE_CLASS( CAlfCrpPlugin ) : public CWsGraphicDrawer
+    {
+public:
+
+    /**
+     * Creates a new instance of the plugin.
+     * @return Created instance.
+     */ 
+    static CWsGraphicDrawer* CreateL();
+    
+    /**
+     * Destructor.
+     */ 
+    ~CAlfCrpPlugin();
+    
+private:
+
+    /**
+     * From CWsGraphicDrawer.
+     *
+     * @param aGc
+     * @param aRect
+     * @param aData
+     */ 
+    void DoDraw( MWsGc& aGc, const TRect& aRect, const TDesC8& aData ) const;
+    
+    /**
+     * Handles message from PreviewProviderClient.
+     *
+     * @param aData Message data.
+     */ 
+    void HandleMessage( const TDesC8& aData );
+
+    /**
+     * 2nd phase constructor.
+     *
+     * @param aEnv
+     * @param aId
+     * @param aOwner
+     * @param aData
+     */     
+    void ConstructL( MWsGraphicDrawerEnvironment& aEnv, 
+                     const TGraphicDrawerId& aId, 
+                     MWsClient& aOwner, 
+                     const TDesC8& aData );   
+
+private:
+    /**
+     * Handles message from PreviewProviderClient.
+     *
+     * @param aData Message data.
+     */     
+    void DoHandleMessageL( const TDesC8& aData );
+    
+    };
+
+#endif // AFLCRPPLUGIN_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/plugins/alfcrpplugin/inc/alfsynchronizer.h	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   AlfSynchronizer waits for synchronization to complete
+*
+*/
+
+
+
+#ifndef __ALFSYNCHRONIZER_H__
+#define __ALFSYNCHRONIZER_H__
+
+#include <e32base.h>
+#include <e32property.h>
+
+/**
+ * Synchronization active object.
+ */
+NONSHARABLE_CLASS( CAlfSynchronizer ) : public CActive
+    {
+public:
+    
+    /**
+     * Two phase constructor.
+     */
+    static CAlfSynchronizer* NewL();
+    
+    /**
+     * C++ destructor
+     */
+    ~CAlfSynchronizer();
+
+public:
+    
+    /**
+     * Starts to wait for synchronization to complete
+     * with particular identifier.
+     * This will start nested active scheduler.
+     */
+    void Start(TInt aId);  
+    
+private:    
+
+    /**
+     * C++ constructor
+     */
+    CAlfSynchronizer();
+
+    /**
+     * ConstructL
+     */
+    void ConstructL();
+
+    void RunL();
+    void DoCancel();
+
+    static TInt CallbackSyncTimeout( TAny* aPtr );
+    void DoCallbackSyncTimeout();
+
+private: // data
+
+    /**
+     * Active scheduler waiter.
+     * Own.
+     */
+    CActiveSchedulerWait* iWait;
+    
+    /**
+     * P&S property for monitoring a variable.
+     * Own.
+     */
+    RProperty iProperty;
+    
+    /**
+     * Timer to ensure that this synchronizer has finite duration.
+     * Own.
+     */
+    CPeriodic* iTimeout;
+    
+    /**
+     * Id waiting to be completed.
+     */
+    TInt iSynchId;
+    
+    /**
+     * ETrue if @c iWait has been stop.
+     * EFalse otherwise.
+     */
+    TBool iAsyncStopDone;
+    };
+
+#endif //__ALFSYNCHRONIZER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/plugins/alfcrpplugin/src/alfcrpplugin.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,144 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Alf CRP ECOM plugin
+*
+*/
+
+
+#include <bldvariant.hrh>
+
+#include "alfcrpplugin.h"
+#include <ecom/implementationproxy.h>
+#include <s32mem.h> //RDesReadStream
+
+#include "alfsynchronizer.h"
+#include "alfrenderstageutils.h"
+
+// CONSTANTS
+const TInt KImpId( 0x2002C358 );
+const TInt KAlfCrpSynchronize = 0;
+
+// --------------------------------------------------------------------------
+// CAlfCrpPlugin::CreateL
+// --------------------------------------------------------------------------
+//
+CWsGraphicDrawer* CAlfCrpPlugin::CreateL()
+    {
+    CAlfCrpPlugin* crp = new (ELeave) CAlfCrpPlugin();
+    return crp;
+    }
+
+// --------------------------------------------------------------------------
+// CAlfCrpPlugin::~CAlfCrpPlugin
+// --------------------------------------------------------------------------
+//    
+CAlfCrpPlugin::~CAlfCrpPlugin()    
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CAlfCrpPlugin::DoDraw
+// --------------------------------------------------------------------------
+//
+void CAlfCrpPlugin::DoDraw( MWsGc& /*aGc*/, const TRect& /*aRect*/, 
+    const TDesC8& /*aData*/) const
+    {
+    // Draws nothing
+    }
+
+// --------------------------------------------------------------------------
+// CAlfCrpPlugin::HandleMessage
+// --------------------------------------------------------------------------
+//    
+void CAlfCrpPlugin::HandleMessage( const TDesC8& aData )
+    {
+    TRAP_IGNORE( DoHandleMessageL( aData ) );
+    }
+    
+// --------------------------------------------------------------------------
+// CAlfCrpPlugin::DoHandleMessageL
+// --------------------------------------------------------------------------
+//    
+void CAlfCrpPlugin::DoHandleMessageL( const TDesC8& aData )
+    {  
+    RDesReadStream in( aData );
+    switch( in.ReadInt32L() )
+        {
+        case KAlfCrpSynchronize:
+            {
+            MAlfSynchronizationInterface* synchronizer = NULL;            
+            if ( Env().ScreenCount() )
+                {
+                MWsScreen* screen = Env().Screen(0);
+                if ( screen )
+                    {
+                    synchronizer = 
+                        (MAlfSynchronizationInterface*)screen->ResolveObjectInterface(
+                            KAlfSynchronizationInterfaceUid);
+                    }
+                }
+            
+            if ( synchronizer )
+                {
+                _LIT_SECURITY_POLICY_S0(KAlfSynchronizerPolicy, 0x10003B20);
+                RProperty::Define( KAlfPSUidSynchronizer, KAlfPSKeySynchronizer, RProperty::EInt, KAlfSynchronizerPolicy, KAlfSynchronizerPolicy );
+                RProperty::Set( KAlfPSUidSynchronizer, KAlfPSKeySynchronizer, 0 );
+                    
+                CAlfSynchronizer* synch = CAlfSynchronizer::NewL();
+                CleanupStack::PushL( synch );
+                TInt syncId = 0;
+                synchronizer->Synchronize(syncId);
+                synch->Start( syncId );
+                            
+                CleanupStack::PopAndDestroy( synch );
+                }
+            }
+            break;
+        default:
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CAlfCrpPlugin::ConstructL
+// --------------------------------------------------------------------------
+//    
+void CAlfCrpPlugin::ConstructL( MWsGraphicDrawerEnvironment& aEnv,
+    const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/ )
+    {
+    BaseConstructL( aEnv, aId, aOwner );
+
+    ShareGlobally();
+    }
+
+// --------------------------------------------------------------------------
+// KImplementationTable
+// --------------------------------------------------------------------------
+//    
+LOCAL_C const TImplementationProxy KImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY(KImpId, CAlfCrpPlugin::CreateL)
+    };
+
+// --------------------------------------------------------------------------
+// ImplementationGroupProxy
+// --------------------------------------------------------------------------
+//    
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = (sizeof(KImplementationTable) / sizeof(TImplementationProxy));
+    return KImplementationTable;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/plugins/alfcrpplugin/src/alfcrpplugin.rss	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM registration file
+*
+*/
+
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x2002C358;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x10281924;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x2002C358;
+					version_no = 1;
+					display_name = "alfcrpplugin";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uiacceltk/hitchcock/plugins/alfcrpplugin/src/alfsynchronizer.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -0,0 +1,153 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  AlfSynchronizer waits for synchronization to complete
+*
+*/
+
+
+#include "alfsynchronizer.h"
+#include "alfrenderstageutils.h"
+
+// Timeout in microseconds - 500 ms.
+const TInt KAlfSyncTimeout = 500000;
+
+// --------------------------------------------------------------------------
+// CAlfSynchronizer::NewL
+// --------------------------------------------------------------------------
+//    
+CAlfSynchronizer* CAlfSynchronizer::NewL()
+    {
+    CAlfSynchronizer* self = new (ELeave) CAlfSynchronizer;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+// --------------------------------------------------------------------------
+// CAlfSynchronizer::~CAlfSynchronizer
+// --------------------------------------------------------------------------
+//
+CAlfSynchronizer::~CAlfSynchronizer()
+    {
+    Cancel();
+    
+    iProperty.Close();
+    
+    delete iWait;
+    delete iTimeout;
+    }
+
+// --------------------------------------------------------------------------
+// CAlfSynchronizer::Start
+// --------------------------------------------------------------------------
+//
+void CAlfSynchronizer::Start(TInt aId)
+    {
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    
+    TInt value = 0;
+    iProperty.Get(value);
+    
+    if ( value != aId )
+        {
+        // Launch timeout AO in case there happens to be deadlock in coretoolkit etc.
+        iTimeout->Start( KAlfSyncTimeout, KAlfSyncTimeout, 
+            TCallBack( CallbackSyncTimeout, this ) );
+
+        // Start wait
+        iSynchId = aId;
+        iWait->Start();
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CAlfSynchronizer::RunL
+// --------------------------------------------------------------------------
+//
+void CAlfSynchronizer::RunL()
+    {
+    if ( !iAsyncStopDone && iStatus.Int() == KErrNone )
+        {
+        iProperty.Subscribe( iStatus );
+        SetActive();
+        }
+    
+    TInt value = 0;
+    iProperty.Get(value);
+        
+    if ( !iAsyncStopDone && value == iSynchId )
+        {
+        iWait->AsyncStop();
+        iAsyncStopDone = ETrue;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CAlfSynchronizer::CallbackSyncTimeout
+// --------------------------------------------------------------------------
+//
+TInt CAlfSynchronizer::CallbackSyncTimeout( TAny* aPtr )
+    {
+    ((CAlfSynchronizer*)aPtr)->DoCallbackSyncTimeout();
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// CAlfSynchronizer::DoCallbackSyncTimeout
+// --------------------------------------------------------------------------
+//
+void CAlfSynchronizer::DoCallbackSyncTimeout()
+    {        
+    iTimeout->Cancel();
+    
+    if (!iAsyncStopDone)
+        {
+        iWait->AsyncStop();
+        iAsyncStopDone = ETrue;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CAlfSynchronizer::DoCancel
+// --------------------------------------------------------------------------
+//
+void CAlfSynchronizer::DoCancel()
+    {
+    iProperty.Cancel();
+    }
+
+// --------------------------------------------------------------------------
+// CAlfSynchronizer::CAlfSynchronizer
+// --------------------------------------------------------------------------
+//
+CAlfSynchronizer::CAlfSynchronizer()
+    : CActive( EPriorityHigh )
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// --------------------------------------------------------------------------
+// CAlfSynchronizer::ConstructL
+// --------------------------------------------------------------------------
+//
+void CAlfSynchronizer::ConstructL()
+    {
+    User::LeaveIfError( iProperty.Attach( KAlfPSUidSynchronizer, KAlfPSKeySynchronizer ) );
+
+    iWait = new (ELeave) CActiveSchedulerWait;
+    
+    iTimeout = CPeriodic::NewL( CActive::EPriorityHigh );
+    }
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alfgfxtransadapter/src/gfxtransenginetfx.cpp	Fri Mar 19 09:43:21 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/alfpolicyhandler.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfpolicyhandler.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -24,12 +24,12 @@
 // ======== HELPER CLASS ========
 
 NONSHARABLE_CLASS(TFullScreenBlock)
-	{
+    {
 public:
-	TUid iFromUid;
-	TUid iToUid;
+    TUid iFromUid;
+    TUid iToUid;
 
-	};
+    };
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -69,128 +69,128 @@
 // ---------------------------------------------------------------------------
 //
 void CPolicyHandler::RegisterListBoxKmlL( const TUid& aUid,
-										  const TThreadId& aThreadId,
+                                          const TThreadId& aThreadId,
                                           const CAlfTransitionServerClient::TListBoxType aListBoxType,
                                           const TDesC& aResourceDir, 
-						                  const TDesC& aBackgroundFilename, 
-						                  const TDesC& aItemFilename,
-						                  TInt aCachePriority, 
-						                  TInt aWantedTime , TInt aMinTime )
+                                          const TDesC& aBackgroundFilename, 
+                                          const TDesC& aItemFilename,
+                                          TInt aCachePriority, 
+                                          TInt aWantedTime , TInt aMinTime )
     {
     __ALFFXLOGSTRING2("CPolicyHandler::RegisterListBoxKmlL - aUid 0x%x, aThreadId >>", aUid, aThreadId.Id());
-	aCachePriority = 1;
-	// For now, the cache priority is always 1 at registration time, and after
-	// fetching the KML information from the policy, it gets set to 0. This is
-	// used to trigger eviction from the KML cache. Newly registered KML:s have
-	// priority over existing...
-	CListBoxPolicy* policy = CListBoxPolicy::NewL( aUid, 
-												   aThreadId, 
-												   aListBoxType,
-	                                               aResourceDir, 
+    aCachePriority = 1;
+    // For now, the cache priority is always 1 at registration time, and after
+    // fetching the KML information from the policy, it gets set to 0. This is
+    // used to trigger eviction from the KML cache. Newly registered KML:s have
+    // priority over existing...
+    CListBoxPolicy* policy = CListBoxPolicy::NewL( aUid, 
+                                                   aThreadId, 
+                                                   aListBoxType,
+                                                   aResourceDir, 
                                                    aBackgroundFilename, 
                                                    aItemFilename,
                                                    aCachePriority,
                                                    aWantedTime,
                                                    aMinTime );
-	CleanupStack::PushL( policy );
-	TInt spec = policy->Specificity();	
-	TInt count = iListBoxPolicies.Count();
-	TInt uid = aUid.iUid;
-	TInt i;
-	
-	// This keeps the list with ListBox KMLs sorted after specifity, 
-	// High specificity is in the beginning of the list and low at the end.
-	// This means that when getting a ListBox KML it will find the more specified
-	// values first. A Uid counts as more specific than a TListBoxType.
-	
-	for ( i = 0; i < count; i++ )
-	    {
-	    CListBoxPolicy* curr = iListBoxPolicies[i];
-	    TInt currspec = curr->Specificity();
-	    
-	    if ( uid == curr->Uid().iUid && aListBoxType == curr->ListBoxType() )
-	        {
-	        // Duplicate policy, delete the old one.
-	        iListBoxPolicies.Remove( i );
-	        delete curr;
-	        break;
-	        }
-	    else if ( spec > currspec )
-	        {
-	        break;
-	        }
-	    }
+    CleanupStack::PushL( policy );
+    TInt spec = policy->Specificity();  
+    TInt count = iListBoxPolicies.Count();
+    TInt uid = aUid.iUid;
+    TInt i;
+    
+    // This keeps the list with ListBox KMLs sorted after specifity, 
+    // High specificity is in the beginning of the list and low at the end.
+    // This means that when getting a ListBox KML it will find the more specified
+    // values first. A Uid counts as more specific than a TListBoxType.
+    
+    for ( i = 0; i < count; i++ )
+        {
+        CListBoxPolicy* curr = iListBoxPolicies[i];
+        TInt currspec = curr->Specificity();
+        
+        if ( uid == curr->Uid().iUid && aListBoxType == curr->ListBoxType() )
+            {
+            // Duplicate policy, delete the old one.
+            iListBoxPolicies.Remove( i );
+            delete curr;
+            break;
+            }
+        else if ( spec > currspec )
+            {
+            break;
+            }
+        }
 
     iListBoxPolicies.InsertL( policy, i );
     
     CleanupStack::Pop();
     __ALFFXLOGSTRING("CPolicyHandler::RegisterListBoxKmlL <<");
-	}
-	
+    }
+    
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::UnregisterListBoxKml( const TUid& aUid,
         CAlfTransitionServerClient::TListBoxType aListBoxType )
-	{
-	__ALFFXLOGSTRING1("CPolicyHandler::UnregisterListBoxKml - Uid: 0x%x >>", aUid);
-	for( TInt count = iListBoxPolicies.Count() - 1 ; count >= 0; count-- )
-		{
-		if( iListBoxPolicies[count]->Uid() == aUid &&
-		    iListBoxPolicies[count]->ListBoxType() == aListBoxType )
-			{
-			delete iListBoxPolicies[count];
-			iListBoxPolicies.Remove( count );
-			__ALFFXLOGSTRING("CPolicyHandler::UnregisterListBoxKml - return KErrNone<<");
-			return KErrNone;
-			}
-		}
-	__ALFFXLOGSTRING("CPolicyHandler::UnregisterListBoxKml - return KErrNotFound <<");
-	return KErrNotFound;
-	}
+    {
+    __ALFFXLOGSTRING1("CPolicyHandler::UnregisterListBoxKml - Uid: 0x%x >>", aUid);
+    for( TInt count = iListBoxPolicies.Count() - 1 ; count >= 0; count-- )
+        {
+        if( iListBoxPolicies[count]->Uid() == aUid &&
+            iListBoxPolicies[count]->ListBoxType() == aListBoxType )
+            {
+            delete iListBoxPolicies[count];
+            iListBoxPolicies.Remove( count );
+            __ALFFXLOGSTRING("CPolicyHandler::UnregisterListBoxKml - return KErrNone<<");
+            return KErrNone;
+            }
+        }
+    __ALFFXLOGSTRING("CPolicyHandler::UnregisterListBoxKml - return KErrNotFound <<");
+    return KErrNotFound;
+    }
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::UnregisterListBoxKml( const TThreadId& aThreadId )
-	{
-	__ALFFXLOGSTRING1("CPolicyHandler::UnregisterListBoxKml - aThreadId: %d >>", aThreadId.Id());
-	TThreadId tid;
-	TInt err = KErrNotFound;
-	
-	for( TInt count = iListBoxPolicies.Count() - 1 ; count >= 0; count-- )
-		{
-		tid = iListBoxPolicies[count]->ThreadId();
-		if( tid.Id() == aThreadId.Id() )
-			{
-			delete iListBoxPolicies[count];
-			iListBoxPolicies.Remove( count );
-			err = KErrNone;
-			}
-		}
-	__ALFFXLOGSTRING1("CPolicyHandler::UnregisterListBoxKml - return: %d <<", err);
-	return err;
-	}
-	
+    {
+    __ALFFXLOGSTRING1("CPolicyHandler::UnregisterListBoxKml - aThreadId: %d >>", aThreadId.Id());
+    TThreadId tid;
+    TInt err = KErrNotFound;
+    
+    for( TInt count = iListBoxPolicies.Count() - 1 ; count >= 0; count-- )
+        {
+        tid = iListBoxPolicies[count]->ThreadId();
+        if( tid.Id() == aThreadId.Id() )
+            {
+            delete iListBoxPolicies[count];
+            iListBoxPolicies.Remove( count );
+            err = KErrNone;
+            }
+        }
+    __ALFFXLOGSTRING1("CPolicyHandler::UnregisterListBoxKml - return: %d <<", err);
+    return err;
+    }
+    
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
-TInt CPolicyHandler::GetListBoxKml(	const TUid& aAppId,
+TInt CPolicyHandler::GetListBoxKml( const TUid& aAppId,
                                     const CAlfTransitionServerClient::TListBoxType aListBoxType,
                                     TPtrC& aResourceDir,
                                     TPtrC& aBackgroundFilename, 
                                     TPtrC& aItemFilename, 
                                     TInt& aCachePriority, TInt& aWantedTime,
-									TInt& aMinTime)
-	{
-	__ALFFXLOGSTRING3("CPolicyHandler::GetListBoxKml - aResourceDir: %S, aBackgroundFilename: %S, aItemFilename: %S >>", &aResourceDir, &aBackgroundFilename, &aItemFilename);
-	TInt count = iListBoxPolicies.Count();
-	TBool hit = EFalse;
-	TInt i;
+                                    TInt& aMinTime)
+    {
+    __ALFFXLOGSTRING3("CPolicyHandler::GetListBoxKml - aResourceDir: %S, aBackgroundFilename: %S, aItemFilename: %S >>", &aResourceDir, &aBackgroundFilename, &aItemFilename);
+    TInt count = iListBoxPolicies.Count();
+    TBool hit = EFalse;
+    TInt i;
     aResourceDir.Set( TPtrC() );
     aBackgroundFilename.Set( TPtrC() );
     aItemFilename.Set( TPtrC() );
-	
+    
     for ( i = 0; i < count; i++ )
         {
         CListBoxPolicy* curr = iListBoxPolicies[i];
@@ -212,127 +212,127 @@
         return KErrNotFound;
         }
 
-	aResourceDir.Set( iListBoxPolicies[i]->ResourceDir() );
-	aBackgroundFilename.Set( iListBoxPolicies[i]->BackgroundFilename() );
-	aItemFilename.Set( iListBoxPolicies[i]->ItemFilename() );
-	aCachePriority = iListBoxPolicies[i]->CachePriority();
-	aWantedTime = iListBoxPolicies[i]->WantedTime();
-	aMinTime = iListBoxPolicies[i]->MinTime();
-		
-	// For now, this entry should have no priority over others
-	iListBoxPolicies[i]->SetCachePriority( 0 );
-	__ALFFXLOGSTRING("CPolicyHandler::GetListBoxKml - return KErrNone <<");
-	return KErrNone;
-	}
+    aResourceDir.Set( iListBoxPolicies[i]->ResourceDir() );
+    aBackgroundFilename.Set( iListBoxPolicies[i]->BackgroundFilename() );
+    aItemFilename.Set( iListBoxPolicies[i]->ItemFilename() );
+    aCachePriority = iListBoxPolicies[i]->CachePriority();
+    aWantedTime = iListBoxPolicies[i]->WantedTime();
+    aMinTime = iListBoxPolicies[i]->MinTime();
+        
+    // For now, this entry should have no priority over others
+    iListBoxPolicies[i]->SetCachePriority( 0 );
+    __ALFFXLOGSTRING("CPolicyHandler::GetListBoxKml - return KErrNone <<");
+    return KErrNone;
+    }
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 void CPolicyHandler::RegisterFullscreenKmlL(TUint aAction, const TUid& aUid, const TThreadId& aThreadId,
-											const TDesC& aResourceDir, const TDesC& aFilename,
-											TInt /*aCachePriority*/, TInt aWantedTime, TInt aMinTime)
-	{
-	__ALFFXLOGSTRING3("CPolicyHandler::RegisterFullscreenKmlL - aAction: %d aUid: 0x%x aThread.Id : %d", aAction, aUid, aThreadId.Id() );
-	__ALFFXLOGSTRING2("CPolicyHandler::RegisterFullscreenKmlL - aResourceDir: %S, aFilename: %S", &aResourceDir, &aFilename );
-	TInt cachePriority = 1; //aCachePriority; 
-	// For now, the cache priority is always 1 at registration time, and after
-	// fetching the KML information from the policy, it gets set to 0. This is
-	// used to trigger eviction from the KML cache. Newly registered KML:s have
-	// priority over existing...
-	
-	CFullscreenPolicy* policy = NULL;
-	
-	// Check if the action was already is registered and if so, delete it.
-	TInt count = iFullscreenPolicies.Count()-1;
-	for(; count >= 0; count--)
-		{
-		if(	iFullscreenPolicies[count]->Action() == aAction && 
-			iFullscreenPolicies[count]->Uid() == aUid)
-			{
-			policy = iFullscreenPolicies[count];
-			iFullscreenPolicies.Remove(count);
-			delete policy;
-			policy = NULL;
-			}
-		} 
+                                            const TDesC& aResourceDir, const TDesC& aFilename,
+                                            TInt /*aCachePriority*/, TInt aWantedTime, TInt aMinTime)
+    {
+    __ALFFXLOGSTRING3("CPolicyHandler::RegisterFullscreenKmlL - aAction: %d aUid: 0x%x aThread.Id : %d", aAction, aUid, aThreadId.Id() );
+    __ALFFXLOGSTRING2("CPolicyHandler::RegisterFullscreenKmlL - aResourceDir: %S, aFilename: %S", &aResourceDir, &aFilename );
+    TInt cachePriority = 1; //aCachePriority; 
+    // For now, the cache priority is always 1 at registration time, and after
+    // fetching the KML information from the policy, it gets set to 0. This is
+    // used to trigger eviction from the KML cache. Newly registered KML:s have
+    // priority over existing...
+    
+    CFullscreenPolicy* policy = NULL;
+    
+    // Check if the action was already is registered and if so, delete it.
+    TInt count = iFullscreenPolicies.Count()-1;
+    for(; count >= 0; count--)
+        {
+        if( iFullscreenPolicies[count]->Action() == aAction && 
+            iFullscreenPolicies[count]->Uid() == aUid)
+            {
+            policy = iFullscreenPolicies[count];
+            iFullscreenPolicies.Remove(count);
+            delete policy;
+            policy = NULL;
+            }
+        } 
 
-	// create and add the new action.
-	policy = CFullscreenPolicy::NewL(aAction, aUid, aThreadId, aResourceDir, aFilename,
-														cachePriority, aWantedTime, aMinTime);
-	CleanupStack::PushL(policy);
-	iFullscreenPolicies.AppendL(policy);
-	CleanupStack::Pop(policy);
-	__ALFFXLOGSTRING("CPolicyHandler::RegisterFullscreenKmlL <<");
-	}
-	
+    // create and add the new action.
+    policy = CFullscreenPolicy::NewL(aAction, aUid, aThreadId, aResourceDir, aFilename,
+                                                        cachePriority, aWantedTime, aMinTime);
+    CleanupStack::PushL(policy);
+    iFullscreenPolicies.AppendL(policy);
+    CleanupStack::Pop(policy);
+    __ALFFXLOGSTRING("CPolicyHandler::RegisterFullscreenKmlL <<");
+    }
+    
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::UnregisterFullscreenKml(TUint aAction, const TUid& aUid)
-	{
-	__ALFFXLOGSTRING2("CPolicyHandler::UnregisterFullscreenKml - aAction: %d, aUid: 0x%x <<", aAction, aUid );
-	TInt count = iFullscreenPolicies.Count() -1;
-	for(; count >= 0; count--)
-		{
-		if(iFullscreenPolicies[count]->Action() == aAction && 
-			iFullscreenPolicies[count]->Uid() == aUid)
-			{
-			CFullscreenPolicy* policy = iFullscreenPolicies[count];
-			iFullscreenPolicies.Remove(count);
-			delete policy;
-			policy = NULL;
-			__ALFFXLOGSTRING("CPolicyHandler::UnregisterFullscreenKml - return KErrNone <<");
-			return KErrNone;
-			}
-		}
-	__ALFFXLOGSTRING("CPolicyHandler::UnregisterFullscreenKml - return KErrNotFound <<");
-	return KErrNotFound;
-	}
+    {
+    __ALFFXLOGSTRING2("CPolicyHandler::UnregisterFullscreenKml - aAction: %d, aUid: 0x%x <<", aAction, aUid );
+    TInt count = iFullscreenPolicies.Count() -1;
+    for(; count >= 0; count--)
+        {
+        if(iFullscreenPolicies[count]->Action() == aAction && 
+            iFullscreenPolicies[count]->Uid() == aUid)
+            {
+            CFullscreenPolicy* policy = iFullscreenPolicies[count];
+            iFullscreenPolicies.Remove(count);
+            delete policy;
+            policy = NULL;
+            __ALFFXLOGSTRING("CPolicyHandler::UnregisterFullscreenKml - return KErrNone <<");
+            return KErrNone;
+            }
+        }
+    __ALFFXLOGSTRING("CPolicyHandler::UnregisterFullscreenKml - return KErrNotFound <<");
+    return KErrNotFound;
+    }
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::UnregisterFullscreenKml(const TThreadId& aThreadId)
-	{
-	__ALFFXLOGSTRING1("CPolicyHandler::UnregisterFullscreenKml - aThreadId: %d >>", aThreadId.Id());
-	TInt count = iFullscreenPolicies.Count() -1;
-	TInt err = KErrNotFound;
-	TThreadId tid;
-	
-	for(; count >= 0; count--)
-		{
-		tid = iFullscreenPolicies[count]->ThreadId();
-		if( tid.Id() == aThreadId.Id())
-			{
-			CFullscreenPolicy* policy = iFullscreenPolicies[count];
-			iFullscreenPolicies.Remove(count);
-			delete policy;
-			policy = NULL;
-			err = KErrNone;
-			}
-		}
-	__ALFFXLOGSTRING1("CPolicyHandler::UnregisterFullscreenKml - return: %d <<", err);
-	return err;
-	}
-	
+    {
+    __ALFFXLOGSTRING1("CPolicyHandler::UnregisterFullscreenKml - aThreadId: %d >>", aThreadId.Id());
+    TInt count = iFullscreenPolicies.Count() -1;
+    TInt err = KErrNotFound;
+    TThreadId tid;
+    
+    for(; count >= 0; count--)
+        {
+        tid = iFullscreenPolicies[count]->ThreadId();
+        if( tid.Id() == aThreadId.Id())
+            {
+            CFullscreenPolicy* policy = iFullscreenPolicies[count];
+            iFullscreenPolicies.Remove(count);
+            delete policy;
+            policy = NULL;
+            err = KErrNone;
+            }
+        }
+    __ALFFXLOGSTRING1("CPolicyHandler::UnregisterFullscreenKml - return: %d <<", err);
+    return err;
+    }
+    
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::UnregisterAllKml(const TThreadId& aThreadId)
-	{
-	__ALFFXLOGSTRING1("CPolicyHandler::UnregisterAllKml - aThreadId: <<", aThreadId.Id());
-	TInt err = KErrNotFound;
-	TInt err1 = UnregisterFullscreenKml(aThreadId);
-	TInt err2 = UnregisterControlKml(aThreadId);
+    {
+    __ALFFXLOGSTRING1("CPolicyHandler::UnregisterAllKml - aThreadId: <<", aThreadId.Id());
+    TInt err = KErrNotFound;
+    TInt err1 = UnregisterFullscreenKml(aThreadId);
+    TInt err2 = UnregisterControlKml(aThreadId);
 
-	if(err1 == KErrNone || err2 == KErrNone)
-		err = KErrNone;
+    if(err1 == KErrNone || err2 == KErrNone)
+        err = KErrNone;
 
 
-	TInt err3 = UnregisterListBoxKml(aThreadId);
-	if(err3 == KErrNone)
-		err = KErrNone;
-	__ALFFXLOGSTRING1("CPolicyHandler::UnregisterAllKml - return: %d <<", err);
+    TInt err3 = UnregisterListBoxKml(aThreadId);
+    if(err3 == KErrNone)
+        err = KErrNone;
+    __ALFFXLOGSTRING1("CPolicyHandler::UnregisterAllKml - return: %d <<", err);
     return err; 
     }
 
@@ -340,688 +340,688 @@
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
-TInt CPolicyHandler::GetFullscreenKml(	TUint aAction, const TUid& aToUid, const TUid& aFromUid,
-									 	TPtrC& aResourceDir, TPtrC& aFilename,
-									 	TInt& aCachePriority, TInt& aWantedTime, TInt& aMinTime)
-	{
+TInt CPolicyHandler::GetFullscreenKml(  TUint aAction, const TUid& aToUid, const TUid& aFromUid,
+                                        TPtrC& aResourceDir, TPtrC& aFilename,
+                                        TInt& aCachePriority, TInt& aWantedTime, TInt& aMinTime)
+    {
     __ALFFXLOGSTRING3("CPolicyHandler::GetFullscreenKml - aAction: %d, aToUid: %d, aFromUid :%d", aAction, aToUid, aFromUid );
     __ALFFXLOGSTRING2("CPolicyHandler::GetFullscreenKml - aResourceDir: %S, aFilename :%S", &aResourceDir, &aFilename );
 
-	// Checking if the UID is blocked.
-	TInt blockedUids = iFullScreenBlocks.Count();
-	aResourceDir.Set( TPtrC() );
-	aFilename.Set( TPtrC() );
-	
-	for( TInt i = 0 ;  i < blockedUids ; i++ )
-		{
-		if( iFullScreenBlocks[i]->iToUid == aToUid ||
-			iFullScreenBlocks[i]->iFromUid == aFromUid)
-			{
-			__ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotSupported <<");
-			return KErrNotSupported;
-			}
-		}
-		
-	TInt count = iFullscreenPolicies.Count();
-	// try to find it using both action and uid
-	for(TInt i = 0; i < count; i++)
-		{
-		if(iFullscreenPolicies[i]->Action() == aAction && 
-			iFullscreenPolicies[i]->Uid() == aToUid)
-			{
-			aResourceDir.Set( iFullscreenPolicies[i]->ResourceDir() );
-			aFilename.Set( iFullscreenPolicies[i]->Filename() );
-			aCachePriority = iFullscreenPolicies[i]->CachePriority();
-			aWantedTime = iFullscreenPolicies[i]->WantedTime();
-			aMinTime = iFullscreenPolicies[i]->MinTime();
-			// Check if theres a block on this UID/Action pair.
-			if( aFilename.Length() == 0 ) 
-				{
-	            __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotSupported <<");
-				return KErrNotSupported;
-				}
-				
-			// For now, this entry should have no priority over others
-			iFullscreenPolicies[i]->SetCachePriority(0);
+    // Checking if the UID is blocked.
+    TInt blockedUids = iFullScreenBlocks.Count();
+    aResourceDir.Set( TPtrC() );
+    aFilename.Set( TPtrC() );
+    
+    for( TInt i = 0 ;  i < blockedUids ; i++ )
+        {
+        if( iFullScreenBlocks[i]->iToUid == aToUid ||
+            iFullScreenBlocks[i]->iFromUid == aFromUid)
+            {
+            __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotSupported <<");
+            return KErrNotSupported;
+            }
+        }
+        
+    TInt count = iFullscreenPolicies.Count();
+    // try to find it using both action and uid
+    for(TInt i = 0; i < count; i++)
+        {
+        if(iFullscreenPolicies[i]->Action() == aAction && 
+            iFullscreenPolicies[i]->Uid() == aToUid)
+            {
+            aResourceDir.Set( iFullscreenPolicies[i]->ResourceDir() );
+            aFilename.Set( iFullscreenPolicies[i]->Filename() );
+            aCachePriority = iFullscreenPolicies[i]->CachePriority();
+            aWantedTime = iFullscreenPolicies[i]->WantedTime();
+            aMinTime = iFullscreenPolicies[i]->MinTime();
+            // Check if theres a block on this UID/Action pair.
+            if( aFilename.Length() == 0 ) 
+                {
+                __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotSupported <<");
+                return KErrNotSupported;
+                }
+                
+            // For now, this entry should have no priority over others
+            iFullscreenPolicies[i]->SetCachePriority(0);
             __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNone <<");
             return KErrNone;
-			}
-		}
-	// try to find the default (Uid == KNullUid)
-	for(TInt i = 0; i < count; i++)
-		{
-		if(iFullscreenPolicies[i]->Action() == aAction && 
-			iFullscreenPolicies[i]->Uid() == KNullUid)
-			{
-			aResourceDir.Set( iFullscreenPolicies[i]->ResourceDir() );
-			aFilename.Set( iFullscreenPolicies[i]->Filename() );
-			aCachePriority = iFullscreenPolicies[i]->CachePriority();
-			aWantedTime = iFullscreenPolicies[i]->WantedTime();
-			aMinTime = iFullscreenPolicies[i]->MinTime();
-			
-			// For now, this entry should have no priority over others
-			iFullscreenPolicies[i]->SetCachePriority(0); 
-			__ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNone <<");
-			return KErrNone;
-			}
-		}
-	__ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotFound <<");
-	return KErrNotFound;
-	}
+            }
+        }
+    // try to find the default (Uid == KNullUid)
+    for(TInt i = 0; i < count; i++)
+        {
+        if(iFullscreenPolicies[i]->Action() == aAction && 
+            iFullscreenPolicies[i]->Uid() == KNullUid)
+            {
+            aResourceDir.Set( iFullscreenPolicies[i]->ResourceDir() );
+            aFilename.Set( iFullscreenPolicies[i]->Filename() );
+            aCachePriority = iFullscreenPolicies[i]->CachePriority();
+            aWantedTime = iFullscreenPolicies[i]->WantedTime();
+            aMinTime = iFullscreenPolicies[i]->MinTime();
+            
+            // For now, this entry should have no priority over others
+            iFullscreenPolicies[i]->SetCachePriority(0); 
+            __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNone <<");
+            return KErrNone;
+            }
+        }
+    __ALFFXLOGSTRING("CPolicyHandler::GetFullscreenKml - return KErrNotFound <<");
+    return KErrNotFound;
+    }
 
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::BlockFullScreenUid(const TUid& aUid, TBool aBlockFrom, TBool aBlockTo)
-	{
-	__ALFFXLOGSTRING3("CPolicyHandler::BlockFullScreenUid - aUid: 0x%x, aBlockFrom: %d, aBlockTo: %d >>", aUid, aBlockFrom, aBlockTo );	
-	TFullScreenBlock* block = NULL;
-	
-	TInt blockedUids = iFullScreenBlocks.Count();
-	if(	blockedUids > 0)
-		{
-		// Looking for an existing To block.
-		if(!aBlockTo && aBlockFrom )
-			{
-			for(TInt i = 0; i < blockedUids; i++)
-				{
-				if(iFullScreenBlocks[i]->iFromUid == aUid)
-					{
-					__ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<");
-					return KErrNone;
-					}
-				}
-			}
-		// Looking for an existing From block.
-		else if(aBlockTo && !aBlockFrom)
-			{
-			for(TInt i = 0; i < blockedUids; i++)
-				{
-				if(iFullScreenBlocks[i]->iToUid  == aUid)
-					{
-					__ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<");
-					return KErrNone;
-					}
-				}
-			}
-		// Trying to unblock stuff.
-		else if(!aBlockTo && !aBlockFrom)
-			{
-			for(TInt i = blockedUids -1; i >= 0; i--)
-				{
-				if(	iFullScreenBlocks[i]->iToUid  == aUid ||
-					iFullScreenBlocks[i]->iFromUid == aUid )
-					{
-					block = iFullScreenBlocks[i];
-					iFullScreenBlocks.Remove(i);
-					delete block;
-					block = NULL;
-					}
-				}
-			__ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<");
-			return KErrNone;
-			}
-		// Looking for an existing To and From block with the same UID's.
-		else
-			{
-			for(TInt i = 0; i < blockedUids; i++)
-				{
-				if(	iFullScreenBlocks[i]->iToUid  == aUid &&
-					iFullScreenBlocks[i]->iFromUid == aUid )
-					{
-					__ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<");
-					return KErrNone;
-					}
-				}
-			}
-		}
+    {
+    __ALFFXLOGSTRING3("CPolicyHandler::BlockFullScreenUid - aUid: 0x%x, aBlockFrom: %d, aBlockTo: %d >>", aUid, aBlockFrom, aBlockTo ); 
+    TFullScreenBlock* block = NULL;
+    
+    TInt blockedUids = iFullScreenBlocks.Count();
+    if( blockedUids > 0)
+        {
+        // Looking for an existing To block.
+        if(!aBlockTo && aBlockFrom )
+            {
+            for(TInt i = 0; i < blockedUids; i++)
+                {
+                if(iFullScreenBlocks[i]->iFromUid == aUid)
+                    {
+                    __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<");
+                    return KErrNone;
+                    }
+                }
+            }
+        // Looking for an existing From block.
+        else if(aBlockTo && !aBlockFrom)
+            {
+            for(TInt i = 0; i < blockedUids; i++)
+                {
+                if(iFullScreenBlocks[i]->iToUid  == aUid)
+                    {
+                    __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<");
+                    return KErrNone;
+                    }
+                }
+            }
+        // Trying to unblock stuff.
+        else if(!aBlockTo && !aBlockFrom)
+            {
+            for(TInt i = blockedUids -1; i >= 0; i--)
+                {
+                if( iFullScreenBlocks[i]->iToUid  == aUid ||
+                    iFullScreenBlocks[i]->iFromUid == aUid )
+                    {
+                    block = iFullScreenBlocks[i];
+                    iFullScreenBlocks.Remove(i);
+                    delete block;
+                    block = NULL;
+                    }
+                }
+            __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<");
+            return KErrNone;
+            }
+        // Looking for an existing To and From block with the same UID's.
+        else
+            {
+            for(TInt i = 0; i < blockedUids; i++)
+                {
+                if( iFullScreenBlocks[i]->iToUid  == aUid &&
+                    iFullScreenBlocks[i]->iFromUid == aUid )
+                    {
+                    __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNone <<");
+                    return KErrNone;
+                    }
+                }
+            }
+        }
 
-	// None found. Create!
-	block = new TFullScreenBlock();
-	if(NULL == block)
-		{
-		__ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNoMemory <<");
-		return KErrNoMemory;
-		}
+    // None found. Create!
+    block = new TFullScreenBlock();
+    if(NULL == block)
+        {
+        __ALFFXLOGSTRING("CPolicyHandler::BlockFullScreenUid - return KErrNoMemory <<");
+        return KErrNoMemory;
+        }
 
-	if(aBlockTo)
-		{
-		block->iToUid = aUid;
-		}
-	if(aBlockFrom)
-		{
-		block->iFromUid = aUid;
-		}
+    if(aBlockTo)
+        {
+        block->iToUid = aUid;
+        }
+    if(aBlockFrom)
+        {
+        block->iFromUid = aUid;
+        }
 
-	TInt err = iFullScreenBlocks.Append(block);
-	if(KErrNone != err)
-		{
-		delete block;
-		block = NULL;
-		}
-	__ALFFXLOGSTRING1("CPolicyHandler::BlockFullScreenUid - return: %d <<", err);
-	return err;
-	}
+    TInt err = iFullScreenBlocks.Append(block);
+    if(KErrNone != err)
+        {
+        delete block;
+        block = NULL;
+        }
+    __ALFFXLOGSTRING1("CPolicyHandler::BlockFullScreenUid - return: %d <<", err);
+    return err;
+    }
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::RegisterControlAction(const TUid aUid, TUint aAction, const TDesC& aActionString)
-	{
-	__ALFFXLOGSTRING3("CPolicyHandler::RegisterControlAction - aUid: 0x%x, aAction: %d, aActionString: %S", aUid, aAction, &aActionString );
-	TInt index = 0;
-	CControlPolicy* pData = NULL;
-	CActionPolicy* pPolicy = NULL;
-	
-	// TEST!!!!!!!!!!
-	// First see if we have an empty entry that means a new KML has been registered
-	// Adding just a KML does not remove the old one, the old one gets removed only
-	// after we add an action to the new KML
-	
-	// The double action of first registering a KML file and then registering the action
-	// should be replaced with single call where the control file and action are defined
-	// in one call
-	
+    {
+    __ALFFXLOGSTRING3("CPolicyHandler::RegisterControlAction - aUid: 0x%x, aAction: %d, aActionString: %S", aUid, aAction, &aActionString );
+    TInt index = 0;
+    CControlPolicy* pData = NULL;
+    CActionPolicy* pPolicy = NULL;
+    
+    // TEST!!!!!!!!!!
+    // First see if we have an empty entry that means a new KML has been registered
+    // Adding just a KML does not remove the old one, the old one gets removed only
+    // after we add an action to the new KML
+    
+    // The double action of first registering a KML file and then registering the action
+    // should be replaced with single call where the control file and action are defined
+    // in one call
+    
     TInt count = iControlPolicies.Count();
-	index = -1;	// Setting index to negative value to use as check if match found.
-	TInt i = 0;
-	TInt j = 0;
-	TInt k = 0;
-	
-	// We stop when we find a matching empty entry
-	// But first old non-empty entries are deleted
-	for( i = count - 1; i >= 0 && index == -1; i-- )
-		{
-		pData = iControlPolicies[i];
-		if( pData->Uid() == aUid )
-			{
-			if ( pData->iControlPolicies.Count() == 0 )
-			    {
-			    index = i;
-			    // We have found an empty definition.
-			    // This means a new effect definition file has been added, and the new action
-			    // should be attached to it.
-			    // But first we have to remove the possible old effect file
-			    for ( j = count - 1; j >= 0; j-- )
-			        {
-               		pData = iControlPolicies[j];
-               		if ( pData->Uid() == aUid )
-               		    {
-                   		for ( k = 0; pData && k < pData->iControlPolicies.Count(); k++ )
-                   		    {
-            				pPolicy = pData->iControlPolicies[k];
-                   		    if ( pPolicy->iAction == aAction )
-                   		        {
-                   		        // Old definition found, remove the whole policy entry
-    			                iControlPolicies.Remove( j );
-    			                count--; // this value is referred later. It must be kept up to date.
-    			                delete pData;
-    			                pData = NULL;
-                   		        }
-                   		    }
-               		    }
-			        }
-			    }
-			}
-		}
-		
-	if( index >= 0 )
-		{
-		index = -1; // paranoid...
-		// find the empty entry again - if it exists
-		// our indexes may have got messed up if we removed something
-		// so we must recheck the index
-		// We only accept entries with no policies, as we just checked
-		// the existence of an entry with matching policy
-    	for( i = count - 1; i >= 0 && index == -1; i-- )
-	    	{
-		    pData = iControlPolicies[i];
-		    if( pData->Uid() == aUid )
-			    {
-     			if ( pData->iControlPolicies.Count() == 0 )
-     			    {
-	     		    index = i;
-     			    }
-			    }
-	    	}
-		}
+    index = -1; // Setting index to negative value to use as check if match found.
+    TInt i = 0;
+    TInt j = 0;
+    TInt k = 0;
+    
+    // We stop when we find a matching empty entry
+    // But first old non-empty entries are deleted
+    for( i = count - 1; i >= 0 && index == -1; i-- )
+        {
+        pData = iControlPolicies[i];
+        if( pData->Uid() == aUid )
+            {
+            if ( pData->iControlPolicies.Count() == 0 )
+                {
+                index = i;
+                // We have found an empty definition.
+                // This means a new effect definition file has been added, and the new action
+                // should be attached to it.
+                // But first we have to remove the possible old effect file
+                for ( j = count - 1; j >= 0; j-- )
+                    {
+                    pData = iControlPolicies[j];
+                    if ( pData->Uid() == aUid )
+                        {
+                        for ( k = 0; pData && k < pData->iControlPolicies.Count(); k++ )
+                            {
+                            pPolicy = pData->iControlPolicies[k];
+                            if ( pPolicy->iAction == aAction )
+                                {
+                                // Old definition found, remove the whole policy entry
+                                iControlPolicies.Remove( j );
+                                count--; // this value is referred later. It must be kept up to date.
+                                delete pData;
+                                pData = NULL;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        
+    if( index >= 0 )
+        {
+        index = -1; // paranoid...
+        // find the empty entry again - if it exists
+        // our indexes may have got messed up if we removed something
+        // so we must recheck the index
+        // We only accept entries with no policies, as we just checked
+        // the existence of an entry with matching policy
+        for( i = count - 1; i >= 0 && index == -1; i-- )
+            {
+            pData = iControlPolicies[i];
+            if( pData->Uid() == aUid )
+                {
+                if ( pData->iControlPolicies.Count() == 0 )
+                    {
+                    index = i;
+                    }
+                }
+            }
+        }
 // Now we have checked if we have an effect file definition that has no entries yet,
 // and if we found one, we deleted old effect file definitions for this UID.
-// Now we check if we just update an old action or add a new one to the existing entry		
+// Now we check if we just update an old action or add a new one to the existing entry      
 
-	// First checking if we need to update a policy.
-	// If we have an empty entry, we must use it, not add our action to a different entry
-	// even if if has the same UID.
-	// So we must not try to find an existing entry if we have already decided to use an
-	// empty entry
-	
-	if ( index < 0 )
-	    {
-    	if(FindControlPolicy(aAction, aUid, pPolicy, index) == KErrNone)
-    		{
-    		// If we get here and pPolicy == NULL, something is really wrong outside of
-    		// our control.
-    		pPolicy->iAction = aAction;
-    		// Setting the action string is a leaving method.
-    		// Trap it here to avoid the rest of the system to become
-    		// leaving to.
-    		TRAPD(err, pPolicy->SetActionStringL(aActionString));
-    		if(KErrNone != err)
-    			{
-    			__ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err);
-    			return err;
-    			}
-    		pPolicy->iPolicy = ESupported;
-    		iClientRequestHandler->RegisterControlAction( aUid, aAction);
-    		__ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNone <<");
-    		return KErrNone;
-    		}
-	    }
-		
-	if( index < 0 )
-		{
-		__ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNotFound <<");
-		return KErrNotFound;
-		}
-		
-	pData = iControlPolicies[index];
-	pPolicy = new CActionPolicy();
-	if(!pPolicy)
-		{
-		__ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNoMemory <<");
-		return KErrNoMemory;
-		}
-	
-	// Assign some values
-	pPolicy->iAction = aAction;
-	pPolicy->iPolicy = ESupported;
-	TRAPD(err, pPolicy->SetActionStringL(aActionString));
-	if(KErrNone != err)
-		{
-		delete pPolicy;
-		__ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err);
-		return err;
-		}	
+    // First checking if we need to update a policy.
+    // If we have an empty entry, we must use it, not add our action to a different entry
+    // even if if has the same UID.
+    // So we must not try to find an existing entry if we have already decided to use an
+    // empty entry
+    
+    if ( index < 0 )
+        {
+        if(FindControlPolicy(aAction, aUid, pPolicy, index) == KErrNone)
+            {
+            // If we get here and pPolicy == NULL, something is really wrong outside of
+            // our control.
+            pPolicy->iAction = aAction;
+            // Setting the action string is a leaving method.
+            // Trap it here to avoid the rest of the system to become
+            // leaving to.
+            TRAPD(err, pPolicy->SetActionStringL(aActionString));
+            if(KErrNone != err)
+                {
+                __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err);
+                return err;
+                }
+            pPolicy->iPolicy = ESupported;
+            iClientRequestHandler->RegisterControlAction( aUid, aAction);
+            __ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNone <<");
+            return KErrNone;
+            }
+        }
+        
+    if( index < 0 )
+        {
+        __ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNotFound <<");
+        return KErrNotFound;
+        }
+        
+    pData = iControlPolicies[index];
+    pPolicy = new CActionPolicy();
+    if(!pPolicy)
+        {
+        __ALFFXLOGSTRING("CPolicyHandler::RegisterControlAction - return KErrNoMemory <<");
+        return KErrNoMemory;
+        }
+    
+    // Assign some values
+    pPolicy->iAction = aAction;
+    pPolicy->iPolicy = ESupported;
+    TRAPD(err, pPolicy->SetActionStringL(aActionString));
+    if(KErrNone != err)
+        {
+        delete pPolicy;
+        __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err);
+        return err;
+        }   
 
-	// Then add it to the list.
-	err = pData->iControlPolicies.Append(pPolicy);
-	if(err != KErrNone)
-		{
-		delete pPolicy;
-		pPolicy = NULL;
-		__ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err);
-		return err;
-		}
-	iClientRequestHandler->RegisterControlAction(aUid, aAction);
-	__ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err);
-	return err;
-	}
-	
+    // Then add it to the list.
+    err = pData->iControlPolicies.Append(pPolicy);
+    if(err != KErrNone)
+        {
+        delete pPolicy;
+        pPolicy = NULL;
+        __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err);
+        return err;
+        }
+    iClientRequestHandler->RegisterControlAction(aUid, aAction);
+    __ALFFXLOGSTRING1("CPolicyHandler::RegisterControlAction - return: %d <<", err);
+    return err;
+    }
+    
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::UnregisterControlAction(const TUid aUid, TUint aAction)
-	{
-	__ALFFXLOGSTRING2("CPolicyHandler::UnregisterControlAction - aUid %d, aAction: %d >>", aUid, aAction);
-	CControlPolicy* pData = NULL;
-	CActionPolicy* pPolicy = NULL;
-		
-	TInt count = iControlPolicies.Count();
-	
-	// Removing policy for action.
-	for(TInt counter = 0; counter < count; counter++)
-		{
-		pData = iControlPolicies[counter];
-		if(pData->Uid() == aUid)
-			{
-			TInt polActionCount = pData->iControlPolicies.Count();
-			// Iterating the list from first. No problem since we only delete one item!
-			for(TInt j = 0; j < polActionCount; j++)
-				{
-				pPolicy = pData->iControlPolicies[j];
-				if(pPolicy->iAction == aAction)
-					{
-					// Call this before removing data permanently!
-					iClientRequestHandler->RemoveControlPolicy( aUid, aAction);
-					delete pPolicy;
-					pPolicy = NULL;
-					pData->iControlPolicies.Remove(j);
-					__ALFFXLOGSTRING("CPolicyHandler::UnregisterControlAction - return KErrNone<<");
-					return KErrNone;
-					}
-				}
-			}
-		}
-	__ALFFXLOGSTRING("CPolicyHandler::UnregisterControlAction - return KErrNotFound<<");
-	return KErrNotFound;
-	}  	
-	
-	
+    {
+    __ALFFXLOGSTRING2("CPolicyHandler::UnregisterControlAction - aUid %d, aAction: %d >>", aUid, aAction);
+    CControlPolicy* pData = NULL;
+    CActionPolicy* pPolicy = NULL;
+        
+    TInt count = iControlPolicies.Count();
+    
+    // Removing policy for action.
+    for(TInt counter = 0; counter < count; counter++)
+        {
+        pData = iControlPolicies[counter];
+        if(pData->Uid() == aUid)
+            {
+            TInt polActionCount = pData->iControlPolicies.Count();
+            // Iterating the list from first. No problem since we only delete one item!
+            for(TInt j = 0; j < polActionCount; j++)
+                {
+                pPolicy = pData->iControlPolicies[j];
+                if(pPolicy->iAction == aAction)
+                    {
+                    // Call this before removing data permanently!
+                    iClientRequestHandler->RemoveControlPolicy( aUid, aAction);
+                    delete pPolicy;
+                    pPolicy = NULL;
+                    pData->iControlPolicies.Remove(j);
+                    __ALFFXLOGSTRING("CPolicyHandler::UnregisterControlAction - return KErrNone<<");
+                    return KErrNone;
+                    }
+                }
+            }
+        }
+    __ALFFXLOGSTRING("CPolicyHandler::UnregisterControlAction - return KErrNotFound<<");
+    return KErrNotFound;
+    }   
+    
+    
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 void CPolicyHandler::RegisterControlKmlL(const TUid &aUid, const TThreadId &aThreadId, 
-										 const TDesC& aResourceDir, const TDesC& aFilename,
-										 const TInt aWantedTime, const TInt aMinTime)
-	{
-	
-	__ALFFXLOGSTRING2("CPolicyHandler::RegisterControlKmlL - aUid :%d aThread.Id :%d", aUid, aThreadId.Id() );
+                                         const TDesC& aResourceDir, const TDesC& aFilename,
+                                         const TInt aWantedTime, const TInt aMinTime)
+    {
+    
+    __ALFFXLOGSTRING2("CPolicyHandler::RegisterControlKmlL - aUid :%d aThread.Id :%d", aUid, aThreadId.Id() );
    __ALFFXLOGSTRING2("CPolicyHandler::RegisterControlKmlL - aResourceDir: %S, aFilename :%S", &aResourceDir, &aFilename );
 
-	CControlPolicy* policy = NULL;
-	TInt cachePriority = 1; //aCachePriority; 
-	// For now, the cache priority is always 1 at registration time, and after
-	// fetching the KML information from the policy, it gets set to 0. This is
-	// used to trigger eviction from the KML cache. Newly registered KML:s have
-	// priority over existing...
+    CControlPolicy* policy = NULL;
+    TInt cachePriority = 1; //aCachePriority; 
+    // For now, the cache priority is always 1 at registration time, and after
+    // fetching the KML information from the policy, it gets set to 0. This is
+    // used to trigger eviction from the KML cache. Newly registered KML:s have
+    // priority over existing...
 
-	// Check if the action was already is registered and if so, delete it.
-	
-// TEST!!!!!!!!!!!! Don't delete before action is added	
+    // Check if the action was already is registered and if so, delete it.
+    
+// TEST!!!!!!!!!!!! Don't delete before action is added 
 // Only delete if the entry has no policies, then we are replacing the xml file
 // though we have added no actions yet
-	TInt count = iControlPolicies.Count()-1;
-	for(; count >= 0; count--)
-		{
-		if(	iControlPolicies[count]->Uid() == aUid)
-			{
-			policy = iControlPolicies[count];
-			if ( policy->iControlPolicies.Count() == 0 )
-			    {
-    			iControlPolicies.Remove(count);
-	    		delete policy;
-		    	policy = NULL;
-			    }
-			}
-		} 
+    TInt count = iControlPolicies.Count()-1;
+    for(; count >= 0; count--)
+        {
+        if( iControlPolicies[count]->Uid() == aUid)
+            {
+            policy = iControlPolicies[count];
+            if ( policy->iControlPolicies.Count() == 0 )
+                {
+                iControlPolicies.Remove(count);
+                delete policy;
+                policy = NULL;
+                }
+            }
+        } 
 
-	// Create the new action and add it.
-	policy = CControlPolicy::NewL(aUid, aThreadId, aResourceDir, aFilename, cachePriority, aWantedTime, aMinTime);
-	CleanupStack::PushL(policy);
-	iControlPolicies.AppendL(policy);
-	CleanupStack::Pop(policy);
-	__ALFFXLOGSTRING("CPolicyHandler::RegisterControlKmlL <<");
-	}
-	
+    // Create the new action and add it.
+    policy = CControlPolicy::NewL(aUid, aThreadId, aResourceDir, aFilename, cachePriority, aWantedTime, aMinTime);
+    CleanupStack::PushL(policy);
+    iControlPolicies.AppendL(policy);
+    CleanupStack::Pop(policy);
+    __ALFFXLOGSTRING("CPolicyHandler::RegisterControlKmlL <<");
+    }
+    
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::RemoveControlKml(const TUid &aUid)
-	{
-	__ALFFXLOGSTRING1("CPolicyHandler::RemoveControlKml - aUid: %d ", aUid);
-	
-	TInt err = KErrNotFound;
-	CControlPolicy* ptr = NULL;
-	CActionPolicy* action = NULL;
-	TInt policyCount = iControlPolicies.Count();
-	// We may remove several KMLs if different actions have different effect files
-	for( TInt i = policyCount - 1; i >= 0; i--)
-		{
-		ptr = iControlPolicies[i];
-		if(ptr->Uid() == aUid)
-			{
-			// making sure that policies get removed from the running clients as well!
-			TInt count = ptr->iControlPolicies.Count();
-			if( count > 0)
-				{
-				for(TInt j = 0; j < count; j++)
-					{
-					action = ptr->iControlPolicies[j];
-					iClientRequestHandler->RemoveControlPolicy(aUid, action->iAction);
-					}
-				}
-			iControlPolicies.Remove(i);
-			delete ptr;
-			ptr = NULL;
-			err = KErrNone;
-			}
-		}
-	__ALFFXLOGSTRING1("CPolicyHandler::RemoveControlKml - return: %d <<", err);
-	return err;
-	}
-	
+    {
+    __ALFFXLOGSTRING1("CPolicyHandler::RemoveControlKml - aUid: %d ", aUid);
+    
+    TInt err = KErrNotFound;
+    CControlPolicy* ptr = NULL;
+    CActionPolicy* action = NULL;
+    TInt policyCount = iControlPolicies.Count();
+    // We may remove several KMLs if different actions have different effect files
+    for( TInt i = policyCount - 1; i >= 0; i--)
+        {
+        ptr = iControlPolicies[i];
+        if(ptr->Uid() == aUid)
+            {
+            // making sure that policies get removed from the running clients as well!
+            TInt count = ptr->iControlPolicies.Count();
+            if( count > 0)
+                {
+                for(TInt j = 0; j < count; j++)
+                    {
+                    action = ptr->iControlPolicies[j];
+                    iClientRequestHandler->RemoveControlPolicy(aUid, action->iAction);
+                    }
+                }
+            iControlPolicies.Remove(i);
+            delete ptr;
+            ptr = NULL;
+            err = KErrNone;
+            }
+        }
+    __ALFFXLOGSTRING1("CPolicyHandler::RemoveControlKml - return: %d <<", err);
+    return err;
+    }
+    
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::UnregisterControlKml(const TThreadId &aThreadId)
-	{
-	__ALFFXLOGSTRING1("CPolicyHandler::UnregisterControlKml - aThreadId: %d ", aThreadId.Id() );
-	CControlPolicy* ptr = NULL;
-	CActionPolicy* action = NULL;
-	TInt err = KErrNotFound;
-	TThreadId tid;
-	TInt policyCount = iControlPolicies.Count();
-	
-	for( TInt i = policyCount - 1; i >= 0; i--)
-		{
-		ptr = iControlPolicies[i];
-		tid = ptr->ThreadId();
-		
-		if(tid.Id() == aThreadId.Id())
-			{
-			// making sure that policies get removed from the running clients as well!
-			TInt count = ptr->iControlPolicies.Count();
-			if(count > 0)
-				{
-				for(TInt j = 0; j < count; j++)
-					{
-					action = ptr->iControlPolicies[j];
-					iClientRequestHandler->RemoveControlPolicy(ptr->Uid(), action->iAction);
-					}
-				}
-			iControlPolicies.Remove(i);
-			delete ptr;
-			ptr = NULL;
-			err = KErrNone;
-			}
-		}
-	__ALFFXLOGSTRING1("CPolicyHandler::UnregisterControlKml - return: %d <<", err);
-	return err;
-	}
+    {
+    __ALFFXLOGSTRING1("CPolicyHandler::UnregisterControlKml - aThreadId: %d ", aThreadId.Id() );
+    CControlPolicy* ptr = NULL;
+    CActionPolicy* action = NULL;
+    TInt err = KErrNotFound;
+    TThreadId tid;
+    TInt policyCount = iControlPolicies.Count();
+    
+    for( TInt i = policyCount - 1; i >= 0; i--)
+        {
+        ptr = iControlPolicies[i];
+        tid = ptr->ThreadId();
+        
+        if(tid.Id() == aThreadId.Id())
+            {
+            // making sure that policies get removed from the running clients as well!
+            TInt count = ptr->iControlPolicies.Count();
+            if(count > 0)
+                {
+                for(TInt j = 0; j < count; j++)
+                    {
+                    action = ptr->iControlPolicies[j];
+                    iClientRequestHandler->RemoveControlPolicy(ptr->Uid(), action->iAction);
+                    }
+                }
+            iControlPolicies.Remove(i);
+            delete ptr;
+            ptr = NULL;
+            err = KErrNone;
+            }
+        }
+    __ALFFXLOGSTRING1("CPolicyHandler::UnregisterControlKml - return: %d <<", err);
+    return err;
+    }
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
-TInt CPolicyHandler::GetControlKml(	TUid aUid, TUint aAction, TPtrC& aResourceDir, 
-					TPtrC& aFileName, TPtrC& aActionString, TInt& aCachePriority,
-					TInt& aWantedTime, TInt& aMinTime)
-	{
-	__ALFFXLOGSTRING2("CPolicyHandler::GetControlKml - aAction: %d aUid :0x%x", aAction, aUid );
-	__ALFFXLOGSTRING3("CPolicyHandler::GetControlKml - aResourceDir: %S, aFilename :%S, aActionString: %S", &aResourceDir, &aFileName, &aActionString );
-	    
-	CControlPolicy* ptr = NULL;
-	CActionPolicy* pPolicy = NULL;
-	aResourceDir.Set( TPtrC() );
-	aFileName.Set( TPtrC() );
+TInt CPolicyHandler::GetControlKml( TUid aUid, TUint aAction, TPtrC& aResourceDir, 
+                    TPtrC& aFileName, TPtrC& aActionString, TInt& aCachePriority,
+                    TInt& aWantedTime, TInt& aMinTime)
+    {
+    __ALFFXLOGSTRING2("CPolicyHandler::GetControlKml - aAction: %d aUid :0x%x", aAction, aUid );
+    __ALFFXLOGSTRING3("CPolicyHandler::GetControlKml - aResourceDir: %S, aFilename :%S, aActionString: %S", &aResourceDir, &aFileName, &aActionString );
+        
+    CControlPolicy* ptr = NULL;
+    CActionPolicy* pPolicy = NULL;
+    aResourceDir.Set( TPtrC() );
+    aFileName.Set( TPtrC() );
     aActionString.Set( TPtrC() );
 
-	TInt itemCount = iControlPolicies.Count();
-	for(TInt i = 0; i < itemCount; i++)
-		{
-		ptr = iControlPolicies[i];
-		if( ptr->Uid() == aUid)
-			{
-			aResourceDir.Set( ptr->ResourceDir() );
-			aFileName.Set( ptr->Filename() );
-			aCachePriority = ptr->CachePriority();
-			aWantedTime = ptr->WantedTime();
-			aMinTime = ptr->MinTime();
-			TInt actionCount = ptr->iControlPolicies.Count();
-			for(TInt j = 0; j < actionCount; j++)
-				{
-				pPolicy = ptr->iControlPolicies[j];
-				if(pPolicy->iAction == aAction)
-					{
-					aActionString.Set( pPolicy->ActionString() );
-					// For now, this entry should have no priority over others
-					ptr->SetCachePriority(0);
-					__ALFFXLOGSTRING("CPolicyHandler::GetControlKml - return KErrNone <<");
-					return KErrNone;
-					}
-				}
-			}
-		}
-	__ALFFXLOGSTRING("CPolicyHandler::GetControlKml - return KErrNotFound <<");
-	return KErrNotFound;
-	}
-	
+    TInt itemCount = iControlPolicies.Count();
+    for(TInt i = 0; i < itemCount; i++)
+        {
+        ptr = iControlPolicies[i];
+        if( ptr->Uid() == aUid)
+            {
+            aResourceDir.Set( ptr->ResourceDir() );
+            aFileName.Set( ptr->Filename() );
+            aCachePriority = ptr->CachePriority();
+            aWantedTime = ptr->WantedTime();
+            aMinTime = ptr->MinTime();
+            TInt actionCount = ptr->iControlPolicies.Count();
+            for(TInt j = 0; j < actionCount; j++)
+                {
+                pPolicy = ptr->iControlPolicies[j];
+                if(pPolicy->iAction == aAction)
+                    {
+                    aActionString.Set( pPolicy->ActionString() );
+                    // For now, this entry should have no priority over others
+                    ptr->SetCachePriority(0);
+                    __ALFFXLOGSTRING("CPolicyHandler::GetControlKml - return KErrNone <<");
+                    return KErrNone;
+                    }
+                }
+            }
+        }
+    __ALFFXLOGSTRING("CPolicyHandler::GetControlKml - return KErrNotFound <<");
+    return KErrNotFound;
+    }
+    
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::GetAllControlPolicies(RPointerArray<CClientControlPolicy>& aControlPolicies)
-	{
-	__ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies >>");
-	TInt err = KErrNone;
-	
-	TInt itemCount = iControlPolicies.Count();
-	if( 0 >= itemCount)
-		{
-		__ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNotFound <<");
-		return KErrNotFound;
-		}
+    {
+    __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies >>");
+    TInt err = KErrNone;
+    
+    TInt itemCount = iControlPolicies.Count();
+    if( 0 >= itemCount)
+        {
+        __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNotFound <<");
+        return KErrNotFound;
+        }
 
-	for(TInt i = 0; i < itemCount; i++)
-		{
-		CClientControlPolicy* ptr = new CClientControlPolicy();
-		if ( ptr == NULL )
-		    {
-		    __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<");
-		    return KErrNoMemory;
-		    }
-		ptr->iUid = iControlPolicies[i]->Uid();
-		HBufC* fname = HBufC::New(iControlPolicies[i]->Filename().Length());
-		if ( fname == NULL )
-		    {
-		    delete ptr;
-		    __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<");
-		    return KErrNoMemory;
-		    }
-		fname->Des().Copy(iControlPolicies[i]->Filename());
-		ptr->iFilename.Assign(fname);
-		HBufC* resdir = HBufC::New(255);
+    for(TInt i = 0; i < itemCount; i++)
+        {
+        CClientControlPolicy* ptr = new CClientControlPolicy();
+        if ( ptr == NULL )
+            {
+            __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<");
+            return KErrNoMemory;
+            }
+        ptr->iUid = iControlPolicies[i]->Uid();
+        HBufC* fname = HBufC::New(iControlPolicies[i]->Filename().Length());
+        if ( fname == NULL )
+            {
+            delete ptr;
+            __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<");
+            return KErrNoMemory;
+            }
+        fname->Des().Copy(iControlPolicies[i]->Filename());
+        ptr->iFilename.Assign(fname);
+        HBufC* resdir = HBufC::New(255);
         if ( resdir == NULL )
             {
             delete ptr;
             __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNoMemory <<");
             return KErrNoMemory;
             }
-		ptr->iResourceDir.Assign(resdir);
-		// In order to actually copy the pointers to the policy data, we
-		// need to iterate through the entire list. 
-		TInt count = iControlPolicies[i]->iControlPolicies.Count();
-		if(count > 0)
-			{
-			for( TInt j = 0; j < count; j++)
-				{
-				err = ptr->iControlPolicies.Append(iControlPolicies[i]->iControlPolicies[j]);
-				if(KErrNone != err)
-					{
-					delete ptr;
-					__ALFFXLOGSTRING1("CPolicyHandler::GetAllControlPolicies - return: %d <<", err);
-					return err;
-					}
-				}
-			err = aControlPolicies.Append(ptr);	
-			if(KErrNone != err)
-				{
-				delete ptr;
-				__ALFFXLOGSTRING1("CPolicyHandler::GetAllControlPolicies - return: %d <<", err);
-				return err;
-				}
-			}
-		else
-			{
-			delete ptr;
-			ptr = NULL;
-			}
-		}
-	__ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNotFound<<");
-	return KErrNone;
-	}
+        ptr->iResourceDir.Assign(resdir);
+        // In order to actually copy the pointers to the policy data, we
+        // need to iterate through the entire list. 
+        TInt count = iControlPolicies[i]->iControlPolicies.Count();
+        if(count > 0)
+            {
+            for( TInt j = 0; j < count; j++)
+                {
+                err = ptr->iControlPolicies.Append(iControlPolicies[i]->iControlPolicies[j]);
+                if(KErrNone != err)
+                    {
+                    delete ptr;
+                    __ALFFXLOGSTRING1("CPolicyHandler::GetAllControlPolicies - return: %d <<", err);
+                    return err;
+                    }
+                }
+            err = aControlPolicies.Append(ptr); 
+            if(KErrNone != err)
+                {
+                delete ptr;
+                __ALFFXLOGSTRING1("CPolicyHandler::GetAllControlPolicies - return: %d <<", err);
+                return err;
+                }
+            }
+        else
+            {
+            delete ptr;
+            ptr = NULL;
+            }
+        }
+    __ALFFXLOGSTRING("CPolicyHandler::GetAllControlPolicies - return KErrNotFound<<");
+    return KErrNone;
+    }
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::RequestPolicy(const RMessage2& aMessage)
-	{
-	return iClientRequestHandler->RequestPolicy(aMessage);
-	}
+    {
+    return iClientRequestHandler->RequestPolicy(aMessage);
+    }
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::GetPolicyL( TThreadId aClientId, TInt aPolicyCount, TPtr8& aOutBuf )
- 	{
- 	return iClientRequestHandler->GetPolicyL( aClientId, aPolicyCount, aOutBuf );
- 	}
- 	
+    {
+    return iClientRequestHandler->GetPolicyL( aClientId, aPolicyCount, aOutBuf );
+    }
+    
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 void CPolicyHandler::RemoveClient( TThreadId aClientId )
- 	{
- 	iClientRequestHandler->RemoveClient( aClientId );
- 	}
+    {
+    iClientRequestHandler->RemoveClient( aClientId );
+    }
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 /*
 void CPolicyHandler::RemoveDeadClients()
- 	{
- 	iClientRequestHandler->RemoveDeadClients();
- 	}
-*/ 	
+    {
+    iClientRequestHandler->RemoveDeadClients();
+    }
+*/  
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 /*
 void CPolicyHandler::DumpClientsL(RFileWriteStream& aFile)
-	{
-	iClientRequestHandler->DumpClientsL(aFile);
-	}
-*/	
- 	
+    {
+    iClientRequestHandler->DumpClientsL(aFile);
+    }
+*/  
+    
 
-//==============  	PRIVATE METHODS =================/
+//==============    PRIVATE METHODS =================/
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 //
 TInt CPolicyHandler::FindControlPolicy(TUint aAction, TUid aUid, CActionPolicy*& aPolicy, TInt& aIndex)
-	{
-	__ALFFXLOGSTRING3("CPolicyHandler::FindControlPolicy - aAction: %d, aUid: 0x%x, aIndex: %d", aAction, aUid, aIndex );
-	
-	TInt count = iControlPolicies.Count();
-	aIndex = -1;	// Setting index to low value to avoid accidental insertion.
-	
-	CControlPolicy* pData = NULL;
-	for(TInt i = 0; i < count; i++)
-		{
-		pData = iControlPolicies[i];
-		if(pData->Uid() == aUid)
-			{
-			aIndex = i;
-			TInt j = pData->iControlPolicies.Count();
-			CActionPolicy* pPolicy = NULL;
-			for(TInt q = 0; q < j; q++)
-				{
-				pPolicy = pData->iControlPolicies[q];
-				if(pPolicy->iAction == aAction)
-					{
-					aPolicy = pPolicy;
-					__ALFFXLOGSTRING("CPolicyHandler::FindControlPolicy - return KErrNone <<");
-					return KErrNone;
-					}
-				}
-			}
-		}
+    {
+    __ALFFXLOGSTRING3("CPolicyHandler::FindControlPolicy - aAction: %d, aUid: 0x%x, aIndex: %d", aAction, aUid, aIndex );
+    
+    TInt count = iControlPolicies.Count();
+    aIndex = -1;    // Setting index to low value to avoid accidental insertion.
+    
+    CControlPolicy* pData = NULL;
+    for(TInt i = 0; i < count; i++)
+        {
+        pData = iControlPolicies[i];
+        if(pData->Uid() == aUid)
+            {
+            aIndex = i;
+            TInt j = pData->iControlPolicies.Count();
+            CActionPolicy* pPolicy = NULL;
+            for(TInt q = 0; q < j; q++)
+                {
+                pPolicy = pData->iControlPolicies[q];
+                if(pPolicy->iAction == aAction)
+                    {
+                    aPolicy = pPolicy;
+                    __ALFFXLOGSTRING("CPolicyHandler::FindControlPolicy - return KErrNone <<");
+                    return KErrNone;
+                    }
+                }
+            }
+        }
     __ALFFXLOGSTRING("CPolicyHandler::FindControlPolicy - return KErrNotFound <<");
-	return KErrNotFound;
-	}
+    return KErrNotFound;
+    }
 
 
 // --- EOF ---
--- a/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp	Tue Feb 02 07:56:43 2010 +0200
+++ b/uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/alfserverdrawer.cpp	Fri Mar 19 09:43:21 2010 +0200
@@ -1103,10 +1103,6 @@
 
     TInt index = 0;
 
-    TInt nodeHandle = KErrNotFound;
-    TInt nodeGroup = KErrNotFound;
-    TInt screenNumber = KErrNotFound;
-      
     IncreaseHandle();
     iTransitionEndObserver->Cancel();
     iFinishFullScreen->Cancel();