|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Interthread synchronization object |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __ALF_STREAMER_BRIDGE__ |
|
20 #define __ALF_STREAMER_BRIDGE__ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <fbs.h> |
|
25 #include "alfbridgecommands.h" |
|
26 #include "uiacceltk/HuiEnv.h" |
|
27 #include "alfstreamerconsts.h" |
|
28 |
|
29 |
|
30 class CAlfStreamerServer; |
|
31 class CAlfCommandDebug; |
|
32 |
|
33 const TInt KInitialVariableBufferSize = 2000; |
|
34 |
|
35 // basic signalling for frame flow control |
|
36 const TInt KRELEASEWINDOWSERVER = 0; |
|
37 const TInt KRELEASEDBEFOREQUEUE = 1; |
|
38 |
|
39 |
|
40 //TODO THESE SHOULD USE MWsWindowTreeNode::TType INSTEAD |
|
41 enum TAlfWindowNodeType |
|
42 { |
|
43 EAlfWinTreeNodeClient = 0, |
|
44 EAlfWinTreeNodeRoot = 1, |
|
45 EAlfWinTreeNodeGroup = 2, |
|
46 EAlfWinTreeNodeAnim = 16, |
|
47 EAlfWinTreeNodeSprite = 17, |
|
48 EAlfWinTreeNodeTextCursor = 18, |
|
49 EAlfWinTreeNodeFloatingSprite = 19 // TODO SOLVE THIS. THIS IS VERY MISLEADING ARRANGAMENT! |
|
50 }; |
|
51 |
|
52 enum TAlfWindowNodeFlags |
|
53 { |
|
54 EAlfWinNodeFlagOpaque = 0x1 |
|
55 }; |
|
56 |
|
57 class TAlfWindowAttributes |
|
58 { |
|
59 public: |
|
60 TAlfWindowAttributes() : |
|
61 iWindowNodeType(0), |
|
62 iPosition(0,0), |
|
63 iSize(0,0), |
|
64 iOrdinalPosition(0), |
|
65 iOpacity(1.f), |
|
66 iRotation(0.f), |
|
67 iTransitionTime(0), |
|
68 iActive(ETrue), |
|
69 iSurfaceExtent(0,0,0,0), |
|
70 iLayerUsesAlphaFlagEnabled(EFalse), |
|
71 iClientHandle(0), |
|
72 iClientGroupHandle(0), |
|
73 iWindowNodeFlags(0), |
|
74 iScreenNumber(0), |
|
75 iSecureId(0), |
|
76 iParentNodeId(0) |
|
77 #ifdef ALF_DEBUG_TRACK_DRAWING |
|
78 ,iTrackWindow(EFalse) |
|
79 #endif |
|
80 { |
|
81 } |
|
82 |
|
83 TInt iWindowNodeType; // MWsWindowTreeNode::TType |
|
84 TPoint iPosition; |
|
85 TSize iSize; |
|
86 TInt iOrdinalPosition; |
|
87 TReal32 iOpacity; |
|
88 TReal32 iRotation; |
|
89 TUint iTransitionTime; |
|
90 TBool iActive; |
|
91 TRect iSurfaceExtent; |
|
92 TBool iLayerUsesAlphaFlagEnabled; |
|
93 TInt iClientHandle; |
|
94 TInt iClientGroupHandle; |
|
95 TInt iWindowNodeFlags; |
|
96 TInt iScreenNumber; |
|
97 TInt iBitmapHandle; |
|
98 TInt32 iSecureId; |
|
99 TInt iParentNodeId; |
|
100 #ifdef ALF_DEBUG_TRACK_DRAWING |
|
101 TBool iTrackWindow; |
|
102 #endif |
|
103 // TODO: We should refactor this to contain unions or |
|
104 // different strcuts for different commands, |
|
105 // every command does not use everything |
|
106 |
|
107 }; |
|
108 |
|
109 class TAlfCursorDataBufferAttributes |
|
110 { |
|
111 public: |
|
112 TInt iColor; |
|
113 TInt iFlashInterval; |
|
114 TInt iFlags; |
|
115 TInt iScreenNumber; |
|
116 }; |
|
117 |
|
118 |
|
119 class TAlfWindowCommandBufferAttributes |
|
120 { |
|
121 |
|
122 public: |
|
123 enum TAlfBufferStatus |
|
124 { |
|
125 EPartComplete, |
|
126 ENotComplete, |
|
127 ELastPart |
|
128 }; |
|
129 |
|
130 TAlfWindowCommandBufferAttributes() : |
|
131 iBufferLength(0), |
|
132 iBuffer(NULL), |
|
133 iEmptyThisBuffer(ETrue), |
|
134 iPartStatus(EPartComplete), |
|
135 iWindowNodeFlags(0) |
|
136 |
|
137 { |
|
138 } |
|
139 TInt iBufferLength; |
|
140 TAny* iBuffer; |
|
141 TBool iEmptyThisBuffer; |
|
142 TAlfBufferStatus iPartStatus; |
|
143 TInt iWindowNodeFlags; |
|
144 TInt iScreenNumber; |
|
145 }; |
|
146 |
|
147 class MAlfStreamerListener |
|
148 { |
|
149 public: |
|
150 virtual void HandleCallback(TInt aStatus) = 0; |
|
151 }; |
|
152 |
|
153 class MAlfBatchObs |
|
154 { |
|
155 public: |
|
156 virtual void BridgerCallback( TInt aOp = 0, TInt aInt = 0) = 0; |
|
157 virtual void BridgerCanceled() = 0; |
|
158 }; |
|
159 |
|
160 class TAlfBridgerData |
|
161 { |
|
162 private: |
|
163 |
|
164 public: |
|
165 TAlfBridgerData() |
|
166 { |
|
167 ResetEntry(); |
|
168 } |
|
169 |
|
170 void Set(TAlfDecoderServerBindings aOp,TInt aI1,TInt aI2,TAny* aPtr) |
|
171 { |
|
172 iOp=aOp; |
|
173 iInt1=aI1; |
|
174 iInt2=aI2; |
|
175 iPtr=aPtr; |
|
176 } |
|
177 |
|
178 void ResetEntry() |
|
179 { |
|
180 Set(KUnInitialized,0,0,0); |
|
181 } |
|
182 |
|
183 TBool IsEmpty() |
|
184 { |
|
185 return iOp == KUnInitialized; |
|
186 } |
|
187 |
|
188 TAlfDecoderServerBindings iOp; |
|
189 TInt iInt1; |
|
190 TInt iInt2; |
|
191 TAny* iPtr; |
|
192 }; |
|
193 |
|
194 |
|
195 NONSHARABLE_CLASS(CAlfStreamerBridge): public CActive, public CHuiEnv::MHuiSwapObserver |
|
196 |
|
197 { |
|
198 public: |
|
199 |
|
200 CAlfStreamerBridge(MAlfStreamerListener* aObserver); |
|
201 |
|
202 static CAlfStreamerBridge* NewL( MAlfStreamerListener* aObserver ); |
|
203 |
|
204 private: |
|
205 |
|
206 void ConstructL(); |
|
207 |
|
208 ~CAlfStreamerBridge(); |
|
209 |
|
210 public: |
|
211 |
|
212 /** |
|
213 * SetBatchObserver |
|
214 * |
|
215 * @since S60 5.0 |
|
216 * @param aWindow |
|
217 */ |
|
218 void SetBatchObserver(MAlfBatchObs* aBatchObserver); |
|
219 |
|
220 /** |
|
221 * Activate |
|
222 * |
|
223 * @since S60 5.0 |
|
224 * @param aWindow |
|
225 */ |
|
226 void Activate(); |
|
227 |
|
228 /** |
|
229 * Trigger |
|
230 * |
|
231 * @since S60 5.0 |
|
232 */ |
|
233 TInt Trigger(TInt aStatus); |
|
234 |
|
235 /** |
|
236 * AddData |
|
237 * |
|
238 * @since S60 5.0 |
|
239 * @param aWindow |
|
240 */ |
|
241 TInt AddData( TAlfDecoderServerBindings aOp,TInt aI1 = 0,TInt aI2 = 0,TAny* aPtr =0); |
|
242 |
|
243 /** |
|
244 * GetData |
|
245 * |
|
246 * @since S60 5.0 |
|
247 * @param aWindow |
|
248 */ |
|
249 TAlfBridgerData GetData(TInt aIndex); |
|
250 |
|
251 /** |
|
252 * StartNewBlock |
|
253 * |
|
254 * @since S60 5.0 |
|
255 */ |
|
256 void StartNewBlock(); |
|
257 |
|
258 /** |
|
259 * StartNewBlock |
|
260 * |
|
261 * @since S60 5.0 |
|
262 * @param aLastReadOffset |
|
263 */ |
|
264 void RequestCommandReadNotification( |
|
265 TInt aLastReadOffset, |
|
266 TAlfDecoderServerBindings aCommand = EAlfRequestCommandReadNotification ); |
|
267 |
|
268 // AppendDataL and GetVarDataL are for keeping the memory allocations inside one thread. |
|
269 IMPORT_C const TAny* AppendVarDataL( TInt aSize, TInt& aIndex ); |
|
270 |
|
271 // Effect data is not synchronized to window server data |
|
272 // It can be safely applied only when refresh is not active in hitchcock scene |
|
273 IMPORT_C const TAny* AppendEffectsDataL( TInt aSize, TInt& aIndex ); |
|
274 const TAny* GetEffectsDataL( TInt aIndex ); |
|
275 |
|
276 |
|
277 /** |
|
278 * GetVarDataL |
|
279 * |
|
280 * @since S60 5.0 |
|
281 * @param aIndex Offset to the data struct (relative to iDataBuf) |
|
282 * @return Pointer to the data struct |
|
283 */ |
|
284 const TAny* GetVarDataL( TInt aIndex ); |
|
285 |
|
286 |
|
287 /** |
|
288 * SetStreamerServer() |
|
289 * |
|
290 * Sets Streamserver instance. |
|
291 */ |
|
292 void SetStreamerServer( CAlfStreamerServer& aStreamerServer ); |
|
293 /** |
|
294 * StreamerServer() |
|
295 * |
|
296 * Gets Streamserver instance set with set functionality. |
|
297 * @see SetStreamerServer() |
|
298 */ |
|
299 CAlfStreamerServer* StreamerServer(); |
|
300 |
|
301 IMPORT_C TUid FindAppUidForWgId(TInt aWgId); |
|
302 IMPORT_C TInt FindWgForAppUid(TUid aAppUid); |
|
303 |
|
304 public: // from CActive |
|
305 |
|
306 void RunL(); |
|
307 |
|
308 void DoCancel(); |
|
309 |
|
310 public: // from SwapObserver |
|
311 void PrepareSwap(); |
|
312 void SwapComplete(); |
|
313 void ReleaseWindowServer(TBool aRelease = ETrue); |
|
314 void SetWgIdArray(TInt* aArray); |
|
315 |
|
316 private: |
|
317 |
|
318 MAlfStreamerListener* iObserver; |
|
319 |
|
320 MAlfBatchObs* iBatchObserver; |
|
321 |
|
322 TThreadId iThread; |
|
323 |
|
324 RArray<TAlfBridgerData> iMessages; |
|
325 |
|
326 RArray<TInt> iQueue; |
|
327 |
|
328 RCriticalSection iQueueSema; |
|
329 |
|
330 RBuf8 iDataBuf; |
|
331 |
|
332 TInt iItemsInBuffer; |
|
333 |
|
334 RArray<TAlfBridgerData> iFxMessages; |
|
335 RArray<TInt> iFxQueue; |
|
336 RBuf8 iFxBuf; |
|
337 TInt iFxItemsInBuffer; |
|
338 |
|
339 CAlfStreamerServer* iStreamerServer; |
|
340 #ifdef ALF_DEBUG_TRACK_DRAWING |
|
341 CAlfCommandDebug* iCommandDebugger; |
|
342 #endif |
|
343 |
|
344 volatile TBool iSwapActive; |
|
345 volatile TBool iMakeCurrentActive; |
|
346 |
|
347 TBool iFxQueueActive; |
|
348 TInt* iWgArray; |
|
349 TBool iVarDataAddedButNotPosted; |
|
350 public: |
|
351 TAlfNativeWindowData iAlfWindowData; |
|
352 |
|
353 }; |
|
354 |
|
355 |
|
356 #endif // __ALF_STREAMER_BRIDGE__ |