# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1284701719 -10800 # Node ID 93c3782a0a3b3b178b011fa335dc84deea9e2472 # Parent 7ced047fb7ae73017acc49d90de41a65e65a9263 Revision: 201035 Kit: 201037 diff -r 7ced047fb7ae -r 93c3782a0a3b uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorplugin.hrh --- a/uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorplugin.hrh Wed Aug 18 10:42:48 2010 +0300 +++ b/uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorplugin.hrh Fri Sep 17 08:35:19 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 diff -r 7ced047fb7ae -r 93c3782a0a3b uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorsession.h --- a/uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorsession.h Wed Aug 18 10:42:48 2010 +0300 +++ b/uiaccelerator_plat/alf_visual_api/inc/goommonitor/goommonitorsession.h Fri Sep 17 08:35:19 2010 +0300 @@ -21,6 +21,10 @@ #include +// 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; diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/bwins/goommonitoru.DEF --- a/uiacceltk/hitchcock/goommonitor/bwins/goommonitoru.DEF Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/bwins/goommonitoru.DEF Fri Sep 17 08:35:19 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) diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/eabi/goommonitoru.DEF --- a/uiacceltk/hitchcock/goommonitor/eabi/goommonitoru.DEF Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/eabi/goommonitoru.DEF Fri Sep 17 08:35:19 2010 +0300 @@ -26,4 +26,5 @@ _ZN19RGOomMonitorSession15AppAboutToStartER14TRequestStatusRK4TUid @ 25 NONAME _ZN19RGOomMonitorSession7ConnectER14TRequestStatus @ 26 NONAME _ZN19RGOomMonitorSession25MemoryAllocationsCompleteEv @ 27 NONAME + _ZN19RGOomMonitorSession18RequestHWRenderingEv @ 28 NONAME diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h --- a/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h Fri Sep 17 08:35:19 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(); diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/inc/goommemorymonitorsession.h --- a/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitorsession.h Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/inc/goommemorymonitorsession.h Fri Sep 17 08:35:19 2010 +0300 @@ -42,6 +42,7 @@ TInt iFunction; TInt iMinimumMemoryRequested; TBool iUseAbsoluteTargets; + TUint iClientId; }; #endif /*GOOMMEMORYMONITORSESSION_H*/ diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/inc/goommonitorclientserver.h --- a/uiacceltk/hitchcock/goommonitor/inc/goommonitorclientserver.h Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/inc/goommonitorclientserver.h Fri Sep 17 08:35:19 2010 +0300 @@ -42,7 +42,8 @@ EGOomMonitorSetPriorityNormal, EGOomMonitorSetPriorityHigh, EGoomMonitorAppAboutToStart, - EGoomMonitorAppUsesAbsoluteMemTargets + EGoomMonitorAppUsesAbsoluteMemTargets, + EGOomMonitorRequestHWRendering }; #endif // GOOMMONITORCLIENTSERVER_H diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp --- a/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/src/goomactionlist.cpp Fri Sep 17 08:35:19 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++; } } diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp --- a/uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/src/goomcloseapp.cpp Fri Sep 17 08:35:19 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) diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp --- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp Fri Sep 17 08:35:19 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; diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp --- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp Fri Sep 17 08:35:19 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; diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/src/goommonitorsession.cpp --- a/uiacceltk/hitchcock/goommonitor/src/goommonitorsession.cpp Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/src/goommonitorsession.cpp Fri Sep 17 08:35:19 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; + } diff -r 7ced047fb7ae -r 93c3782a0a3b uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp --- a/uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp Wed Aug 18 10:42:48 2010 +0300 +++ b/uiacceltk/hitchcock/goommonitor/src/goomwindowgrouplist.cpp Fri Sep 17 08:35:19 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] )