uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp
changeset 48 7ced047fb7ae
parent 43 95d73125a086
child 56 93c3782a0a3b
--- a/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Tue Jul 06 15:18:10 2010 +0300
+++ b/uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp	Wed Aug 18 10:42:48 2010 +0300
@@ -253,7 +253,17 @@
         {
         return;
         }
-    iForegroundAppUid = aForegroundAppUid;    
+    
+    if(iForegroundAppUid != aForegroundAppUid)
+        {
+        iForegroundAppUid = aForegroundAppUid;
+        iForegroundAppHasChanged = ETrue;
+        iRendswitched = 0;
+        }
+    else
+        {
+        iForegroundAppHasChanged = EFalse;
+        }
 
     // Refresh the low and good memory thresholds as they may have changed due to the new foreground application
     RefreshThresholds(aForegroundAppUid);
@@ -325,31 +335,59 @@
     // Run the memory freeing actions
     iGOomActionList->FreeMemory(aMaxPriority);
     
-    SwitchMemMode(EGOomLowMemMode);
     }
 
 void CMemoryMonitor::SwitchMemMode(TGOomMemMode aMemMode)
     {
     if(iMemMode == aMemMode)
+        {
+        if(iMemMode == EGOomGoodMemMode)
+            {
+            TRACES("CMemoryMonitor::SwitchMemMode NOT switching rendering mode. Already in GOOD Mode");
+            }
+        else
+            {
+            TRACES("CMemoryMonitor::SwitchMemMode NOT switching rendering mode. Already in LOW Mode");
+            }
         return;
+        }
 
 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS    
     TWsEvent event;
  
     if(aMemMode == EGOomLowMemMode)
         {
+        if(iRendswitched < 3)
+            iRendswitched ++;
+        else
+            return;
+        
         iLowOnMemWgs.Reset();
         iGOomWindowGroupList->GetListOfWindowGroupsWSurfaces(iLowOnMemWgs);
         event.SetType(KGoomMemoryLowEvent);
+        TRACES("CMemoryMonitor::SwitchMemMode. Switching rendering mode to SW, Sending KGoomMemoryLowEvent");
         }
     else
         {
+        if(iRendswitched > 0)
+            {
+            if(iRendswitched < 3)
+                iRendswitched ++;
+            else
+                {
+                TRACES("CMemoryMonitor::SwitchMemMode GOOM Detected SW-HW-SW looping. NOT switching to HW rendering mode");
+                return;
+                }
+            }
+    
         event.SetType(KGoomMemoryGoodEvent);
+        TRACES("CMemoryMonitor::SwitchMemMode. Switching rendering mode to HW, Sending KGoomMemoryGoodEvent");
         }
     
     for (TInt i = iLowOnMemWgs.Count()-1; i>=0; i--)
         {
         iWs.SendEventToWindowGroup(iLowOnMemWgs[i], event);
+        TRACES1("CMemoryMonitor::SwitchMemMode. Sending event to wg %d",iLowOnMemWgs[i]);
         }
 #endif
     
@@ -612,6 +650,7 @@
 
 	/* Allocate room for the profiling data */
 	prof_data = (EGLint*)User::Alloc(data_count * sizeof(EGLint));
+	TRACES("eglQueryProfilingData - alloc for data done");
 	if (prof_data == NULL)
 	    {
     	TRACES1("eglQueryProfilingData - could not alloc: %d", data_count * sizeof(EGLint));	
@@ -625,7 +664,9 @@
 							 prof_data,
 							 data_count,
 							 &data_count);
-
+	
+	TRACES("eglQueryProfilingData - profiling data acquired");
+	
 	/* Iterate over the returned data */
 	while (i < data_count)
 		{