201035
authorhgs
Thu, 02 Sep 2010 13:30:25 +0300
changeset 53 5ba07f7750a9
parent 46 180438f24a1e
child 58 57d26d31c595
201035
uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorplugin.hrh
uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorsession.h
uiacceltk/hitchcock/goommonitor/bwins/goommonitoru.DEF
uiacceltk/hitchcock/goommonitor/eabi/goommonitoru.DEF
uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h
uiacceltk/hitchcock/goommonitor/inc/goommemorymonitorsession.h
uiacceltk/hitchcock/goommonitor/inc/goommonitorclientserver.h
uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp
uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp
uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp
uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp
uiacceltk/hitchcock/goommonitor/src/goommonitorsession.cpp
uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp
--- a/uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorplugin.hrh	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorplugin.hrh	Thu Sep 02 13:30:25 2010 +0300
@@ -25,8 +25,6 @@
 // Extension interface "uids"
 #define KGoomClientSecureId     0x1000
 
-// Goom Events through Window Server
-#define KGoomMemoryLowEvent 0x10282DBF
-#define KGoomMemoryGoodEvent 0x20026790
+
 
 #endif // GOOMMONITORPLUGIN_HRH
--- a/uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorsession.h	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorsession.h	Thu Sep 02 13:30:25 2010 +0300
@@ -21,6 +21,10 @@
 
 #include <e32std.h>
 
+// Goom Events through Window Server
+#define KGoomMemoryLowEvent 0x10282DBF
+#define KGoomMemoryGoodEvent 0x20026790
+
 /**
  *  The maximum amount of memory that can be allocated without permission.
  */
@@ -174,6 +178,12 @@
     * Notify the GOOM monitor that this application has finished allocating memory.  
     */
     IMPORT_C void MemoryAllocationsComplete();
+    
+    /**
+     * Request GOOM monitor to switch to HW rendering mnode
+     * returns KErrNone if succeeds , else KErrNoMemory
+     */
+    IMPORT_C TInt RequestHWRendering();
 
 private://data 
     TInt iFlags;
--- a/uiacceltk/hitchcock/goommonitor/bwins/goommonitoru.DEF	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/bwins/goommonitoru.DEF	Thu Sep 02 13:30:25 2010 +0300
@@ -22,4 +22,5 @@
 	?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)
+	?RequestHWRendering@RGOomMonitorSession@@QAEHXZ @ 24 NONAME ; int RGOomMonitorSession::RequestHWRendering(void)
 
--- a/uiacceltk/hitchcock/goommonitor/eabi/goommonitoru.DEF	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/eabi/goommonitoru.DEF	Thu Sep 02 13:30:25 2010 +0300
@@ -26,4 +26,5 @@
 	_ZN19RGOomMonitorSession15AppAboutToStartER14TRequestStatusRK4TUid @ 25 NONAME
 	_ZN19RGOomMonitorSession7ConnectER14TRequestStatus @ 26 NONAME
 	_ZN19RGOomMonitorSession25MemoryAllocationsCompleteEv @ 27 NONAME
+	_ZN19RGOomMonitorSession18RequestHWRenderingEv @ 28 NONAME
 
--- a/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h	Thu Sep 02 13:30:25 2010 +0300
@@ -130,7 +130,8 @@
         
         } 
     
-    void DoPostponedMemoryGood();
+    TBool DoPostponedMemoryGood();
+    TBool SwitchRenderingToHW();
     
     TBool NeedToPostponeMemGood()
         {
@@ -140,7 +141,7 @@
     void WaitAndSynchroniseMemoryState();
     void SynchroniseMemoryState();
     
-    void SwitchMemMode(TGOomMemMode aMemMode);
+    void SwitchMemMode(TGOomMemMode aMemMode, TBool aForced = 0);
     
 private:
     CMemoryMonitor();
--- a/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitorsession.h	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitorsession.h	Thu Sep 02 13:30:25 2010 +0300
@@ -42,6 +42,7 @@
     TInt iFunction;
     TInt iMinimumMemoryRequested;
     TBool iUseAbsoluteTargets;
+    TUint iClientId;
     };
 
 #endif /*GOOMMEMORYMONITORSESSION_H*/
--- a/uiacceltk/hitchcock/goommonitor/inc/goommonitorclientserver.h	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/inc/goommonitorclientserver.h	Thu Sep 02 13:30:25 2010 +0300
@@ -42,7 +42,8 @@
     EGOomMonitorSetPriorityNormal,
     EGOomMonitorSetPriorityHigh,
     EGoomMonitorAppAboutToStart,
-    EGoomMonitorAppUsesAbsoluteMemTargets
+    EGoomMonitorAppUsesAbsoluteMemTargets,
+    EGOomMonitorRequestHWRendering
     };
 
 #endif // GOOMMONITORCLIENTSERVER_H
--- a/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp	Thu Sep 02 13:30:25 2010 +0300
@@ -236,7 +236,7 @@
     if (aWindowGroupList.Count())
             {
             // Go through each item in the wglist, create an app close action for this application
-            TInt wgIndex = aWindowGroupList.Count() - 1;
+            TInt wgIndex = 0;
             
             TRACES1("BuildActionListL: Windowgroup list count %d ",aWindowGroupList.Count());
     
@@ -247,7 +247,7 @@
     
             TRACES1("BuildActionListL: Foreground App %x ", foregroundUid);
             
-            while (wgIndex >= 0)
+            while (wgIndex < aWindowGroupList.Count())
                 {
                 CGOomCloseAppConfig* appCloseConfig = NULL;
     
@@ -257,7 +257,8 @@
                 
                 if(AppCloseActionAlreadyExists(aWindowGroupList, appId))
                     {
-                    wgIndex--;
+                    TRACES2("CGOomActionList::BuildKillAppActionListL - Action item already exists for this app %x wgid %d", appId, aWindowGroupList.WgId(wgIndex).iId)
+                    wgIndex++;
                     continue;
                     }
                     
@@ -319,7 +320,7 @@
                     TRACES3("BuildActionListL: Adding app to action list, Uid = %x, wgId = %d, wgIndex = %d", appId, wgId, wgIndex);
                     }
     
-                wgIndex--;
+                wgIndex++;
                 }
             }
             
@@ -662,19 +663,21 @@
     {
     FUNC_LOG;
 
-    TInt index = iCloseAppActions.Count();
-    TRACES1("CGOomCloseApp::AppNotExiting: count of actions %d",index);
+    TInt index = 0;
 
-    while (index--)
+    while (index < iCloseAppActions.Count())
         {
         CGOomCloseApp* action = iCloseAppActions[index];
-        TRACES3("CGOomCloseApp::AppNotExiting: %d %d %d", aWgId, action->WgId(), action->IsRunning());
+        TRACES3("CGOomCloseApp::AppNotExiting: recvd from %d , checking against %d , isRunning %d", aWgId, action->WgId(), action->IsRunning());
         
         if ( (action->WgId() == aWgId) && (action->IsRunning()) )
             {
-            TRACES1("CGOomCloseApp::AppNotExiting: App with window group id %d has not responded to the close event", aWgId);
+            TRACES1("CGOomCloseApp::AppNotExiting: App with window group id %d has responded to the close event", aWgId);
             action->CloseAppEvent();
+            break;
             }
+        
+        index++;
         }
     }
 
--- a/uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp	Thu Sep 02 13:30:25 2010 +0300
@@ -25,6 +25,7 @@
 #include "goomappclosetimer.h"
 #include "goomappclosewatcher.h"
 #include "goomactionref.h"
+#include "goommonitorsession.h"
 
 
 CGOomCloseApp* CGOomCloseApp::NewL(MGOomActionObserver& aStateChangeObserver, RWsSession& aWs)
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Thu Sep 02 13:30:25 2010 +0300
@@ -337,7 +337,7 @@
     
     }
 
-void CMemoryMonitor::SwitchMemMode(TGOomMemMode aMemMode)
+void CMemoryMonitor::SwitchMemMode(TGOomMemMode aMemMode, TBool aForced)
     {
     if(iMemMode == aMemMode)
         {
@@ -357,10 +357,13 @@
  
     if(aMemMode == EGOomLowMemMode)
         {
-        if(iRendswitched < 3)
-            iRendswitched ++;
-        else
-            return;
+        if(!aForced)
+            {
+            if(iRendswitched < 3)
+                iRendswitched ++;
+            else
+                return;
+            }
         
         iLowOnMemWgs.Reset();
         iGOomWindowGroupList->GetListOfWindowGroupsWSurfaces(iLowOnMemWgs);
@@ -369,14 +372,17 @@
         }
     else
         {
-        if(iRendswitched > 0)
+        if(!aForced)
             {
-            if(iRendswitched < 3)
-                iRendswitched ++;
-            else
+            if(iRendswitched > 0)
                 {
-                TRACES("CMemoryMonitor::SwitchMemMode GOOM Detected SW-HW-SW looping. NOT switching to HW rendering mode");
-                return;
+                if(iRendswitched < 3)
+                    iRendswitched ++;
+                else
+                    {
+                    TRACES("CMemoryMonitor::SwitchMemMode GOOM Detected SW-HW-SW looping. NOT switching to HW rendering mode");
+                    return;
+                    }
                 }
             }
     
@@ -730,7 +736,7 @@
     return totalMem - totalUsed;
     }
 
-void CMemoryMonitor::DoPostponedMemoryGood()
+TBool CMemoryMonitor::DoPostponedMemoryGood()
     {
     FUNC_LOG;
     TInt current = GetFreeMemory();
@@ -740,6 +746,7 @@
             {
             TRACES2("DoPostponedMemoryGood calling MemoryGOOD current %d, iGoodThreshold %d",current, iGoodThreshold);
             iGOomActionList->MemoryGood();
+            return ETrue;
             }
         else
             {
@@ -750,8 +757,23 @@
         {
         iMemAllocationsGoingDown->Continue();
         }   
+    return EFalse;
     }    
 
+TBool CMemoryMonitor::SwitchRenderingToHW()
+    {
+    FUNC_LOG;
+    TInt current = GetFreeMemory();
+    if(current >= iGoodThreshold)
+        {
+        SwitchMemMode(EGOomGoodMemMode, ETrue);
+        iMemAllocationsGrowing->Continue();
+        return ETrue;
+        }
+    return EFalse;
+    }    
+
+
 void CMemoryMonitor::AppClosePriorityChanged(TInt aWgId, TInt aPriority)
     {
     FUNC_LOG;
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp	Thu Sep 02 13:30:25 2010 +0300
@@ -35,7 +35,7 @@
 CMemoryMonitorSession::~CMemoryMonitorSession()
     {
     FUNC_LOG;
-    Server().Monitor().SessionInCriticalAllocation(0,0);
+    Server().Monitor().SessionInCriticalAllocation(0,iClientId);
     CloseAppsFinished(0, EFalse);
     }
 
@@ -61,35 +61,35 @@
     RThread t;
     aMessage.Client(t);
     
-    TUint clientId = t.SecureId();
+    iClientId = t.SecureId();
     t.Close();
     
-    TRACES1("NEW REQUEST from client %x", clientId);
+    TRACES1("NEW REQUEST from client %x", iClientId);
     switch (aMessage.Function())
         {
         case EGOomMonitorRequestFreeMemory:
 
             //Do not take any more requests from the same client if previous request being served
-            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId))
+            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(iClientId))
                 {
-                TRACES1("CANNOT PROCESS NEW REQUEST from %x", clientId);
+                TRACES1("CANNOT PROCESS NEW REQUEST from %x", iClientId);
                 aMessage.Complete(KErrInUse);
                 return;
                 }
             
-            Server().Monitor().SetActiveClient(clientId);
+            Server().Monitor().SetActiveClient(iClientId);
             // message will be completed when CloseAppsFinished() is called.
             if (aMessage.Int1() == 0)
                 {
                 iRequestFreeRam = aMessage;
 
-                Server().Monitor().SessionInCriticalAllocation(1, clientId);
+                Server().Monitor().SessionInCriticalAllocation(1, iClientId);
                 
                 TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0()));
                 if(err == KErrCompletion) 
                     {
                     TRACES("There is already enough memory - nothing to do");
-                    Server().Monitor().SessionInCriticalAllocation(0, clientId);
+                    Server().Monitor().SessionInCriticalAllocation(0, iClientId);
                     }
                 else if (err != KErrNone )
                     {
@@ -108,8 +108,8 @@
             break;
             
         case EGOomMonitorMemoryAllocationsComplete:
-            TRACES1("ServiceL : Memory Allocations complete from %x", clientId);
-            Server().Monitor().SessionInCriticalAllocation(0, clientId);
+            TRACES1("ServiceL : Memory Allocations complete from %x", iClientId);
+            Server().Monitor().SessionInCriticalAllocation(0, iClientId);
             aMessage.Complete(KErrNone);
             break;
 
@@ -118,7 +118,7 @@
                 {
                 iRequestFreeRam.Complete(KErrCancel);
                 }
-            Server().Monitor().SessionInCriticalAllocation(0, clientId);
+            Server().Monitor().SessionInCriticalAllocation(0, iClientId);
             aMessage.Complete(KErrNone);
             break;
 
@@ -128,11 +128,11 @@
             break;
 
         case EGOomMonitorRequestOptionalRam:
-            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId))
+            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(iClientId))
                 {
                 aMessage.Complete(KErrInUse);
                 }
-            Server().Monitor().SetActiveClient(clientId);
+            Server().Monitor().SetActiveClient(iClientId);
             // message will be completed when CloseAppsFinished() is called.
             iRequestFreeRam = aMessage;
             iMinimumMemoryRequested = aMessage.Int1();
@@ -167,10 +167,19 @@
             iUseAbsoluteTargets = aMessage.Int0();
 /*            TRACES2("EGoomMonitorAppUsesAbsoluteMemTargets this: 0x%x, use abs targets %d", this, iUseAbsoluteTargets);
             Server().Monitor().SessionInCriticalAllocation(iUseAbsoluteTargets);
-*/           aMessage.Complete(KErrNone);     
+*/          aMessage.Complete(KErrNone);     
             break;
             }    
+        case EGOomMonitorRequestHWRendering:
+            {
+            RDebug::Printf("RAN_DEBUG : GOOM EGOomMonitorRequestHWRendering");
+            if(Server().Monitor().SwitchRenderingToHW())
+                aMessage.Complete(KErrNone);
+            else
+                aMessage.Complete(KErrNoMemory);
             
+            break;
+            }
         default:
             PanicClient(aMessage, EPanicIllegalFunction);
             break;
--- a/uiacceltk/hitchcock/goommonitor/src/goommonitorsession.cpp	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goommonitorsession.cpp	Thu Sep 02 13:30:25 2010 +0300
@@ -56,7 +56,7 @@
         TIpcArgs p(aBytesRequested,0);
         return SendReceive(EGOomMonitorRequestFreeMemory, p);
         }
-    return KErrNone;    
+    return KErrCouldNotConnect;    
     }
 
 EXPORT_C void RGOomMonitorSession::MemoryAllocationsComplete()
@@ -83,7 +83,7 @@
 
         return ret;
         }
-    return KErrNone;
+    return KErrCouldNotConnect;
     }    
 
 EXPORT_C void RGOomMonitorSession::RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TRequestStatus& aStatus)
@@ -223,3 +223,14 @@
 #endif
         }
     }
+
+EXPORT_C TInt RGOomMonitorSession::RequestHWRendering()
+    {
+    FUNC_LOG;
+    if (IsConnected())
+        {        
+        RDebug::Printf("RAN_DEBUG : GOOM RGOomMonitorSession::RequestHWRendering");
+        return SendReceive(EGOomMonitorRequestHWRendering);
+        }
+    return KErrCouldNotConnect;    
+    }
--- a/uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp	Mon Aug 02 12:09:20 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp	Thu Sep 02 13:30:25 2010 +0300
@@ -241,23 +241,13 @@
     // Refresh window group list
     // get all window groups, with info about parents
     TInt numGroups = iWs.NumWindowGroups();
+    iWgIds.Reset();
     iWgIds.ReserveL(numGroups);
     User::LeaveIfError(iWs.WindowGroupList(&iWgIds));
     
     // Remove all child window groups, promote parents to foremost child position
     CollapseWindowGroupTree(inactiveSurfaces);
-/*    
-#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
-    TWsEvent event;
-    event.SetType(KGoomMemoryLowEvent); // naive
 
-    for (TInt i = iLowOnMemWgs.Count()-1; i>=0; i--)
-        {
-        iWs.SendEventToWindowGroup(iLowOnMemWgs[i], event);
-        }
-        
-#endif    
-*/    
     // Note the current foreground window ID (if there is one)
     TBool oldForegroundWindowExists = EFalse;
 
@@ -292,6 +282,7 @@
         TUint secureId = AppId(index,ETrue);
         TBool found = 0;
         TInt i = 0;
+        //TRACES1("Checking WG ID : %d", iWgIds[index].iId); 
         //todo - do we really need to check this list , when we have all ids in inactiveSurfaces[]
         for(i = 0; i < processIds.Count(); i++)
             {
@@ -316,8 +307,7 @@
             }
         
         if(!found)
-            {
-            TRACES1("Checking WG ID : %d", iWgIds[index].iId);             
+            {            
             for(TInt ii = 0; ii < inactiveSurfaces.Count(); ii++)
                 {
                 if (iWgIds[index].iId == inactiveSurfaces[ii] )