24 #include <w32std.h> |
24 #include <w32std.h> |
25 #include <EGL/egl.h> |
25 #include <EGL/egl.h> |
26 #include "goomglobalconfig.h" |
26 #include "goomglobalconfig.h" |
27 #include "goomwindowgrouplist.h" |
27 #include "goomwindowgrouplist.h" |
28 #include "goomtraces.h" |
28 #include "goomtraces.h" |
|
29 |
|
30 #define ALWAYS_SW_REND 0 //enable only for testing purpose - will force sw rendering no matter what |
29 |
31 |
30 // --------------------------------------------------------- |
32 // --------------------------------------------------------- |
31 // CMemoryMonitor |
33 // CMemoryMonitor |
32 // --------------------------------------------------------- |
34 // --------------------------------------------------------- |
33 // |
35 // |
54 EGOomTriggerNone = 0, |
56 EGOomTriggerNone = 0, |
55 EGOomTriggerFocusChanged, |
57 EGOomTriggerFocusChanged, |
56 EGOomTriggerRequestMemory, |
58 EGOomTriggerRequestMemory, |
57 EGOomTriggerThresholdCrossed |
59 EGOomTriggerThresholdCrossed |
58 }; |
60 }; |
|
61 |
|
62 enum TGOomMemMode |
|
63 { |
|
64 EGOomGoodMemMode = 0, |
|
65 EGOomLowMemMode |
|
66 }; |
59 |
67 |
60 public: // event handlers |
68 public: // event handlers |
61 void FreeMemThresholdCrossedL(TInt aAction = 0, TInt aThreshold = 0); |
69 void FreeMemThresholdCrossedL(TInt aAction = 0, TInt aThreshold = 0); |
62 void AppNotExiting(TInt aWgId); |
70 void AppNotExiting(TInt aWgId); |
63 void StartFreeSomeRamL(TInt aTargetFree, TGOomTrigger aTrigger); |
71 void StartFreeSomeRamL(TInt aTargetFree, TGOomTrigger aTrigger); |
89 return iForegroundAppUid; |
97 return iForegroundAppUid; |
90 } |
98 } |
91 void SessionInCriticalAllocation(TBool aPostponeMemGood, TUint aClientId) |
99 void SessionInCriticalAllocation(TBool aPostponeMemGood, TUint aClientId) |
92 { |
100 { |
93 FUNC_LOG; |
101 FUNC_LOG; |
|
102 TInt oldCount = iClientsRequestingMemory.Count(); |
|
103 |
94 if (aPostponeMemGood) |
104 if (aPostponeMemGood) |
95 { |
105 { |
96 iPostponeMemGood++; |
|
97 if(iClientsRequestingMemory.Find(aClientId) == KErrNotFound) |
106 if(iClientsRequestingMemory.Find(aClientId) == KErrNotFound) |
98 iClientsRequestingMemory.Append(aClientId); |
107 iClientsRequestingMemory.Append(aClientId); |
99 |
108 |
100 TRACES2("SessionInCriticalAllocation : STARTING Critical Allocations for Client %x, ClientsRequestingMemory Count %d", aClientId, iClientsRequestingMemory.Count()); |
109 TRACES2("SessionInCriticalAllocation : STARTING Critical Allocations for Client %x, ClientsRequestingMemory Count %d", aClientId, iClientsRequestingMemory.Count()); |
101 } |
110 } |
102 else |
111 else |
103 { |
112 { |
104 iPostponeMemGood--; |
113 if(aClientId == 0) |
|
114 { |
|
115 iClientsRequestingMemory.Reset(); |
|
116 } |
|
117 |
105 TInt idx = iClientsRequestingMemory.Find(aClientId); |
118 TInt idx = iClientsRequestingMemory.Find(aClientId); |
106 if(idx != KErrNotFound) |
119 if(idx != KErrNotFound) |
107 { |
120 { |
108 iClientsRequestingMemory.Remove(idx); |
121 iClientsRequestingMemory.Remove(idx); |
109 TRACES2("SessionInCriticalAllocation : ENDING Critical Allocations for Client %x, ClientsRequestingMemory Count %d", aClientId, iClientsRequestingMemory.Count()); |
122 TRACES2("SessionInCriticalAllocation : ENDING Critical Allocations for Client %x, ClientsRequestingMemory Count %d", aClientId, iClientsRequestingMemory.Count()); |
110 } |
123 } |
111 |
|
112 if(iPostponeMemGood<0) |
|
113 { |
|
114 iPostponeMemGood = 0; |
|
115 } |
|
116 } |
124 } |
117 TRACES1("SessionInCriticalAllocation : ClientsRequestingMemory Count %d", iClientsRequestingMemory.Count()); |
125 TRACES1("SessionInCriticalAllocation : ClientsRequestingMemory Count %d", iClientsRequestingMemory.Count()); |
118 if (iClientsRequestingMemory.Count() == 0) |
126 if (oldCount && iClientsRequestingMemory.Count() == 0) |
119 { |
127 { |
120 DoPostponedMemoryGood(); |
128 DoPostponedMemoryGood(); |
121 } |
129 } |
122 |
130 |
123 } |
131 } |
124 |
132 |
125 void DoPostponedMemoryGood(); |
133 void DoPostponedMemoryGood(); |
126 |
134 |
127 TBool NeedToPostponeMemGood() |
135 TBool NeedToPostponeMemGood() |
128 { |
136 { |
129 //return (iPostponeMemGood != 0); |
|
130 return (iClientsRequestingMemory.Count() != 0); |
137 return (iClientsRequestingMemory.Count() != 0); |
131 } |
138 } |
132 |
139 |
133 void WaitAndSynchroniseMemoryState(); |
140 void WaitAndSynchroniseMemoryState(); |
134 void SynchroniseMemoryState(); |
141 void SynchroniseMemoryState(); |
|
142 |
|
143 void SwitchMemMode(TGOomMemMode aMemMode); |
135 |
144 |
136 private: |
145 private: |
137 CMemoryMonitor(); |
146 CMemoryMonitor(); |
138 void ConstructL(); |
147 void ConstructL(); |
139 TBool FreeGraphicsMemoryAboveThresholdL(TInt& aCurrentFreeMemory); |
148 TBool FreeGraphicsMemoryAboveThresholdL(TInt& aCurrentFreeMemory); |
199 // could use pointer array |
208 // could use pointer array |
200 CGoomThresholdCrossed* iMemAllocationsGrowing; |
209 CGoomThresholdCrossed* iMemAllocationsGrowing; |
201 CGoomThresholdCrossed* iMemAllocationsGoingDown; |
210 CGoomThresholdCrossed* iMemAllocationsGoingDown; |
202 |
211 |
203 TInt iForegroundAppUid; |
212 TInt iForegroundAppUid; |
204 TInt iPostponeMemGood; |
|
205 |
213 |
206 RArray<TUint> iClientsRequestingMemory; |
214 RArray<TUint> iClientsRequestingMemory; |
207 |
215 |
208 TGOomTrigger iTrigger; |
216 TGOomTrigger iTrigger; |
209 |
217 |
210 CGOomSynchTimer* iSynchTimer; |
218 CGOomSynchTimer* iSynchTimer; |
|
219 |
|
220 TBool iMemMode; |
|
221 TBool iForegroundAppHasChanged; |
|
222 |
|
223 TInt iRendswitched; |
|
224 |
|
225 RArray<TInt> iLowOnMemWgs; |
211 }; |
226 }; |
212 |
227 |
213 |
228 |
214 |
229 |
215 NONSHARABLE_CLASS(CGOomSynchTimer) : public CTimer |
230 NONSHARABLE_CLASS(CGOomSynchTimer) : public CTimer |