uiacceltk/hitchcock/goommonitor/src/goommemorymonitor.cpp
changeset 48 7ced047fb7ae
parent 43 95d73125a086
child 56 93c3782a0a3b
equal deleted inserted replaced
43:95d73125a086 48:7ced047fb7ae
   251     
   251     
   252     if(aForegroundAppUid == 0)
   252     if(aForegroundAppUid == 0)
   253         {
   253         {
   254         return;
   254         return;
   255         }
   255         }
   256     iForegroundAppUid = aForegroundAppUid;    
   256     
       
   257     if(iForegroundAppUid != aForegroundAppUid)
       
   258         {
       
   259         iForegroundAppUid = aForegroundAppUid;
       
   260         iForegroundAppHasChanged = ETrue;
       
   261         iRendswitched = 0;
       
   262         }
       
   263     else
       
   264         {
       
   265         iForegroundAppHasChanged = EFalse;
       
   266         }
   257 
   267 
   258     // Refresh the low and good memory thresholds as they may have changed due to the new foreground application
   268     // Refresh the low and good memory thresholds as they may have changed due to the new foreground application
   259     RefreshThresholds(aForegroundAppUid);
   269     RefreshThresholds(aForegroundAppUid);
   260     
   270     
   261     if(iCurrentTarget || ALWAYS_SW_REND)
   271     if(iCurrentTarget || ALWAYS_SW_REND)
   323     
   333     
   324     iGOomActionList->SetUseSwRendering(ETrue); //Always use SW rendering in low mode .. (for now..) 
   334     iGOomActionList->SetUseSwRendering(ETrue); //Always use SW rendering in low mode .. (for now..) 
   325     // Run the memory freeing actions
   335     // Run the memory freeing actions
   326     iGOomActionList->FreeMemory(aMaxPriority);
   336     iGOomActionList->FreeMemory(aMaxPriority);
   327     
   337     
   328     SwitchMemMode(EGOomLowMemMode);
       
   329     }
   338     }
   330 
   339 
   331 void CMemoryMonitor::SwitchMemMode(TGOomMemMode aMemMode)
   340 void CMemoryMonitor::SwitchMemMode(TGOomMemMode aMemMode)
   332     {
   341     {
   333     if(iMemMode == aMemMode)
   342     if(iMemMode == aMemMode)
       
   343         {
       
   344         if(iMemMode == EGOomGoodMemMode)
       
   345             {
       
   346             TRACES("CMemoryMonitor::SwitchMemMode NOT switching rendering mode. Already in GOOD Mode");
       
   347             }
       
   348         else
       
   349             {
       
   350             TRACES("CMemoryMonitor::SwitchMemMode NOT switching rendering mode. Already in LOW Mode");
       
   351             }
   334         return;
   352         return;
       
   353         }
   335 
   354 
   336 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS    
   355 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS    
   337     TWsEvent event;
   356     TWsEvent event;
   338  
   357  
   339     if(aMemMode == EGOomLowMemMode)
   358     if(aMemMode == EGOomLowMemMode)
   340         {
   359         {
       
   360         if(iRendswitched < 3)
       
   361             iRendswitched ++;
       
   362         else
       
   363             return;
       
   364         
   341         iLowOnMemWgs.Reset();
   365         iLowOnMemWgs.Reset();
   342         iGOomWindowGroupList->GetListOfWindowGroupsWSurfaces(iLowOnMemWgs);
   366         iGOomWindowGroupList->GetListOfWindowGroupsWSurfaces(iLowOnMemWgs);
   343         event.SetType(KGoomMemoryLowEvent);
   367         event.SetType(KGoomMemoryLowEvent);
       
   368         TRACES("CMemoryMonitor::SwitchMemMode. Switching rendering mode to SW, Sending KGoomMemoryLowEvent");
   344         }
   369         }
   345     else
   370     else
   346         {
   371         {
       
   372         if(iRendswitched > 0)
       
   373             {
       
   374             if(iRendswitched < 3)
       
   375                 iRendswitched ++;
       
   376             else
       
   377                 {
       
   378                 TRACES("CMemoryMonitor::SwitchMemMode GOOM Detected SW-HW-SW looping. NOT switching to HW rendering mode");
       
   379                 return;
       
   380                 }
       
   381             }
       
   382     
   347         event.SetType(KGoomMemoryGoodEvent);
   383         event.SetType(KGoomMemoryGoodEvent);
       
   384         TRACES("CMemoryMonitor::SwitchMemMode. Switching rendering mode to HW, Sending KGoomMemoryGoodEvent");
   348         }
   385         }
   349     
   386     
   350     for (TInt i = iLowOnMemWgs.Count()-1; i>=0; i--)
   387     for (TInt i = iLowOnMemWgs.Count()-1; i>=0; i--)
   351         {
   388         {
   352         iWs.SendEventToWindowGroup(iLowOnMemWgs[i], event);
   389         iWs.SendEventToWindowGroup(iLowOnMemWgs[i], event);
       
   390         TRACES1("CMemoryMonitor::SwitchMemMode. Sending event to wg %d",iLowOnMemWgs[i]);
   353         }
   391         }
   354 #endif
   392 #endif
   355     
   393     
   356     iMemMode = aMemMode;
   394     iMemMode = aMemMode;
   357     }
   395     }
   610 	TRACES1("eglQueryProfilingData - data size: %d", data_count);
   648 	TRACES1("eglQueryProfilingData - data size: %d", data_count);
   611 
   649 
   612 
   650 
   613 	/* Allocate room for the profiling data */
   651 	/* Allocate room for the profiling data */
   614 	prof_data = (EGLint*)User::Alloc(data_count * sizeof(EGLint));
   652 	prof_data = (EGLint*)User::Alloc(data_count * sizeof(EGLint));
       
   653 	TRACES("eglQueryProfilingData - alloc for data done");
   615 	if (prof_data == NULL)
   654 	if (prof_data == NULL)
   616 	    {
   655 	    {
   617     	TRACES1("eglQueryProfilingData - could not alloc: %d", data_count * sizeof(EGLint));	
   656     	TRACES1("eglQueryProfilingData - could not alloc: %d", data_count * sizeof(EGLint));	
   618 		return KErrNoMemory;
   657 		return KErrNoMemory;
   619         }
   658         }
   623 							 EGL_PROF_QUERY_GLOBAL_BIT_NOK |
   662 							 EGL_PROF_QUERY_GLOBAL_BIT_NOK |
   624 							 EGL_PROF_QUERY_MEMORY_USAGE_BIT_NOK,
   663 							 EGL_PROF_QUERY_MEMORY_USAGE_BIT_NOK,
   625 							 prof_data,
   664 							 prof_data,
   626 							 data_count,
   665 							 data_count,
   627 							 &data_count);
   666 							 &data_count);
   628 
   667 	
       
   668 	TRACES("eglQueryProfilingData - profiling data acquired");
       
   669 	
   629 	/* Iterate over the returned data */
   670 	/* Iterate over the returned data */
   630 	while (i < data_count)
   671 	while (i < data_count)
   631 		{
   672 		{
   632 		TRACES2("EGL_NOK_resource_profiling - index: %d data: %d", i, prof_data[i]);
   673 		TRACES2("EGL_NOK_resource_profiling - index: %d data: %d", i, prof_data[i]);
   633 		
   674