|
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: AppUi class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <apgtask.h> |
|
20 #include <AknDoc.h> |
|
21 #include "alf/alfappui.h" |
|
22 #include "alf/alfappserver.h" |
|
23 #include <uiacceltk/HuiEnv.h> |
|
24 #include <aknenv.h> |
|
25 #include <AknsConstants.h> |
|
26 #include <s32mem.h> |
|
27 #include <uiacceltk/HuiSkin.h> |
|
28 #include <uiacceltk/HuiDisplay.h> |
|
29 #include <uiacceltk/HuiControl.h> |
|
30 #include <uiacceltk/HuiControlGroup.h> |
|
31 #include <uiacceltk/HuiEvent.h> |
|
32 #include <uiacceltk/HuiDeckLayout.h> |
|
33 #include <uiacceltk/HuiImageVisual.h> |
|
34 #include <uiacceltk/HuiTransformation.h> |
|
35 #include <uiacceltk/HuiBorderBrush.h> |
|
36 #include <uiacceltk/HuiUtil.h> |
|
37 #include <uiacceltk/HuiTextVisual.h> |
|
38 #include <uiacceltk/HuiGradientBrush.h> |
|
39 #include <uiacceltk/HuiImageBrush.h> |
|
40 #include <uiacceltk/HuiRoster.h> |
|
41 |
|
42 #ifdef ALF_USE_CANVAS |
|
43 #include <uiacceltk/HuiCanvasVisual.h> |
|
44 #endif |
|
45 |
|
46 #include "alflogger.h" |
|
47 #include "alf/alfappsrvsessionbase.h" |
|
48 #include "alfsrvresourcemanager.h" |
|
49 #include "alfsrvsettingshandler.h" |
|
50 #include <uiacceltk/HuiTextureManager.h> |
|
51 #include "alfsrvtexturemanager.h" |
|
52 |
|
53 #include "alfstreamerserver.h" |
|
54 #include "alfshareddisplaycoecontrol.h" |
|
55 #include "alfbridge.h" |
|
56 #include "alfstreamerconsts.h" |
|
57 #include "alfscreen.h" |
|
58 #include <akntranseffect.h> |
|
59 |
|
60 #include "alfwindowmanager.h" |
|
61 #include "alfwindowstructs.h" |
|
62 #include <e32property.h> |
|
63 #include "HuiFxEffect.h" |
|
64 #include <akntransitionutils.h> |
|
65 #include <alf/AlfTransEffectPlugin.h> |
|
66 #include "alfwindowdata.h" |
|
67 #include "huieffectable.h" |
|
68 #include <akntranseffect.h> |
|
69 #include "HuiRenderPlugin.h" |
|
70 #include "huicanvasgc.h" |
|
71 #include "huicanvasrenderbuffer.h" |
|
72 |
|
73 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
74 #include <alfcommanddebug.h> |
|
75 #endif |
|
76 |
|
77 #ifdef _ALF_FXLOGGING |
|
78 #include <alfcommanddebug.h> |
|
79 #endif |
|
80 |
|
81 #ifdef SYMBIAN_BUILD_GCE |
|
82 #include <bautils.h> |
|
83 #endif |
|
84 |
|
85 const TInt KVisualTransformationStepRotate = 0; |
|
86 |
|
87 const TReal32 KAlfVisualDefaultOpacity = 1.0f; |
|
88 //const TReal32 KAlfVisualDefaultOpacity = 0.5f; |
|
89 |
|
90 _LIT8(KAlfWindowGroupContainerControlTag, "WGROUP"); |
|
91 const TInt KAlfNumberOfFixedControlGroups = 2; |
|
92 |
|
93 // This debug option prints window group order with __ALFLOGSTRING |
|
94 //#define ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
95 |
|
96 // This debug option shows window groups in a grid |
|
97 //#define ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER |
|
98 |
|
99 |
|
100 const TInt KFadeAction = 6000; |
|
101 |
|
102 const TInt KRosterFreezeEndTimeoutInMs = 400; |
|
103 |
|
104 // Timer to send finish full screen effect |
|
105 // --------------------------------------------------------- |
|
106 // CAlfFinishTimer |
|
107 // --------------------------------------------------------- |
|
108 // |
|
109 NONSHARABLE_CLASS( CAlfRosterFreezeEndTimer ):public CTimer |
|
110 { |
|
111 public: // Constructors and destructor |
|
112 static CAlfRosterFreezeEndTimer* NewL( CAlfBridge& aBridge ); |
|
113 virtual ~CAlfRosterFreezeEndTimer(); |
|
114 |
|
115 public: // New functions |
|
116 void Start( TTimeIntervalMicroSeconds32 aPeriod ); |
|
117 |
|
118 protected: // Functions from base classes |
|
119 void DoCancel(); |
|
120 |
|
121 private: |
|
122 CAlfRosterFreezeEndTimer( CAlfBridge& aBridge ); |
|
123 void ConstructL(); |
|
124 void RunL(); |
|
125 |
|
126 private: // Data |
|
127 CAlfBridge& iBridge; |
|
128 |
|
129 }; |
|
130 |
|
131 |
|
132 // --------------------------------------------------------- |
|
133 // CAlfRosterFreezeEndTimer |
|
134 // --------------------------------------------------------- |
|
135 // |
|
136 CAlfRosterFreezeEndTimer::CAlfRosterFreezeEndTimer( CAlfBridge& aBridge ) |
|
137 :CTimer ( EPriorityStandard ), |
|
138 iBridge( aBridge ) |
|
139 { |
|
140 } |
|
141 |
|
142 void CAlfRosterFreezeEndTimer::ConstructL() |
|
143 { |
|
144 CTimer::ConstructL(); |
|
145 CActiveScheduler::Add( this ); |
|
146 } |
|
147 |
|
148 CAlfRosterFreezeEndTimer* CAlfRosterFreezeEndTimer::NewL( CAlfBridge& aBridge ) |
|
149 { |
|
150 CAlfRosterFreezeEndTimer* self = new ( ELeave ) CAlfRosterFreezeEndTimer( aBridge ); |
|
151 CleanupStack::PushL( self ); |
|
152 self->ConstructL(); |
|
153 CleanupStack::Pop( self ); |
|
154 return self; |
|
155 } |
|
156 |
|
157 CAlfRosterFreezeEndTimer::~CAlfRosterFreezeEndTimer() |
|
158 { |
|
159 Cancel(); |
|
160 } |
|
161 |
|
162 void CAlfRosterFreezeEndTimer::Start( TTimeIntervalMicroSeconds32 aPeriod ) |
|
163 { |
|
164 if (!IsActive()) |
|
165 { |
|
166 After( aPeriod ); |
|
167 } |
|
168 } |
|
169 |
|
170 void CAlfRosterFreezeEndTimer::RunL() |
|
171 { |
|
172 iBridge.iHuiEnv->Display(0).SetDirty(); |
|
173 TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse)); |
|
174 iBridge.SetVisualTreeVisibilityChanged(ETrue); |
|
175 } |
|
176 |
|
177 void CAlfRosterFreezeEndTimer::DoCancel() |
|
178 { |
|
179 CTimer::DoCancel(); |
|
180 } |
|
181 |
|
182 // --------------------------------------------------------- |
|
183 // CAlfLayoutSwitchEffectcoordinator |
|
184 // --------------------------------------------------------- |
|
185 // |
|
186 NONSHARABLE_CLASS( CAlfLayoutSwitchEffectCoordinator ) : public CBase, public MAlfGfxEffectObserver |
|
187 { |
|
188 public: // Constructors and destructor |
|
189 CAlfLayoutSwitchEffectCoordinator( CAlfBridge& aBridge ); |
|
190 virtual ~CAlfLayoutSwitchEffectCoordinator(); |
|
191 |
|
192 public: // MAlfGfxEffectObserver |
|
193 void AlfGfxEffectEndCallBack( TInt aHandle ); |
|
194 |
|
195 public: |
|
196 void BeginLayoutSwitch(); |
|
197 void Cancel(); |
|
198 |
|
199 private: |
|
200 AknTransEffect::TContext NextLayoutSwitchContext(); |
|
201 void SetLayoutSwitchEffect(AknTransEffect::TContext aContext); |
|
202 TBool LayoutSwitchEffectsExist(); |
|
203 |
|
204 private: // Data |
|
205 |
|
206 CAlfBridge& iBridge; |
|
207 AknTransEffect::TContext iLayoutSwitchEffectContext; |
|
208 TThreadPriority iOriginalPriority; |
|
209 CAlfRosterFreezeEndTimer* iRosterFreezeEndTimer; |
|
210 }; |
|
211 |
|
212 CAlfLayoutSwitchEffectCoordinator::CAlfLayoutSwitchEffectCoordinator( CAlfBridge& aBridge ) : |
|
213 iBridge( aBridge ), |
|
214 iLayoutSwitchEffectContext(AknTransEffect::ENone) |
|
215 { |
|
216 RThread me = RThread(); |
|
217 iOriginalPriority = me.Priority(); |
|
218 me.Close(); |
|
219 } |
|
220 |
|
221 CAlfLayoutSwitchEffectCoordinator::~CAlfLayoutSwitchEffectCoordinator() |
|
222 { |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------- |
|
226 // CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack |
|
227 // |
|
228 // This method is callback which gets called when layout |
|
229 // switch effect has ended. |
|
230 // --------------------------------------------------------- |
|
231 // |
|
232 void CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack( TInt aHandle ) |
|
233 { |
|
234 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack")); |
|
235 if (iLayoutSwitchEffectContext == aHandle) |
|
236 { |
|
237 AknTransEffect::TContext nextContext = NextLayoutSwitchContext(); |
|
238 |
|
239 // Unfreeze visible content. This reveals real roster content (in new orientation). |
|
240 if (nextContext == AknTransEffect::ELayoutSwitchExit) |
|
241 { |
|
242 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
243 RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack unfreezing roster content")); |
|
244 #endif |
|
245 iBridge.iHuiEnv->Display(0).SetDirty(); |
|
246 TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse)); |
|
247 iBridge.SetVisualTreeVisibilityChanged(ETrue); |
|
248 } |
|
249 |
|
250 // Set next effect |
|
251 SetLayoutSwitchEffect(nextContext); |
|
252 |
|
253 if (nextContext == AknTransEffect::ENone) |
|
254 { |
|
255 // Restore normal priority |
|
256 RThread me = RThread(); |
|
257 me.SetPriority(iOriginalPriority); |
|
258 me.Close(); |
|
259 |
|
260 // Just in case refresh everything |
|
261 iBridge.iHuiEnv->Display(0).SetDirty(); |
|
262 } |
|
263 } |
|
264 else |
|
265 { |
|
266 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::AlfGfxEffectEndCallBack - got different handle (normal, dont worry...) - %i"), aHandle); |
|
267 } |
|
268 } |
|
269 |
|
270 // --------------------------------------------------------- |
|
271 // CAlfLayoutSwitchEffectCoordinator::Cancel |
|
272 // --------------------------------------------------------- |
|
273 // |
|
274 void CAlfLayoutSwitchEffectCoordinator::Cancel() |
|
275 { |
|
276 // Disable effect |
|
277 SetLayoutSwitchEffect( AknTransEffect::ENone ); |
|
278 |
|
279 // Unfreeze visible content |
|
280 if ( iRosterFreezeEndTimer ) |
|
281 { |
|
282 iRosterFreezeEndTimer->Cancel(); |
|
283 } |
|
284 |
|
285 iBridge.iHuiEnv->Display(0).SetDirty(); |
|
286 TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(EFalse)); |
|
287 iBridge.SetVisualTreeVisibilityChanged(ETrue); |
|
288 |
|
289 // Restore normal priority |
|
290 RThread me = RThread(); |
|
291 me.SetPriority(iOriginalPriority); |
|
292 me.Close(); |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------- |
|
296 // CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch |
|
297 // |
|
298 // This method starts the layout switch effect procedure. |
|
299 // --------------------------------------------------------- |
|
300 // |
|
301 void CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch() |
|
302 { |
|
303 // Hm. what to do if earlier is already in progress ? |
|
304 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch")); |
|
305 if ( iBridge.iHuiEnv->MemoryLevel() <= EHuiMemoryLevelLowest ) |
|
306 { |
|
307 // No effects in low memory mode |
|
308 return; |
|
309 } |
|
310 |
|
311 if (!iLayoutSwitchEffectContext) |
|
312 { |
|
313 TBool tfxOn = CAknTransitionUtils::TransitionsEnabled(AknTransEffect::ELayoutswitchTransitionsOff ); |
|
314 TBool tfxExists = LayoutSwitchEffectsExist(); |
|
315 if (tfxOn && tfxExists) |
|
316 { |
|
317 // Boost priority so that we are able to draw more frames for the effect |
|
318 RThread me = RThread(); |
|
319 me.SetPriority(EPriorityAbsoluteHigh); |
|
320 me.Close(); |
|
321 |
|
322 // Freeze visual content |
|
323 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch freezing roster content")); |
|
324 iBridge.iHuiEnv->Display(0).SetDirty(); |
|
325 TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(ETrue)); |
|
326 |
|
327 // Remove all other effects |
|
328 iBridge.HandleGfxStopEvent( EFalse ); |
|
329 iBridge.RemoveAllTemporaryPresenterVisuals(); |
|
330 |
|
331 // Set first layout switch effect |
|
332 SetLayoutSwitchEffect(AknTransEffect::ELayoutSwitchStart); |
|
333 } |
|
334 else |
|
335 { |
|
336 if (!iRosterFreezeEndTimer) |
|
337 { |
|
338 TRAP_IGNORE(iRosterFreezeEndTimer = CAlfRosterFreezeEndTimer::NewL(iBridge)); |
|
339 } |
|
340 |
|
341 if (iRosterFreezeEndTimer) |
|
342 { |
|
343 iBridge.iHuiEnv->Display(0).SetDirty(); |
|
344 TRAP_IGNORE(iBridge.iHuiEnv->Display(0).Roster().FreezeVisibleContentL(ETrue)); |
|
345 |
|
346 // Remove all other effects |
|
347 iBridge.HandleGfxStopEvent( EFalse ); |
|
348 iBridge.RemoveAllTemporaryPresenterVisuals(); |
|
349 |
|
350 // Set remove freeze timer |
|
351 iRosterFreezeEndTimer->Start(KRosterFreezeEndTimeoutInMs*1000); |
|
352 } |
|
353 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch - tfx are set OFF -> I am not starting effect.")); |
|
354 } |
|
355 } |
|
356 else |
|
357 { |
|
358 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::BeginLayoutSwitch - old effect exists - %i"), iLayoutSwitchEffectContext); |
|
359 } |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------- |
|
363 // CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchContext |
|
364 // |
|
365 // This method automatically selects the next context in the |
|
366 // layout switch procedure. |
|
367 // |
|
368 // Contextes change in the following order during layout switch: |
|
369 // |
|
370 // 1. AknTransEffect::ENone |
|
371 // 2. AknTransEffect::ELayoutSwitchStart |
|
372 // 3. AknTransEffect::ELayoutSwitchExit |
|
373 // 4. AknTransEffect::ENone |
|
374 // |
|
375 // After new context is selected, appropriate effect is set |
|
376 // (and/or removed) from the roster. |
|
377 // |
|
378 // --------------------------------------------------------- |
|
379 // |
|
380 AknTransEffect::TContext CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchContext() |
|
381 { |
|
382 // Resolve next context based on current context |
|
383 AknTransEffect::TContext newContext = AknTransEffect::ENone; |
|
384 switch (iLayoutSwitchEffectContext) |
|
385 { |
|
386 case AknTransEffect::ENone: |
|
387 { |
|
388 newContext = AknTransEffect::ELayoutSwitchStart; |
|
389 break; |
|
390 } |
|
391 case AknTransEffect::ELayoutSwitchStart: |
|
392 { |
|
393 newContext = AknTransEffect::ELayoutSwitchExit; |
|
394 break; |
|
395 } |
|
396 case AknTransEffect::ELayoutSwitchExit: // fallthrough |
|
397 default: |
|
398 { |
|
399 newContext = AknTransEffect::ENone; |
|
400 break; |
|
401 } |
|
402 } |
|
403 |
|
404 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchEffectL old ctx = %i, new ctx = %i"), iLayoutSwitchEffectContext, newContext); |
|
405 return newContext; |
|
406 } |
|
407 |
|
408 // --------------------------------------------------------- |
|
409 // CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffectL |
|
410 // |
|
411 // This method sets correct effect based on the given |
|
412 // layout switch context. |
|
413 // |
|
414 // --------------------------------------------------------- |
|
415 // |
|
416 void CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffect(AknTransEffect::TContext aContext) |
|
417 { |
|
418 MHuiEffectable* effectable = iBridge.iHuiEnv->Display(0).Roster().Effectable(); |
|
419 CHuiFxEffect* effect = NULL; |
|
420 CHuiFxEngine* engine = iBridge.iHuiEnv->EffectsEngine(); |
|
421 |
|
422 if (!effectable || !engine) |
|
423 { |
|
424 return; |
|
425 } |
|
426 |
|
427 // Update current context |
|
428 iLayoutSwitchEffectContext = aContext; |
|
429 |
|
430 if (aContext == AknTransEffect::ENone) |
|
431 { |
|
432 // Just remove effect |
|
433 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::NextLayoutSwitchEffectL - removing effect")); |
|
434 effectable->EffectSetEffect(NULL); // This calls AlfGfxEffectEndCallBack |
|
435 } |
|
436 else |
|
437 { |
|
438 // Load correct effect |
|
439 for ( TInt i = 0; i<iBridge.iAlfRegisteredEffects.Count(); i++ ) |
|
440 { |
|
441 if ( iBridge.iAlfRegisteredEffects[i].iAction == aContext) |
|
442 { |
|
443 //RDebug::Print(_L("CAlfLayoutSwitchEffectCoordinator::SetLayoutSwitchEffectL - loading effect")); |
|
444 TRAP_IGNORE(engine->LoadEffectL(*iBridge.iAlfRegisteredEffects[i].iEffectFile, effect, effectable, NULL, this, iLayoutSwitchEffectContext, 0 ) ); |
|
445 break; |
|
446 } |
|
447 } |
|
448 } |
|
449 } |
|
450 |
|
451 TBool CAlfLayoutSwitchEffectCoordinator::LayoutSwitchEffectsExist() |
|
452 { |
|
453 TBool appearExists = EFalse; |
|
454 TBool disAppearExists = EFalse; |
|
455 |
|
456 for ( TInt i = 0; i<iBridge.iAlfRegisteredEffects.Count(); i++ ) |
|
457 { |
|
458 if ( iBridge.iAlfRegisteredEffects[i].iAction == AknTransEffect::ELayoutSwitchStart) |
|
459 { |
|
460 disAppearExists = ETrue; |
|
461 break; |
|
462 } |
|
463 else if ( iBridge.iAlfRegisteredEffects[i].iAction == AknTransEffect::ELayoutSwitchExit) |
|
464 { |
|
465 appearExists = ETrue; |
|
466 break; |
|
467 } |
|
468 } |
|
469 |
|
470 return (appearExists || disAppearExists); |
|
471 } |
|
472 |
|
473 // Timer to send finish full screen effect |
|
474 // --------------------------------------------------------- |
|
475 // CAlfFinishTimer |
|
476 // --------------------------------------------------------- |
|
477 // |
|
478 NONSHARABLE_CLASS( CAlfEffectEndTimer ):public CTimer |
|
479 { |
|
480 public: // Constructors and destructor |
|
481 static CAlfEffectEndTimer* NewL( CAlfBridge& aBridge ); |
|
482 virtual ~CAlfEffectEndTimer(); |
|
483 |
|
484 public: // New functions |
|
485 void Start( TTimeIntervalMicroSeconds32 aPeriod, TInt aHandle ); |
|
486 |
|
487 protected: // Functions from base classes |
|
488 void DoCancel(); |
|
489 |
|
490 private: |
|
491 CAlfEffectEndTimer( CAlfBridge& aBridge ); |
|
492 void ConstructL(); |
|
493 void RunL(); |
|
494 |
|
495 private: // Data |
|
496 CAlfBridge& iBridge; |
|
497 TInt iHandle; |
|
498 |
|
499 }; |
|
500 |
|
501 |
|
502 // --------------------------------------------------------- |
|
503 // CAlfFinishTimer |
|
504 // --------------------------------------------------------- |
|
505 // |
|
506 CAlfEffectEndTimer::CAlfEffectEndTimer( CAlfBridge& aBridge ) |
|
507 :CTimer(EPriorityHigh), |
|
508 iBridge(aBridge) |
|
509 { |
|
510 } |
|
511 |
|
512 void CAlfEffectEndTimer::ConstructL() |
|
513 { |
|
514 CTimer::ConstructL(); |
|
515 CActiveScheduler::Add( this ); |
|
516 } |
|
517 |
|
518 CAlfEffectEndTimer* CAlfEffectEndTimer::NewL( CAlfBridge& aBridge ) |
|
519 { |
|
520 CAlfEffectEndTimer* self = new ( ELeave ) CAlfEffectEndTimer( aBridge ); |
|
521 CleanupStack::PushL( self ); |
|
522 self->ConstructL(); |
|
523 CleanupStack::Pop( self ); |
|
524 return self; |
|
525 } |
|
526 |
|
527 CAlfEffectEndTimer::~CAlfEffectEndTimer() |
|
528 { |
|
529 Cancel(); |
|
530 } |
|
531 |
|
532 void CAlfEffectEndTimer::Start( TTimeIntervalMicroSeconds32 aPeriod, TInt aHandle ) |
|
533 { |
|
534 iHandle = aHandle; |
|
535 After( aPeriod ); |
|
536 } |
|
537 |
|
538 void CAlfEffectEndTimer::RunL() |
|
539 { |
|
540 // |
|
541 // timer completes and control is returned to caller |
|
542 // |
|
543 iBridge.TransitionFinishedHandlerL( iHandle ); |
|
544 // We don't become active unless we are explicitly restarted |
|
545 } |
|
546 |
|
547 void CAlfEffectEndTimer::DoCancel() |
|
548 { |
|
549 CTimer::DoCancel(); |
|
550 } |
|
551 |
|
552 |
|
553 // ======== MEMBER FUNCTIONS ======== |
|
554 |
|
555 // ======== MEMBER FUNCTIONS ======== |
|
556 |
|
557 // --------------------------------------------------------------------------- |
|
558 // --------------------------------------------------------------------------- |
|
559 // |
|
560 CAlfBridge* CAlfBridge::NewL( CAlfStreamerBridge** aHost, CHuiEnv* aEnv ) |
|
561 { |
|
562 CAlfBridge* self = new (ELeave) CAlfBridge( aHost ); |
|
563 CleanupStack::PushL( self ); |
|
564 self->ConstructL( aEnv ); |
|
565 CleanupStack::Pop( self ); |
|
566 return self; |
|
567 } |
|
568 |
|
569 |
|
570 // --------------------------------------------------------------------------- |
|
571 // --------------------------------------------------------------------------- |
|
572 // |
|
573 void CAlfBridge::ProvideBitmapL(TInt /*aId*/, CFbsBitmap*& aBitmap, CFbsBitmap*& aMaskBitmap) |
|
574 { |
|
575 aBitmap = iHack; |
|
576 aMaskBitmap = iDummyMask; |
|
577 }; |
|
578 |
|
579 |
|
580 // --------------------------------------------------------------------------- |
|
581 // --------------------------------------------------------------------------- |
|
582 // |
|
583 CAlfBridge::CAlfBridge(CAlfStreamerBridge** aHost) |
|
584 : iHost(aHost), iCurrentMemoryLevel(EHuiMemoryLevelNormal) |
|
585 { |
|
586 } |
|
587 |
|
588 |
|
589 // --------------------------------------------------------------------------- |
|
590 // --------------------------------------------------------------------------- |
|
591 // |
|
592 CAlfBridge::~CAlfBridge() |
|
593 { |
|
594 delete iFadeEffectFile; |
|
595 iWindowHashArray.Close(); |
|
596 for( TInt i = 0; i< iAlfRegisteredEffects.Count(); i++ ) |
|
597 { |
|
598 delete iAlfRegisteredEffects[i].iEffectFile; |
|
599 } |
|
600 iAlfRegisteredEffects.Close(); |
|
601 iFinishedEffects.Close(); |
|
602 delete iEffectEndTimer; |
|
603 iDeadControlGroups.Close(); |
|
604 iEffectWindowGroups.Close(); |
|
605 delete iFullScreenEffectData; |
|
606 |
|
607 if (iActivated) |
|
608 { |
|
609 iBridgerClient.Close(); |
|
610 } |
|
611 |
|
612 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
613 delete iCommandDebug; |
|
614 #endif |
|
615 delete iCursorTimer; |
|
616 delete iLayoutSwitchEffectCoordinator; |
|
617 } |
|
618 |
|
619 |
|
620 // --------------------------------------------------------------------------- |
|
621 // --------------------------------------------------------------------------- |
|
622 // |
|
623 void CAlfBridge::ConstructL(CHuiEnv* aEnv) |
|
624 { |
|
625 iHuiEnv = aEnv; |
|
626 |
|
627 #ifdef SYMBIAN_BUILD_GCE |
|
628 iPrintFPS = EFalse; |
|
629 #ifndef __WINSCW__ |
|
630 _LIT(KRDSupport, "c:\\resource\\errrd" ); |
|
631 RFs& fs = CHuiStatic::FsSession(); |
|
632 if (fs.Handle() && BaflUtils::FileExists( fs, KRDSupport )) |
|
633 { |
|
634 iPrintFPS = ETrue; |
|
635 } |
|
636 #endif |
|
637 #endif //SYMBIAN_BUILD_GCE |
|
638 // create the key for indication transition ends |
|
639 // No access restrictions for starters |
|
640 TInt err = RProperty::Define( KPSAlfDomain, KAlfTransitionStatus, |
|
641 RProperty::EInt ); |
|
642 if (!err) |
|
643 { |
|
644 // Initialize to no transition |
|
645 RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, 0 ); |
|
646 } |
|
647 |
|
648 iEffectEndTimer = CAlfEffectEndTimer::NewL( *this ); |
|
649 iWindowHashArray.ReserveL( 500 ); |
|
650 iAlfRegisteredEffects.ReserveL(10); |
|
651 |
|
652 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
653 iCommandDebug = CAlfCommandDebug::NewL(); |
|
654 #endif |
|
655 |
|
656 iLayoutSwitchEffectCoordinator = new (ELeave) CAlfLayoutSwitchEffectCoordinator(*this); |
|
657 iAlfSecureId = RThread().SecureId(); |
|
658 RegisterFadeEffectL(); |
|
659 } |
|
660 |
|
661 // --------------------------------------------------------------------------- |
|
662 // RegisterFadeEffectL |
|
663 // |
|
664 // Note, If theme DOES NOT register its own fade effect, another hardcoded fade |
|
665 // effect will be used instead. For example, if theme effects are turned off, |
|
666 // a fade that does not belong to the theme may be in use. |
|
667 // --------------------------------------------------------------------------- |
|
668 void CAlfBridge::RegisterFadeEffectL() |
|
669 { |
|
670 // TODO: RND, REMOVE MMC DRIVE-F, WHEN NOT REQUIRED FOR TESTING |
|
671 _LIT(KDrivePrefence,"FZC"); |
|
672 // Force register fade effect. Try first MMC, then ROM. |
|
673 CHuiFxEngine* engine = iHuiEnv->EffectsEngine(); |
|
674 RFs& fs = CHuiStatic::FsSession(); |
|
675 if (fs.Handle() && engine) |
|
676 { |
|
677 _LIT(KFadeEffectPath, ":\\resource\\effects\\fade_effect.fxml"); |
|
678 TBufC<4> drives(KDrivePrefence); |
|
679 HBufC* effectFullName = HBufC::NewLC(KFadeEffectPath().Length() + 1); |
|
680 |
|
681 for(TInt i=0; i< drives.Length(); i++) |
|
682 { |
|
683 effectFullName->Des().Copy(drives.Mid(i,1)); |
|
684 effectFullName->Des().Append(KFadeEffectPath); |
|
685 |
|
686 if (BaflUtils::FileExists( fs, *effectFullName )) |
|
687 { |
|
688 DoRegisterEffectL(*effectFullName, KFadeAction); |
|
689 break; |
|
690 } |
|
691 } |
|
692 CleanupStack::PopAndDestroy(effectFullName); |
|
693 DoSetCachedFadeEffectL(); |
|
694 } |
|
695 } |
|
696 |
|
697 // --------------------------------------------------------------------------- |
|
698 // DoSetCachedFadeEffectL |
|
699 // --------------------------------------------------------------------------- |
|
700 // |
|
701 void CAlfBridge::DoSetCachedFadeEffectL() |
|
702 { |
|
703 for (TInt i = 0; i < iAlfRegisteredEffects.Count(); i++) |
|
704 { |
|
705 //KFadeAction = 6000, indicating the action corroposnds to fading |
|
706 if (iAlfRegisteredEffects[i].iAction == KFadeAction) |
|
707 { |
|
708 delete iFadeEffectFile; |
|
709 iFadeEffectFile = NULL; |
|
710 iFadeEffectFile = iAlfRegisteredEffects[i].iEffectFile->AllocL(); |
|
711 __ALFLOGSTRING1( ">> Setting fade effect file %S", iFadeEffectFile ); |
|
712 break; |
|
713 } |
|
714 } |
|
715 } |
|
716 |
|
717 // --------------------------------------------------------------------------- |
|
718 // AddNewScreenL |
|
719 // --------------------------------------------------------------------------- |
|
720 // |
|
721 void CAlfBridge::AddNewScreenL(CAlfSharedDisplayCoeControl* aSharedCoeControl) |
|
722 { |
|
723 TInt screenNumber = iAlfScreens.Count(); // \todo this might not be the same as real WServ screen number |
|
724 |
|
725 // We do not yet support drawing winGC draw commands to other than primary screen. |
|
726 // As fully functional and tested implementation is not there, better to panic here. |
|
727 if (screenNumber!=0) |
|
728 { |
|
729 __ALFLOGSTRING("CAlfBridge::AddNewScreenL. Fatal error! Only screen 0 is supported in Alf server!"); |
|
730 User::Invariant(); |
|
731 } |
|
732 |
|
733 CAlfScreen* screen = new(ELeave) CAlfScreen(); |
|
734 CleanupStack::PushL(screen); |
|
735 screen->ConstructL(screenNumber, *this, *iHuiEnv, aSharedCoeControl); |
|
736 iAlfScreens.AppendL( screen ); |
|
737 CleanupStack::Pop(screen); |
|
738 |
|
739 ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFloatingSpriteControlGroup), KHuiRosterShowAtTop, screenNumber); |
|
740 ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFullscreenEffectControlGroup), KHuiRosterShowAtTop, screenNumber); |
|
741 |
|
742 |
|
743 screen->iFloatingSpriteControlGroup->SetAcceptInput(EFalse); |
|
744 screen->iFullscreenEffectControlGroup->SetAcceptInput(EFalse); |
|
745 } |
|
746 |
|
747 //------------------------------------------------------------------------------ |
|
748 // Dumdidumdidum.. |
|
749 //------------------------------------------------------------------------------ |
|
750 void CAlfBridge::AddNewScreenFromWindowL(RWindow* aWindow) |
|
751 { |
|
752 TInt screenNumber = iAlfScreens.Count(); // \todo this might not be the same as real WServ screen number |
|
753 |
|
754 CAlfScreen* screen = new(ELeave) CAlfScreen(); |
|
755 CleanupStack::PushL(screen); |
|
756 screen->ConstructL(screenNumber, *this, *iHuiEnv, aWindow); |
|
757 iAlfScreens.AppendL( screen ); |
|
758 CleanupStack::Pop(screen); |
|
759 |
|
760 ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFloatingSpriteControlGroup), KHuiRosterShowAtTop, screenNumber); |
|
761 ShowControlGroupL(screen->iDisplay->Roster(), *(screen->iFullscreenEffectControlGroup), KHuiRosterShowAtTop, screenNumber); |
|
762 |
|
763 screen->iFloatingSpriteControlGroup->SetAcceptInput(EFalse); |
|
764 screen->iFullscreenEffectControlGroup->SetAcceptInput(EFalse); |
|
765 } |
|
766 |
|
767 |
|
768 |
|
769 // --------------------------------------------------------------------------- |
|
770 // AddVisual |
|
771 // --------------------------------------------------------------------------- |
|
772 // |
|
773 void CAlfBridge::AddVisual( |
|
774 TInt aWindowNodeId, |
|
775 TInt aClientSideId, |
|
776 TInt aClientSideGroupId, |
|
777 CHuiCanvasVisual* aVisual ) |
|
778 { |
|
779 __ALFFXLOGSTRING1("CAlfBridge::AddVisual 0x%x", aWindowNodeId); |
|
780 THashVisualStruct visualStruct( aVisual, aClientSideId, aClientSideGroupId); |
|
781 iWindowHashArray.Insert( aWindowNodeId, visualStruct ); |
|
782 iPreviouslySearchedVisualId = aWindowNodeId; |
|
783 iPreviouslySearchedVisual = aVisual; |
|
784 } |
|
785 |
|
786 // --------------------------------------------------------------------------- |
|
787 // RemoveVisual |
|
788 // --------------------------------------------------------------------------- |
|
789 // |
|
790 void CAlfBridge::RemoveVisual( TInt aWindowNodeId ) |
|
791 { |
|
792 __ALFFXLOGSTRING1("CAlfBridge::RemoveVisual 0x%x", aWindowNodeId); |
|
793 iWindowHashArray.Remove( aWindowNodeId ); |
|
794 iPreviouslySearchedVisualId = 0; |
|
795 } |
|
796 |
|
797 // --------------------------------------------------------------------------- |
|
798 // FindVisual |
|
799 // --------------------------------------------------------------------------- |
|
800 // |
|
801 CHuiCanvasVisual* CAlfBridge::FindVisual(TInt aWindowNodeId ) |
|
802 { |
|
803 if ( iPreviouslySearchedVisualId == aWindowNodeId ) |
|
804 { |
|
805 return iPreviouslySearchedVisual; |
|
806 } |
|
807 |
|
808 THashVisualStruct* visualStruct = iWindowHashArray.Find( aWindowNodeId ); |
|
809 if ( visualStruct ) |
|
810 { |
|
811 iPreviouslySearchedVisualId = aWindowNodeId; |
|
812 iPreviouslySearchedVisual = visualStruct->iVisual; |
|
813 return iPreviouslySearchedVisual; |
|
814 } |
|
815 __ALFFXLOGSTRING1("CAlfBridge::FindVisual - Visual 0x%x not found", aWindowNodeId); |
|
816 return NULL; |
|
817 } |
|
818 |
|
819 // --------------------------------------------------------------------------- |
|
820 // FindVisualByClientSideId |
|
821 // --------------------------------------------------------------------------- |
|
822 // |
|
823 CHuiCanvasVisual* CAlfBridge::FindVisualByClientSideIds( |
|
824 TUint32 aClientSideId, |
|
825 TUint32 aClientSideGroupId ) |
|
826 { |
|
827 THashMapIter<TUint32, THashVisualStruct> iter(iWindowHashArray); |
|
828 THashVisualStruct const * node = 0; |
|
829 do |
|
830 { |
|
831 node = iter.NextValue(); |
|
832 if (node |
|
833 && (*node).iClientSideId==aClientSideId |
|
834 && (*node).iClientSideGroupId==aClientSideGroupId ) |
|
835 { |
|
836 return (*node).iVisual; |
|
837 } |
|
838 } |
|
839 while(node); |
|
840 return NULL; |
|
841 } |
|
842 |
|
843 // --------------------------------------------------------------------------- |
|
844 // --------------------------------------------------------------------------- |
|
845 // |
|
846 CHuiControlGroup* CAlfBridge::FindControlGroup(TInt aWindowGroupNodeId, TInt aScreenNumber ) |
|
847 { |
|
848 for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++) |
|
849 { |
|
850 if (iAlfScreens[aScreenNumber]->iControlGroups[i].iWindowGroupNodeId == aWindowGroupNodeId) |
|
851 { |
|
852 return iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup; |
|
853 } |
|
854 } |
|
855 return NULL; |
|
856 } |
|
857 |
|
858 // --------------------------------------------------------------------------- |
|
859 // FindClientWindowGroupId |
|
860 // --------------------------------------------------------------------------- |
|
861 // |
|
862 TInt CAlfBridge::FindClientWindowGroupId( TInt aScreenNumber, CHuiControlGroup& aControlGroup ) |
|
863 { |
|
864 for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++) |
|
865 { |
|
866 if( iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup == &aControlGroup ) |
|
867 { |
|
868 return iAlfScreens[aScreenNumber]->iControlGroups[i].iClientWindowGroupId; |
|
869 } |
|
870 } |
|
871 return KErrNotFound; |
|
872 } |
|
873 |
|
874 // --------------------------------------------------------------------------- |
|
875 // --------------------------------------------------------------------------- |
|
876 // |
|
877 CHuiControlGroup* CAlfBridge::FindControlGroupByWindowGroupId( TInt aWindowGroupId, TInt& aScreenNumber, TAlfControlGroupEntry** aAlfGroup ) |
|
878 { |
|
879 TInt firstWin = aScreenNumber; |
|
880 TInt lastWin = aScreenNumber; |
|
881 if ( aScreenNumber == KErrNotFound ) |
|
882 { |
|
883 firstWin = 0; |
|
884 lastWin = iAlfScreens.Count()-1; |
|
885 } |
|
886 |
|
887 for ( TInt j = firstWin; j <= lastWin; j++ ) |
|
888 { |
|
889 for ( TInt i = 0; i < iAlfScreens[j]->iControlGroups.Count(); i++ ) |
|
890 { |
|
891 if ( iAlfScreens[j]->iControlGroups[i].iClientWindowGroupId == aWindowGroupId ) |
|
892 { |
|
893 aScreenNumber = j; |
|
894 if ( aAlfGroup != NULL ) |
|
895 { |
|
896 *aAlfGroup = &iAlfScreens[j]->iControlGroups[i]; |
|
897 } |
|
898 return iAlfScreens[j]->iControlGroups[i].iControlGroup; |
|
899 } |
|
900 } |
|
901 } |
|
902 return NULL; |
|
903 } |
|
904 |
|
905 // --------------------------------------------------------------------------- |
|
906 // --------------------------------------------------------------------------- |
|
907 // |
|
908 CHuiControlGroup* CAlfBridge::FindControlGroupByAppId( TInt aAppId ) |
|
909 { |
|
910 for ( TInt i = 0; i < iAlfScreens[0]->iControlGroups.Count(); i++ ) |
|
911 { |
|
912 if ( iAlfScreens[0]->iControlGroups[i].iSecureId == aAppId ) |
|
913 { |
|
914 return iAlfScreens[0]->iControlGroups[i].iControlGroup; |
|
915 } |
|
916 } |
|
917 return NULL; |
|
918 } |
|
919 |
|
920 // --------------------------------------------------------------------------- |
|
921 // --------------------------------------------------------------------------- |
|
922 // |
|
923 |
|
924 void CAlfBridge::ListFamilyTreeL( RPointerArray<CHuiLayout>& aArray, const CHuiLayout* aLayout ) |
|
925 { |
|
926 if (aLayout->Count()) |
|
927 { |
|
928 aArray.Append(aLayout); |
|
929 |
|
930 for(TInt i = 0; i< aLayout->Count(); i++) |
|
931 { |
|
932 ListFamilyTreeL(aArray, (CHuiLayout*)&aLayout->Visual(i)); |
|
933 } |
|
934 } |
|
935 else |
|
936 { |
|
937 aArray.Append(aLayout); |
|
938 } |
|
939 } |
|
940 |
|
941 // --------------------------------------------------------------------------- |
|
942 // --------------------------------------------------------------------------- |
|
943 // |
|
944 void CAlfBridge::DeleteControlGroupL(TInt aWindowGroupNodeId, TInt aScreenNumber ) |
|
945 { |
|
946 for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++) |
|
947 { |
|
948 if (iAlfScreens[aScreenNumber]->iControlGroups[i].iWindowGroupNodeId == aWindowGroupNodeId) |
|
949 { |
|
950 if (iAlfScreens[aScreenNumber]->iDisplay) |
|
951 { |
|
952 CHuiControl& control = iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup->Control(0); |
|
953 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0); |
|
954 // wserv has notifed that this control group and its layout should be destroyed. However, we might be |
|
955 // have effect on the layout itself or layout is being drawn as external content. This indicates that |
|
956 // we should not delete the control group at this point, but add it to iDeadControlGroup list, which |
|
957 // is cleared when effect has finished. |
|
958 RPointerArray<CHuiLayout> familyTree; |
|
959 ListFamilyTreeL(familyTree, layout); // recursively dig the family tree |
|
960 |
|
961 if (HasActiveEffect(layout)) |
|
962 { |
|
963 __ALFFXLOGSTRING1("Layout 0x%x has external content", layout); |
|
964 // EHuiVisualFlagShouldDestroy destroy flag should have come for the windows in this layout already |
|
965 layout->SetFlags(EHuiVisualFlagShouldDestroy); |
|
966 // move this layout to effect control group, where it can still be shown. this control group may be deleted. |
|
967 CHuiControl& control = iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup->Control(0); |
|
968 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0); |
|
969 |
|
970 for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++) |
|
971 { |
|
972 control.Remove(familyTree[familyIndex]); // remove ownership from original group |
|
973 } |
|
974 |
|
975 control.Remove(layout); // remove ownership from original group |
|
976 // move visuals to safe place. the original group must be destroyed. |
|
977 __ALFFXLOGSTRING1("MOVING 0x%x to effect group", layout); |
|
978 CHuiControl& effectControlGroup = iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0); |
|
979 CHuiLayout* effectControlGroupLayout = (CHuiLayout*) &effectControlGroup.Visual(0); |
|
980 // Transfers ownership of visuals. |
|
981 effectControlGroup.AppendL(layout, effectControlGroupLayout); // this will remove it from the previous layout |
|
982 layout->SetOwner(effectControlGroup); |
|
983 |
|
984 for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++) |
|
985 { |
|
986 familyTree[familyIndex]->SetOwner(effectControlGroup); |
|
987 } |
|
988 } |
|
989 else |
|
990 { |
|
991 // check once more, that the windows in this group are not having effects. |
|
992 // the layout is not have effect, but some child window might. |
|
993 // in this case, the child window effects WILL BE REMOVED. |
|
994 for(TInt familyIndex = 0; familyIndex < familyTree.Count();familyIndex++) |
|
995 { |
|
996 RemoveTemporaryPresenterVisual(familyTree[familyIndex]); |
|
997 } |
|
998 } |
|
999 familyTree.Close(); |
|
1000 iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup); |
|
1001 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group"); |
|
1002 iAlfScreens[aScreenNumber]->iControlGroups.Remove(i); |
|
1003 iHuiEnv->DeleteControlGroup(aWindowGroupNodeId); |
|
1004 __ALFFXLOGSTRING("CAlfBridge::DeleteControlGroupL - Deleting group done"); |
|
1005 } |
|
1006 break; |
|
1007 } |
|
1008 } |
|
1009 } |
|
1010 |
|
1011 |
|
1012 // --------------------------------------------------------------------------- |
|
1013 // --------------------------------------------------------------------------- |
|
1014 // |
|
1015 CHuiControlGroup& CAlfBridge::CreateControlGroupL( |
|
1016 TInt aWindowGroupNodeId, |
|
1017 TInt aClientWindowGroupId, |
|
1018 TInt aSecureId, |
|
1019 TInt aScreenNumber ) |
|
1020 { |
|
1021 CHuiControlGroup* group = FindControlGroup(aWindowGroupNodeId,aScreenNumber); |
|
1022 if (!group) |
|
1023 { |
|
1024 group = &iHuiEnv->NewControlGroupL(aWindowGroupNodeId); |
|
1025 CleanupStack::PushL(group); |
|
1026 CHuiControl* cntrl = new (ELeave) CHuiControl(*iHuiEnv); |
|
1027 CleanupStack::PushL(cntrl); |
|
1028 CHuiLayout* layout = NULL; |
|
1029 |
|
1030 cntrl->ConstructL(); |
|
1031 group->AppendL(cntrl); |
|
1032 CleanupStack::Pop(cntrl); |
|
1033 cntrl->SetRole(EAlfWindowGroupContainer); |
|
1034 |
|
1035 layout = CHuiCanvasVisual::AddNewL(*cntrl); |
|
1036 layout->SetTagL(KAlfWindowGroupContainerControlTag); |
|
1037 layout->ClearFlag(EHuiVisualFlagClipping); // No need to clip, should be faster without clipping |
|
1038 // IsVisualOpaque should return true if there is no effect. |
|
1039 // So that's why opaque flag is set to this layout. |
|
1040 layout->SetFlag(EHuiVisualFlagOpaqueHint); |
|
1041 |
|
1042 TAlfControlGroupEntry entry; |
|
1043 entry.iControlGroup = group; |
|
1044 entry.iWindowGroupNodeId = aWindowGroupNodeId; |
|
1045 entry.iClientWindowGroupId = aClientWindowGroupId; |
|
1046 entry.iSecureId = aSecureId; |
|
1047 // we have received start effect for this group, but the group did not exist in alf universe at the time. hide the group. |
|
1048 if (iFullScreenEffectData |
|
1049 && iFullScreenEffectData->iWaitingWindowGroup |
|
1050 && iFullScreenEffectData->iToAppId == aSecureId) |
|
1051 { |
|
1052 CHuiControlGroup* fromGroup = NULL; |
|
1053 CHuiLayout* fromLayout = NULL; |
|
1054 fromGroup = FindControlGroupByAppId(iFullScreenEffectData->iFromAppId); |
|
1055 if (fromGroup) |
|
1056 { |
|
1057 CHuiControl& control2 = fromGroup->Control(0); |
|
1058 fromLayout = (CHuiLayout*)&control2.Visual(0); |
|
1059 } |
|
1060 |
|
1061 |
|
1062 // First HandleGfxEvent, then clear iWaitingWindowGroup. |
|
1063 TBool failed = HandleGfxEventL( *iFullScreenEffectData, layout, fromLayout ); |
|
1064 if ( iFullScreenEffectData ) |
|
1065 { |
|
1066 iFullScreenEffectData->iWaitingWindowGroup = EFalse; |
|
1067 } |
|
1068 if ( failed ) |
|
1069 { |
|
1070 // Effect failed, reset state |
|
1071 HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData |
|
1072 } |
|
1073 } |
|
1074 entry.iScreenNumber = aScreenNumber; |
|
1075 // entry.iRole = EAlfWindowGroupContainer; |
|
1076 |
|
1077 iAlfScreens[aScreenNumber]->iControlGroups.Append(entry); |
|
1078 CleanupStack::Pop(group); |
|
1079 |
|
1080 if (iAlfScreens[aScreenNumber]->iDisplay) |
|
1081 ShowControlGroupL(iAlfScreens[aScreenNumber]->iDisplay->Roster(), *group, KHuiRosterShowAtTop, aScreenNumber); |
|
1082 } |
|
1083 |
|
1084 |
|
1085 return *group; |
|
1086 } |
|
1087 |
|
1088 |
|
1089 // --------------------------------------------------------------------------- |
|
1090 // --------------------------------------------------------------------------- |
|
1091 // |
|
1092 void CAlfBridge::ShowControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber ) |
|
1093 { |
|
1094 CAlfScreen* screen = iAlfScreens[aScreenNumber]; |
|
1095 |
|
1096 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
1097 DebugPrintControlGroupOrder(*screen, aRoster, aGroup); |
|
1098 #endif |
|
1099 |
|
1100 #ifdef ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER |
|
1101 if (!aGroup.IsTransformed()) |
|
1102 { |
|
1103 aGroup.EnableTransformationL(); |
|
1104 aGroup.Transformation().Translate(0,0); |
|
1105 aGroup.Transformation().Scale(0.3,0.3); |
|
1106 } |
|
1107 #endif |
|
1108 |
|
1109 TInt last = aRoster.Count() - 1; |
|
1110 |
|
1111 |
|
1112 // when an application exits, it must be shown on top util the effect has run its course. |
|
1113 // But this tends to mess up the order of other groups, and application menu softkeys will |
|
1114 // disappear. |
|
1115 if ( aGroup.Control(0).Visual(0).Effect() ) |
|
1116 { |
|
1117 if ( aGroup.Control(0).Role() != EAlfWindowGroupContainer ) |
|
1118 { |
|
1119 // The case where the application control group is deleted by window server |
|
1120 // has been solved by deleting the tag when window server wants to delete |
|
1121 // the group. Window server no longer has it, but we keep it alive for a while |
|
1122 // to show the effect. The group will be deleted when the effect ends. |
|
1123 aWhere = aRoster.Count() - KAlfNumberOfFixedControlGroups; |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 if (aGroup.Control(0).Role() == EAlfWindowGroupContainer) |
|
1128 { |
|
1129 // Window group control groups |
|
1130 ShowWindowGroupControlGroupL(aRoster, aGroup, aWhere, aScreenNumber); |
|
1131 aGroup.SetAcceptInput(EFalse); |
|
1132 } |
|
1133 else if (aGroup.Control(0).Role() == EAlfSessionContainer) |
|
1134 { |
|
1135 // ALF application control groups |
|
1136 ShowSessionContainerControlGroupL(aRoster, aGroup, aWhere, aScreenNumber); |
|
1137 } |
|
1138 else |
|
1139 { |
|
1140 aRoster.ShowL(aGroup, aWhere); |
|
1141 aGroup.SetAcceptInput(EFalse); |
|
1142 } |
|
1143 |
|
1144 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
1145 DebugPrintControlGroupOrder(*screen, aRoster, aGroup); |
|
1146 #endif |
|
1147 |
|
1148 #ifdef ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER |
|
1149 VisualizeControlGroupOrderL(aRoster, aGroup); |
|
1150 #endif |
|
1151 |
|
1152 } |
|
1153 |
|
1154 // --------------------------------------------------------------------------- |
|
1155 // --------------------------------------------------------------------------- |
|
1156 // |
|
1157 void CAlfBridge::ShowSessionContainerControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber ) |
|
1158 { |
|
1159 TInt last = aRoster.Count() - 1; |
|
1160 |
|
1161 CAlfScreen* screen = iAlfScreens[aScreenNumber]; |
|
1162 |
|
1163 if (aWhere == KHuiRosterShowAtBottom) |
|
1164 { |
|
1165 // Most bottom one of alf control groups |
|
1166 aRoster.ShowL(aGroup, FirstAlfControlGroupIndex(aScreenNumber)); |
|
1167 } |
|
1168 else if (aWhere == KHuiRosterShowAtTop) |
|
1169 { |
|
1170 // Most top one of alf control groups |
|
1171 TInt newIndex = LastAlfControlGroupIndex(aScreenNumber); |
|
1172 |
|
1173 // check if the aGroup is already in a roster |
|
1174 for (TInt j=0; j<newIndex;j++) |
|
1175 { |
|
1176 if( &aRoster.ControlGroup(j) == &aGroup ) |
|
1177 { |
|
1178 // adjust position a bit because this is in fact "move" operation |
|
1179 // move would move alf event window and place this control group |
|
1180 // on top of it if we don't do this adjusment |
|
1181 newIndex--; |
|
1182 break; |
|
1183 } |
|
1184 } |
|
1185 |
|
1186 aRoster.ShowL(aGroup, newIndex); |
|
1187 } |
|
1188 else |
|
1189 { |
|
1190 TInt index = 0; // Index for ALF group control groups |
|
1191 TBool added = EFalse; |
|
1192 TBool move = EFalse; // indicates that controlgroup is already in the roster somewhere below the new index. |
|
1193 for (TInt i=FirstAlfControlGroupIndex(aScreenNumber); i<last; i++) |
|
1194 { |
|
1195 if (index == aWhere) |
|
1196 { |
|
1197 if( move ) |
|
1198 { |
|
1199 // adjust the new index because of ShowL call |
|
1200 // will first remove the controlgroup from original position |
|
1201 index--; |
|
1202 } |
|
1203 aRoster.ShowL(aGroup, i); |
|
1204 added = ETrue; |
|
1205 break; |
|
1206 } |
|
1207 |
|
1208 if( &aRoster.ControlGroup(i) == &aGroup ) |
|
1209 { |
|
1210 move = ETrue; |
|
1211 } |
|
1212 |
|
1213 if (aRoster.ControlGroup(i).Control(0).Role() == EAlfSessionContainer) |
|
1214 { |
|
1215 index++; |
|
1216 } |
|
1217 } |
|
1218 |
|
1219 // Too large index was given, just add it to topmost |
|
1220 if (!added) |
|
1221 { |
|
1222 // Topmost alf group |
|
1223 ShowSessionContainerControlGroupL( aRoster, aGroup, KHuiRosterShowAtTop, aScreenNumber ); |
|
1224 } |
|
1225 } |
|
1226 } |
|
1227 |
|
1228 // --------------------------------------------------------------------------- |
|
1229 // --------------------------------------------------------------------------- |
|
1230 // |
|
1231 void CAlfBridge::ShowWindowGroupControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber ) |
|
1232 { |
|
1233 CAlfScreen* screen = iAlfScreens[aScreenNumber]; |
|
1234 |
|
1235 if (aWhere == KHuiRosterShowAtBottom) |
|
1236 { |
|
1237 // Most bottom one of any control groups |
|
1238 aRoster.ShowL(aGroup, KHuiRosterShowAtBottom); |
|
1239 } |
|
1240 else if (aWhere == KHuiRosterShowAtTop) |
|
1241 { |
|
1242 // Topmost |
|
1243 aRoster.ShowL(aGroup, aRoster.Count() - KAlfNumberOfFixedControlGroups); |
|
1244 } |
|
1245 else |
|
1246 { |
|
1247 TInt index = 0; // Index for Window group control groups |
|
1248 TBool added = EFalse; |
|
1249 for (TInt i=0; i<aRoster.Count() - KAlfNumberOfFixedControlGroups; i++) |
|
1250 { |
|
1251 if (index == aWhere) |
|
1252 { |
|
1253 aRoster.ShowL(aGroup, i); |
|
1254 added = ETrue; |
|
1255 break; |
|
1256 } |
|
1257 |
|
1258 if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer && |
|
1259 &aRoster.ControlGroup(i) != &aGroup) |
|
1260 { |
|
1261 index++; |
|
1262 } |
|
1263 } |
|
1264 |
|
1265 // Too large index was given, just add it to topmost |
|
1266 if (!added) |
|
1267 { |
|
1268 // Topmost |
|
1269 for (TInt i=aRoster.Count()-KAlfNumberOfFixedControlGroups; i >= 0; i--) |
|
1270 { |
|
1271 if (aRoster.ControlGroup(i).Control(0).Role() == EAlfWindowGroupContainer) |
|
1272 { |
|
1273 aRoster.ShowL(aGroup, i); |
|
1274 break; |
|
1275 } |
|
1276 } |
|
1277 } |
|
1278 } |
|
1279 } |
|
1280 |
|
1281 |
|
1282 // --------------------------------------------------------------------------- |
|
1283 // --------------------------------------------------------------------------- |
|
1284 // |
|
1285 void CAlfBridge::SetAlfWindowGroupId(TInt aAlfWindowGroupId) |
|
1286 { |
|
1287 iAlfWindowGroupId = aAlfWindowGroupId; |
|
1288 // check if hithcock window group was already there |
|
1289 TInt secureId = RThread().SecureId(); |
|
1290 if (iAlfScreens.Count()) |
|
1291 { |
|
1292 for ( TInt i = 0; i < iAlfScreens[0]->iControlGroups.Count(); i++ ) |
|
1293 { |
|
1294 if ( iAlfScreens[0]->iControlGroups[i].iSecureId == secureId && |
|
1295 iAlfScreens[0]->iControlGroups[i].iClientWindowGroupId != CHuiStatic::RootWin(0)->Identifier()) |
|
1296 { |
|
1297 iAlfWindowGroupNodeId = iAlfScreens[0]->iControlGroups[i].iWindowGroupNodeId; |
|
1298 return; |
|
1299 } |
|
1300 } |
|
1301 } |
|
1302 } |
|
1303 |
|
1304 // --------------------------------------------------------------------------- |
|
1305 // --------------------------------------------------------------------------- |
|
1306 // |
|
1307 CHuiDisplay* CAlfBridge::Display(TInt aScreenNum) |
|
1308 { |
|
1309 for ( TInt i = 0 ; i < iAlfScreens.Count() ; i++ ) |
|
1310 { |
|
1311 if ( iAlfScreens[i]->iScreenNum == aScreenNum ) |
|
1312 { |
|
1313 return iAlfScreens[i]->iDisplay; |
|
1314 } |
|
1315 } |
|
1316 return NULL; |
|
1317 } |
|
1318 |
|
1319 |
|
1320 // --------------------------------------------------------------------------- |
|
1321 // --------------------------------------------------------------------------- |
|
1322 // |
|
1323 void CAlfBridge::ReorderAlfControlGroupsL( TInt aScreenNumber ) |
|
1324 { |
|
1325 if (iAlfScreens[aScreenNumber]->iDisplay) |
|
1326 { |
|
1327 RPointerArray<CHuiControlGroup> controlGroupOrder; |
|
1328 CHuiRoster& roster = iAlfScreens[aScreenNumber]->iDisplay->Roster(); |
|
1329 for (TInt j=0; j<roster.Count();j++) |
|
1330 { |
|
1331 CHuiControlGroup& controlGroup = roster.ControlGroup(j); |
|
1332 if (controlGroup.Control(0).Role() == EAlfSessionContainer) |
|
1333 { |
|
1334 controlGroupOrder.Append(&controlGroup); |
|
1335 roster.Hide(controlGroup); |
|
1336 j--; // roster.Hide does remove controlGroup from the roster |
|
1337 } |
|
1338 } |
|
1339 |
|
1340 for (TInt k=0;k<controlGroupOrder.Count();k++) |
|
1341 { |
|
1342 ShowControlGroupL(roster, *controlGroupOrder[k], KHuiRosterShowAtTop, aScreenNumber); |
|
1343 } |
|
1344 |
|
1345 controlGroupOrder.Close(); |
|
1346 } |
|
1347 } |
|
1348 |
|
1349 |
|
1350 // --------------------------------------------------------------------------- |
|
1351 // --------------------------------------------------------------------------- |
|
1352 // |
|
1353 TInt CAlfBridge::FirstAlfControlGroupIndex( TInt aScreenNumber ) |
|
1354 { |
|
1355 if (iAlfScreens[aScreenNumber]->iDisplay) |
|
1356 { |
|
1357 CHuiRoster& roster = iAlfScreens[aScreenNumber]->iDisplay->Roster(); |
|
1358 for (TInt j=0; j<roster.Count();j++) |
|
1359 { |
|
1360 if( roster.ControlGroup(j).Control(0).Role() == EAlfSessionContainer |
|
1361 || roster.ControlGroup(j).ResourceId() == iAlfWindowGroupNodeId ) |
|
1362 { |
|
1363 return j; // Alf groups positioned just above alf servers window group |
|
1364 } |
|
1365 } |
|
1366 } |
|
1367 return 0; // Not found |
|
1368 } |
|
1369 |
|
1370 |
|
1371 // --------------------------------------------------------------------------- |
|
1372 // --------------------------------------------------------------------------- |
|
1373 // |
|
1374 TInt CAlfBridge::LastAlfControlGroupIndex( TInt aScreenNumber ) |
|
1375 { |
|
1376 if (iAlfScreens[aScreenNumber]->iDisplay) |
|
1377 { |
|
1378 CHuiRoster& roster = iAlfScreens[aScreenNumber]->iDisplay->Roster(); |
|
1379 for (TInt j=0; j<roster.Count();j++) |
|
1380 { // last is always a index of pointer event window position |
|
1381 if( roster.ControlGroup(j).ResourceId() == iAlfWindowGroupNodeId ) |
|
1382 { |
|
1383 return j; // Alf groups positioned just above alf servers window group |
|
1384 } |
|
1385 } |
|
1386 } |
|
1387 return 0; |
|
1388 } |
|
1389 |
|
1390 |
|
1391 // --------------------------------------------------------------------------- |
|
1392 // --------------------------------------------------------------------------- |
|
1393 // |
|
1394 TInt CAlfBridge::ResolveScreenNumber( CHuiDisplay& aDisplay ) |
|
1395 { |
|
1396 for ( TInt i = 0 ; i < iAlfScreens.Count() ; i++ ) |
|
1397 { |
|
1398 if ( iAlfScreens[i]->iDisplay == &aDisplay ) |
|
1399 { |
|
1400 return iAlfScreens[i]->iScreenNum; |
|
1401 } |
|
1402 } |
|
1403 return KErrNotFound; |
|
1404 } |
|
1405 |
|
1406 |
|
1407 // --------------------------------------------------------------------------- |
|
1408 // --------------------------------------------------------------------------- |
|
1409 // |
|
1410 void CAlfBridge::NotifyDisplayRefreshStarted(CHuiDisplay& aDisplay) |
|
1411 { |
|
1412 // Look for the correct display |
|
1413 TInt screenNumber = ResolveScreenNumber(aDisplay); |
|
1414 RemoveTemporaryPresenterVisuals(); |
|
1415 if ( screenNumber != KErrNotFound ) |
|
1416 { |
|
1417 // FPS Counter with hitchcock drawing |
|
1418 #ifdef SYMBIAN_BUILD_GCE |
|
1419 if(iPrintFPS) |
|
1420 { |
|
1421 TReal fps = CHuiStatic::FrameRate(); |
|
1422 if(fps > 0) |
|
1423 { |
|
1424 TBuf<8> numBuf; |
|
1425 numBuf.AppendNum(fps, TRealFormat(5,1)); |
|
1426 TRAP_IGNORE( |
|
1427 { |
|
1428 iAlfScreens[screenNumber]->iFPSText->SetTextL( numBuf ); |
|
1429 }) |
|
1430 } |
|
1431 } |
|
1432 #endif |
|
1433 |
|
1434 if (iAlfScreens[screenNumber]->IsVisualTreeVisibilityChanged()) |
|
1435 { |
|
1436 HandleVisualVisibility( screenNumber ); |
|
1437 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(EFalse); |
|
1438 } |
|
1439 |
|
1440 if (!iActivated) |
|
1441 { |
|
1442 iBridgerClient.Connect(); |
|
1443 iActivated = ETrue; |
|
1444 } |
|
1445 } |
|
1446 } |
|
1447 |
|
1448 // --------------------------------------------------------------------------- |
|
1449 // Check if there is effect and it's not fade effect. |
|
1450 // --------------------------------------------------------------------------- |
|
1451 // |
|
1452 static TBool IsNonFadeEffect(CHuiFxEffect* aEffect) |
|
1453 { |
|
1454 return aEffect && !(aEffect->EffectFlags() & KHuiFadeEffectFlag); |
|
1455 } |
|
1456 |
|
1457 // --------------------------------------------------------------------------- |
|
1458 // --------------------------------------------------------------------------- |
|
1459 // |
|
1460 TBool CAlfBridge::IsVisualOpaque(CHuiVisual& aVisual) |
|
1461 { |
|
1462 TBool transparent = EFalse; |
|
1463 |
|
1464 // TODO: We should check transformation too and perhaps parent transformations as well ? |
|
1465 //transparent |= aVisual.IsTransformed(); |
|
1466 |
|
1467 // if the control has an attached effect which is transformed, it must be considered transparent |
|
1468 // as it may not cover the full screen |
|
1469 if ( IsNonFadeEffect( aVisual.Effect() ) ) |
|
1470 { |
|
1471 return EFalse; |
|
1472 } |
|
1473 if ( aVisual.Layout() && IsNonFadeEffect( aVisual.Layout()->Effect() ) ) |
|
1474 { |
|
1475 return EFalse; |
|
1476 } |
|
1477 |
|
1478 if (aVisual.Flags() & EHuiVisualFlagDrawOnlyAsExternalContent) |
|
1479 { |
|
1480 return EFalse; // not transparent |
|
1481 } |
|
1482 |
|
1483 transparent |= (!((aVisual.Flags() & EHuiVisualFlagOpaqueHint) == EHuiVisualFlagOpaqueHint)); |
|
1484 transparent |= (aVisual.iOpacity.Now() < KAlfVisualDefaultOpacity); |
|
1485 transparent |= (aVisual.iOpacity.Target() < KAlfVisualDefaultOpacity); |
|
1486 |
|
1487 return !transparent; |
|
1488 } |
|
1489 |
|
1490 // --------------------------------------------------------------------------- |
|
1491 // --------------------------------------------------------------------------- |
|
1492 // |
|
1493 void CAlfBridge::ClipVisualRect(TRect& aRect, const TRect& aClippingRect) |
|
1494 { |
|
1495 if (aRect.Intersects(aClippingRect)) |
|
1496 { |
|
1497 // Clip to visible area, there are windows larger than screen for some reason. |
|
1498 aRect.Intersection(aClippingRect); |
|
1499 } |
|
1500 else |
|
1501 { |
|
1502 // no intersection with the clipping rect -> outside of the screen -> not visible |
|
1503 aRect = TRect(0,0,0,0); |
|
1504 } |
|
1505 } |
|
1506 |
|
1507 // --------------------------------------------------------------------------- |
|
1508 // --------------------------------------------------------------------------- |
|
1509 // |
|
1510 TBool CAlfBridge::IsRectCoveredByRegion(TRect aRect, TRegion& aCoveringRegion) |
|
1511 { |
|
1512 TBool isCovered = EFalse; |
|
1513 |
|
1514 // Zero sized rects are considered as covered (although it is a bit philosphical question) |
|
1515 if (aRect.Size() == TSize(0,0)) |
|
1516 { |
|
1517 isCovered = ETrue; |
|
1518 } |
|
1519 |
|
1520 // First check if it is covered by one of the rects in the covering region... |
|
1521 if (!isCovered) |
|
1522 { |
|
1523 TPoint topLeft = aRect.iTl; |
|
1524 TPoint bottomRight = aRect.iBr; |
|
1525 bottomRight.iX--; |
|
1526 bottomRight.iY--; |
|
1527 |
|
1528 for (TInt i=0; i < aCoveringRegion.Count(); i++) |
|
1529 { |
|
1530 if (aCoveringRegion[i].Contains(topLeft) && |
|
1531 aCoveringRegion[i].Contains(bottomRight)) |
|
1532 { |
|
1533 isCovered = ETrue; |
|
1534 } |
|
1535 } |
|
1536 } |
|
1537 |
|
1538 // ...it may still cover it with a combination of several rects |
|
1539 if (!isCovered) |
|
1540 { |
|
1541 iTempVisualRegion.Clear(); |
|
1542 iTempIntersectingRegion.Clear(); |
|
1543 |
|
1544 iTempVisualRegion.AddRect(aRect); |
|
1545 |
|
1546 iTempIntersectingRegion.Intersection(aCoveringRegion, iTempVisualRegion); |
|
1547 iTempIntersectingRegion.Tidy(); |
|
1548 |
|
1549 if (iTempIntersectingRegion.Count() == 1) |
|
1550 { |
|
1551 if (iTempIntersectingRegion[0] == aRect) |
|
1552 { |
|
1553 isCovered = ETrue; |
|
1554 } |
|
1555 } |
|
1556 } |
|
1557 |
|
1558 return isCovered; |
|
1559 } |
|
1560 |
|
1561 |
|
1562 |
|
1563 // --------------------------------------------------------------------------- |
|
1564 // --------------------------------------------------------------------------- |
|
1565 // |
|
1566 void CAlfBridge::HandleVisualVisibility( TInt aScreenNumber ) |
|
1567 { |
|
1568 if (!iAlfScreens.Count()) |
|
1569 return; |
|
1570 |
|
1571 iTempRegion.Clear(); |
|
1572 |
|
1573 CAlfScreen* screen = iAlfScreens[aScreenNumber]; |
|
1574 TRect fullscreen = TRect(TPoint(0,0), screen->Size()); |
|
1575 TBool fadeEffectInScreen = EFalse; |
|
1576 |
|
1577 |
|
1578 // Prepare SW render target (if needed) |
|
1579 if (iSwRenderingEnabled) |
|
1580 { |
|
1581 TBool modified = PrepareSwRenderingTarget( screen ); |
|
1582 |
|
1583 if ( modified ) |
|
1584 { |
|
1585 // To avoid debug panic, we need to reset foreground bitmap. |
|
1586 TRAP_IGNORE( screen->iDisplay->SetForegroundBitmapL( |
|
1587 screen->iSwRenderingTarget ) ); |
|
1588 } |
|
1589 } |
|
1590 |
|
1591 TBool fullscreenCovered = EFalse; |
|
1592 //iActiveVisualCount = 0; |
|
1593 iBgSurfaceFound = EFalse; |
|
1594 //iPaintedArea = 0; |
|
1595 // skip the topmost (effect) layer, start from floating sprite group |
|
1596 for (TInt j=screen->iDisplay->Roster().Count() - 2; j>=0; j--) |
|
1597 { |
|
1598 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
1599 TInt activevisualcount = 0; |
|
1600 TInt passivevisualcount = 0; |
|
1601 #endif |
|
1602 |
|
1603 CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j); |
|
1604 CHuiControl& control = controlgroup.Control(0); |
|
1605 CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0); |
|
1606 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
1607 if ( layout->Tracking() ) |
|
1608 { |
|
1609 RDebug::Print(_L("CAlfBridge::HandleVisualVisibility: tracked visual 0x%x"), canvasVisual); |
|
1610 } |
|
1611 #endif |
|
1612 |
|
1613 // Dont mess with alf control group visuals, alf session handling does it for us |
|
1614 // just add the rect to covered region because alf draws solid background. |
|
1615 if (control.Role() == EAlfSessionContainer) |
|
1616 { |
|
1617 iTempRegion.AddRect(fullscreen); |
|
1618 iTempRegion.Tidy(); |
|
1619 continue; |
|
1620 } |
|
1621 |
|
1622 // For optimization reasons, check if all visuals below in Z-order are covered |
|
1623 if (!fullscreenCovered) |
|
1624 { |
|
1625 fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion); |
|
1626 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
1627 if (fullscreenCovered) |
|
1628 __ALFLOGSTRING("Full screen covered!"); |
|
1629 #endif |
|
1630 } |
|
1631 |
|
1632 if (!fullscreenCovered) |
|
1633 { |
|
1634 fullscreenCovered = screen->iDisplay->Roster().IsVisibleContentFrozen(); |
|
1635 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
1636 if (fullscreenCovered) |
|
1637 __ALFLOGSTRING("Full screen covered because of frozen roster content"); |
|
1638 #endif |
|
1639 } |
|
1640 |
|
1641 TBool subTreeCovered = EFalse; |
|
1642 TBool hasActiveVisualsInVisualTree = HandleLayoutVisualVisibility( layout, controlgroup, control, fullscreenCovered, fullscreen, screen, subTreeCovered, IsVisualOpaque(*layout) ); |
|
1643 TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree); |
|
1644 |
|
1645 // If we layout is active setup the fade effects. Also if it is inactive, but has been |
|
1646 // flagged as containing fade effect, then run the setup as well so that effects which |
|
1647 // are no more needed get removed. |
|
1648 if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree)) |
|
1649 { |
|
1650 fadeEffectInScreen = ETrue; |
|
1651 |
|
1652 // Prepare fade effects to whole visual tree below layout |
|
1653 PrepareFadeEffects( *layout ); |
|
1654 |
|
1655 // Load needed fade effects (or remove them) |
|
1656 TBool visualTreeHasFadeEffects = LoadFadeEffectsL( *layout ); |
|
1657 |
|
1658 // Set flag so that next time we can optimize |
|
1659 if (visualTreeHasFadeEffects) |
|
1660 { |
|
1661 layout->SetCanvasFlags(EHuiCanvasFlagExternalFadeExistsInsideVisualTree); |
|
1662 } |
|
1663 else |
|
1664 { |
|
1665 layout->ClearCanvasFlags(EHuiCanvasFlagExternalFadeExistsInsideVisualTree); |
|
1666 } |
|
1667 } |
|
1668 |
|
1669 if (!hasActiveVisualsInVisualTree) |
|
1670 { |
|
1671 // Setting also the root visual (layout) as inactive, if it had none |
|
1672 // active children. This is because otherwise the Inactive checks won't |
|
1673 // work correctly within RosterImpl ScanDirty & ClearChanged phases. |
|
1674 layout->SetFlag(EHuiVisualFlagInactive); |
|
1675 } |
|
1676 else |
|
1677 { |
|
1678 layout->ClearFlag(EHuiVisualFlagInactive); |
|
1679 } |
|
1680 |
|
1681 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
1682 __ALFLOGSTRING1(">>>> HandleVisualVisibility: Control group index: %d", j ); |
|
1683 __ALFLOGSTRING1(">>>> HandleVisualVisibility: Active visuals : %d", activevisualcount ); |
|
1684 __ALFLOGSTRING1(">>>> HandleVisualVisibility: Passive visuals: %d", passivevisualcount ); |
|
1685 #endif |
|
1686 |
|
1687 } |
|
1688 if (iBgSurfaceFound) |
|
1689 { |
|
1690 if (!iInLowMemMode) |
|
1691 { |
|
1692 SetLowMemory(ETrue); |
|
1693 iBridgerClient.SendBlind(KAlfCompositionTargetHidden, TIpcArgs()); |
|
1694 iInLowMemMode = ETrue; |
|
1695 } |
|
1696 } |
|
1697 else if (iInLowMemMode) |
|
1698 { |
|
1699 SetLowMemory(EFalse); |
|
1700 iBridgerClient.SendBlind(KAlfCompositionTargetVisible, TIpcArgs()); |
|
1701 iInLowMemMode = EFalse; |
|
1702 } |
|
1703 |
|
1704 |
|
1705 // Finally, if there are fadeeffects applied to windowgroups, make sure first one does not |
|
1706 // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others |
|
1707 // would clear the screen areas where they do not really draw. |
|
1708 if (fadeEffectInScreen) |
|
1709 { |
|
1710 TBool firstFadedWindowGroupFound = EFalse; |
|
1711 for (TInt j=0; j<screen->iDisplay->Roster().Count() - 2; j++) // skip the topmost (effect) layer |
|
1712 { |
|
1713 CHuiControlGroup& controlgroup = iAlfScreens[aScreenNumber]->iDisplay->Roster().ControlGroup(j); |
|
1714 CHuiControl& control = controlgroup.Control(0); |
|
1715 CHuiCanvasVisual* layout = (CHuiCanvasVisual*)&control.Visual(0); |
|
1716 if (layout->Effect() && (layout->Effect()->EffectFlags() & KHuiFadeEffectFlag)) |
|
1717 { |
|
1718 if (firstFadedWindowGroupFound) |
|
1719 { |
|
1720 TInt flags = layout->Effect()->EffectFlags(); |
|
1721 flags |= KHuiFxAlwaysBlend; |
|
1722 layout->Effect()->SetEffectFlags(flags); |
|
1723 } |
|
1724 firstFadedWindowGroupFound = ETrue; |
|
1725 } |
|
1726 } |
|
1727 } |
|
1728 } |
|
1729 |
|
1730 TBool CAlfBridge::HandleLayoutVisualVisibility( |
|
1731 CHuiLayout* aLayout, |
|
1732 CHuiControlGroup& aControlGroup, |
|
1733 CHuiControl& aControl, |
|
1734 TBool& aFullscreenCovered, |
|
1735 TRect& aFullscreen, |
|
1736 CAlfScreen* aScreen, |
|
1737 TBool& aSubtreeVisible, |
|
1738 TBool aChildCanBeOpaque ) |
|
1739 { |
|
1740 TBool visualTreeActive = EFalse; |
|
1741 TRect visualDisplayRect; |
|
1742 TBool visualRectIsCovered = EFalse; |
|
1743 TBool visualIsOpaque = EFalse; |
|
1744 TBool visualIsActive = EFalse; |
|
1745 CHuiCanvasVisual* canvasVisual = NULL; |
|
1746 |
|
1747 for (TInt i=aLayout->Count()-1; i >= 0; i--) |
|
1748 { |
|
1749 visualDisplayRect = TRect(0,0,0,0); |
|
1750 visualRectIsCovered = EFalse; |
|
1751 visualIsOpaque = EFalse; |
|
1752 visualIsActive = EFalse; |
|
1753 TBool visualSubtreeVisible = EFalse; |
|
1754 |
|
1755 // Check first if visual itself is hidden or does hide other visuals below |
|
1756 // in z-order. If it does not hide, then we do not add its displayrect to covering |
|
1757 // region. |
|
1758 canvasVisual = (CHuiCanvasVisual*)(&aLayout->Visual(i)); |
|
1759 |
|
1760 // Child can be considered to be opaque only if all parents are opaque and |
|
1761 // visual itself is opaque. |
|
1762 // For example, parent can have opacity < 1 and that affects children as well. |
|
1763 // As another example, parent can have scaling transformation. |
|
1764 visualIsOpaque = aChildCanBeOpaque && IsVisualOpaque(*canvasVisual); |
|
1765 if (canvasVisual->Count()) |
|
1766 { |
|
1767 visualTreeActive |= HandleLayoutVisualVisibility( canvasVisual, aControlGroup, aControl, aFullscreenCovered, aFullscreen, aScreen, visualSubtreeVisible, visualIsOpaque ); |
|
1768 } |
|
1769 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
1770 if ( canvasVisual->Tracking() ) |
|
1771 { |
|
1772 RDebug::Print(_L("CAlfBridge::HandleVisualVisibility: tracked visual 0x%x"), canvasVisual); |
|
1773 } |
|
1774 #endif |
|
1775 |
|
1776 if (visualSubtreeVisible) |
|
1777 { |
|
1778 aSubtreeVisible = ETrue; |
|
1779 } |
|
1780 |
|
1781 // Optimization, it is faster to check fullscreen than read visuals displayrect |
|
1782 if (aFullscreenCovered) |
|
1783 { |
|
1784 visualRectIsCovered = ETrue; |
|
1785 } |
|
1786 else |
|
1787 { |
|
1788 // Check where visual is |
|
1789 visualDisplayRect = canvasVisual->DisplayRect(); |
|
1790 |
|
1791 // Make sure we clip visual rect to visible screen area |
|
1792 ClipVisualRect(visualDisplayRect, aFullscreen); |
|
1793 |
|
1794 // Check if this visual is covered by other opaque visuals which rects are in "covered" region |
|
1795 visualRectIsCovered = IsRectCoveredByRegion(visualDisplayRect, iTempRegion); |
|
1796 } |
|
1797 |
|
1798 /* if ( layout->Effect() || canvasVisual->Effect() ) |
|
1799 { |
|
1800 visualRectIsCovered = EFalse; |
|
1801 } |
|
1802 */ |
|
1803 TBool wasInactive = canvasVisual->Flags() & |
|
1804 ( EHuiVisualFlagInactive | EHuiVisualFlagUnderOpaqueHint ); |
|
1805 |
|
1806 if (visualRectIsCovered) |
|
1807 { |
|
1808 // We clear texture cache here to avoid running out of texture memory |
|
1809 if (!(canvasVisual->Flags() & EHuiVisualFlagAlwaysDraw)) // The window has been hidden. However it has exit effect and it must stay active until effect has stopped |
|
1810 { |
|
1811 if (visualSubtreeVisible) |
|
1812 { |
|
1813 canvasVisual->SetFlag(EHuiVisualFlagUnderOpaqueHint); |
|
1814 canvasVisual->ClearFlags(EHuiVisualFlagInactive); |
|
1815 } |
|
1816 else |
|
1817 { |
|
1818 canvasVisual->SetFlag(EHuiVisualFlagInactive); |
|
1819 canvasVisual->ClearFlags(EHuiVisualFlagUnderOpaqueHint); |
|
1820 } |
|
1821 |
|
1822 canvasVisual->ClearCache(); |
|
1823 // For SW rendering, disable capturing buffer |
|
1824 canvasVisual->SetCapturingBufferL(NULL); |
|
1825 } |
|
1826 else |
|
1827 { // this should be drawn, but inactivate when effect is done |
|
1828 canvasVisual->ClearFlags( |
|
1829 EHuiVisualFlagInactive | EHuiVisualFlagUnderOpaqueHint | |
|
1830 EHuiVisualFlagShouldBeInactive | EHuiVisualFlagShouldBeUnderOpaqueHint ); |
|
1831 if (visualSubtreeVisible) |
|
1832 { |
|
1833 canvasVisual->SetFlag(EHuiVisualFlagShouldBeUnderOpaqueHint); |
|
1834 } |
|
1835 else |
|
1836 { |
|
1837 canvasVisual->SetFlag(EHuiVisualFlagShouldBeInactive); |
|
1838 } |
|
1839 canvasVisual->PrepareCache(); |
|
1840 // For SW rendering, set capturing buffer if it exists) |
|
1841 canvasVisual->SetCapturingBufferL(aScreen->iSwRenderingTarget); |
|
1842 |
|
1843 if (wasInactive) |
|
1844 { |
|
1845 canvasVisual->SetChanged(); |
|
1846 } |
|
1847 } |
|
1848 |
|
1849 if (!wasInactive) |
|
1850 { |
|
1851 aScreen->iDisplay->SetDirty(); |
|
1852 } |
|
1853 |
|
1854 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
1855 passivevisualcount++; |
|
1856 #endif |
|
1857 } |
|
1858 else |
|
1859 { |
|
1860 aSubtreeVisible = ETrue; |
|
1861 canvasVisual->ClearFlags( |
|
1862 EHuiVisualFlagInactive | EHuiVisualFlagShouldBeInactive | |
|
1863 EHuiVisualFlagUnderOpaqueHint | EHuiVisualFlagShouldBeUnderOpaqueHint ); |
|
1864 canvasVisual->PrepareCache(); |
|
1865 canvasVisual->SetCapturingBufferL(aScreen->iSwRenderingTarget); |
|
1866 |
|
1867 // we've found non-inactive window which has background surface |
|
1868 // attached.. |
|
1869 if (canvasVisual->IsBackgroundDrawingEnabled() && |
|
1870 canvasVisual->LayerExtent() != TRect() && |
|
1871 !canvasVisual->LayerUsesAlphaFlag() ) |
|
1872 { |
|
1873 // if paintedareacount is exactly one, it means that the window |
|
1874 // has background surface but no drawing commands |
|
1875 if (canvasVisual->PaintedAreaCount() == 1) |
|
1876 { |
|
1877 THuiCanvasPaintedArea pa = canvasVisual->PaintedArea(0); |
|
1878 TRect r = pa.iPaintedRect.Round(); |
|
1879 // if we found a fullscreen surface with no other drawing commands |
|
1880 // we can safely assume that it's about the only thing to be visible |
|
1881 // and we can release memory occupied by other parts of the system |
|
1882 // |
|
1883 // NOTE: this mechanism keeps the system in low mem state |
|
1884 // if the surface is visible, meaning that for example |
|
1885 // opening an options menu does not instantly trigger normal |
|
1886 // memory state. We want to do it like this as otherwise |
|
1887 // we would be triggering for example background animation |
|
1888 // on / off quite rapidly........ |
|
1889 if ( r == Display(0)->VisibleArea()) |
|
1890 { |
|
1891 // Final test. Surface must not be ALF surface, but some other surface. |
|
1892 CHuiControlGroup* alfControlGroup = FindControlGroupByAppId( iAlfSecureId ); |
|
1893 if (alfControlGroup != &aControlGroup) |
|
1894 { |
|
1895 iBgSurfaceFound = ETrue; |
|
1896 } |
|
1897 } |
|
1898 } |
|
1899 } |
|
1900 |
|
1901 if (wasInactive) |
|
1902 { |
|
1903 canvasVisual->SetChanged(); |
|
1904 } |
|
1905 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
1906 activevisualcount++; |
|
1907 #endif |
|
1908 } |
|
1909 |
|
1910 // Finally check the area that this visual covers and add it to covered region |
|
1911 visualIsActive = !(canvasVisual->Flags() & EHuiVisualFlagInactive); |
|
1912 |
|
1913 // Sprites and effects as we consider them always as transparent and also |
|
1914 // if controlgroup is transformed somehow |
|
1915 |
|
1916 if (aControl.Role() == EAlfFullScreenEffectContainer |
|
1917 || aControl.Role() == EAlfWindowFloatingSpriteContainer || |
|
1918 aControlGroup.IsTransformed()) |
|
1919 { |
|
1920 visualIsOpaque = EFalse; |
|
1921 } |
|
1922 |
|
1923 if (visualIsActive && visualIsOpaque && !visualRectIsCovered) |
|
1924 { |
|
1925 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
1926 if (canvasVisual->PaintedAreaCount()) |
|
1927 __ALFLOGSTRING2("Visual has painted areas: displayrect: iTl: %i, %i", visualDisplayRect.iTl.iX, visualDisplayRect.iTl.iY); |
|
1928 __ALFLOGSTRING2("Visual has painted areas: displayrect: iBr: %i, %i", visualDisplayRect.iBr.iX,visualDisplayRect.iBr.iY); |
|
1929 #endif |
|
1930 for (TInt k=0; k < canvasVisual->PaintedAreaCount(); k++) |
|
1931 { |
|
1932 THuiCanvasPaintedArea paintArea = canvasVisual->PaintedArea(k); |
|
1933 TRect coveredRect = paintArea.iPaintedRect; |
|
1934 |
|
1935 // Clip to visible area, there are windows larger than screen for some reason. |
|
1936 ClipVisualRect(coveredRect, aFullscreen); |
|
1937 |
|
1938 // Only add to covering region if the painted area is defined as opaque |
|
1939 if (paintArea.iPaintType == EHuiCanvasPaintTypeOpaque) |
|
1940 { |
|
1941 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
1942 __ALFLOGSTRING2("Covered rect: iTl: %i, %i", coveredRect.iTl.iX, coveredRect.iTl.iY); |
|
1943 __ALFLOGSTRING2("Covered rect: iBr: %i, %i", coveredRect.iBr.iX,coveredRect.iBr.iY); |
|
1944 #endif |
|
1945 iTempRegion.AddRect(coveredRect); |
|
1946 iTempRegion.Tidy(); |
|
1947 } |
|
1948 } |
|
1949 } |
|
1950 } |
|
1951 |
|
1952 visualTreeActive |= visualIsActive; |
|
1953 return visualTreeActive; |
|
1954 } |
|
1955 |
|
1956 |
|
1957 // --------------------------------------------------------------------------- |
|
1958 // --------------------------------------------------------------------------- |
|
1959 // |
|
1960 void CAlfBridge::ClearCanvasVisualCommandSets(TBool aInactiveOnly) |
|
1961 { |
|
1962 if (!iAlfScreens.Count()) |
|
1963 return; |
|
1964 |
|
1965 CAlfScreen* screen = iAlfScreens[0]; // TODO |
|
1966 for (TInt j=screen->iDisplay->Roster().Count() - 2; j>=0; j--) // skip the topmost (effect) layer |
|
1967 { |
|
1968 CHuiControlGroup& controlgroup = iAlfScreens[0]->iDisplay->Roster().ControlGroup(j); |
|
1969 CHuiControl& control = controlgroup.Control(0); |
|
1970 |
|
1971 if ( control.Role() == EAlfSessionContainer ) |
|
1972 { |
|
1973 continue; |
|
1974 } |
|
1975 |
|
1976 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0); |
|
1977 for (TInt i=layout->Count()-1; i >= 0; i--) |
|
1978 { |
|
1979 CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)(&layout->Visual(i)); |
|
1980 if (!aInactiveOnly) |
|
1981 { |
|
1982 canvasVisual->ClearCommandSet(); |
|
1983 } |
|
1984 else if (aInactiveOnly && (canvasVisual->Flags() & EHuiVisualFlagInactive)) |
|
1985 { |
|
1986 canvasVisual->ClearCommandSet(); |
|
1987 } |
|
1988 else |
|
1989 { |
|
1990 // dont clear |
|
1991 } |
|
1992 } |
|
1993 } |
|
1994 } |
|
1995 |
|
1996 |
|
1997 // --------------------------------------------------------------------------- |
|
1998 // --------------------------------------------------------------------------- |
|
1999 // |
|
2000 void CAlfBridge::EnableVisualDefaultTransformationsL(CHuiVisual& aVisual) |
|
2001 { |
|
2002 aVisual.EnableTransformationL(); |
|
2003 if (!aVisual.Transformation().Count()) |
|
2004 { |
|
2005 aVisual.Transformation().Rotate(0); |
|
2006 aVisual.Transformation().Scale(1,1); |
|
2007 aVisual.Transformation().Translate(0,0); |
|
2008 } |
|
2009 } |
|
2010 |
|
2011 // --------------------------------------------------------------------------- |
|
2012 // --------------------------------------------------------------------------- |
|
2013 // |
|
2014 void CAlfBridge::HandleCallback(TInt aStatus) |
|
2015 { |
|
2016 TInt err = KErrNone; |
|
2017 if (aStatus >= 0) |
|
2018 { |
|
2019 TRAP(err, DoDispatchL(aStatus)) |
|
2020 } |
|
2021 |
|
2022 if (aStatus < 0 || err) |
|
2023 { |
|
2024 __ALFLOGSTRING2("CAlfBridge::HandleCallback status: %d error: %d",aStatus,err); |
|
2025 |
|
2026 CEikonEnv* eikenv = CEikonEnv::Static(); |
|
2027 if ( eikenv ) |
|
2028 { |
|
2029 eikenv->HandleError(err?err:aStatus); |
|
2030 } |
|
2031 } |
|
2032 } |
|
2033 |
|
2034 |
|
2035 // --------------------------------------------------------------------------- |
|
2036 // DoDispatchL |
|
2037 // --------------------------------------------------------------------------- |
|
2038 // |
|
2039 void CAlfBridge::DoDispatchL(TInt aStatus) |
|
2040 { |
|
2041 if (*iHost) |
|
2042 { |
|
2043 TAlfBridgerData data = (*iHost)->GetData(aStatus); |
|
2044 // dispatch |
|
2045 __ALFLOGSTRING1( "CAlfBridge::DoDispatchL: %d",data.iOp ); |
|
2046 |
|
2047 switch (data.iOp) |
|
2048 { |
|
2049 case EAlfDSCreateNewDisplay: |
|
2050 { |
|
2051 AddNewScreenL(NULL); |
|
2052 break; |
|
2053 } |
|
2054 case EAlfDSDestroyDisplay: |
|
2055 { |
|
2056 HandleDestroyDisplay( data.iInt1 ); |
|
2057 break; |
|
2058 } |
|
2059 case EAlfDSNewWindow: |
|
2060 { |
|
2061 HandleNewWindowL( data ); |
|
2062 break; |
|
2063 } |
|
2064 case EAlfDSDestroyWindow: |
|
2065 { |
|
2066 HandleDestroyWindowL( data ); |
|
2067 break; |
|
2068 } |
|
2069 case EAlfDSSetWindowPos: |
|
2070 { |
|
2071 HandleSetWindowPosL( data ); |
|
2072 break; |
|
2073 } |
|
2074 case EAlfDSSetWindowSize: |
|
2075 { |
|
2076 HandleSetWindowSizeL( data ); |
|
2077 break; |
|
2078 } |
|
2079 case EAlfDSSetWindowRotation: |
|
2080 { |
|
2081 HandleSetWindowRotationL( data ); |
|
2082 break; |
|
2083 } |
|
2084 case EAlfDSSetWindowOpacity: |
|
2085 { |
|
2086 HandleSetWindowOpacityL( data ); |
|
2087 break; |
|
2088 } |
|
2089 case EAlfDSRefreshCallback: |
|
2090 { |
|
2091 iHuiEnv->ContinueRefresh(); |
|
2092 break; |
|
2093 } |
|
2094 case EAlfDSReorder: |
|
2095 { |
|
2096 HandleReorderWindowL( data ); |
|
2097 break; |
|
2098 } |
|
2099 case EAlfDSPostCanvasBuffer: |
|
2100 { |
|
2101 HandlePostCanvasBufferL( data ); |
|
2102 break; |
|
2103 } |
|
2104 case EAlfDSSetWindowActive: |
|
2105 { |
|
2106 HandleSetWindowActiveL( data ); |
|
2107 break; |
|
2108 } |
|
2109 case EAlfDSSetWindowFlag: |
|
2110 case EAlfDSClearWindowFlag: |
|
2111 { |
|
2112 HandleSetWindowFlagL(data, data.iOp); |
|
2113 break; |
|
2114 } |
|
2115 case EAlfDSSetSurfaceExtent: |
|
2116 { |
|
2117 HandleSetSurfaceExtentL( data ); |
|
2118 break; |
|
2119 } |
|
2120 case EAlfDsLayerUsesAlphaFlagChanged: |
|
2121 { |
|
2122 HandleLayerUsesAlphaFlagChanged( data ); |
|
2123 break; |
|
2124 } |
|
2125 case EAlfDSGetAlfNativeWindowData: |
|
2126 { |
|
2127 // HandleGetNativeWindowDataL( data ); |
|
2128 break; |
|
2129 } |
|
2130 case EAlfDSGroupChained: |
|
2131 { |
|
2132 __ALFLOGSTRING("CAlfBridge::DoDispatchL, EAlfDSGroupChained"); |
|
2133 // TODO, link groups |
|
2134 break; |
|
2135 } |
|
2136 case EAlfDSGroupChainBroken: |
|
2137 { |
|
2138 __ALFLOGSTRING("CAlfBridge::DoDispatchL, EAlfDSGroupChainBroken"); |
|
2139 // TODO, break link |
|
2140 break; |
|
2141 } |
|
2142 case EAlfDSMoveWindowToNewGroup: |
|
2143 { |
|
2144 /* |
|
2145 RDebug::Print(_L("CAlfBridge::DoDispatchL, EAlfDSMoveWindowToNewGroup, THIS METHOD IS UNTESTED. EXPECT TROUBLE!")); |
|
2146 // TODO: TEST! |
|
2147 TInt windowGroupNodeId = data.iInt1; |
|
2148 TInt windowNodeId = data.iInt2; |
|
2149 TInt newGroupId = (TInt)data.iPtr; |
|
2150 CHuiLayout* layout = NULL; |
|
2151 CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId, windowGroupNodeId,screenNumber); |
|
2152 if (viz) |
|
2153 { |
|
2154 // #1 remove visual from old group |
|
2155 layout = viz->Layout(); |
|
2156 layout->Remove(viz); |
|
2157 viz->Owner().Remove(viz); |
|
2158 // #2 insert visual to the beginning of the new group |
|
2159 CHuiControlGroup* controlGroup = FindControlGroup(newGroupId,screenNumber); |
|
2160 if (controlGroup) |
|
2161 { |
|
2162 CHuiControl& control = controlGroup->Control(0); |
|
2163 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0); |
|
2164 layout->AppendL( viz ); |
|
2165 } |
|
2166 }*/ |
|
2167 break; |
|
2168 } |
|
2169 case EAlfEffectFx: |
|
2170 { |
|
2171 HandleGfxEffectsL( data ); |
|
2172 break; |
|
2173 } |
|
2174 case EAlfStopEffectFx: |
|
2175 { |
|
2176 HandleGfxStopEffectsL( data ); |
|
2177 break; |
|
2178 } |
|
2179 case EAlfControlEffectFx: |
|
2180 { |
|
2181 HandleGfxControlEffectsL( data ); |
|
2182 break; |
|
2183 } |
|
2184 // TODO: implement these |
|
2185 case EAlfRegisterEffectFx: |
|
2186 { |
|
2187 HandleRegisterEffectL( data ); |
|
2188 break; |
|
2189 } |
|
2190 case EAlfUnregisterEffectFx: |
|
2191 { |
|
2192 for (TInt i = 0; i < iAlfRegisteredEffects.Count(); i++) |
|
2193 { |
|
2194 if (iAlfRegisteredEffects[i].iAction == data.iInt1) |
|
2195 { |
|
2196 TRegisteredEffectsStruct removed = |
|
2197 iAlfRegisteredEffects[i]; |
|
2198 iAlfRegisteredEffects.Remove(i); |
|
2199 CHuiFxEngine* engine = NULL; |
|
2200 engine = iHuiEnv->EffectsEngine(); |
|
2201 if (engine) |
|
2202 { |
|
2203 engine->UnRegisterEffectL(*removed.iEffectFile); |
|
2204 } |
|
2205 delete removed.iEffectFile; |
|
2206 // if this happened to be the fade effect, the cached fade effect filename should |
|
2207 // be cleared |
|
2208 if ( data.iInt1 == KFadeAction) |
|
2209 { |
|
2210 RegisterFadeEffectL(); |
|
2211 } |
|
2212 break; |
|
2213 } |
|
2214 } |
|
2215 break; |
|
2216 } |
|
2217 case EAlfUnregisterAllFx: |
|
2218 { |
|
2219 while (iAlfRegisteredEffects.Count()) |
|
2220 { |
|
2221 TRegisteredEffectsStruct removed = |
|
2222 iAlfRegisteredEffects[0]; |
|
2223 iAlfRegisteredEffects.Remove(0); |
|
2224 CHuiFxEngine* engine = NULL; |
|
2225 engine = iHuiEnv->EffectsEngine(); |
|
2226 if (engine) |
|
2227 { |
|
2228 engine->UnRegisterEffectL(*removed.iEffectFile); |
|
2229 } |
|
2230 |
|
2231 delete removed.iEffectFile; |
|
2232 } |
|
2233 // fade file might have changed. This will be resolved when next fade effect request arrives. |
|
2234 RegisterFadeEffectL(); |
|
2235 break; |
|
2236 } |
|
2237 case EAlfDSSetCursorData: |
|
2238 { |
|
2239 HandleSetCursorDataL( data ); |
|
2240 break; |
|
2241 } |
|
2242 case EAlfDSSetFadeEffect: |
|
2243 { |
|
2244 HandleSetFadeEffectL( data ); |
|
2245 break; |
|
2246 } |
|
2247 case EAlfDSSetNodeTracking: |
|
2248 { |
|
2249 HandleSetNodeTracking( data ); |
|
2250 break; |
|
2251 } |
|
2252 case EAlfBridgeSetScreenRotation: |
|
2253 { |
|
2254 //short cut.. |
|
2255 __ALFLOGSTRING1("CAlfBridge::DoDispatchL: EAlfBridgeSetScreenRotation: %d",data.iInt1); |
|
2256 CHuiGc::TOrientation huiOrientation(CHuiGc::EOrientationNormal); |
|
2257 switch(data.iInt1) |
|
2258 { |
|
2259 case 1: // 90 |
|
2260 huiOrientation = CHuiGc::EOrientationCCW90; |
|
2261 break; |
|
2262 case 2: // 180 |
|
2263 huiOrientation = CHuiGc::EOrientation180; |
|
2264 break; |
|
2265 case 3: // 270 |
|
2266 huiOrientation = CHuiGc::EOrientationCW90; |
|
2267 break; |
|
2268 default: |
|
2269 break; |
|
2270 } |
|
2271 if (iAlfScreens[0]->iDisplay->Orientation() != huiOrientation) |
|
2272 { |
|
2273 HandleSetLayoutSwitchEffectL(); |
|
2274 iAlfScreens[0]->iDisplay->SetOrientation(huiOrientation); |
|
2275 if (iAppUi) |
|
2276 { |
|
2277 iAppUi->AdjustWindowGroupPositionL(0,CAlfAppServer::EAlfWindowSize); // hackish, but one way to enforce alf window resizing |
|
2278 } |
|
2279 __ALFLOGSTRING1("AlfScreens[0]->iDisplay->SetOrientation: %d",huiOrientation); |
|
2280 } |
|
2281 |
|
2282 break; |
|
2283 } |
|
2284 case EAlfEffectFxBeginSyncronizedGroup: |
|
2285 { |
|
2286 CHuiFxEngine* engine = iHuiEnv->EffectsEngine(); |
|
2287 if (engine) |
|
2288 { |
|
2289 engine->BeginGroupEffect(data.iInt1); |
|
2290 } |
|
2291 break; |
|
2292 } |
|
2293 case EAlfEffectFxEndSyncronizedGroup: |
|
2294 { |
|
2295 TInt groupId = data.iInt1; |
|
2296 //TBool forced = data.iInt2; |
|
2297 __ALFLOGSTRING1("CAlfBridge::DoDispatchL - Ending for group %d requested.", |
|
2298 groupId ); |
|
2299 CHuiFxEngine* engine = iHuiEnv->EffectsEngine(); |
|
2300 if (engine) |
|
2301 { |
|
2302 engine->StartGroupEffect(groupId); |
|
2303 } |
|
2304 iHuiEnv->ContinueRefresh(); |
|
2305 break; |
|
2306 } |
|
2307 case KUnInitialized: |
|
2308 { |
|
2309 __ALFLOGSTRING1("CAlfBridge::DoDispatchL: Received KUnInitialized: %d - CRITICAL ERROR!",data.iOp); |
|
2310 USER_INVARIANT(); |
|
2311 } |
|
2312 default: |
|
2313 { |
|
2314 // Should not happen |
|
2315 __ALFLOGSTRING1("CAlfBridge::DoDispatchL: Received Unknown op: %d",data.iOp); |
|
2316 } |
|
2317 } |
|
2318 } |
|
2319 } |
|
2320 |
|
2321 // --------------------------------------------------------------------------- |
|
2322 // HandleDestroyDisplay |
|
2323 // --------------------------------------------------------------------------- |
|
2324 // |
|
2325 void CAlfBridge::HandleDestroyDisplay( TInt aScreenNumber ) |
|
2326 { |
|
2327 iAlfScreens[aScreenNumber]->iDisplay->iRefreshObservers.Remove( *this ); |
|
2328 // TODO: Following delete iAlfScreens[aScreenNumber] crashes when display is trying to delete roster. |
|
2329 // RosterEntry is trying to refer to display, which is appareantly alrady destroyed. The roster should have no iRootVisual when display is removed. |
|
2330 |
|
2331 iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*(iAlfScreens[aScreenNumber]->iFloatingSpriteControlGroup)); |
|
2332 iAlfScreens[aScreenNumber]->iDisplay->Roster().Hide(*(iAlfScreens[aScreenNumber]->iFullscreenEffectControlGroup)); |
|
2333 delete iAlfScreens[aScreenNumber]; |
|
2334 iAlfScreens.Remove( aScreenNumber ); |
|
2335 } |
|
2336 |
|
2337 // --------------------------------------------------------------------------- |
|
2338 // HandleNewWindowL |
|
2339 // --------------------------------------------------------------------------- |
|
2340 // |
|
2341 void CAlfBridge::HandleNewWindowL( TAlfBridgerData& aData ) |
|
2342 { |
|
2343 TInt windowGroupNodeId = aData.iInt1; |
|
2344 TInt windowNodeId = aData.iInt2; |
|
2345 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
2346 TInt screenNumber = windowAttributes->iScreenNumber; |
|
2347 __ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: new window %d!",windowNodeId); |
|
2348 |
|
2349 switch (windowAttributes->iWindowNodeType) |
|
2350 { |
|
2351 case EAlfWinTreeNodeGroup: |
|
2352 { |
|
2353 CHuiControlGroup& controlGroup = CreateControlGroupL( |
|
2354 windowGroupNodeId, |
|
2355 windowAttributes->iClientHandle, |
|
2356 windowAttributes->iSecureId, |
|
2357 screenNumber); |
|
2358 |
|
2359 // We just received notification for our own window group creation, store its node id for doing |
|
2360 // faster lookups later... |
|
2361 if (windowAttributes->iClientHandle == iAlfWindowGroupId) |
|
2362 { |
|
2363 iAlfWindowGroupNodeId = windowGroupNodeId; |
|
2364 } |
|
2365 break; |
|
2366 } |
|
2367 case EAlfWinTreeNodeClient: |
|
2368 case EAlfWinTreeNodeRoot: // TODO: Root window receives drawing commands too |
|
2369 case EAlfWinTreeNodeAnim: |
|
2370 case EAlfWinTreeNodeSprite: |
|
2371 case EAlfWinTreeNodeTextCursor: |
|
2372 { |
|
2373 CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber); |
|
2374 // Floating sprites only require own group. Normal sprites should behave as normal visuals. |
|
2375 if (!controlGroup && windowAttributes->iWindowNodeType == EAlfWinTreeNodeSprite ) |
|
2376 { |
|
2377 controlGroup = iAlfScreens[screenNumber]->iFloatingSpriteControlGroup; |
|
2378 } |
|
2379 |
|
2380 if (controlGroup) |
|
2381 { |
|
2382 CHuiControl& control = controlGroup->Control(0); |
|
2383 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0); |
|
2384 CHuiCanvasVisual* viz = NULL; |
|
2385 CHuiCanvasVisual* parentViz = NULL; |
|
2386 parentViz = (CHuiCanvasVisual*)FindVisual(windowAttributes->iParentNodeId); |
|
2387 if (parentViz) |
|
2388 { |
|
2389 viz = CHuiCanvasVisual::AddNewL(control, parentViz); |
|
2390 } |
|
2391 else |
|
2392 { |
|
2393 viz = CHuiCanvasVisual::AddNewL(control, layout); |
|
2394 } |
|
2395 __ALFFXLOGSTRING2("CAlfBridge::HandleNewWindowL visual: 0x%x, id 0x%x", viz, windowNodeId); |
|
2396 AddVisual( |
|
2397 windowNodeId, |
|
2398 windowAttributes->iClientHandle, |
|
2399 windowAttributes->iClientGroupHandle, |
|
2400 viz ); |
|
2401 |
|
2402 // check , if a window is having already defined effect. |
|
2403 if (iControlEffectData |
|
2404 && iControlEffectData->iClientHandle == windowAttributes->iClientHandle |
|
2405 && iControlEffectData->iClientGroupHandle == windowAttributes->iClientGroupHandle) |
|
2406 { |
|
2407 HandleGfxControlEventL(*iControlEffectData, viz); |
|
2408 delete iControlEffectData; |
|
2409 iControlEffectData = NULL; |
|
2410 } |
|
2411 viz->SetCommandType( CHuiCanvasVisual::ECommandBufferSgc ); |
|
2412 viz->SetFlags(EHuiVisualFlagManualLayout | EHuiVisualFlagInactive); |
|
2413 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2414 if ( windowAttributes->iTrackWindow ) |
|
2415 { |
|
2416 viz->SetTracking( windowAttributes->iTrackWindow ); |
|
2417 } |
|
2418 #endif |
|
2419 // draw sprites and anims the last inside their windowgroup |
|
2420 /*if (windowAttributes->iWindowNodeType == EAlfWinTreeNodeSprite || windowAttributes->iWindowNodeType == EAlfWinTreeNodeAnim ) |
|
2421 { |
|
2422 viz->SetFlag(EHuiVisualFlagDrawAfterOthers); |
|
2423 } |
|
2424 */ |
|
2425 // Store identifier / tag to get handle of this visual later |
|
2426 TBuf8<16> buf; |
|
2427 buf.AppendNum(windowNodeId); |
|
2428 viz->SetTagL(buf); |
|
2429 viz->SetPos(windowAttributes->iPosition, windowAttributes->iTransitionTime); |
|
2430 viz->SetSize(windowAttributes->iSize, windowAttributes->iTransitionTime); |
|
2431 |
|
2432 // Keep window invisible until activated, for now we use opacity for that. |
|
2433 viz->iOpacity.Set(0, 0); |
|
2434 |
|
2435 // Set up parent link for clipping calculations |
|
2436 if (parentViz) |
|
2437 { |
|
2438 viz->SetCanvasFlags(EHuiCanvasFlagEnableCanvasClipping); |
|
2439 viz->SetParentCanvas(parentViz); |
|
2440 } |
|
2441 else |
|
2442 { |
|
2443 __ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: Parent not found for visual %d!",windowNodeId); |
|
2444 } |
|
2445 } |
|
2446 else |
|
2447 { |
|
2448 __ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: Control group not found for visual %d!",windowNodeId); |
|
2449 } |
|
2450 |
|
2451 break; |
|
2452 } |
|
2453 default: |
|
2454 { |
|
2455 __ALFLOGSTRING("CAlfBridge::HandleNewWindowL: Unknown window node type received !"); |
|
2456 } |
|
2457 } |
|
2458 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); |
|
2459 } |
|
2460 |
|
2461 // --------------------------------------------------------------------------- |
|
2462 // HandleDestroyWindow |
|
2463 // --------------------------------------------------------------------------- |
|
2464 // |
|
2465 void CAlfBridge::DestroyWindow(CHuiVisual* aVisual, TBool aUseForce) |
|
2466 { |
|
2467 if ( !aUseForce && HasActiveEffect(aVisual) ) |
|
2468 { |
|
2469 // this visual will be destroyed on the effect call back. |
|
2470 __ALFFXLOGSTRING1("CAlfBridge::DestroyWindow - not destroying 0x%x", aVisual); |
|
2471 aVisual->SetFlag(EHuiVisualFlagShouldDestroy); |
|
2472 // TODO: Revise |
|
2473 // move to effect controlgroup |
|
2474 //CHuiControl& effectControlGroup = iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0); |
|
2475 //CHuiLayout* effectControlGroupLayout = (CHuiLayout*) &effectControlGroup.Visual(0); |
|
2476 // Transfers ownership of visuals. |
|
2477 //effectControlGroup.AppendL(aVisual, effectControlGroupLayout); // this will remove it from the previous layout |
|
2478 //aVisual->SetOwner(effectControlGroup); |
|
2479 return; |
|
2480 } |
|
2481 __ALFFXLOGSTRING1("CAlfBridge::DestroyWindow 0x%x", aVisual); |
|
2482 RemoveImageBrushL(*aVisual); |
|
2483 CHuiLayout* layout = aVisual->Layout(); |
|
2484 if (layout) |
|
2485 layout->Remove(aVisual); |
|
2486 aVisual->Owner().Remove(aVisual); |
|
2487 __ALFLOGSTRING1("CAlfBridge::HandleDestroyWindow - destroying visual 0x%x", aVisual); |
|
2488 // check if visual is having an effect at the moment. This could occur, if options menu is exited (with effect) and then |
|
2489 // application is exited. EHuiVisualFlagDrawOnlyAsExternalContent is indication that |
|
2490 // there might be effect on this visual. It is not guaranteen. |
|
2491 |
|
2492 delete aVisual; |
|
2493 } |
|
2494 // --------------------------------------------------------------------------- |
|
2495 // HandleDestroyWindowL |
|
2496 // --------------------------------------------------------------------------- |
|
2497 // |
|
2498 void CAlfBridge::HandleDestroyWindowL( TAlfBridgerData& aData ) |
|
2499 { |
|
2500 TInt windowGroupNodeId = aData.iInt1; |
|
2501 TInt windowNodeId = aData.iInt2; |
|
2502 |
|
2503 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
2504 TInt screenNumber = windowAttributes->iScreenNumber; |
|
2505 |
|
2506 switch (windowAttributes->iWindowNodeType) |
|
2507 { |
|
2508 case EAlfWinTreeNodeGroup: |
|
2509 { |
|
2510 DeleteControlGroupL(windowGroupNodeId, screenNumber); |
|
2511 break; |
|
2512 } |
|
2513 case EAlfWinTreeNodeClient: |
|
2514 case EAlfWinTreeNodeRoot: |
|
2515 case EAlfWinTreeNodeAnim: |
|
2516 case EAlfWinTreeNodeSprite: |
|
2517 case EAlfWinTreeNodeFloatingSprite: |
|
2518 case EAlfWinTreeNodeTextCursor: |
|
2519 { |
|
2520 // close cursor timer |
|
2521 if (windowAttributes->iWindowNodeType == EAlfWinTreeNodeTextCursor) |
|
2522 { |
|
2523 iCursorTimer->Cancel(); |
|
2524 } |
|
2525 |
|
2526 //just remove the visual |
|
2527 CHuiCanvasVisual* viz; |
|
2528 |
|
2529 viz = (CHuiCanvasVisual*)FindVisual(windowNodeId); |
|
2530 CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber ); |
|
2531 // Sprite is in its own group, and can be deleted normally. |
|
2532 if ( !controlGroup && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite ) |
|
2533 { |
|
2534 __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.!"); |
|
2535 // the group containing this visual has been destroyed. Thus the visual itself has been destroyed by |
|
2536 // the group. Ignore this. |
|
2537 } |
|
2538 else |
|
2539 { |
|
2540 // = (CHuiCanvasVisual*)de(windowNodeId, windowGroupNodeId,screenNumber); |
|
2541 if (viz) |
|
2542 { |
|
2543 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2544 if ( viz->Tracking() ) |
|
2545 { |
|
2546 RDebug::Print(_L("CAlfBridge::HandleDestroyWindowL - Tracked visual")); |
|
2547 } |
|
2548 #endif |
|
2549 DestroyWindow(viz); |
|
2550 } |
|
2551 else |
|
2552 { |
|
2553 __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: visual not found!"); |
|
2554 } |
|
2555 } |
|
2556 RemoveVisual( windowNodeId ); |
|
2557 break; |
|
2558 } |
|
2559 default: |
|
2560 { |
|
2561 __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: Unknown window node type received !"); |
|
2562 break; |
|
2563 } |
|
2564 } |
|
2565 // TODO: Toolkit does not support recycling (of visuals), |
|
2566 // this is not in line with Nokia environmental policy... |
|
2567 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); |
|
2568 } |
|
2569 |
|
2570 // --------------------------------------------------------------------------- |
|
2571 // HandleSetWindowPosL |
|
2572 // --------------------------------------------------------------------------- |
|
2573 // |
|
2574 void CAlfBridge::HandleSetWindowPosL( TAlfBridgerData& aData ) |
|
2575 { |
|
2576 TInt windowNodeId = aData.iInt2; |
|
2577 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
2578 TInt screenNumber = windowAttributes->iScreenNumber; |
|
2579 // fetch visual |
|
2580 CHuiVisual* viz = FindVisual(windowNodeId); |
|
2581 if (viz) |
|
2582 { |
|
2583 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2584 if ( viz->Tracking() ) |
|
2585 { |
|
2586 RDebug::Print(_L("CAlfBridge::HandleSetWindowPosL - Tracked visual")); |
|
2587 } |
|
2588 #endif |
|
2589 |
|
2590 viz->SetPos(windowAttributes->iPosition, windowAttributes->iTransitionTime); |
|
2591 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed |
|
2592 } |
|
2593 else |
|
2594 { |
|
2595 __ALFLOGSTRING("CAlfBridge::HandleSetWindowPosL, EAlfDSSetWindowPos: Visual not found!"); |
|
2596 } |
|
2597 } |
|
2598 |
|
2599 // --------------------------------------------------------------------------- |
|
2600 // HandleSetWindowSizeL |
|
2601 // --------------------------------------------------------------------------- |
|
2602 // |
|
2603 void CAlfBridge::HandleSetWindowSizeL( TAlfBridgerData& aData ) |
|
2604 { |
|
2605 TInt windowNodeId = aData.iInt2; |
|
2606 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
2607 TInt screenNumber = windowAttributes->iScreenNumber; |
|
2608 // fetch visual |
|
2609 CHuiVisual* viz = FindVisual(windowNodeId); |
|
2610 if (viz) |
|
2611 { |
|
2612 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2613 if ( viz->Tracking() ) |
|
2614 { |
|
2615 RDebug::Print(_L("CAlfBridge::HandleSetWindowSizeL - Tracked visual")); |
|
2616 } |
|
2617 #endif |
|
2618 viz->SetSize(windowAttributes->iSize, windowAttributes->iTransitionTime); |
|
2619 } |
|
2620 else |
|
2621 { |
|
2622 __ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!"); |
|
2623 } |
|
2624 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); |
|
2625 } |
|
2626 |
|
2627 // --------------------------------------------------------------------------- |
|
2628 // HandleSetWindowRotationL |
|
2629 // --------------------------------------------------------------------------- |
|
2630 // |
|
2631 void CAlfBridge::HandleSetWindowRotationL( TAlfBridgerData& aData ) |
|
2632 { |
|
2633 TInt windowNodeId = aData.iInt2; |
|
2634 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
2635 // fetch visual |
|
2636 CHuiVisual* viz = FindVisual(windowNodeId); |
|
2637 if (viz) |
|
2638 { |
|
2639 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2640 if ( viz->Tracking() ) |
|
2641 { |
|
2642 RDebug::Print(_L("CAlfBridge::HandleSetWindowRotationL - Tracked visual")); |
|
2643 } |
|
2644 #endif |
|
2645 EnableVisualDefaultTransformationsL(*viz); |
|
2646 viz->Transformation()[KVisualTransformationStepRotate].iParams[0].Set(windowAttributes->iRotation, |
|
2647 windowAttributes->iTransitionTime); |
|
2648 } |
|
2649 else |
|
2650 { |
|
2651 __ALFLOGSTRING("CAlfBridge::HandleSetWindowRotationL, EAlfDSSetWindowRotation: Visual not found!"); |
|
2652 } |
|
2653 } |
|
2654 |
|
2655 // --------------------------------------------------------------------------- |
|
2656 // HandleSetWindowOpacityL |
|
2657 // --------------------------------------------------------------------------- |
|
2658 // |
|
2659 void CAlfBridge::HandleSetWindowOpacityL( TAlfBridgerData& aData ) |
|
2660 { |
|
2661 TInt windowNodeId = aData.iInt2; |
|
2662 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
2663 TInt screenNumber = windowAttributes->iScreenNumber; |
|
2664 // fetch visual |
|
2665 CHuiVisual* viz = FindVisual(windowNodeId); |
|
2666 if (viz) |
|
2667 { |
|
2668 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2669 if ( viz->Tracking() ) |
|
2670 { |
|
2671 RDebug::Print(_L("CAlfBridge::HandleSetWindowOpacityL - Tracked visual")); |
|
2672 } |
|
2673 #endif |
|
2674 viz->iOpacity.Set(windowAttributes->iOpacity, windowAttributes->iTransitionTime); |
|
2675 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed |
|
2676 } |
|
2677 else |
|
2678 { |
|
2679 __ALFLOGSTRING("CAlfBridge::HandleSetWindowOpacityL, EAlfDSSetWindowOpacity: Visual not found!"); |
|
2680 } |
|
2681 } |
|
2682 |
|
2683 // --------------------------------------------------------------------------- |
|
2684 // HandleReorderWindowL |
|
2685 // --------------------------------------------------------------------------- |
|
2686 // |
|
2687 void CAlfBridge::HandleReorderWindowL( TAlfBridgerData& aData ) |
|
2688 { |
|
2689 TInt windowGroupNodeId = aData.iInt1; |
|
2690 TInt windowNodeId = aData.iInt2; |
|
2691 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
2692 TInt screenNumber = windowAttributes->iScreenNumber; |
|
2693 TInt ordinalPosition = windowAttributes->iOrdinalPosition; |
|
2694 |
|
2695 switch (windowAttributes->iWindowNodeType) |
|
2696 { |
|
2697 case EAlfWinTreeNodeGroup: |
|
2698 { |
|
2699 |
|
2700 // HACK !!!! |
|
2701 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
2702 if (windowGroupNodeId == iAlfWindowGroupNodeId) |
|
2703 { |
|
2704 __ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Alf window group going to: %d ",windowAttributes->iOrdinalPosition); |
|
2705 } |
|
2706 else |
|
2707 { |
|
2708 __ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: WS window group going to: %d ",windowAttributes->iOrdinalPosition); |
|
2709 } |
|
2710 #endif |
|
2711 |
|
2712 CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber); |
|
2713 |
|
2714 if (!controlGroup) |
|
2715 { |
|
2716 User::Leave(KErrNotFound); |
|
2717 } |
|
2718 |
|
2719 // Window server nodes are in inverted Z-order, we switch it here. |
|
2720 iAlfScreens[screenNumber]->iDisplay->Roster().Hide(*controlGroup); |
|
2721 TInt wsWindowGroupCount = 0; |
|
2722 for (TInt i=0; i<iAlfScreens[screenNumber]->iDisplay->Roster().Count();i++) |
|
2723 { |
|
2724 if (iAlfScreens[screenNumber]->iDisplay->Roster().ControlGroup(i).Control(0).Role()==EAlfWindowGroupContainer) |
|
2725 { |
|
2726 wsWindowGroupCount++; |
|
2727 } |
|
2728 } |
|
2729 ordinalPosition = wsWindowGroupCount - windowAttributes->iOrdinalPosition; |
|
2730 |
|
2731 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
2732 __ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: wsWindowGroupCount: %d ", wsWindowGroupCount); |
|
2733 __ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Wimpautettu: %d ", ordinalPosition); |
|
2734 //RDebug::Print(_L("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Last total pos: %d "), iDisplay->Roster().Count() - 1); |
|
2735 #endif |
|
2736 |
|
2737 if (ordinalPosition < -1) |
|
2738 { |
|
2739 ordinalPosition = -1; // show at top ? |
|
2740 } |
|
2741 |
|
2742 if (iAlfScreens[screenNumber]->iDisplay && controlGroup) |
|
2743 { |
|
2744 ShowControlGroupL(iAlfScreens[screenNumber]->iDisplay->Roster(), *controlGroup, ordinalPosition, screenNumber); |
|
2745 } |
|
2746 else |
|
2747 { |
|
2748 __ALFLOGSTRING2("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Control group not found! Screen: %d, Id: %d ", screenNumber, windowNodeId ); |
|
2749 } |
|
2750 |
|
2751 ReorderAlfControlGroupsL(screenNumber); |
|
2752 break; |
|
2753 } |
|
2754 case EAlfWinTreeNodeClient: |
|
2755 case EAlfWinTreeNodeRoot: |
|
2756 case EAlfWinTreeNodeAnim: |
|
2757 case EAlfWinTreeNodeSprite: |
|
2758 case EAlfWinTreeNodeFloatingSprite: |
|
2759 case EAlfWinTreeNodeTextCursor: |
|
2760 { |
|
2761 |
|
2762 // fetch visual |
|
2763 CHuiLayout* layout = NULL; |
|
2764 CHuiVisual* viz = FindVisual(windowNodeId); |
|
2765 if (viz) |
|
2766 { |
|
2767 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2768 if ( viz->Tracking() ) |
|
2769 { |
|
2770 __ALFLOGSTRING("CAlfBridge::HandleReorderWindowL - Tracked visual"); |
|
2771 } |
|
2772 #endif |
|
2773 layout = viz->Layout(); |
|
2774 __ALFLOGSTRING3("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Id: %d, position %d, layout count %d", windowNodeId, windowAttributes->iOrdinalPosition, layout->Count() ); |
|
2775 TInt pos = windowAttributes->iOrdinalPosition; |
|
2776 TInt layoutCount = layout->Count(); |
|
2777 |
|
2778 if (windowAttributes->iOrdinalPosition > layoutCount - 1 ) |
|
2779 { |
|
2780 __ALFLOGSTRING("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Illegal visual index !"); |
|
2781 pos = layoutCount - 1; // FixMe !!! |
|
2782 } |
|
2783 |
|
2784 pos = layoutCount - pos - 1; |
|
2785 layout->Reorder(*viz, pos); |
|
2786 } |
|
2787 else |
|
2788 { |
|
2789 __ALFLOGSTRING2("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Visual not found! Screen: %d, Id: %d ", screenNumber, windowNodeId ); |
|
2790 } |
|
2791 break; |
|
2792 } |
|
2793 default: |
|
2794 { |
|
2795 __ALFLOGSTRING("CAlfBridge::HandleReorderWindowL: Unknown window node type received !"); |
|
2796 break; |
|
2797 } |
|
2798 } |
|
2799 |
|
2800 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed |
|
2801 } |
|
2802 |
|
2803 // --------------------------------------------------------------------------- |
|
2804 // HandlePostCanvasBufferL |
|
2805 // --------------------------------------------------------------------------- |
|
2806 // |
|
2807 void CAlfBridge::HandlePostCanvasBufferL( TAlfBridgerData& aData ) |
|
2808 { |
|
2809 TInt windowGroupNodeId = aData.iInt1; |
|
2810 TInt windowNodeId = aData.iInt2; |
|
2811 TAlfWindowCommandBufferAttributes* bufferAttributes = (TAlfWindowCommandBufferAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
2812 TInt screenNumber = bufferAttributes->iScreenNumber; |
|
2813 |
|
2814 CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId); |
|
2815 |
|
2816 // For now we omit drawing commands to ALF window group because in some configurations it causes issues |
|
2817 // TODO: Possible viz->Flags() & EHuiVisualFlagDrawAf.. is not needed anymore. To be checked. Currently this enables floating sprites on the "root visual" |
|
2818 if (viz && iAlfWindowGroupNodeId != windowGroupNodeId |
|
2819 || ( viz && viz->Flags() & EHuiVisualFlagDrawAfterOthers )/* THIS LINE IS HACK FOR DRAWING FLOATING SPRITES */ ) |
|
2820 { |
|
2821 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2822 TBool tracking( EFalse ); |
|
2823 CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber ); |
|
2824 CAlfScreen* screen = iAlfScreens[screenNumber]; |
|
2825 |
|
2826 //TInt clientWindowGroupId = FindClientWindowGroupId( screenNumber, *controlGroup ); |
|
2827 // NOTE, THE FOLLOWING WServClientFileName MAY CAUSE DEADLOCK. |
|
2828 // THIS DOES NOT HAPPEN IF HUI_DEBUG_TRACK_DRAWING IS NOT ENABLED (DEFAULT) |
|
2829 TFileName processName;/* = iCommandDebug->WServClientFileName( clientWindowGroupId, CHuiStatic::WsSession() ); |
|
2830 |
|
2831 if ( viz->Tracking() || |
|
2832 ( processName.Length() > 0 && iCommandDebug->TrackProcess( (HBufC16*)processName.Ptr() ) ) ) |
|
2833 { |
|
2834 tracking = ETrue; |
|
2835 }*/ |
|
2836 #endif |
|
2837 // Now when we receive actual drawing commands, we can set the window as opaque (unless the flags say it isn't opaque). |
|
2838 if (bufferAttributes->iWindowNodeFlags & EAlfWinNodeFlagOpaque) |
|
2839 { |
|
2840 viz->SetFlag(EHuiVisualFlagOpaqueHint); |
|
2841 } |
|
2842 |
|
2843 if (!viz->HasCommandBuffers(EFalse)) |
|
2844 { |
|
2845 // For performance resons, only set visual tree changed if this |
|
2846 // was the first buffer for the window. |
|
2847 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); |
|
2848 } |
|
2849 |
|
2850 TPtrC8 commands((TUint8*)bufferAttributes->iBuffer, bufferAttributes->iBufferLength); |
|
2851 if ( bufferAttributes->iEmptyThisBuffer ) |
|
2852 { |
|
2853 viz->ClearCommandSet(); |
|
2854 } |
|
2855 // If tracking has been enabled for this CHuiCanvasVisual object, the buffers will be marked for tracking aswell in CHuiCanvasVisual |
|
2856 switch( bufferAttributes->iPartStatus ) |
|
2857 { |
|
2858 case TAlfWindowCommandBufferAttributes::EPartComplete: |
|
2859 { |
|
2860 viz->AddCommandSetL( commands ); |
|
2861 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2862 viz->SetTrackCommandSet( processName, tracking ); |
|
2863 #endif |
|
2864 break; |
|
2865 } |
|
2866 case TAlfWindowCommandBufferAttributes::ENotComplete: // ENotComplete part should be eventually followed by ELastPart |
|
2867 { |
|
2868 viz->AddPartialCommandSetL( commands, EFalse ); |
|
2869 break; |
|
2870 } |
|
2871 case TAlfWindowCommandBufferAttributes::ELastPart: |
|
2872 { |
|
2873 viz->AddPartialCommandSetL( commands, ETrue ); |
|
2874 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2875 viz->SetTrackCommandSet( processName, tracking ); |
|
2876 #endif |
|
2877 break; |
|
2878 } |
|
2879 default: |
|
2880 __ALFLOGSTRING("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Unknown iPartStatus !!!!"); |
|
2881 USER_INVARIANT(); |
|
2882 break; |
|
2883 } |
|
2884 } |
|
2885 else |
|
2886 { |
|
2887 __ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId ); |
|
2888 } |
|
2889 } |
|
2890 |
|
2891 // --------------------------------------------------------------------------- |
|
2892 // SetWindowActiveL |
|
2893 // --------------------------------------------------------------------------- |
|
2894 // |
|
2895 void CAlfBridge::SetWindowActiveL(CHuiVisual* aVisual, TBool aActive) |
|
2896 { |
|
2897 if (!HasActiveEffect(aVisual)) |
|
2898 { |
|
2899 // Does not have effect |
|
2900 if (aActive) |
|
2901 { |
|
2902 aVisual->ClearFlags(EHuiVisualFlagShouldBeHidden | EHuiVisualFlagShouldBeShown); |
|
2903 aVisual->iOpacity.Set(KAlfVisualDefaultOpacity); |
|
2904 } |
|
2905 else |
|
2906 { |
|
2907 aVisual->ClearFlags(EHuiVisualFlagShouldBeShown | EHuiVisualFlagShouldBeHidden); |
|
2908 aVisual->iOpacity.Set(0.0f); |
|
2909 } |
|
2910 } |
|
2911 else |
|
2912 { |
|
2913 // Has effect |
|
2914 // these flags are put to action in RemoveTemporaryPresenterItem |
|
2915 if (aActive) |
|
2916 { |
|
2917 // this prevents windows appearing before their "effected" time |
|
2918 aVisual->SetFlag(EHuiVisualFlagShouldBeShown); |
|
2919 aVisual->ClearFlag(EHuiVisualFlagShouldBeHidden); |
|
2920 } |
|
2921 else |
|
2922 { |
|
2923 // this prevents windows disappearing before their effect has finished |
|
2924 aVisual->SetFlag(EHuiVisualFlagShouldBeHidden); |
|
2925 aVisual->ClearFlag(EHuiVisualFlagShouldBeShown); |
|
2926 } |
|
2927 } |
|
2928 } |
|
2929 |
|
2930 // --------------------------------------------------------------------------- |
|
2931 // HandleSetWindowActiveL |
|
2932 // --------------------------------------------------------------------------- |
|
2933 // |
|
2934 void CAlfBridge::HandleSetWindowActiveL( TAlfBridgerData& aData ) |
|
2935 { |
|
2936 TInt windowGroupNodeId = aData.iInt1; |
|
2937 TInt windowNodeId = aData.iInt2; |
|
2938 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
2939 TInt screenNumber = windowAttributes->iScreenNumber; |
|
2940 |
|
2941 if (windowAttributes->iWindowNodeType == EAlfWinTreeNodeTextCursor && iCursorTimer) |
|
2942 { |
|
2943 if (!windowAttributes->iActive) |
|
2944 { |
|
2945 iCursorTimer->Cancel(); |
|
2946 } |
|
2947 else |
|
2948 { |
|
2949 SetCursorTimerL(); // continue with set interwal |
|
2950 } |
|
2951 } |
|
2952 |
|
2953 |
|
2954 switch (windowAttributes->iWindowNodeType) |
|
2955 { |
|
2956 case EAlfWinTreeNodeGroup: |
|
2957 { |
|
2958 CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber); |
|
2959 if (controlGroup) |
|
2960 { |
|
2961 CHuiControl& control = controlGroup->Control(0); |
|
2962 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0); |
|
2963 // Uses opacity for now |
|
2964 SetWindowActiveL(layout, windowAttributes->iActive); |
|
2965 } |
|
2966 else |
|
2967 { |
|
2968 __ALFLOGSTRING("CAlfBridge::HandleSetWindowActiveL, EAlfDSSetWindowActive: EAlfWinTreeNodeGroup not found!"); |
|
2969 } |
|
2970 break; |
|
2971 } |
|
2972 case EAlfWinTreeNodeClient: |
|
2973 case EAlfWinTreeNodeRoot: |
|
2974 case EAlfWinTreeNodeAnim: |
|
2975 case EAlfWinTreeNodeSprite: |
|
2976 case EAlfWinTreeNodeFloatingSprite: |
|
2977 case EAlfWinTreeNodeTextCursor: |
|
2978 { |
|
2979 CHuiVisual* viz = FindVisual(windowNodeId); |
|
2980 if (viz) |
|
2981 { |
|
2982 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
2983 if ( viz->Tracking() ) |
|
2984 { |
|
2985 RDebug::Print(_L("CAlfBridge::HandleSetWindowActiveL - Tracked visual")); |
|
2986 } |
|
2987 #endif |
|
2988 // Uses opacity for now |
|
2989 SetWindowActiveL(viz, windowAttributes->iActive); |
|
2990 } |
|
2991 else |
|
2992 { |
|
2993 __ALFLOGSTRING("CAlfBridge::HandleSetWindowActiveL, EAlfDSSetWindowActive: Visual not found!"); |
|
2994 } |
|
2995 break; |
|
2996 } |
|
2997 default: |
|
2998 { |
|
2999 __ALFLOGSTRING("CAlfBridge::HandleSetWindowActiveL, EAlfDSSetWindowActive: Unknown iWindowNodeType!"); |
|
3000 USER_INVARIANT(); |
|
3001 break; |
|
3002 } |
|
3003 } |
|
3004 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed |
|
3005 } |
|
3006 |
|
3007 |
|
3008 // --------------------------------------------------------------------------- |
|
3009 // HandleSetWindowFlagL |
|
3010 // --------------------------------------------------------------------------- |
|
3011 // |
|
3012 void CAlfBridge::HandleSetWindowFlagL( TAlfBridgerData& aData, TInt aOp ) |
|
3013 { |
|
3014 TInt windowGroupNodeId = aData.iInt1; |
|
3015 TInt windowNodeId = aData.iInt2; |
|
3016 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
3017 TInt screenNumber = windowAttributes->iScreenNumber; |
|
3018 TInt windowFlag = windowAttributes->iActive; |
|
3019 THuiVisualFlags visualFlag = (THuiVisualFlags)0; |
|
3020 switch(windowFlag) |
|
3021 { |
|
3022 case TAlfWindowData::EShouldInactivate: |
|
3023 { |
|
3024 visualFlag = EHuiVisualFlagShouldBeHidden; |
|
3025 break; |
|
3026 } |
|
3027 case TAlfWindowData::EShouldDestroy: |
|
3028 { |
|
3029 visualFlag = EHuiVisualFlagShouldDestroy; |
|
3030 break; |
|
3031 } |
|
3032 default:; |
|
3033 } |
|
3034 |
|
3035 switch (windowAttributes->iWindowNodeType) |
|
3036 { |
|
3037 case EAlfWinTreeNodeGroup: |
|
3038 { |
|
3039 CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber); |
|
3040 if (controlGroup) |
|
3041 { |
|
3042 CHuiControl& control = controlGroup->Control(0); |
|
3043 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0); |
|
3044 // Uses opacity for now |
|
3045 if (aOp == EAlfDSSetWindowFlag) |
|
3046 { |
|
3047 layout->SetFlag(visualFlag); |
|
3048 } |
|
3049 else |
|
3050 { |
|
3051 layout->ClearFlag(visualFlag); |
|
3052 } |
|
3053 } |
|
3054 else |
|
3055 { |
|
3056 __ALFLOGSTRING("CAlfBridge::HandleSetWindowActiveL, EAlfDSSetWindowActive: EAlfWinTreeNodeGroup not found!"); |
|
3057 } |
|
3058 break; |
|
3059 } |
|
3060 case EAlfWinTreeNodeClient: |
|
3061 case EAlfWinTreeNodeRoot: |
|
3062 case EAlfWinTreeNodeAnim: |
|
3063 case EAlfWinTreeNodeSprite: |
|
3064 case EAlfWinTreeNodeFloatingSprite: |
|
3065 case EAlfWinTreeNodeTextCursor: |
|
3066 { |
|
3067 CHuiVisual* viz = FindVisual(windowNodeId); |
|
3068 if (viz) |
|
3069 { |
|
3070 if (aOp == EAlfDSSetWindowFlag) |
|
3071 { |
|
3072 viz->SetFlag(visualFlag); |
|
3073 if (visualFlag == EHuiVisualFlagShouldDestroy ) |
|
3074 { |
|
3075 if (windowAttributes->iWindowNodeType == EAlfWinTreeNodeTextCursor && iCursorTimer) |
|
3076 { |
|
3077 iCursorTimer->Cancel(); |
|
3078 } |
|
3079 RemoveVisual(windowNodeId); // Only the effect will have pointer to this visual from here on |
|
3080 } |
|
3081 } |
|
3082 else |
|
3083 { |
|
3084 viz->ClearFlag(visualFlag); |
|
3085 } |
|
3086 } |
|
3087 else |
|
3088 { |
|
3089 __ALFLOGSTRING("CAlfBridge::HandleSetWindowFlagL, HandleSetWindowFlagL: Visual not found!"); |
|
3090 } |
|
3091 break; |
|
3092 } |
|
3093 default: |
|
3094 { |
|
3095 __ALFLOGSTRING("CAlfBridge::HandleSetWindowFlagL, HandleSetWindowFlagL: Unknown iWindowNodeType!"); |
|
3096 USER_INVARIANT(); |
|
3097 break; |
|
3098 } |
|
3099 } |
|
3100 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed |
|
3101 } |
|
3102 |
|
3103 // --------------------------------------------------------------------------- |
|
3104 // InsertImageBrushL |
|
3105 // --------------------------------------------------------------------------- |
|
3106 // |
|
3107 void CAlfBridge::InsertImageBrushL(CHuiVisual& aVisual, TInt aBitmapHandle) |
|
3108 { |
|
3109 // NOTE: We wssume that image brush is always the only brush |
|
3110 CHuiTexture* texture = CHuiTexture::NewL(); |
|
3111 CleanupStack::PushL(texture); |
|
3112 THuiImage image(*texture); |
|
3113 CHuiImageBrush* imageBrush = CHuiImageBrush::NewL(image); |
|
3114 imageBrush->SetLayer(EHuiBrushLayerForeground); |
|
3115 CleanupStack::Pop(texture); |
|
3116 |
|
3117 aVisual.EnableBrushesL(ETrue); |
|
3118 aVisual.Brushes()->InsertL(0, imageBrush, EHuiHasOwnership); |
|
3119 |
|
3120 UpdateImageBrushL(aVisual, aBitmapHandle); |
|
3121 } |
|
3122 |
|
3123 // --------------------------------------------------------------------------- |
|
3124 // UpdateImageBrushL |
|
3125 // --------------------------------------------------------------------------- |
|
3126 // |
|
3127 void CAlfBridge::UpdateImageBrushL(CHuiVisual& aVisual, TInt aBitmapHandle) |
|
3128 { |
|
3129 // NOTE: We wssume that image brush is always the only brush with EImageBrush type |
|
3130 const TInt KAlfCanvasVisualImageBrushIndex = 0; |
|
3131 |
|
3132 if (aVisual.Brushes() && aVisual.Brushes()->BrushWithTypeCount(CHuiBrush::EImageBrush)) |
|
3133 { |
|
3134 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
3135 CleanupStack::PushL(bitmap); |
|
3136 bitmap->Duplicate(aBitmapHandle); |
|
3137 |
|
3138 CHuiImageBrush* imageBrush = (CHuiImageBrush*) aVisual.Brushes()->BrushWithTypeAt(CHuiBrush::EImageBrush, KAlfCanvasVisualImageBrushIndex); |
|
3139 CHuiTexture* texture = (CHuiTexture*) &imageBrush->Image().Texture(); |
|
3140 |
|
3141 // Use of direct upload here would give much better performance, but is |
|
3142 // it too risky ? |
|
3143 texture->UploadL(*bitmap, NULL); |
|
3144 imageBrush->SetChanged(); |
|
3145 |
|
3146 CleanupStack::PopAndDestroy(bitmap); |
|
3147 } |
|
3148 } |
|
3149 |
|
3150 // --------------------------------------------------------------------------- |
|
3151 // RemoveImageBrushL |
|
3152 // --------------------------------------------------------------------------- |
|
3153 // |
|
3154 void CAlfBridge::RemoveImageBrushL(CHuiVisual& aVisual) |
|
3155 { |
|
3156 // NOTE: We wssume that image brush is always the only brush with EImageBrush type |
|
3157 const TInt KAlfCanvasVisualImageBrushIndex = 0; |
|
3158 |
|
3159 if (aVisual.Brushes() && aVisual.Brushes()->BrushWithTypeCount(CHuiBrush::EImageBrush)) |
|
3160 { |
|
3161 CHuiImageBrush* imageBrush = (CHuiImageBrush*) aVisual.Brushes()->BrushWithTypeAt(CHuiBrush::EImageBrush, KAlfCanvasVisualImageBrushIndex); |
|
3162 CHuiTexture* texture = (CHuiTexture*) &imageBrush->Image().Texture(); |
|
3163 THuiImage image; |
|
3164 imageBrush->SetImage(image); |
|
3165 delete texture; |
|
3166 } |
|
3167 |
|
3168 if (aVisual.Brushes()) |
|
3169 { |
|
3170 aVisual.EnableBrushesL(EFalse); |
|
3171 } |
|
3172 } |
|
3173 |
|
3174 |
|
3175 // --------------------------------------------------------------------------- |
|
3176 // HandleSetSurfaceExtentL |
|
3177 // --------------------------------------------------------------------------- |
|
3178 // |
|
3179 void CAlfBridge::HandleSetSurfaceExtentL( TAlfBridgerData& aData ) |
|
3180 { |
|
3181 TInt windowGroupNodeId = aData.iInt1; |
|
3182 TInt windowNodeId = aData.iInt2; |
|
3183 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
3184 TInt screenNumber = windowAttributes->iScreenNumber; |
|
3185 // fetch visual |
|
3186 CHuiCanvasVisual* viz = FindVisual(windowNodeId); |
|
3187 |
|
3188 // We should not do this for alf window, but renderstage does not know if it is |
|
3189 // handling alf window or other window, so we ignore the request here if needed. |
|
3190 // TODO: When alf apps work in multiple display, check here for every displays alf groups... |
|
3191 if (viz && iAlfWindowGroupNodeId != windowGroupNodeId) |
|
3192 { |
|
3193 viz->SetLayerExtent(windowAttributes->iSurfaceExtent); |
|
3194 // Set surface extend area to be cleared with fully transparent color |
|
3195 // Note: does not support extend that is bigger that the visual |
|
3196 // if surface extent is (0,0,0,0) then the background item array is reseted |
|
3197 // and surface extent will not be cleared. |
|
3198 if (windowAttributes->iSurfaceExtent != TRect()) |
|
3199 { |
|
3200 // Set surface extend area to be cleared with fully transparent color |
|
3201 // Note: does not support extend that is bigger that the visual |
|
3202 TRgb fullyTransparentColor(255,0,0,0); // Red but fully transparent. Red color component has been set only for debug purposes, it is not visible. |
|
3203 viz->SetClearBackground(CHuiDisplay::EClearWithColor); |
|
3204 viz->SetBackgroundColor(fullyTransparentColor); |
|
3205 } |
|
3206 else |
|
3207 { |
|
3208 viz->SetClearBackground(CHuiDisplay::EClearNone); |
|
3209 } |
|
3210 } |
|
3211 else |
|
3212 { |
|
3213 if (iAlfWindowGroupNodeId != windowGroupNodeId) |
|
3214 __ALFLOGSTRING("CAlfBridge::HandleSetSurfaceExtentL, EAlfDSSetSurfaceExtent: Visual not found!"); |
|
3215 } |
|
3216 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed |
|
3217 } |
|
3218 |
|
3219 // --------------------------------------------------------------------------- |
|
3220 // HandleLayerUsesAlphaFlagChanged |
|
3221 // --------------------------------------------------------------------------- |
|
3222 // |
|
3223 void CAlfBridge::HandleLayerUsesAlphaFlagChanged( TAlfBridgerData& aData ) |
|
3224 { |
|
3225 TInt windowGroupNodeId = aData.iInt1; |
|
3226 TInt windowNodeId = aData.iInt2; |
|
3227 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
3228 TInt screenNumber = windowAttributes->iScreenNumber; |
|
3229 |
|
3230 // fetch visual |
|
3231 CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId); |
|
3232 |
|
3233 // We should not do this for alf window, but renderstage does not know if it is |
|
3234 // handling alf window or other window, so we ignore the request here if needed. |
|
3235 // TODO: When alf apps work in multiple display, check here for every displays alf groups... |
|
3236 if (viz && iAlfWindowGroupNodeId != windowGroupNodeId) |
|
3237 { |
|
3238 viz->SetLayerUsesAlphaFlag(windowAttributes->iLayerUsesAlphaFlagEnabled); |
|
3239 } |
|
3240 else |
|
3241 { |
|
3242 if (iAlfWindowGroupNodeId != windowGroupNodeId) |
|
3243 __ALFLOGSTRING("CAlfBridge::HandleLayerUsesAlphaFlagChanged: Visual not found!"); |
|
3244 } |
|
3245 iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed |
|
3246 } |
|
3247 |
|
3248 |
|
3249 // --------------------------------------------------------------------------- |
|
3250 // HandleGetNativeWindowDataL |
|
3251 // --------------------------------------------------------------------------- |
|
3252 // |
|
3253 void CAlfBridge::HandleGetNativeWindowDataL( TAlfBridgerData& aData ) |
|
3254 { |
|
3255 // Get the data from original Render Stage message |
|
3256 RMessage2* rsMessage = (RMessage2*)aData.iInt1; |
|
3257 TAlfNativeWindowData winData; |
|
3258 TPckg<TAlfNativeWindowData> winDataPckg(winData); |
|
3259 rsMessage->Read(0, winDataPckg); |
|
3260 |
|
3261 if(winData.iScreenNumber == 0) |
|
3262 { |
|
3263 // primary screen |
|
3264 CHuiDisplay& disp = iHuiEnv->PrimaryDisplay(); |
|
3265 if (disp.NativeWindow()) |
|
3266 { |
|
3267 winData.iAlfWindowHandle = disp.NativeWindow()->ClientHandle(); |
|
3268 winData.iAlfWindowGrpId = disp.NativeWindow()->WindowGroupId(); |
|
3269 } |
|
3270 } |
|
3271 else |
|
3272 { |
|
3273 // other than primary screen |
|
3274 for (TInt i = 1; i < iAlfScreens.Count(); i++) |
|
3275 { |
|
3276 if (iAlfScreens[i]->iScreenNum == winData.iScreenNumber) |
|
3277 { |
|
3278 RDrawableWindow* win = iAlfScreens[i]->iCoeControl->DrawableWindow(); |
|
3279 winData.iAlfWindowHandle = win->ClientHandle(); |
|
3280 winData.iAlfWindowGrpId = win->WindowGroupId(); |
|
3281 } |
|
3282 } |
|
3283 } |
|
3284 |
|
3285 // write result |
|
3286 rsMessage->Write(0, winDataPckg); |
|
3287 |
|
3288 if (winData.iAlfWindowHandle == 0) |
|
3289 { |
|
3290 __ALFLOGSTRING("CAlfBridge::HandleGetNativeWindowDataL, EAlfDSGetAlfNativeWindowData. Error: window data not found!"); |
|
3291 } |
|
3292 } |
|
3293 |
|
3294 |
|
3295 void CAlfBridge::PrepareFadeEffects( CHuiCanvasVisual& aVisual ) |
|
3296 { |
|
3297 TBool faded = aVisual.CanvasFlags() & EHuiCanvasFlagExternalFade; |
|
3298 if (faded) |
|
3299 { |
|
3300 if (IsFadedByParent( aVisual )) |
|
3301 { |
|
3302 // Faded by parent |
|
3303 aVisual.SetCanvasFlags(EHuiCanvasFlagExternalFadeByParent); |
|
3304 |
|
3305 // Faded by parent, include to parent effect |
|
3306 aVisual.ClearCanvasFlags(EHuiCanvasFlagExcludeFromParentEffect); |
|
3307 |
|
3308 // Does not fade own children because parent already does that. |
|
3309 aVisual.ClearCanvasFlags(EHuiCanvasFlagExternalFadeToChildren); |
|
3310 } |
|
3311 else |
|
3312 { |
|
3313 // Not faded by parent |
|
3314 aVisual.ClearCanvasFlags(EHuiCanvasFlagExternalFadeByParent); |
|
3315 |
|
3316 // Not faded by parent, exclude from parent effect |
|
3317 aVisual.SetCanvasFlags(EHuiCanvasFlagExcludeFromParentEffect); |
|
3318 |
|
3319 // Does (or does not) fade own children if it can. |
|
3320 if (CanFadeChildren(aVisual)) |
|
3321 { |
|
3322 aVisual.SetCanvasFlags(EHuiCanvasFlagExternalFadeToChildren); |
|
3323 } |
|
3324 else |
|
3325 { |
|
3326 aVisual.ClearCanvasFlags(EHuiCanvasFlagExternalFadeToChildren); |
|
3327 } |
|
3328 } |
|
3329 } |
|
3330 else |
|
3331 { |
|
3332 // Not faded |
|
3333 aVisual.ClearCanvasFlags(EHuiCanvasFlagExternalFadeByParent); |
|
3334 |
|
3335 if (IsNearestParentEffectFade( aVisual )) |
|
3336 { |
|
3337 // Exclude from parent effect to avoid getting faded by parent. |
|
3338 aVisual.SetCanvasFlags(EHuiCanvasFlagExcludeFromParentEffect); |
|
3339 } |
|
3340 else |
|
3341 { |
|
3342 // By default included into parent effects. |
|
3343 aVisual.ClearCanvasFlags(EHuiCanvasFlagExcludeFromParentEffect); |
|
3344 } |
|
3345 |
|
3346 // Does not fade own children because it is not faded itself. |
|
3347 aVisual.ClearCanvasFlags(EHuiCanvasFlagExternalFadeToChildren); |
|
3348 } |
|
3349 |
|
3350 // Handle children |
|
3351 TInt count = aVisual.Count(); |
|
3352 for (TInt i=0; i<count; i++) |
|
3353 { |
|
3354 CHuiCanvasVisual* child = (CHuiCanvasVisual*) (&aVisual.Visual(i)); |
|
3355 PrepareFadeEffects(*child); |
|
3356 } |
|
3357 } |
|
3358 |
|
3359 TBool CAlfBridge::LoadFadeEffectsL( CHuiCanvasVisual& aVisual ) |
|
3360 { |
|
3361 TBool fadeEffectLoadedInsideTree = EFalse; |
|
3362 |
|
3363 // Load fade effect (or remove existing) |
|
3364 fadeEffectLoadedInsideTree |= SetupFadeEffectL(aVisual); |
|
3365 |
|
3366 // Handle children |
|
3367 TInt count = aVisual.Count(); |
|
3368 for (TInt i=0; i<count; i++) |
|
3369 { |
|
3370 CHuiCanvasVisual* child = (CHuiCanvasVisual*) (&aVisual.Visual(i)); |
|
3371 fadeEffectLoadedInsideTree |= LoadFadeEffectsL(*child); |
|
3372 } |
|
3373 |
|
3374 return fadeEffectLoadedInsideTree; |
|
3375 } |
|
3376 |
|
3377 |
|
3378 TBool CAlfBridge::CanFadeChildren( CHuiCanvasVisual& aParent ) |
|
3379 { |
|
3380 // NOTE! This function is not yet implemented optimally !!!! |
|
3381 // Below is some initial description how it could behave, but even that has some downsides. |
|
3382 // Ultimate solution which would implement legacy symbian fading functionality and |
|
3383 // on the other hand fully effectable solution needs to be developed at some point. |
|
3384 // |
|
3385 // |
|
3386 // This function shold determine wheter we can fade whole visual tree starting from aParent with just |
|
3387 // one fade effect. Even if visual tree has non-fading windows, it is possible to use tree fading |
|
3388 // in some cases where children can be excluded from parent visual effects using EHuiCanvasFlagExcludeFromParentEffect |
|
3389 // flag. However it changes drawing order of the childern (visuals with EHuiCanvasFlagExcludeFromParentEffect |
|
3390 // are drawn after other children) so it cannot be used in those cases without side-effect. |
|
3391 // |
|
3392 // |
|
3393 // V1 = Visual 1, parent of Visual 2 etc. Index number refers to order how visuals are drawn. |
|
3394 // (f) = Visal is faded |
|
3395 // |
|
3396 // Example scenario 1) CanFadeChildren(V1) (YES) |
|
3397 // CanFadeChildren(V2) (YES) (Can fade because faded child is drawn first, but no need because parent can fade as well) |
|
3398 // |
|
3399 // V4 V3(f) |
|
3400 // \ / |
|
3401 // \ / |
|
3402 // V5(f) V2(f) |
|
3403 // \ / |
|
3404 // \ / |
|
3405 // V1(f) |
|
3406 // |
|
3407 // Example Scenario 2) CanFadeChildren(V1) (NO) (Cant fade because nonfading grandchild draw before faded) |
|
3408 // CanFadeChildren(V2) (NO) (Can't fade children because non-faded child is drawn first) |
|
3409 // |
|
3410 // V4(f) V3 |
|
3411 // \ / |
|
3412 // \ / |
|
3413 // V5(f) V2(f) |
|
3414 // \ / |
|
3415 // \ / |
|
3416 // V1(f) |
|
3417 // |
|
3418 // Example scenario 3) CanFadeChildren(V1) (YES) (Can fade because faded child (V2) is drawn first) |
|
3419 // CanFadeChildren(V2) (YES) (Can fade because all children are faded, but no need because parent can fade as well) |
|
3420 // |
|
3421 // V4(f) V3(f) |
|
3422 // \ / |
|
3423 // \ / |
|
3424 // V5 V2(f) |
|
3425 // \ / |
|
3426 // \ / |
|
3427 // V1(f) |
|
3428 // |
|
3429 // Scenario 4) CanFadeChildren(V1) (NO) (Can't fade because non-faded child is drawn first) |
|
3430 // CanFadeChildren(V2) (NO) (It would be YES, but V2 it self is not faded -> NO) |
|
3431 // |
|
3432 // V4(f) V3(f) |
|
3433 // \ / |
|
3434 // \ / |
|
3435 // V5(f) V2 |
|
3436 // \ / |
|
3437 // \ / |
|
3438 // V1(f) |
|
3439 // |
|
3440 // Scenario 5) CanFadeChildren(V1) (NO) (Can't fade because non-faded child is drawn first) |
|
3441 // CanFadeChildren(V2) (NO) (Can't fade children because it does not have children) |
|
3442 // CanFadeChildren(V3) (YES) (All children are faded) |
|
3443 // |
|
3444 // V4(f) V4(f) |
|
3445 // \ / |
|
3446 // \ / |
|
3447 // V3(f) V2 |
|
3448 // \ / |
|
3449 // \ / |
|
3450 // V1(f) |
|
3451 // |
|
3452 // |
|
3453 // TODO: Real implementation for algorithm which takes into account the order of non-fading and |
|
3454 // fading children. Current implentation has side-effect where drawing order of non-fading |
|
3455 // children may get altered. But on the other hand without visual treefader (i.e each visual |
|
3456 // faded with separate effects) there still exists a potential problem with faded transparent |
|
3457 // windows above faded windows (double fade)! |
|
3458 // |
|
3459 |
|
3460 // For now this function just checks if there are children to be faded... |
|
3461 return HasActiveFadedChildren( aParent ); |
|
3462 } |
|
3463 |
|
3464 |
|
3465 TInt CAlfBridge::RecursiveChildCount( CHuiCanvasVisual& aParent, TInt aCanvasFlags ) |
|
3466 { |
|
3467 TInt childCount = 0; |
|
3468 TInt count = aParent.Count(); |
|
3469 for (TInt i=0; i<count; i++) |
|
3470 { |
|
3471 CHuiCanvasVisual* child = (CHuiCanvasVisual*) (&aParent.Visual(i)); |
|
3472 if (aCanvasFlags) |
|
3473 { |
|
3474 if (child->CanvasFlags() & aCanvasFlags) |
|
3475 { |
|
3476 childCount++; |
|
3477 } |
|
3478 } |
|
3479 else |
|
3480 { |
|
3481 childCount++; |
|
3482 } |
|
3483 childCount += RecursiveChildCount( *child, aCanvasFlags ); |
|
3484 } |
|
3485 return childCount; |
|
3486 } |
|
3487 |
|
3488 TBool CAlfBridge::IsNearestParentEffectFade( CHuiCanvasVisual& aVisual ) |
|
3489 { |
|
3490 TBool nearestParentEffectFade = EFalse; |
|
3491 CHuiCanvasVisual* parent = (CHuiCanvasVisual*) (aVisual.Layout()); |
|
3492 while (parent) |
|
3493 { |
|
3494 if (parent->Effect()) |
|
3495 { |
|
3496 nearestParentEffectFade |= (parent->Effect() && (parent->Effect()->EffectFlags() & KHuiFadeEffectFlag)); |
|
3497 return nearestParentEffectFade; |
|
3498 } |
|
3499 parent = (CHuiCanvasVisual*) (parent->Layout()); |
|
3500 } |
|
3501 return EFalse; |
|
3502 } |
|
3503 |
|
3504 |
|
3505 TBool CAlfBridge::IsFadedByParent( CHuiCanvasVisual& aVisual ) |
|
3506 { |
|
3507 CHuiCanvasVisual* parent = (CHuiCanvasVisual*) (aVisual.Layout()); |
|
3508 while (parent) |
|
3509 { |
|
3510 TInt flags = parent->CanvasFlags(); |
|
3511 if ((flags & EHuiCanvasFlagExternalFade) && (flags & EHuiCanvasFlagExternalFadeToChildren)) |
|
3512 { |
|
3513 return ETrue; |
|
3514 } |
|
3515 parent = (CHuiCanvasVisual*) (parent->Layout()); |
|
3516 } |
|
3517 return EFalse; |
|
3518 } |
|
3519 |
|
3520 TBool CAlfBridge::HasActivePaintedAreas( CHuiCanvasVisual& aVisual, TBool aIncludeChildren ) |
|
3521 { |
|
3522 TBool visualHasPaintedAreas = aVisual.PaintedAreaCount() > 0; |
|
3523 if (!visualHasPaintedAreas && aIncludeChildren) |
|
3524 { |
|
3525 TInt count = aVisual.Count(); |
|
3526 for (TInt i=0; i<count; i++) |
|
3527 { |
|
3528 CHuiCanvasVisual* child = (CHuiCanvasVisual*) (&aVisual.Visual(i)); |
|
3529 TBool childIsActive = !(child->Flags() & EHuiVisualFlagInactive); |
|
3530 if (childIsActive && child->PaintedAreaCount()) |
|
3531 { |
|
3532 visualHasPaintedAreas = ETrue; |
|
3533 break; |
|
3534 } |
|
3535 } |
|
3536 } |
|
3537 return visualHasPaintedAreas; |
|
3538 } |
|
3539 |
|
3540 TBool CAlfBridge::HasActiveFadedChildren( CHuiCanvasVisual& aVisual ) |
|
3541 { |
|
3542 TBool has = EFalse; |
|
3543 TInt count = aVisual.Count(); |
|
3544 for (TInt i=0; i<count; i++) |
|
3545 { |
|
3546 CHuiCanvasVisual* child = (CHuiCanvasVisual*) (&aVisual.Visual(i)); |
|
3547 TBool active = !(child->Flags() & EHuiVisualFlagInactive); |
|
3548 TBool faded = child->CanvasFlags() & EHuiCanvasFlagExternalFade; |
|
3549 |
|
3550 if (active && faded && child->PaintedAreaCount()) |
|
3551 { |
|
3552 has = ETrue; |
|
3553 break; |
|
3554 } |
|
3555 } |
|
3556 return has; |
|
3557 } |
|
3558 |
|
3559 |
|
3560 // --------------------------------------------------------------------------- |
|
3561 // SetupFadeEffectL |
|
3562 // |
|
3563 // NOTE: This method gets called very often, so we should not do anything time |
|
3564 // consuming here (unless we really need to). |
|
3565 // |
|
3566 // --------------------------------------------------------------------------- |
|
3567 // |
|
3568 TBool CAlfBridge::SetupFadeEffectL( CHuiCanvasVisual& aVisual ) |
|
3569 { |
|
3570 TBool didFadeEffectLoad = EFalse; |
|
3571 |
|
3572 TBool faded = (aVisual.CanvasFlags() & EHuiCanvasFlagExternalFade); |
|
3573 |
|
3574 // Just in case, check if we are alrady faded to avoid unnecassary effect loadings. |
|
3575 TBool alreadyFaded = aVisual.Effect() && (aVisual.Effect()->EffectFlags() & KHuiFadeEffectFlag); |
|
3576 |
|
3577 TBool fadesChildren = EFalse; |
|
3578 |
|
3579 if (faded) |
|
3580 { |
|
3581 fadesChildren = (aVisual.CanvasFlags() & EHuiCanvasFlagExternalFadeToChildren); |
|
3582 |
|
3583 // Inactive visuals are not faded. |
|
3584 TBool visualIsActive = !(aVisual.Flags() & EHuiVisualFlagInactive); |
|
3585 |
|
3586 // Avoid interrupting other effects. |
|
3587 TBool otherEffectActive = aVisual.Effect() && !(aVisual.Effect()->EffectFlags() & KHuiFadeEffectFlag); |
|
3588 |
|
3589 // Check if we really need to fade. Note the order of if-conditions, fastest checks first to optimize performance. |
|
3590 if (visualIsActive && !alreadyFaded && !otherEffectActive && !IsFadedByParent(aVisual) && HasActivePaintedAreas(aVisual, fadesChildren)) |
|
3591 { |
|
3592 CHuiFxEffect* effect = NULL; |
|
3593 CHuiFxEngine* engine = iHuiEnv->EffectsEngine(); |
|
3594 |
|
3595 if (engine && iFadeEffectFile ) |
|
3596 { |
|
3597 __ALFLOGSTRING1( ">> Using cached fade effect file name: %S", iFadeEffectFile ); |
|
3598 TInt err = 0; |
|
3599 // CHuiFxParser sets the effect to visual if loading succeeds. |
|
3600 TInt effectFlags = 0; |
|
3601 effectFlags |= KHuiFadeEffectFlag; |
|
3602 effectFlags |= KHuiFxEffectDisableMarginsFlag; // Margins cannot safely be used in fade usecase, artefacts may appear depending on window location in window tree |
|
3603 |
|
3604 // For top level canvas visuals (window group visuals) disable background for |
|
3605 // performance reasons (in case canvas visual is not opaque). |
|
3606 if (!aVisual.Layout()) |
|
3607 { |
|
3608 effectFlags |= KHuiFxDisableBackground; |
|
3609 } |
|
3610 |
|
3611 if (fadesChildren) |
|
3612 { |
|
3613 /* |
|
3614 TInt children = RecursiveChildCount( aVisual, 0 ); |
|
3615 TInt faded = RecursiveChildCount( aVisual, EHuiCanvasFlagExternalFade ); |
|
3616 TInt fadedbyparent = RecursiveChildCount( aVisual, EHuiCanvasFlagExternalFadeByParent ); |
|
3617 TInt excludedfromparenteffect = RecursiveChildCount( aVisual, EHuiCanvasFlagExcludeFromParentEffect ); |
|
3618 RDebug::Print(_L("CAlfBridge::SetupFadeEffectL - faded parent has %i children"), children); |
|
3619 RDebug::Print(_L("CAlfBridge::SetupFadeEffectL - faded parent has %i faded children"), faded); |
|
3620 RDebug::Print(_L("CAlfBridge::SetupFadeEffectL - faded parent fades %i children"), fadedbyparent); |
|
3621 RDebug::Print(_L("CAlfBridge::SetupFadeEffectL - faded parent has %i children which are excluded from parent fx"), excludedfromparenteffect); |
|
3622 */ |
|
3623 } |
|
3624 else |
|
3625 { |
|
3626 // All children in the tree are not faded, do not apply effect on children. |
|
3627 effectFlags |= KHuiFxEffectExcludeChildrenFlag; |
|
3628 //RDebug::Print(_L("CAlfBridge::SetupFadeEffectL - no children faded by parent")); |
|
3629 } |
|
3630 TRAP( err, engine->LoadEffectL(*iFadeEffectFile, effect, aVisual.Effectable(), NULL, NULL, 0, effectFlags ) ); |
|
3631 didFadeEffectLoad = ETrue; |
|
3632 } |
|
3633 } |
|
3634 } |
|
3635 else |
|
3636 { |
|
3637 // remove only an old fade effect, leave any others intact |
|
3638 if (alreadyFaded) |
|
3639 { |
|
3640 aVisual.SetEffect( NULL ); |
|
3641 alreadyFaded = EFalse; |
|
3642 } |
|
3643 } |
|
3644 |
|
3645 // If we did load and fade children we must re-prepare the flags again |
|
3646 // Maybe there is more elegant way to avoid this. |
|
3647 if (didFadeEffectLoad && fadesChildren) |
|
3648 { |
|
3649 PrepareFadeEffects( aVisual ); |
|
3650 } |
|
3651 |
|
3652 return (didFadeEffectLoad || alreadyFaded); |
|
3653 } |
|
3654 |
|
3655 |
|
3656 // --------------------------------------------------------------------------- |
|
3657 // HandleSetFadeEffect |
|
3658 // --------------------------------------------------------------------------- |
|
3659 // |
|
3660 void CAlfBridge::HandleSetFadeEffectL( TAlfBridgerData& aData ) |
|
3661 { |
|
3662 TInt windowNodeId = aData.iInt1; |
|
3663 TBool faded = aData.iInt2; |
|
3664 |
|
3665 CHuiVisual* viz = (CHuiVisual*)FindVisual(windowNodeId); |
|
3666 if (!viz) |
|
3667 { |
|
3668 // Visual not found, it could be window group. It must be searched with other method. |
|
3669 CHuiControlGroup* cg = FindControlGroup(windowNodeId, 0); // TODO: Screen |
|
3670 if (cg) |
|
3671 { |
|
3672 CHuiControl& control = cg->Control(0); |
|
3673 viz = &control.Visual(0); |
|
3674 } |
|
3675 } |
|
3676 |
|
3677 if ( viz ) |
|
3678 { |
|
3679 CHuiCanvasVisual* canvasviz = (CHuiCanvasVisual*)viz; |
|
3680 if (faded) |
|
3681 { |
|
3682 canvasviz->SetCanvasFlags(EHuiCanvasFlagExternalFade); |
|
3683 } |
|
3684 else |
|
3685 { |
|
3686 canvasviz->ClearCanvasFlags(EHuiCanvasFlagExternalFade); |
|
3687 } |
|
3688 iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Screen |
|
3689 } |
|
3690 } |
|
3691 |
|
3692 void CAlfBridge::HandleSetLayoutSwitchEffectL() |
|
3693 { |
|
3694 ClearCanvasVisualCommandSets(EFalse); |
|
3695 iLayoutSwitchEffectCoordinator->BeginLayoutSwitch(); |
|
3696 } |
|
3697 |
|
3698 TInt Blink(TAny* aVisual) |
|
3699 { |
|
3700 CHuiVisual* visual = (CHuiVisual*)aVisual; |
|
3701 if (visual->iOpacity.Now() > 0.01 ) // kind of an epsilon |
|
3702 { |
|
3703 visual->iOpacity.Set(0); |
|
3704 } |
|
3705 else |
|
3706 { |
|
3707 visual->iOpacity.Set(1); |
|
3708 } |
|
3709 |
|
3710 return ETrue; // call me again |
|
3711 } |
|
3712 |
|
3713 void CAlfBridge::SetCursorTimerL(TUint aTime, CHuiVisual* aCursor) |
|
3714 { |
|
3715 if (aTime) |
|
3716 { |
|
3717 iCursorInterval = aTime; |
|
3718 } |
|
3719 |
|
3720 if (aCursor) |
|
3721 { |
|
3722 iCursorVisual = aCursor; |
|
3723 } |
|
3724 |
|
3725 if (iCursorInterval && iCursorVisual) |
|
3726 { |
|
3727 if (iCursorTimer) |
|
3728 { |
|
3729 iCursorTimer->Cancel(); |
|
3730 } |
|
3731 |
|
3732 if (!iCursorTimer) |
|
3733 { |
|
3734 iCursorTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
3735 } |
|
3736 |
|
3737 iCursorTimer->Start(iCursorInterval, iCursorInterval, TCallBack(Blink, aCursor)); |
|
3738 } |
|
3739 } |
|
3740 |
|
3741 // --------------------------------------------------------------------------- |
|
3742 // HandleSetCursorDataL |
|
3743 // --------------------------------------------------------------------------- |
|
3744 // |
|
3745 void CAlfBridge::HandleSetCursorDataL( TAlfBridgerData& aData ) |
|
3746 { |
|
3747 TInt windowNodeId = aData.iInt2; |
|
3748 |
|
3749 TAlfCursorDataBufferAttributes* windowAttributes = (TAlfCursorDataBufferAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr ); |
|
3750 CHuiVisual* viz = (CHuiVisual*)FindVisual(windowNodeId); |
|
3751 if (viz) |
|
3752 { |
|
3753 viz->SetFlags(windowAttributes->iFlags); |
|
3754 SetCursorTimerL(windowAttributes->iFlashInterval, viz); |
|
3755 } |
|
3756 else |
|
3757 { |
|
3758 __ALFLOGSTRING1("CAlfBridge::HandleSetCursorDataL - WARNING! Cursor node 0x%x not found!", windowNodeId); |
|
3759 } |
|
3760 } |
|
3761 |
|
3762 // --------------------------------------------------------------------------- |
|
3763 // HandleSetNodeTracking |
|
3764 // --------------------------------------------------------------------------- |
|
3765 // |
|
3766 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
3767 void CAlfBridge::HandleSetNodeTracking( TAlfBridgerData& aData ) |
|
3768 { |
|
3769 TInt windowNodeId = aData.iInt1; |
|
3770 CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId); |
|
3771 if ( aData.iInt2 ) |
|
3772 { |
|
3773 viz->SetTracking( aData.iInt2 ); |
|
3774 } |
|
3775 #else |
|
3776 void CAlfBridge::HandleSetNodeTracking( TAlfBridgerData& ) |
|
3777 { |
|
3778 #endif |
|
3779 } |
|
3780 |
|
3781 void RecursiveStoreRenderBufferL(CHuiVisual *aVisual) |
|
3782 { |
|
3783 CHuiCanvasVisual *canvasvisual = dynamic_cast<CHuiCanvasVisual*>(aVisual); |
|
3784 if (canvasvisual && canvasvisual->Layout()) |
|
3785 { |
|
3786 canvasvisual->StoreRenderBufferL(); |
|
3787 } |
|
3788 |
|
3789 TInt c = aVisual->Count(); |
|
3790 for(int i=0;i<c;i++) |
|
3791 { |
|
3792 CHuiVisual &vis = aVisual->Visual(i); |
|
3793 RecursiveStoreRenderBufferL(&vis); |
|
3794 } |
|
3795 } |
|
3796 |
|
3797 void StoreRenderBufferStartL(CHuiLayout *aLayout) |
|
3798 { |
|
3799 // assumes that the layout takes full screen area. |
|
3800 CHuiRenderPlugin& renderplugin = CHuiStatic::Renderer(); |
|
3801 CHuiCanvasGc *canvasGc = renderplugin.CreateCanvasGcL(); |
|
3802 CleanupStack::PushL(canvasGc); |
|
3803 |
|
3804 CHuiCanvasRenderBuffer *renderBuffer; |
|
3805 renderBuffer = canvasGc->CreateRenderBufferL(TSize(0,0)); |
|
3806 CleanupStack::PushL(renderBuffer); |
|
3807 renderBuffer->InitializeL(CHuiStatic::Env().Display(0).VisibleArea().Size()); |
|
3808 renderBuffer->Copy(TPoint(0,0)); |
|
3809 CleanupStack::Pop(renderBuffer); |
|
3810 aLayout->SetStoredRenderBuffer(renderBuffer); // moves ownership |
|
3811 |
|
3812 CleanupStack::PopAndDestroy(); |
|
3813 } |
|
3814 TBool NeedsStoredBuffers(CHuiFxEngine *aEngine, const TDesC &aFileName) |
|
3815 { |
|
3816 return aEngine->FxmlUsesInput1(aFileName); |
|
3817 } |
|
3818 |
|
3819 TBool CAlfBridge::HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout *aFromLayout) |
|
3820 { |
|
3821 TInt err = KErrNone; |
|
3822 TBool failed = EFalse; |
|
3823 |
|
3824 // Check if there is an effects engine in HuiEnv |
|
3825 CHuiFxEffect* effect = NULL; |
|
3826 // We need to pass the filenamerta from the transeffect plugin that handles the controls |
|
3827 // that define which effect is used for the selected skin or the selected application |
|
3828 // For full screen effects the skin should determine the effect, or there should be |
|
3829 // some default effects. |
|
3830 |
|
3831 CHuiFxEngine* engine = NULL; |
|
3832 // engine is not owned by us, it is a member of HuiEnv |
|
3833 engine = iHuiEnv->EffectsEngine(); |
|
3834 |
|
3835 if ( engine ) |
|
3836 { |
|
3837 switch(aEvent.iOperation) |
|
3838 { |
|
3839 case MAlfGfxEffectPlugin::EBeginFullscreen: |
|
3840 { |
|
3841 aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue); |
|
3842 TBool needStoredBuffers = NeedsStoredBuffers(engine, *aEvent.iEffectName); |
|
3843 if (needStoredBuffers) |
|
3844 { |
|
3845 TRAP(err,StoreRenderBufferStartL(aToLayout)); |
|
3846 if (err == KErrNone) |
|
3847 { |
|
3848 aToLayout->SetFreezeState(ETrue); |
|
3849 } |
|
3850 else |
|
3851 { |
|
3852 return ETrue; // failed, effect will be canceled |
|
3853 } |
|
3854 } |
|
3855 |
|
3856 switch(aEvent.iAction) |
|
3857 { |
|
3858 case AknTransEffect::EApplicationStart: |
|
3859 case AknTransEffect::EApplicationStartRect: |
|
3860 { |
|
3861 aToLayout->iOpacity.Set(0.0f); // these are meant for applications that yet dont have anything to show |
|
3862 FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle); |
|
3863 break; |
|
3864 } |
|
3865 case AknTransEffect::EApplicationStartSwitch: |
|
3866 case AknTransEffect::EApplicationStartSwitchRect: |
|
3867 { |
|
3868 aToLayout->iOpacity.Set(0.0f); // this is meant for applications that are in the background. |
|
3869 FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle); |
|
3870 break; |
|
3871 } |
|
3872 |
|
3873 case AknTransEffect::EApplicationExit: |
|
3874 { |
|
3875 // The effect should start when the new view is ready, |
|
3876 // but we have no signal telling us that, so we just have to do our best |
|
3877 |
|
3878 // Effect end observer is given to engine in LoadEffectL |
|
3879 // It will be set to effect there and called when the effect ends or is deleted |
|
3880 |
|
3881 // The layout should be visible at this time. if not, then this is assumed |
|
3882 // as effect to an background application and ignored. |
|
3883 if (aToLayout->Effect()) |
|
3884 { |
|
3885 // effect on a layout must be an application start effect. |
|
3886 // External content visual is not used for that. |
|
3887 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Found effect on layout 0x%x. Removing effect 0x%x", aToLayout, aToLayout->Effect()); |
|
3888 aToLayout->SetEffect(NULL); |
|
3889 } |
|
3890 if (!(aToLayout->Flags() & EHuiVisualFlagInactive)) |
|
3891 { |
|
3892 // this will tag the visual, that they cannot be hidden by HandleVisualVisibility |
|
3893 // Initialize layout for the exit effect |
|
3894 iLayoutInitializedForExitEffect = SetupEffectLayoutContainerL(aEvent.iHandle, aToLayout, ETrue); |
|
3895 aEvent.iSetupDone = iLayoutInitializedForExitEffect; |
|
3896 } |
|
3897 else |
|
3898 { |
|
3899 iLayoutInitializedForExitEffect = EFalse; |
|
3900 } |
|
3901 return failed; |
|
3902 } |
|
3903 default: |
|
3904 break; |
|
3905 } |
|
3906 break; |
|
3907 } |
|
3908 case MAlfGfxEffectPlugin::EEndFullscreen: |
|
3909 { |
|
3910 TBool layoutEffectable(EFalse); |
|
3911 if (aEvent.iAction != 5000) |
|
3912 { |
|
3913 if ( aEvent.iAction != AknTransEffect::EApplicationExit && aToLayout->Flags() & EHuiVisualFlagInactive) |
|
3914 { |
|
3915 aToLayout->iOpacity.Set(1.0f); |
|
3916 failed = ETrue; |
|
3917 return failed; |
|
3918 } |
|
3919 |
|
3920 if (aToLayout) |
|
3921 { |
|
3922 aToLayout->iOpacity.Set(1.0f); |
|
3923 __ALFFXLOGSTRING1("HandleGfxEventL - loading effect, handle %d", aEvent.iHandle ); |
|
3924 if (aEvent.iAction == AknTransEffect::EApplicationExit) |
|
3925 { |
|
3926 // Exit effect was initialized earlier with EBeginFullscreen event |
|
3927 layoutEffectable = iLayoutInitializedForExitEffect; |
|
3928 } |
|
3929 else |
|
3930 { |
|
3931 // add visuals to visual cleanupstack |
|
3932 aToLayout->SetStoredRenderBufferModificationsEnabled(EFalse); |
|
3933 layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle,aToLayout, EFalse); |
|
3934 aEvent.iSetupDone = layoutEffectable; |
|
3935 aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue); |
|
3936 } |
|
3937 |
|
3938 if (layoutEffectable) |
|
3939 { |
|
3940 if (aEvent.iRect != TRect()) |
|
3941 { |
|
3942 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), &aEvent.iRect, this, aEvent.iHandle ) ); |
|
3943 } |
|
3944 else |
|
3945 { |
|
3946 TRAP( err, engine->LoadGroupEffectL( *aEvent.iEffectName, effect, aToLayout->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle ) ); |
|
3947 } |
|
3948 effect = NULL; |
|
3949 // only use the effect if the effect file was correctly parsed |
|
3950 if (err != KErrNone) |
|
3951 { |
|
3952 // visuals added to "active effect visual" stack, but they wont be used, because effect loading has failed. cleanup. |
|
3953 RemoveTemporaryPresenterVisual(NULL, aEvent.iHandle); |
|
3954 aToLayout->SetEffect(NULL); |
|
3955 failed = ETrue; |
|
3956 } |
|
3957 } |
|
3958 else |
|
3959 { |
|
3960 failed = ETrue; |
|
3961 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEventL - Effect layout initialization failed. Skipping effect handle: %d, Visual: 0x%x", aEvent.iHandle, aToLayout); |
|
3962 } |
|
3963 } |
|
3964 } |
|
3965 break; |
|
3966 } |
|
3967 default: |
|
3968 { |
|
3969 // just in case... |
|
3970 break; |
|
3971 } |
|
3972 } |
|
3973 } |
|
3974 iLastAction = aEvent.iAction; // TODO: useless? |
|
3975 return failed; |
|
3976 } |
|
3977 |
|
3978 void CAlfBridge::FreezeLayoutUntilEffectDestroyedL(CHuiLayout* aLayout, TInt aHandle) |
|
3979 { |
|
3980 if (aLayout) |
|
3981 { |
|
3982 TRAPD(err, StoreRenderBufferStartL(aLayout)); |
|
3983 if (err == KErrNone) |
|
3984 { |
|
3985 // Freeze only, if buffer was reserved succesfully |
|
3986 aLayout->SetFreezeState(ETrue); |
|
3987 TBool itemsDestroyed; |
|
3988 AddEffectItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, EFalse); |
|
3989 iFullScreenEffectData->iAppStartScreenshotItemHandle = aHandle; |
|
3990 } |
|
3991 } |
|
3992 } |
|
3993 |
|
3994 void CAlfBridge::HandleGfxStopEvent( TBool aClientRequest ) |
|
3995 { |
|
3996 __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent BEGIN"); |
|
3997 if (!iFullScreenEffectData) |
|
3998 { |
|
3999 __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END: none"); |
|
4000 return; |
|
4001 } |
|
4002 |
|
4003 CFullScreenEffectState* fxData = iFullScreenEffectData; |
|
4004 iFullScreenEffectData = NULL; |
|
4005 CleanupStack::PushL( fxData ); |
|
4006 |
|
4007 __ALFFXLOGSTRING2(" - handle: %d, toAppUid: 0x%x", fxData->iHandle, fxData->iToAppId); |
|
4008 |
|
4009 // clean effects with this handle |
|
4010 RemoveTemporaryPresenterVisual(NULL, fxData->iHandle); |
|
4011 // this was abort, so we might have received earlier event hiding this window. Here we'll bring it |
|
4012 // back |
|
4013 if (fxData->iToAppId && fxData->iToAppId != KErrNotFound) |
|
4014 { |
|
4015 RemoveEffectFromApp(fxData->iToAppId); |
|
4016 RemoveEffectFromApp(fxData->iFromAppId); |
|
4017 } |
|
4018 else |
|
4019 { |
|
4020 // abort ALL effects |
|
4021 RemoveAllTemporaryPresenterVisuals(); |
|
4022 } |
|
4023 |
|
4024 iHuiEnv->ContinueRefresh(); |
|
4025 |
|
4026 if ( !aClientRequest ) |
|
4027 { |
|
4028 // Aborted errornously, signal client side |
|
4029 RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, fxData->iCompletionHandle ); |
|
4030 } |
|
4031 |
|
4032 CleanupStack::PopAndDestroy( fxData ); |
|
4033 __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEvent - END"); |
|
4034 } |
|
4035 |
|
4036 void CAlfBridge::RemoveEffectFromApp(TInt aAppUid) |
|
4037 { |
|
4038 if(aAppUid <= 0) |
|
4039 { |
|
4040 return; |
|
4041 } |
|
4042 CHuiControlGroup* group = FindControlGroupByAppId(aAppUid); |
|
4043 if (group) |
|
4044 { |
|
4045 CHuiControl& control = group->Control(0); |
|
4046 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0); |
|
4047 |
|
4048 TInt handle = FindEffectHandle(layout); |
|
4049 if (handle != KErrNotFound) |
|
4050 { |
|
4051 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxStopEvent - layout visual: 0x%x ; handle: %d ", layout, handle); |
|
4052 RemoveTemporaryPresenterVisual(NULL, handle); |
|
4053 } |
|
4054 layout->iOpacity.Set(1.0f); |
|
4055 } |
|
4056 } |
|
4057 |
|
4058 CAlfBridge::CEffectState::CEffectState() |
|
4059 { |
|
4060 // CBase clears all variables |
|
4061 } |
|
4062 |
|
4063 CAlfBridge::CEffectState::~CEffectState() |
|
4064 { |
|
4065 delete iEffectName; |
|
4066 } |
|
4067 |
|
4068 void CAlfBridge::CEffectState::ResolveFileNameL(RMemReadStream& aStream) |
|
4069 { |
|
4070 HBufC* effectDirectory = HBufC::NewLC(aStream, 256); |
|
4071 HBufC* effectFile = HBufC::NewLC(aStream, 256); |
|
4072 |
|
4073 // Add one extra because we want to be able to append a number to the filename |
|
4074 HBufC* effectFullName = HBufC::NewL(effectDirectory->Des().Length() |
|
4075 + effectFile->Des().Length() + 1); |
|
4076 CleanupStack::PushL(effectFullName); |
|
4077 |
|
4078 effectFullName->Des().Copy(*(effectDirectory)); |
|
4079 effectFullName->Des().Append(*(effectFile)); |
|
4080 delete iEffectName; |
|
4081 iEffectName = effectFullName; // ownership transferred |
|
4082 CleanupStack::Pop(effectFullName); |
|
4083 CleanupStack::PopAndDestroy(2, effectDirectory); |
|
4084 } |
|
4085 |
|
4086 void CAlfBridge::CFullScreenEffectState::ConstructL( |
|
4087 TInt aAction, |
|
4088 RMemReadStream& aStream) |
|
4089 { |
|
4090 iAction = aAction; |
|
4091 |
|
4092 iHandle = aStream.ReadInt32L(); |
|
4093 |
|
4094 iType = aStream.ReadInt32L(); |
|
4095 iWg1 = aStream.ReadInt32L(); |
|
4096 iWg2 = aStream.ReadInt32L(); |
|
4097 iToAppId = aStream.ReadInt32L(); |
|
4098 iFromAppId = aStream.ReadInt32L(); |
|
4099 |
|
4100 if (iType == AknTransEffect::EParameterType) |
|
4101 { |
|
4102 /*screen1 =*/aStream.ReadInt32L(); |
|
4103 /*screen2 =*/aStream.ReadInt32L(); |
|
4104 } |
|
4105 /*TInt flags =*/ |
|
4106 aStream.ReadInt32L(); |
|
4107 iRect.iTl.iX = aStream.ReadInt32L(); |
|
4108 iRect.iTl.iY = aStream.ReadInt32L(); |
|
4109 iRect.iBr.iX = aStream.ReadInt32L(); |
|
4110 iRect.iBr.iY = aStream.ReadInt32L(); |
|
4111 |
|
4112 ResolveFileNameL(aStream); |
|
4113 |
|
4114 iCompletionHandle = iHandle; |
|
4115 } |
|
4116 |
|
4117 void CAlfBridge::CControlEffectState::ConstructL(TInt aAction, |
|
4118 RMemReadStream& aStream) |
|
4119 { |
|
4120 iAction = aAction; |
|
4121 TInt operation = aStream.ReadInt32L(); |
|
4122 iHandle = aStream.ReadInt32L(); |
|
4123 iClientHandle = aStream.ReadInt32L(); |
|
4124 iClientGroupHandle = aStream.ReadInt32L(); |
|
4125 TInt screenNumber = aStream.ReadInt32L(); // this has always value 0 |
|
4126 // Are Symbian full filename+directory combinations still max 256 characters long? |
|
4127 ResolveFileNameL(aStream); |
|
4128 } |
|
4129 |
|
4130 // --------------------------------------------------------------------------- |
|
4131 // HandleGfxEffectsL |
|
4132 // --------------------------------------------------------------------------- |
|
4133 // |
|
4134 |
|
4135 void CAlfBridge::HandleGfxEffectsL( TAlfBridgerData data ) |
|
4136 { |
|
4137 // This method is called when "Begin fullscreen" and "End fullscreen" are |
|
4138 // invoked. Data in "Begin fullscreen" is used, "End fullscreen" and |
|
4139 // "Abort fullscreen" (HandleStopGfxEffectsL) are just signals. |
|
4140 // As a general limitation, there can be exactly one fullscreen effect |
|
4141 // ongoing at once. |
|
4142 |
|
4143 TInt action = data.iInt1; |
|
4144 TInt length = data.iInt2; |
|
4145 __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEffectsL - BEGIN (bridge data %d)", (TInt)data.iPtr); |
|
4146 void* bridgeBuffer = (void*) (*iHost)->GetEffectsDataL( (TInt)data.iPtr ); |
|
4147 RMemReadStream stream( bridgeBuffer, length ); |
|
4148 |
|
4149 // operation tells if this is begin full screen or end full screen |
|
4150 TInt operation = stream.ReadInt32L(); |
|
4151 |
|
4152 if ( operation == MAlfGfxEffectPlugin::EBeginFullscreen ) |
|
4153 { |
|
4154 if ( !iFullScreenEffectData || !iFullScreenEffectData->iSetupDone ) |
|
4155 { |
|
4156 // No fullsceen effect ongoing or fullscreen effect hasn't yet been set up, |
|
4157 // so we can initialize iFullScreenEffectData from stream. |
|
4158 |
|
4159 __ALFFXLOGSTRING("HandleGfxEffectsL - fresh start"); |
|
4160 |
|
4161 CFullScreenEffectState* fxData = new (ELeave) CFullScreenEffectState; |
|
4162 CleanupStack::PushL( fxData ); |
|
4163 fxData->ConstructL( action, stream ); |
|
4164 CleanupStack::Pop( fxData ); |
|
4165 |
|
4166 // the effect handle of freezed layout (iAppStartScreenshotItemHandle) must match the actual |
|
4167 // effect handle that is run. Only then frozen application can be freed at the end of the effect |
|
4168 if (iFullScreenEffectData) |
|
4169 { |
|
4170 for (TInt i = 0; i < iEffectCleanupStack.Count(); i++) |
|
4171 { |
|
4172 TEffectCleanupStruct& effectItem = iEffectCleanupStack[i]; |
|
4173 if (iFullScreenEffectData->iAppStartScreenshotItemHandle == effectItem.iHandle) |
|
4174 { |
|
4175 effectItem.iHandle = fxData->iHandle; |
|
4176 } |
|
4177 } |
|
4178 } |
|
4179 |
|
4180 if (iFullScreenEffectData && iFullScreenEffectData->iToAppId != fxData->iToAppId) |
|
4181 { |
|
4182 __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - WARNING - Another fullscreen effect to different app. Deleting the previous ongoing effect"); |
|
4183 RemoveEffectFromApp(iFullScreenEffectData->iToAppId);// Fullscreen effect for another app has arrived, and the previous has not finished and abort effect was not called. |
|
4184 RemoveEffectFromApp(iFullScreenEffectData->iFromAppId); |
|
4185 // Fullscreen effect for another |
|
4186 } |
|
4187 |
|
4188 delete iFullScreenEffectData; |
|
4189 iFullScreenEffectData = fxData; |
|
4190 iFullScreenEffectData->iAppStartScreenshotItemHandle = fxData->iHandle; |
|
4191 |
|
4192 stream.Release(); |
|
4193 } |
|
4194 else |
|
4195 { |
|
4196 // Fullscreen effect is ongoing. We could either use new data |
|
4197 // and abort the ongoing effect, or just continue ongoing. |
|
4198 // For now, we continue ongoing. |
|
4199 |
|
4200 __ALFFXLOGSTRING("HandleGfxEffectsL - END: ongoing"); |
|
4201 |
|
4202 // Client expects completion to be signalled with this handle. |
|
4203 iFullScreenEffectData->iCompletionHandle = stream.ReadInt32L(); |
|
4204 |
|
4205 stream.Release(); |
|
4206 return ; |
|
4207 } |
|
4208 } |
|
4209 else // MAlfGfxEffectPlugin::EEndFullscreen |
|
4210 { |
|
4211 stream.Release(); |
|
4212 |
|
4213 // End fullscreen signal received. We proceed only if there is really |
|
4214 // effect ongoing and "end fullscreen" hasn't already been processed. |
|
4215 |
|
4216 if ( !iFullScreenEffectData || iFullScreenEffectData->iEndFullScreen ) |
|
4217 { |
|
4218 __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - END: fx ready"); |
|
4219 return; |
|
4220 } |
|
4221 |
|
4222 __ALFFXLOGSTRING("HandleGfxEffectsL - process end"); |
|
4223 iFullScreenEffectData->iEndFullScreen = ETrue; |
|
4224 } |
|
4225 |
|
4226 CFullScreenEffectState* fxData = iFullScreenEffectData; |
|
4227 fxData->iOperation = operation; |
|
4228 fxData->iWaitingWindowGroup = EFalse; |
|
4229 |
|
4230 __ALFFXLOGSTRING3("Operation: %d, handle: %d, type: %d", operation, fxData->iHandle, fxData->iType); |
|
4231 __ALFFXLOGSTRING2("wg1: %d, wg2: %d", fxData->iWg1, fxData->iWg2); |
|
4232 |
|
4233 // find root nodes and attach effects to them |
|
4234 // First we need a windowgroup node id. So far we have a list of window ids |
|
4235 |
|
4236 // wg2 is the window group that is supposed to disappear from view |
|
4237 // when a new application starts. We don't have any use for it now... |
|
4238 |
|
4239 // This is the group that is disappearing |
|
4240 // Currently we don't add an effect to it. |
|
4241 |
|
4242 // TODO: when ids available from wserv... |
|
4243 // if ( appUid2 ) |
|
4244 //{ |
|
4245 // group2 = FindControlGrouAppUId( appUid2, screen2, &alfGroup ); |
|
4246 // } |
|
4247 //if ( toAppId2 ) |
|
4248 // { |
|
4249 // group2 = FindControlGroupByAppId(toAppId2); |
|
4250 // } |
|
4251 //if ( wg2 && wg2 != KErrNotFound ) |
|
4252 // { |
|
4253 // group2 = FindControlGroupByWindowGroupId( wg2, screen2 ); |
|
4254 // } |
|
4255 // if ( group2 ) |
|
4256 // { |
|
4257 // CHuiControl& control = group2->Control(0); |
|
4258 // layout2 = (CHuiLayout*)&control.Visual(0); |
|
4259 // } |
|
4260 |
|
4261 // This effect is triggered either by BeginFullScreen or by EndFullScreen |
|
4262 // depending on if we have an application that is already running or not |
|
4263 |
|
4264 // TAlfControlGroupEntry* alfGroup = NULL; |
|
4265 // TODO: |
|
4266 //wg1 = (*iHost)->FindWgForAppUid(TUid::Uid(toAppId1)); |
|
4267 //if (!wg1 && action != AknTransEffect::EApplicationExit ) |
|
4268 // { |
|
4269 // // window group is not available yet, but it will be created in short while. |
|
4270 // iEffectWaitingWindowgroup.Append(toAppId1); |
|
4271 // } |
|
4272 // TODO: when ids available from wserv... |
|
4273 // if ( appUid1 ) |
|
4274 //{ |
|
4275 // group1 = FindControlGrouAppUId( appUid1, screen1, &alfGroup ); |
|
4276 // } |
|
4277 |
|
4278 TBool failed = EFalse; |
|
4279 if (fxData->iToAppId && fxData->iToAppId != KErrNotFound) |
|
4280 { |
|
4281 CHuiControlGroup* toGroup = NULL; |
|
4282 CHuiLayout* toLayout = NULL; |
|
4283 toGroup = FindControlGroupByAppId(fxData->iToAppId); |
|
4284 |
|
4285 CHuiControlGroup* fromGroup = NULL; |
|
4286 CHuiLayout* fromLayout = NULL; |
|
4287 fromGroup = FindControlGroupByAppId(fxData->iFromAppId); |
|
4288 |
|
4289 if (!toGroup) // group has been destroyed and moved to effectControlGroup for waiting the application exit effect EndFullScreen trigger |
|
4290 { |
|
4291 toLayout = FindLayoutByEffectHandle(fxData->iHandle); |
|
4292 } |
|
4293 else |
|
4294 { |
|
4295 CHuiControl& control = toGroup->Control(0); |
|
4296 toLayout = (CHuiLayout*)&control.Visual(0); |
|
4297 } |
|
4298 if (fromGroup) |
|
4299 { |
|
4300 CHuiControl& control2 = fromGroup->Control(0); |
|
4301 fromLayout = (CHuiLayout*)&control2.Visual(0); |
|
4302 } |
|
4303 |
|
4304 if (toLayout) |
|
4305 { |
|
4306 failed = HandleGfxEventL(*fxData, toLayout, fromLayout); |
|
4307 } |
|
4308 else |
|
4309 { |
|
4310 __ALFFXLOGSTRING("HandleGfxEffectsL - waiting window group"); |
|
4311 fxData->iWaitingWindowGroup = ETrue; |
|
4312 } |
|
4313 } |
|
4314 |
|
4315 if ( failed ) |
|
4316 { |
|
4317 // Effect failed, reset state |
|
4318 HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData |
|
4319 } |
|
4320 |
|
4321 for (TInt i = 0; i < iAlfScreens.Count(); i++) |
|
4322 { |
|
4323 iAlfScreens[i]->iDisplay->SetDirty(); |
|
4324 } |
|
4325 iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue; |
|
4326 iHuiEnv->ContinueRefresh(); |
|
4327 |
|
4328 __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - END"); |
|
4329 } |
|
4330 |
|
4331 // TODO: add effect type to effect struct. remove all fullscreen effects. currently some might hang around |
|
4332 void CAlfBridge::HandleGfxStopEffectsL(TAlfBridgerData data) |
|
4333 { |
|
4334 // Fullscreen effect is aborted. Clear the state. |
|
4335 |
|
4336 //TInt action = data.iInt1; |
|
4337 TInt length = data.iInt2; |
|
4338 __ALFFXLOGSTRING1("CAlfBridge::HandleGfxStopEffectsL - Reading bridge data %d", (TInt)data.iPtr); |
|
4339 void* bridgeBuffer = (void*) (*iHost)->GetEffectsDataL( (TInt)data.iPtr ); |
|
4340 RMemReadStream stream( bridgeBuffer, length ); |
|
4341 |
|
4342 TInt operation = stream.ReadInt32L(); |
|
4343 TInt handle = stream.ReadInt32L(); |
|
4344 TInt type = stream.ReadInt32L(); |
|
4345 TInt wg1 = stream.ReadInt32L(); |
|
4346 TInt wg2 = stream.ReadInt32L(); |
|
4347 TInt toAppUi = stream.ReadInt32L(); |
|
4348 stream.Release(); |
|
4349 |
|
4350 // operation tells if this is abort full screen or something else |
|
4351 // When this function is used to abort control transitions, all data is 0s |
|
4352 if ( iFullScreenEffectData ) |
|
4353 { |
|
4354 __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill fullscreen"); |
|
4355 HandleGfxStopEvent( ETrue ); |
|
4356 } |
|
4357 |
|
4358 if ( !toAppUi ) |
|
4359 { |
|
4360 __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - kill all"); |
|
4361 RemoveAllTemporaryPresenterVisuals(); |
|
4362 iHuiEnv->ContinueRefresh(); |
|
4363 } |
|
4364 __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopEffectsL - end"); |
|
4365 } |
|
4366 |
|
4367 void CAlfBridge::HandleRegisterEffectL( TAlfBridgerData data ) |
|
4368 { |
|
4369 TInt action = data.iInt1; |
|
4370 TInt length = data.iInt2; |
|
4371 |
|
4372 void* bridgeBuffer = (void*) (*iHost)->GetEffectsDataL( (TInt)data.iPtr ); |
|
4373 RMemReadStream stream( bridgeBuffer, length ); |
|
4374 |
|
4375 |
|
4376 HBufC* effectDirectory = HBufC::NewL( stream, 256 ); |
|
4377 CleanupStack::PushL( effectDirectory ); |
|
4378 HBufC* effectFile = HBufC::NewL( stream, 256 ); |
|
4379 CleanupStack::PushL( effectFile ); |
|
4380 HBufC* effectFullName = HBufC::NewL( effectDirectory->Des().Length() + effectFile->Des().Length() ); |
|
4381 CleanupStack::PushL( effectFullName ); |
|
4382 effectFullName->Des().Copy( *effectDirectory ); |
|
4383 effectFullName->Des().Append( *effectFile ); |
|
4384 |
|
4385 stream.Release(); |
|
4386 __ALFFXLOGSTRING2("CAlfBridge::HandleRegisterEffectL - dir: %S, file: %S", effectDirectory, effectFile); |
|
4387 DoRegisterEffectL(*effectFullName, action); |
|
4388 |
|
4389 if (action == KFadeAction) |
|
4390 { |
|
4391 DoSetCachedFadeEffectL(); |
|
4392 } |
|
4393 |
|
4394 CleanupStack::PopAndDestroy(effectFullName); |
|
4395 CleanupStack::PopAndDestroy(effectFile); |
|
4396 CleanupStack::PopAndDestroy(effectDirectory); |
|
4397 } |
|
4398 |
|
4399 void CAlfBridge::DoRegisterEffectL(const TDesC& aFilename, TInt aAction) |
|
4400 { |
|
4401 TRegisteredEffectsStruct newEntry; |
|
4402 newEntry.iAction = aAction; |
|
4403 newEntry.iEffectFile = HBufC::NewL(aFilename.Length()); |
|
4404 newEntry.iEffectFile->Des().Append(aFilename); |
|
4405 iAlfRegisteredEffects.AppendL(newEntry); |
|
4406 |
|
4407 CHuiFxEngine* engine = NULL; |
|
4408 engine = iHuiEnv->EffectsEngine(); |
|
4409 if (engine) |
|
4410 { |
|
4411 engine->RegisterEffectL(aFilename); |
|
4412 } |
|
4413 } |
|
4414 |
|
4415 CHuiCanvasVisual* CAlfBridge::AddEffectItemL( |
|
4416 TInt aEffectHandle, |
|
4417 CHuiVisual* aSourceVisual, |
|
4418 CHuiLayout* aTargetLayout, |
|
4419 CHuiControl* aEffectControl, |
|
4420 TBool aInsertTemporaryVisual, |
|
4421 TInt& aItemDestroyed, |
|
4422 TBool aIsExitEffect) |
|
4423 { |
|
4424 CHuiCanvasVisual* temporaryPresenterVisual = NULL; |
|
4425 TInt enableEffect = ETrue; |
|
4426 |
|
4427 aSourceVisual->ClearFlags(EHuiVisualFlagShouldBeInactive | EHuiVisualFlagShouldBeUnderOpaqueHint); |
|
4428 if (aIsExitEffect) |
|
4429 { |
|
4430 aSourceVisual->SetFlag(EHuiVisualFlagAlwaysDraw); // forces drawing during exit effect. handlevisualvisibility will set the EShouldbeInactive flag, if visual is determined inactive while this flag is set |
|
4431 } |
|
4432 |
|
4433 if (HasActiveEffect(aSourceVisual)) |
|
4434 { |
|
4435 // this visual is having effect and we are closing down the layout this visual inhabits. |
|
4436 // Propably this is the case, when application is closed while the options menu is |
|
4437 // still having effect animation. |
|
4438 |
|
4439 // removes the effect, and the visual (if EShouldDestroy flag enabled). Removes from effect |
|
4440 // cleanup stack iEffectCleanupStack |
|
4441 enableEffect = aSourceVisual->Flags() & EHuiVisualFlagShouldDestroy ? 0 : 1; |
|
4442 __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - visual 0x%x is having effect. EShouldBeDestroyed flag state %d", &aSourceVisual, enableEffect ); |
|
4443 RemoveTemporaryPresenterVisual(aSourceVisual); |
|
4444 if (!enableEffect) |
|
4445 { |
|
4446 aItemDestroyed++; |
|
4447 } |
|
4448 } |
|
4449 if ( enableEffect ) |
|
4450 { |
|
4451 // RDebug::Print(_L("CAlfBridge::SetupEffectLayoutContainerL - binding visual 0x%x (source)--> 0x%x (presenter) layout 0x%x (presenter layout)"), &sourceVisual, temporaryPresenterVisual, temporaryPresenterLayout); |
|
4452 if (aInsertTemporaryVisual) |
|
4453 { |
|
4454 temporaryPresenterVisual = CHuiCanvasVisual::AddNewL(*aEffectControl, aTargetLayout); |
|
4455 |
|
4456 temporaryPresenterVisual->SetExternalContentL(aSourceVisual); |
|
4457 temporaryPresenterVisual->SetSize(THuiRealSize(640, 640)); |
|
4458 temporaryPresenterVisual->SetPos(aSourceVisual->Pos().Target()); |
|
4459 aSourceVisual->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
|
4460 temporaryPresenterVisual->SetChanged(); |
|
4461 TEffectCleanupStruct item = TEffectCleanupStruct( |
|
4462 aEffectHandle, |
|
4463 aSourceVisual, |
|
4464 temporaryPresenterVisual, |
|
4465 ETrue, |
|
4466 EFalse); |
|
4467 iEffectCleanupStack.AppendL(item); |
|
4468 } |
|
4469 else |
|
4470 { |
|
4471 // this will be a child of another visual, and draw by its parent external content visual |
|
4472 // aSourceVisual->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
|
4473 TEffectCleanupStruct item = TEffectCleanupStruct(aEffectHandle, |
|
4474 aSourceVisual, NULL, EFalse, |
|
4475 EFalse); |
|
4476 iEffectCleanupStack.AppendL(item); |
|
4477 } |
|
4478 } |
|
4479 return temporaryPresenterVisual; |
|
4480 } |
|
4481 |
|
4482 void CAlfBridge::AddToEffectLayoutContainerL( |
|
4483 TInt aEffectHandle, |
|
4484 CHuiLayout* aSourceLayout, |
|
4485 CHuiLayout* aTargetLayout, |
|
4486 CHuiControl* aEffectControl, |
|
4487 TInt& aItemsDestroyed, |
|
4488 TBool aAddLayout, |
|
4489 TBool aIsExitEffect) |
|
4490 { |
|
4491 __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x is having %d children", aSourceLayout, aSourceLayout->Count()); |
|
4492 if (aAddLayout) |
|
4493 { |
|
4494 AddEffectItemL(aEffectHandle, aSourceLayout, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsExitEffect); |
|
4495 } |
|
4496 |
|
4497 for (TInt i = 0; i < aSourceLayout->Count(); i++) |
|
4498 { |
|
4499 CHuiCanvasVisual& sourceVisual = static_cast<CHuiCanvasVisual&> (aSourceLayout->Visual(i)); |
|
4500 |
|
4501 if (sourceVisual.Count()) |
|
4502 { |
|
4503 CHuiLayout& layout = static_cast<CHuiLayout&> (aSourceLayout->Visual(i)); |
|
4504 AddToEffectLayoutContainerL(aEffectHandle, &layout, NULL, aEffectControl, aItemsDestroyed, EFalse,aIsExitEffect ); |
|
4505 } |
|
4506 AddEffectItemL(aEffectHandle, &sourceVisual, aTargetLayout, aEffectControl, EFalse, aItemsDestroyed, aIsExitEffect); |
|
4507 } |
|
4508 __ALFFXLOGSTRING2("CAlfBridge::AddToEffectLayoutContainerL 0x%x end of children", aSourceLayout, aSourceLayout->Count()); |
|
4509 } |
|
4510 |
|
4511 TBool CAlfBridge::SetupEffectLayoutContainerL(TInt aHandle,CHuiLayout* aSourceLayout, TBool aIsExitEffect) |
|
4512 { |
|
4513 if (aSourceLayout->Flags() & EHuiVisualFlagDrawOnlyAsExternalContent) |
|
4514 { |
|
4515 // the requested visual is already having an effect. |
|
4516 __ALFFXLOGSTRING("CAlfBridge::SetupEffectLayoutContainerL - WE ARE ALREADY HAVING EFFECT! WHAT TO DO??"); |
|
4517 // layout is having already effect. this is tricky. This might be place to panic. Resolve later. |
|
4518 } |
|
4519 // duplicate the layout to effect window group |
|
4520 CHuiControl& effectControlGroup = iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0); |
|
4521 CHuiLayout& effectControlGroupLayout = (CHuiLayout&) effectControlGroup.Visual(0); |
|
4522 |
|
4523 // CHuiCanvasVisual* temporaryPresenterLayout = CHuiCanvasVisual::AddNewL( effectControlGroup, &effectControlGroupLayout); |
|
4524 // create presenter visual and set bindings |
|
4525 TInt itemsDestroyed(0); |
|
4526 AddToEffectLayoutContainerL(aHandle, aSourceLayout, NULL, &effectControlGroup, itemsDestroyed, EFalse, aIsExitEffect); |
|
4527 |
|
4528 if (aIsExitEffect) |
|
4529 { |
|
4530 CHuiCanvasVisual* temporaryPresenterVisual = AddEffectItemL(aHandle, aSourceLayout, &effectControlGroupLayout, &effectControlGroup, ETrue, itemsDestroyed, aIsExitEffect); |
|
4531 aSourceLayout->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
|
4532 __ALFFXLOGSTRING3("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout)-> 0x%x (presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout, temporaryPresenterVisual); |
|
4533 } |
|
4534 else |
|
4535 { |
|
4536 AddEffectItemL(aHandle, aSourceLayout, NULL, &effectControlGroup, ETrue, itemsDestroyed, EFalse); |
|
4537 __ALFFXLOGSTRING2("CAlfBridge::SetupEffectLayoutContainerL - adding handle: %d, 0x%x (source layout), NO presenter layout) to iEffectCleanupStack", aHandle, aSourceLayout); |
|
4538 } |
|
4539 iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue; |
|
4540 iAlfScreens[0]->iDisplay->SetDirty(); |
|
4541 if (itemsDestroyed) |
|
4542 { |
|
4543 __ALFFXLOGSTRING3("CAlfBridge::SetupEffectLayoutContainerL - trying to put effect on destroyed visuals. Skipping effect visual: 0x%x, handle %d, %d items destroyed", aSourceLayout, aHandle, itemsDestroyed); |
|
4544 } |
|
4545 __ALFFXLOGSTRING("CAlfBridge::SetupEffectLayoutContainerL"); |
|
4546 return ETrue; // TBool(!itemsDestroyed); |
|
4547 } |
|
4548 |
|
4549 void CAlfBridge::SetupEffectContainerL(TInt aHandle, |
|
4550 CHuiCanvasVisual* aSourceVisual, TBool aIsExitEffect) |
|
4551 { |
|
4552 // if the original visual is having an effect, then remove it. |
|
4553 if (HasActiveEffect(aSourceVisual)) |
|
4554 { |
|
4555 RemoveTemporaryPresenterVisual(aSourceVisual); |
|
4556 } |
|
4557 |
|
4558 // Create new temporary presenter visual for the effect |
|
4559 CHuiControl& effectControlGroup = |
|
4560 iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0); |
|
4561 CHuiLayout* layout = (CHuiLayout*) &effectControlGroup.Visual(0); |
|
4562 CHuiCanvasVisual* temporaryPresenterVisual = NULL; |
|
4563 temporaryPresenterVisual = CHuiCanvasVisual::AddNewL(effectControlGroup, layout); |
|
4564 // attach the source to the presenter visual |
|
4565 temporaryPresenterVisual->SetExternalContentL(aSourceVisual); |
|
4566 aSourceVisual->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
|
4567 temporaryPresenterVisual->ClearFlag(EHuiVisualFlagInactive); |
|
4568 aSourceVisual->SetChanged(); |
|
4569 // append to cleanup stack. this is cleaned in RemoveTemporaryVisuals after effect has finished |
|
4570 iEffectCleanupStack.AppendL(TEffectCleanupStruct(aHandle, aSourceVisual, temporaryPresenterVisual, EFalse /*iIsLayout*/, aIsExitEffect)); |
|
4571 __ALFFXLOGSTRING3("CAlfBridge::SetupEffectContainerL - adding handle: %d, 0x%x (source visual)-> 0x%x (presenter visual)", aHandle, aSourceVisual, temporaryPresenterVisual); |
|
4572 } |
|
4573 |
|
4574 void CAlfBridge::HandleGfxControlEffectsL( TAlfBridgerData data ) |
|
4575 { |
|
4576 TInt err = KErrNone; |
|
4577 TInt action = data.iInt1; |
|
4578 TInt length = data.iInt2; |
|
4579 __ALFFXLOGSTRING1("HandleGfxControlEffectsL - Reading bridge data %d", (TInt)data.iPtr); |
|
4580 void* bridgeBuffer = (void*) (*iHost)->GetEffectsDataL((TInt) data.iPtr); |
|
4581 RMemReadStream stream(bridgeBuffer, length); |
|
4582 if (iControlEffectData) |
|
4583 { |
|
4584 delete iControlEffectData; |
|
4585 iControlEffectData = NULL; |
|
4586 } |
|
4587 CControlEffectState* fxData = new (ELeave) CControlEffectState; |
|
4588 CleanupStack::PushL(fxData); |
|
4589 fxData->ConstructL(action, stream); |
|
4590 iControlEffectData = fxData; |
|
4591 CleanupStack::Pop(fxData); |
|
4592 |
|
4593 // We now have all the data sent to us. |
|
4594 stream.Release(); |
|
4595 |
|
4596 // We need to pass the filename from the transeffect plugin that handles the controls |
|
4597 // that define which effect is used for the selected skin or the selected application |
|
4598 // For full screen effects the skin should determine the effect, or there should be |
|
4599 // some default effects. |
|
4600 |
|
4601 CHuiCanvasVisual* visual = FindVisualByClientSideIds(fxData->iClientHandle, fxData->iClientGroupHandle); |
|
4602 |
|
4603 if (visual) |
|
4604 { |
|
4605 HandleGfxControlEventL(*iControlEffectData, visual); |
|
4606 } |
|
4607 else |
|
4608 { |
|
4609 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxControlEffectsL - Control not found. iClientHandle 0x%x, iClientGroupHandle 0x%x", |
|
4610 iControlEffectData->iClientHandle, |
|
4611 iControlEffectData->iClientGroupHandle); |
|
4612 return; |
|
4613 } |
|
4614 iAlfScreens[0]->iDisplay->SetDirty(); |
|
4615 |
|
4616 iHuiEnv->ContinueRefresh(); |
|
4617 |
|
4618 if (visual && err != KErrNone) |
|
4619 { |
|
4620 // if the effect loading failed too soon, we must call our callback ourselves |
|
4621 // RDebug::Print(_L("HandleGfxControlEffectsL - effect not set - going directly to callback")); |
|
4622 AlfGfxEffectEndCallBack(fxData->iHandle); |
|
4623 } |
|
4624 |
|
4625 delete iControlEffectData; |
|
4626 iControlEffectData = NULL; |
|
4627 |
|
4628 __ALFFXLOGSTRING("HandleGfxControlEffectsL - end"); |
|
4629 } |
|
4630 |
|
4631 void CAlfBridge::HandleGfxControlEventL(CControlEffectState& aEvent, |
|
4632 CHuiCanvasVisual* aCanvasVisual) |
|
4633 { |
|
4634 TInt err = KErrNone; |
|
4635 // Check if there is an effects engine in HuiEnv |
|
4636 CHuiFxEffect* effect = NULL; |
|
4637 CHuiFxEngine* engine = NULL; |
|
4638 // engine is not owned by us, it is a member of HuiEnv |
|
4639 engine = iHuiEnv->EffectsEngine(); |
|
4640 if (NeedsStoredBuffers(engine, *aEvent.iEffectName)) |
|
4641 { |
|
4642 RecursiveStoreRenderBufferL(aCanvasVisual); |
|
4643 } |
|
4644 |
|
4645 if (engine) |
|
4646 { |
|
4647 // clear out old effect if this visual has one |
|
4648 __ALFFXLOGSTRING1("HandleGfxControlEffectsL - loading effect %S", &aEvent.iEffectName ); |
|
4649 __ALFFXLOGSTRING1("HandleGfxControlEffectsL - loading control effect, handle %d", aEvent.iHandle ); |
|
4650 if (HasActiveEffect(aCanvasVisual)) |
|
4651 { |
|
4652 __ALFFXLOGSTRING1("HandleGfxControlEffectsL - 0x%x has active effect. Requesting removal.", aCanvasVisual); |
|
4653 // another effect coming to already effected visual. E.g. close options menu, while opening effect still ongoing |
|
4654 RemoveTemporaryPresenterVisual(aCanvasVisual); |
|
4655 } |
|
4656 TBool layoutEffectable(EFalse); |
|
4657 aCanvasVisual->iOpacity.Set(KAlfVisualDefaultOpacity); |
|
4658 if (aEvent.iAction == KGfxControlDisappearAction) |
|
4659 { // TODO: revise |
|
4660 // The control stays visible because the inactive flag is not set |
|
4661 // if the window is reserved. |
|
4662 /*if (aCanvasVisual->iOpacity.Target() == 0.0f) |
|
4663 { |
|
4664 // this visual was hidden, before the effect arrived. sounds like trouble. |
|
4665 // Lets make it visible again, and ask it to be hidden in the end of the effect |
|
4666 // this enables at least the notes disappear effects |
|
4667 aCanvasVisual->iOpacity.Set(KAlfVisualDefaultOpacity); |
|
4668 // visual->SetFlag(EHuiVisualFlagShouldBeHidden); |
|
4669 }*/ |
|
4670 layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, ETrue); |
|
4671 } |
|
4672 else |
|
4673 { |
|
4674 layoutEffectable = SetupEffectLayoutContainerL(aEvent.iHandle, aCanvasVisual, EFalse); |
|
4675 } |
|
4676 if (layoutEffectable) |
|
4677 { |
|
4678 TRAP( err, engine->LoadGroupEffectL(*aEvent.iEffectName, effect, aCanvasVisual->Effectable(), engine->ActiveGroupEffect(), NULL, this, aEvent.iHandle ) ); |
|
4679 } |
|
4680 else |
|
4681 { |
|
4682 err = KErrNotFound; |
|
4683 } |
|
4684 // RDebug::Print(_L("HandleGfxControlEffectsL - loading effect returned %d"), err ); |
|
4685 // only use the effect if the effect file was correctly parsed |
|
4686 if (err == KErrNone) |
|
4687 { |
|
4688 iLastEffectHandle = aEvent.iHandle; |
|
4689 |
|
4690 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
4691 visual->SetTracking(ETrue); |
|
4692 #endif |
|
4693 // HuiVisual takes ownership of the effect, but we save the value for reference |
|
4694 // add new visual to iFullscreenEffectControlGroup. This enables multiple effects in the group, and their |
|
4695 // destruction in any order |
|
4696 } |
|
4697 else |
|
4698 { |
|
4699 // visuals added to "active effect visual" stack, but they wont be used, because effect loading has failed. cleanup. |
|
4700 RemoveTemporaryPresenterVisual(NULL, aEvent.iHandle); |
|
4701 } |
|
4702 effect = NULL; // HuiVisual has taken ownership |
|
4703 } |
|
4704 } |
|
4705 |
|
4706 TBool CAlfBridge::RemoveTemporaryPresenterItem(TEffectCleanupStruct& aEffectItem) |
|
4707 { |
|
4708 CHuiVisual* sourceViz = aEffectItem.iEffectedVisual; |
|
4709 CHuiCanvasVisual* sourceViz2 = dynamic_cast<CHuiCanvasVisual*> (aEffectItem.iEffectedVisual); |
|
4710 // wserv has already hidden this window. Effect has finished, so lets do what |
|
4711 // was asked. Also hide, if this is supposed to be destroyed by now. |
|
4712 sourceViz->SetFreezeState(EFalse); |
|
4713 sourceViz->SetStoredRenderBuffer(NULL); // free render buffer from visual |
|
4714 if (sourceViz2 && sourceViz2->Layout()) |
|
4715 { |
|
4716 sourceViz2->FreeRenderBuffer(); |
|
4717 } |
|
4718 sourceViz->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
|
4719 TBool hideVisual = sourceViz->Flags() & EHuiVisualFlagShouldBeHidden; |
|
4720 TBool showVisual = sourceViz->Flags() & EHuiVisualFlagShouldBeShown; |
|
4721 TBool destroyVisual = sourceViz->Flags() & EHuiVisualFlagShouldDestroy; |
|
4722 TBool shouldInactivate = sourceViz->Flags() & EHuiVisualFlagShouldBeInactive; |
|
4723 TBool shouldBeUnderOpaqueHint = sourceViz->Flags() & EHuiVisualFlagShouldBeUnderOpaqueHint; |
|
4724 __ALFFXLOGSTRING3("CAlfBridge::RemoveTemporaryPresenterItem - cleaning handle: %d, 0x%x -> 0x%x", aEffectItem.iHandle, aEffectItem.iEffectedVisual, aEffectItem.iTemporaryPresenterVisual); |
|
4725 __ALFFXLOGSTRING3("CAlfBridge::RemoveTemporaryPresenterItem - hide %d, destroy %d, should inactivate: %d", TBool(hideVisual), TBool(destroyVisual), TBool(shouldInactivate)); |
|
4726 |
|
4727 sourceViz->ClearFlag(EHuiVisualFlagAlwaysDraw); |
|
4728 if (hideVisual) |
|
4729 { |
|
4730 // this was exit effect, and window was not really destroyed. |
|
4731 sourceViz->iOpacity.Set(0.0f); |
|
4732 sourceViz->ClearFlag(EHuiVisualFlagShouldBeHidden); // it is now hidden |
|
4733 } |
|
4734 else |
|
4735 { |
|
4736 // visual may be transparent after manipulation of the effect |
|
4737 sourceViz->iOpacity.Set(KAlfVisualDefaultOpacity); |
|
4738 } |
|
4739 if (showVisual) |
|
4740 { |
|
4741 sourceViz->iOpacity.Set(KAlfVisualDefaultOpacity); |
|
4742 sourceViz->ClearFlag(EHuiVisualFlagShouldBeShown); // it is now hidden |
|
4743 } |
|
4744 |
|
4745 if (destroyVisual) |
|
4746 { |
|
4747 sourceViz->iOpacity.Set(0.0f); |
|
4748 } |
|
4749 if (shouldInactivate) |
|
4750 { |
|
4751 sourceViz->SetFlag(EHuiVisualFlagInactive); |
|
4752 |
|
4753 if (sourceViz2) |
|
4754 { |
|
4755 sourceViz2->ClearCache(); |
|
4756 } |
|
4757 sourceViz->ClearFlags(EHuiVisualFlagShouldBeInactive); |
|
4758 } |
|
4759 if (shouldBeUnderOpaqueHint) |
|
4760 { |
|
4761 sourceViz->SetFlag(EHuiVisualFlagUnderOpaqueHint); |
|
4762 if (sourceViz2) |
|
4763 { |
|
4764 sourceViz2->ClearCache(); |
|
4765 } |
|
4766 sourceViz->ClearFlags(EHuiVisualFlagShouldBeUnderOpaqueHint); |
|
4767 } |
|
4768 if (sourceViz->Effect()) |
|
4769 { |
|
4770 sourceViz->SetEffect(NULL); |
|
4771 } |
|
4772 |
|
4773 // first delete the temporary presenter visual, because this will unbind the external content |
|
4774 if (aEffectItem.iTemporaryPresenterVisual) |
|
4775 { |
|
4776 CHuiVisual* viz = aEffectItem.iTemporaryPresenterVisual; |
|
4777 |
|
4778 if (viz) |
|
4779 { |
|
4780 if (viz->Effect()) |
|
4781 { |
|
4782 // temporary presenter visual should not have effect, because the effect is |
|
4783 // applied to the original visual. However, if somebody misuses this API, it |
|
4784 // is good to cleap up the effect here. |
|
4785 viz->SetEffect(NULL); |
|
4786 } |
|
4787 if (viz->Layout()) |
|
4788 { |
|
4789 viz->Layout()->Remove(viz); |
|
4790 } |
|
4791 viz->Owner().Remove(viz); |
|
4792 delete viz; |
|
4793 aEffectItem.iTemporaryPresenterVisual = NULL; |
|
4794 } |
|
4795 } |
|
4796 // although layout does not support EHuiVisualFlagDrawOnlyAsExternalContent flag, it is being used to indicate a layout that has effect. flag must be cleared, that the layout can be drawn normally after the effect. |
|
4797 if (aEffectItem.iIsLayout) |
|
4798 { |
|
4799 aEffectItem.iEffectedVisual->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
|
4800 // sourceViz->iOpacity.Set(1.0f); |
|
4801 } |
|
4802 |
|
4803 if (destroyVisual) |
|
4804 { |
|
4805 // window has been destroyed during effect. Kill it once and for all |
|
4806 // DeleteControlGroupL and DestroyWindow can do their duty, when this flag is cleared |
|
4807 sourceViz->ClearFlags(EHuiVisualFlagShouldDestroy | EHuiVisualFlagDrawOnlyAsExternalContent); |
|
4808 if (aEffectItem.iIsLayout) |
|
4809 { |
|
4810 if (sourceViz->Layout()) |
|
4811 { |
|
4812 sourceViz->Layout()->Remove(sourceViz); |
|
4813 } |
|
4814 sourceViz->Owner().Remove(sourceViz); |
|
4815 |
|
4816 delete sourceViz; |
|
4817 __ALFFXLOGSTRING1("CAlfBridge::RemoveTemporaryPresenterItem - Destroying sourceViz: 0x%x", sourceViz); |
|
4818 aEffectItem.iEffectedVisual = NULL; |
|
4819 } |
|
4820 else |
|
4821 { |
|
4822 TLex8 lex(sourceViz->Tag()); |
|
4823 TInt nodeId; |
|
4824 lex.Val(nodeId); |
|
4825 DestroyWindow(sourceViz, ETrue); |
|
4826 } |
|
4827 } |
|
4828 return TBool(destroyVisual); |
|
4829 } |
|
4830 |
|
4831 // RemoveTemporaryPresenterVisual removes the temporary presenter visual, and unbinds it from the source. |
|
4832 TBool CAlfBridge::RemoveTemporaryPresenterVisual(CHuiVisual* aVisual, |
|
4833 TInt aHandle) |
|
4834 { |
|
4835 __ALFFXLOGSTRING2("CAlfBridge::RemoveTemporaryPresenterVisual - cleaning handle: %d, 0x%x", aHandle, aVisual); |
|
4836 TInt visualsRemoved = 0; |
|
4837 for (TInt i = 0; i < iEffectCleanupStack.Count(); i++) |
|
4838 { |
|
4839 TEffectCleanupStruct& effectItem = iEffectCleanupStack[i]; |
|
4840 if (aVisual == effectItem.iEffectedVisual || |
|
4841 aHandle == effectItem.iHandle) |
|
4842 { |
|
4843 if (RemoveTemporaryPresenterItem(effectItem)) |
|
4844 { |
|
4845 visualsRemoved++; |
|
4846 } |
|
4847 // must remove from finished effects to keep it in sync |
|
4848 for(TInt k = 0; k < iFinishedCleanupStackEffects.Count(); k++) |
|
4849 { |
|
4850 if (iFinishedCleanupStackEffects[k] == effectItem.iHandle) |
|
4851 { |
|
4852 iFinishedCleanupStackEffects.Remove(k); |
|
4853 k--; |
|
4854 } |
|
4855 } |
|
4856 iEffectCleanupStack.Remove(i); |
|
4857 i--; |
|
4858 } |
|
4859 } |
|
4860 return TBool(visualsRemoved); |
|
4861 } |
|
4862 |
|
4863 CHuiLayout* CAlfBridge::FindTemporaryPresenterLayout(CHuiVisual* aVisual) |
|
4864 { |
|
4865 for (TInt i = 0; i < iEffectCleanupStack.Count(); i++) |
|
4866 { |
|
4867 if (aVisual == iEffectCleanupStack[i].iEffectedVisual) |
|
4868 { |
|
4869 ASSERT(iEffectCleanupStack[i].iIsLayout); |
|
4870 return (CHuiLayout*)iEffectCleanupStack[i].iTemporaryPresenterVisual; |
|
4871 } |
|
4872 } |
|
4873 return NULL; |
|
4874 } |
|
4875 |
|
4876 TBool CAlfBridge::HasActiveEffect(CHuiVisual* aVisual) |
|
4877 { |
|
4878 for (TInt i = 0; i < iEffectCleanupStack.Count(); i++) |
|
4879 { |
|
4880 if (aVisual == iEffectCleanupStack[i].iEffectedVisual) |
|
4881 { |
|
4882 return ETrue; |
|
4883 } |
|
4884 } |
|
4885 return EFalse; |
|
4886 } |
|
4887 |
|
4888 TInt CAlfBridge::FindEffectHandle(CHuiVisual* aVisual) |
|
4889 { |
|
4890 for (TInt i = 0; i < iEffectCleanupStack.Count(); i++) |
|
4891 { |
|
4892 if (aVisual == iEffectCleanupStack[i].iEffectedVisual) |
|
4893 { |
|
4894 return iEffectCleanupStack[i].iHandle; |
|
4895 } |
|
4896 } |
|
4897 __ALFFXLOGSTRING1(" CAlfBridge::SetupEffectLayoutContainerL - Could not find handle for 0x%x", aVisual); |
|
4898 return KErrNotFound; |
|
4899 } |
|
4900 |
|
4901 CHuiLayout* CAlfBridge::FindLayoutByEffectHandle(TInt aHandle) |
|
4902 { |
|
4903 for (TInt i = 0; i < iEffectCleanupStack.Count(); i++) |
|
4904 { |
|
4905 if (aHandle == iEffectCleanupStack[i].iHandle && iEffectCleanupStack[i].iIsLayout) |
|
4906 { |
|
4907 return (CHuiLayout*)iEffectCleanupStack[i].iEffectedVisual; |
|
4908 } |
|
4909 } |
|
4910 return NULL; |
|
4911 } |
|
4912 |
|
4913 |
|
4914 TBool CAlfBridge::RemoveTemporaryPresenterVisuals() |
|
4915 { |
|
4916 if (!iFinishedCleanupStackEffects.Count()) |
|
4917 { |
|
4918 return 0; |
|
4919 } |
|
4920 TInt itemsRemoved(0); |
|
4921 CHuiControl& effectControlGroup = iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0); |
|
4922 CHuiLayout* effectControlGroupLayout = (CHuiLayout*) &effectControlGroup.Visual(0); |
|
4923 __ALFFXLOGSTRING1("CAlfBridge::RemoveTemporaryPresenterVisuals - BEGIN - effects in layout %d", effectControlGroupLayout->Count()); |
|
4924 |
|
4925 while (iFinishedCleanupStackEffects.Count()) |
|
4926 { |
|
4927 for (TInt i = 0; i < iEffectCleanupStack.Count() && iFinishedCleanupStackEffects.Count(); i++) |
|
4928 { |
|
4929 __ALFFXLOGSTRING2("CAlfBridge::RemoveTemporaryPresenterVisuals - looping, finished count: %d, index in active effecs: %d", iFinishedCleanupStackEffects.Count(), i ); |
|
4930 |
|
4931 TEffectCleanupStruct& effectItem = iEffectCleanupStack[i]; |
|
4932 if (iFinishedCleanupStackEffects[0] == effectItem.iHandle) |
|
4933 { |
|
4934 if (RemoveTemporaryPresenterItem(effectItem)) |
|
4935 { |
|
4936 itemsRemoved++; |
|
4937 } |
|
4938 iEffectCleanupStack.Remove(i); |
|
4939 iFinishedCleanupStackEffects.Remove(0); |
|
4940 i--; |
|
4941 } |
|
4942 } |
|
4943 } |
|
4944 iAlfScreens[0]->iVisualTreeVisibilityChanged = ETrue; // TODO: Check if really changed |
|
4945 iAlfScreens[0]->iDisplay->SetDirty(); |
|
4946 __ALFFXLOGSTRING1("CAlfBridge::RemoveTemporaryPresenterVisuals - END - effects in layout %d", effectControlGroupLayout->Count()); |
|
4947 return itemsRemoved; |
|
4948 } |
|
4949 |
|
4950 void CAlfBridge::RemoveAllTemporaryPresenterVisuals() |
|
4951 { |
|
4952 CHuiControl& effectControlGroup = iAlfScreens[0]->iFullscreenEffectControlGroup->Control(0); |
|
4953 CHuiLayout* effectControlGroupLayout = (CHuiLayout*) &effectControlGroup.Visual(0); |
|
4954 __ALFFXLOGSTRING1("CAlfBridge::RemoveAllTemporaryPresenterVisuals - BEGIN - effects in layout %d", effectControlGroupLayout->Count()); |
|
4955 |
|
4956 while(iEffectCleanupStack.Count()) |
|
4957 { |
|
4958 TEffectCleanupStruct& effectItem = iEffectCleanupStack[0]; |
|
4959 RemoveTemporaryPresenterItem(effectItem); |
|
4960 iEffectCleanupStack.Remove(0); |
|
4961 } |
|
4962 |
|
4963 while(iFinishedCleanupStackEffects.Count()) |
|
4964 { |
|
4965 iFinishedCleanupStackEffects.Remove(0); |
|
4966 } |
|
4967 } |
|
4968 |
|
4969 void CAlfBridge::AlfGfxEffectEndCallBack(TInt aHandle) |
|
4970 { |
|
4971 // We need a delay to prevent the refresh from being messed up |
|
4972 // We try a short delay before clearing everything up. |
|
4973 __ALFFXLOGSTRING1("AlfGfxEffectEndCallBack, append handle %d", aHandle ); |
|
4974 // RDebug::Print(_L("AlfGfxEffectEndCallBack, append handle %d"), aHandle ); |
|
4975 // If the handle cannot be appended, the function returns an error. |
|
4976 // However, if the memory is low, there is nothing we can do about it. |
|
4977 // We try to handle the transition finish anyway. |
|
4978 // If there are already other handles in the queue, the handler will not |
|
4979 // be called for this handle, but all handles that have been left hanging |
|
4980 // around will be cleared when HandleGfxStopEffectsL is called |
|
4981 |
|
4982 |
|
4983 iFinishedEffects.Append(aHandle); |
|
4984 |
|
4985 // iFinishedCleanupStackEffects.Append(aHandle); |
|
4986 if (!iEffectEndTimer->IsActive()) |
|
4987 { |
|
4988 iEffectEndTimer->Start( 10000, aHandle ); |
|
4989 } |
|
4990 |
|
4991 // We should do visual visibility scan after effect is ended |
|
4992 iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); |
|
4993 } |
|
4994 |
|
4995 void CAlfBridge::TransitionFinishedHandlerL(TInt aHandle) |
|
4996 { |
|
4997 for (TInt i=0;i<iEffectCleanupStack.Count();i++) |
|
4998 { |
|
4999 if(aHandle==iEffectCleanupStack[i].iHandle) |
|
5000 { |
|
5001 // effect might have been cleaned even without this callback. e.g. closing of applicaion while option menu disappear |
|
5002 // effect is running, would cause it. There is no need to request cleaning again. |
|
5003 iFinishedCleanupStackEffects.Append(aHandle); |
|
5004 } |
|
5005 } |
|
5006 // If the finish request comes from the plugin, the plugin is not interested |
|
5007 // in getting a notification of the transition end. |
|
5008 __ALFFXLOGSTRING1("Gfx transition finished, handle %d", aHandle ); |
|
5009 if ( aHandle == KErrNotFound ) |
|
5010 { |
|
5011 __ALFFXLOGSTRING("invalid handle"); |
|
5012 } |
|
5013 // alftranstion plugin may cancel end timers connected to this effect |
|
5014 TBool fsEffectDone = iFullScreenEffectData && aHandle == iFullScreenEffectData->iHandle; |
|
5015 if ( fsEffectDone ) |
|
5016 { |
|
5017 aHandle = iFullScreenEffectData->iCompletionHandle; |
|
5018 } |
|
5019 RProperty::Set( KPSAlfDomain, KAlfTransitionStatus, aHandle ); |
|
5020 |
|
5021 // Effect finished |
|
5022 if ( fsEffectDone ) |
|
5023 { |
|
5024 delete iFullScreenEffectData; |
|
5025 iFullScreenEffectData = NULL; |
|
5026 } |
|
5027 } |
|
5028 |
|
5029 |
|
5030 void CAlfBridge::PrintAllocMem() |
|
5031 { |
|
5032 #ifdef _ALF_LOGGING |
|
5033 TInt allocCells = 0; |
|
5034 TInt allocSpace = 0; |
|
5035 TInt freeSpace = 0; |
|
5036 TInt largestFreeBlock = 0; |
|
5037 allocCells = User::AllocSize( allocSpace ); |
|
5038 freeSpace = User::Available( largestFreeBlock ); |
|
5039 __ALFLOGSTRING2("CAlfBridge::PrintAllocMem - alloc cells %d, alloc space %d", allocCells, allocSpace ); |
|
5040 __ALFLOGSTRING2("CAlfBridge::PrintAllocMem - free space %d, largest free block %d", freeSpace, largestFreeBlock ); |
|
5041 #endif |
|
5042 } |
|
5043 |
|
5044 // --------------------------------------------------------------------------- |
|
5045 // DebugPrintControlGroupOrder |
|
5046 // |
|
5047 // Note, that HUI_DEBUG_TRACK_DRAWING must be enabled if you want to see the |
|
5048 // real process names |
|
5049 // --------------------------------------------------------------------------- |
|
5050 // |
|
5051 |
|
5052 #ifdef ALF_DEBUG_PRINT_WINDOWGROUP_ORDER |
|
5053 void CAlfBridge::DebugPrintControlGroupOrder(CAlfScreen& aScreen, CHuiRoster& aRoster, CHuiControlGroup& aGroup) |
|
5054 { |
|
5055 __ALFLOGSTRING(">> ---AFTER-----"); |
|
5056 for (TInt i=0; i<aRoster.Count();i++) |
|
5057 { |
|
5058 CHuiControlGroup& indexedGroup = aRoster.ControlGroup(i); |
|
5059 |
|
5060 if (&indexedGroup == &aGroup) |
|
5061 { |
|
5062 __ALFLOGSTRING("<<"); |
|
5063 } |
|
5064 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
5065 TInt clientWindowGroupId = FindClientWindowGroupId( aScreen.iScreenNum, indexedGroup ); |
|
5066 |
|
5067 TFileName processName = iCommandDebug->WServClientFileName( clientWindowGroupId, CHuiStatic::WsSession() ); |
|
5068 #endif |
|
5069 if (indexedGroup.Control(0).Role() == EAlfWindowGroupContainer) |
|
5070 { |
|
5071 if (aRoster.ControlGroup(i).ResourceId() == iAlfWindowGroupNodeId) |
|
5072 { |
|
5073 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
5074 __ALFLOGSTRING2(">> %d WINDOW GROUP (ALF), %d", i, clientWindowGroupId); |
|
5075 #endif |
|
5076 } |
|
5077 else |
|
5078 { |
|
5079 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
5080 __ALFLOGSTRING3(">> %d WINDOW GROUP %S, %d", i, &processName, clientWindowGroupId); |
|
5081 #else |
|
5082 __ALFLOGSTRING1(">> %d WINDOW GROUP", i); |
|
5083 #endif |
|
5084 } |
|
5085 } |
|
5086 else if (indexedGroup.Control(0).Role() == EAlfSessionContainer) |
|
5087 { |
|
5088 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
5089 __ALFLOGSTRING2(">> %d ALF GROUP, %d", i, clientWindowGroupId); |
|
5090 #endif |
|
5091 } |
|
5092 else if (indexedGroup.Control(0).Role() == EAlfWindowFloatingSpriteContainer) |
|
5093 { |
|
5094 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
5095 __ALFLOGSTRING3(">> %d FLOATING SPRITE GROUP %S, %d", i, &processName, clientWindowGroupId); |
|
5096 #else |
|
5097 __ALFLOGSTRING1(">> %d FLOATING SPRITE GROUP", i); |
|
5098 #endif |
|
5099 } |
|
5100 else if (indexedGroup.Control(0).Role() == EAlfFullScreenEffectContainer) |
|
5101 { |
|
5102 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
5103 __ALFLOGSTRING3(">> %d EFFECT GROUP %S, %d", i, &processName, clientWindowGroupId ); |
|
5104 #else |
|
5105 __ALFLOGSTRING1(">> %d EFFECT GROUP", i); |
|
5106 #endif |
|
5107 } |
|
5108 else |
|
5109 { |
|
5110 #ifdef HUI_DEBUG_TRACK_DRAWING |
|
5111 __ALFLOGSTRING3(">> %d UNKNOWN GROUP ?!!? %S, %d", i, &processName, clientWindowGroupId ); |
|
5112 #endif |
|
5113 } |
|
5114 |
|
5115 if (&indexedGroup == &aGroup) |
|
5116 { |
|
5117 __ALFLOGSTRING("<<"); |
|
5118 } |
|
5119 } |
|
5120 |
|
5121 // Print the group that has keyboard focus |
|
5122 TInt focusWindowGroupId = CHuiStatic::WsSession().GetFocusWindowGroup(); |
|
5123 TFileName processName; |
|
5124 TThreadId threadId; |
|
5125 TInt error = CHuiStatic::WsSession().GetWindowGroupClientThreadId( focusWindowGroupId, threadId ); |
|
5126 RThread thread; |
|
5127 TInt err = thread.Open( threadId ); |
|
5128 if( !err ) |
|
5129 { |
|
5130 RProcess process; |
|
5131 err = thread.Process( process ); |
|
5132 if( !err ) |
|
5133 { |
|
5134 processName = process.FileName(); |
|
5135 __ALFLOGSTRING2( ">> Keyboard focus group: %S, %d", &processName, focusWindowGroupId ); |
|
5136 } |
|
5137 process.Close(); |
|
5138 thread.Close(); |
|
5139 } |
|
5140 __ALFLOGSTRING(">> ---------------"); |
|
5141 } |
|
5142 #else |
|
5143 void CAlfBridge::DebugPrintControlGroupOrder(CAlfScreen& /*aScreen*/, CHuiRoster& /*aRoster*/, CHuiControlGroup& /*aGroup*/) |
|
5144 { |
|
5145 } |
|
5146 #endif |
|
5147 |
|
5148 #ifdef ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER |
|
5149 void CAlfBridge::VisualizeControlGroupOrderL(CHuiRoster& aRoster, CHuiControlGroup& /*aGroup*/) |
|
5150 { |
|
5151 TInt nbrofcolums = 3; |
|
5152 TInt nbrofrows = 3; |
|
5153 TInt gridIndex = 0; |
|
5154 TBool skipEmpty = EFalse; |
|
5155 if (aRoster.Count() > 3) |
|
5156 { |
|
5157 for (TInt i=aRoster.Count() - 3; i>0; i--) |
|
5158 { |
|
5159 CHuiControl& control = aRoster.ControlGroup(i).Control(0); |
|
5160 if (skipEmpty) |
|
5161 { |
|
5162 TBool empty = ETrue; |
|
5163 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0); |
|
5164 for (TInt j=layout->Count()-1; j >= 0; j--) |
|
5165 { |
|
5166 CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*) &layout->Visual(j); |
|
5167 if (canvasVisual && canvasVisual->DisplayRect().Size().Round() != TSize(0,0) && canvasVisual->PaintedAreaCount()) |
|
5168 { |
|
5169 empty = EFalse; |
|
5170 break; |
|
5171 } |
|
5172 } |
|
5173 |
|
5174 if (empty && skipEmpty) |
|
5175 { |
|
5176 continue; |
|
5177 } |
|
5178 } |
|
5179 |
|
5180 TSize screensize = HuiUtil::ScreenSize(); |
|
5181 CHuiTransformation::TTransform& step = aRoster.ControlGroup(i).Transformation().Step(0); |
|
5182 step.iParams[EHuiTransformParamTranslateX].Set((gridIndex % nbrofcolums) * (screensize.iWidth/nbrofcolums), 500); |
|
5183 step.iParams[EHuiTransformParamTranslateY].Set((gridIndex / nbrofrows) * (screensize.iHeight/nbrofrows), 500); |
|
5184 gridIndex++; |
|
5185 } |
|
5186 } |
|
5187 iAlfScreens[0]->iDisplay->SetClearBackgroundL(CHuiDisplay::EClearWithSkinBackground); |
|
5188 } |
|
5189 #else |
|
5190 void CAlfBridge::VisualizeControlGroupOrderL(CHuiRoster& /*aRoster*/, CHuiControlGroup& /*aGroup*/) |
|
5191 { |
|
5192 } |
|
5193 #endif |
|
5194 |
|
5195 // --------------------------------------------------------------------------- |
|
5196 // PostQTCommandBufferL |
|
5197 // --------------------------------------------------------------------------- |
|
5198 // |
|
5199 void CAlfBridge::PostQTCommandBufferL( TAlfQtCommandBufferParams params ) |
|
5200 { |
|
5201 CHuiCanvasVisual* huiVisual = NULL; |
|
5202 if ((*iHost)) |
|
5203 { |
|
5204 if( (*iHost)->StreamerServer() ) |
|
5205 { |
|
5206 if ((*iHost)->StreamerServer()->WindowMgr()) |
|
5207 { |
|
5208 RArray<TAlfWServInfo> winInfoList; |
|
5209 |
|
5210 (*iHost)->StreamerServer()->WindowMgr()->GetWinInfoListL( params.iWsWgId, |
|
5211 params.iWsClientId, winInfoList ); |
|
5212 |
|
5213 for ( TInt i= 0; i<winInfoList.Count(); i++ ) |
|
5214 { |
|
5215 if( winInfoList[i].iClientSideId.iWindowIdentifer == params.iWsClientId ) |
|
5216 { |
|
5217 huiVisual = FindVisual( winInfoList[i].iRefId.iWindowIdentifer ); |
|
5218 break; |
|
5219 } |
|
5220 } |
|
5221 winInfoList.Close(); |
|
5222 } |
|
5223 } |
|
5224 } |
|
5225 |
|
5226 if ( huiVisual ) |
|
5227 { |
|
5228 TPtrC8 commands( (TUint8 *)params.iPtr, params.iLength ); |
|
5229 TAlfCommandBufferStatus bufferStatus = params.iBufferStatus; |
|
5230 huiVisual->SetCommandType( 1 ); // set to ECommandBufferWs should it be some QT specific? |
|
5231 if ( bufferStatus == EComplete ) |
|
5232 { |
|
5233 huiVisual->ClearCommandSet(); |
|
5234 huiVisual->AddCommandSetL(commands); |
|
5235 } |
|
5236 else if ( bufferStatus == EPartial ) |
|
5237 { |
|
5238 huiVisual->AddPartialCommandSetL( commands, EFalse ); |
|
5239 } |
|
5240 else if ( bufferStatus == ELastPart ) |
|
5241 { |
|
5242 huiVisual->AddPartialCommandSetL( commands, ETrue ); |
|
5243 } |
|
5244 } |
|
5245 } |
|
5246 |
|
5247 |
|
5248 // --------------------------------------------------------------------------- |
|
5249 // SetClientWindowForDrawingL |
|
5250 // |
|
5251 // Note: One external content visual can exist in one canvas visual at the |
|
5252 // time. When external content visual is deleted, in destructor, it removes |
|
5253 // pointers to it from all canvas visuals. So canvasVisual->ExternalContent() |
|
5254 // always returns a valid pointer, or NULL. The parameter aRootVisual can |
|
5255 // be NULL, which means that the external content is removed from the canvas |
|
5256 // visual |
|
5257 // --------------------------------------------------------------------------- |
|
5258 // |
|
5259 void CAlfBridge::SetClientWindowForDrawingL(TInt aWindowGroupId, TInt aClientWindowHandle, |
|
5260 CHuiVisual* aExternalContentVisual) |
|
5261 { |
|
5262 RArray<TAlfWServInfo> winInfoList; |
|
5263 CleanupClosePushL(winInfoList); |
|
5264 |
|
5265 // Find canvas visual for the RWindow |
|
5266 |
|
5267 (*iHost)->StreamerServer()->WindowMgr()->GetWinInfoListL(aWindowGroupId, aClientWindowHandle, winInfoList ); |
|
5268 if(winInfoList.Count() != 1) |
|
5269 { |
|
5270 User::Leave(KErrArgument); |
|
5271 } |
|
5272 |
|
5273 CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)FindVisual(winInfoList[0].iRefId.iWindowIdentifer); |
|
5274 if (!canvasVisual) |
|
5275 { |
|
5276 User::Leave(KErrNotFound); |
|
5277 } |
|
5278 |
|
5279 // Current external content |
|
5280 CHuiVisual* currentContent = canvasVisual->ExternalContent(); |
|
5281 |
|
5282 if (!aExternalContentVisual) |
|
5283 { |
|
5284 // Do not draw external content any more. |
|
5285 |
|
5286 // Disable external content for the canvas visual |
|
5287 canvasVisual->SetExternalContentL(NULL); |
|
5288 // For the current content, enable drawing it in the original visual tree. |
|
5289 if (currentContent) |
|
5290 { |
|
5291 currentContent->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
|
5292 } |
|
5293 } |
|
5294 else if (!(aExternalContentVisual->Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)) |
|
5295 { |
|
5296 // The visual is not yet used by other canvas visual |
|
5297 |
|
5298 // Enable external content for the canvas visual |
|
5299 canvasVisual->SetExternalContentL(aExternalContentVisual); |
|
5300 // For the current content, enable drawing it in the original visual tree. |
|
5301 if (currentContent) |
|
5302 { |
|
5303 currentContent->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
|
5304 } |
|
5305 // Disable normal drawing and start using as external content |
|
5306 aExternalContentVisual->SetFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
|
5307 } |
|
5308 else |
|
5309 { |
|
5310 // aExternalContentVisual is already used as an external content for some visual |
|
5311 User::Leave(KErrAlreadyExists); |
|
5312 } |
|
5313 |
|
5314 CleanupStack::PopAndDestroy(); // winInfoList |
|
5315 } |
|
5316 |
|
5317 void CAlfBridge::SetVisualTreeVisibilityChanged(TBool aChanged) |
|
5318 { |
|
5319 for (TInt i=0; i<iAlfScreens.Count();i++) |
|
5320 { |
|
5321 iAlfScreens[i]->iVisualTreeVisibilityChanged = aChanged; |
|
5322 } |
|
5323 } |
|
5324 |
|
5325 // --------------------------------------------------------------------------- |
|
5326 // --------------------------------------------------------------------------- |
|
5327 // |
|
5328 void CAlfBridge::EnableSwRenderingL(TBool aEnable) |
|
5329 { |
|
5330 if (aEnable == iSwRenderingEnabled) |
|
5331 { |
|
5332 return; |
|
5333 } |
|
5334 |
|
5335 iSwRenderingEnabled = aEnable; |
|
5336 for (TInt i=0; i<iAlfScreens.Count();i++) |
|
5337 { |
|
5338 PrepareSwRenderingTarget(iAlfScreens[i]); |
|
5339 |
|
5340 if (iSwRenderingEnabled) |
|
5341 { |
|
5342 CHuiTexture* texture = CHuiTexture::NewL(); |
|
5343 CleanupStack::PushL(texture); |
|
5344 iAlfScreens[i]->iDisplay->SetForegroundBitmapL( iAlfScreens[i]->iSwRenderingTarget ); |
|
5345 CleanupStack::Pop(texture); |
|
5346 iAlfScreens[i]->iDisplay->SetForegroundTexture(texture); |
|
5347 iAlfScreens[i]->iDisplay->iRosterObservers.AppendL(*this); |
|
5348 } |
|
5349 else |
|
5350 { |
|
5351 iAlfScreens[i]->iDisplay->SetForegroundBitmapL(NULL); |
|
5352 iAlfScreens[i]->iDisplay->SetForegroundTexture(NULL); |
|
5353 iAlfScreens[i]->iDisplay->iRosterObservers.Remove(*this); |
|
5354 } |
|
5355 |
|
5356 // SetCapturingBufferL is called from HandleVisualVisibility. |
|
5357 iAlfScreens[i]->SetVisualTreeVisibilityChanged(ETrue); |
|
5358 } |
|
5359 } |
|
5360 |
|
5361 // --------------------------------------------------------------------------- |
|
5362 // --------------------------------------------------------------------------- |
|
5363 // |
|
5364 void CAlfBridge::UploadSwRenderingTargetL(CAlfScreen* aScreen) |
|
5365 { |
|
5366 if (iSwRenderingEnabled) |
|
5367 { |
|
5368 CHuiTexture* texture = aScreen->iDisplay->ForegroundTexture(); |
|
5369 if (texture && aScreen->iSwRenderingTarget) |
|
5370 { |
|
5371 texture->UploadL(*aScreen->iSwRenderingTarget, NULL); |
|
5372 } |
|
5373 } |
|
5374 } |
|
5375 |
|
5376 // --------------------------------------------------------------------------- |
|
5377 // --------------------------------------------------------------------------- |
|
5378 // |
|
5379 TBool CAlfBridge::PrepareSwRenderingTarget( CAlfScreen* aScreen ) |
|
5380 { |
|
5381 TBool modified = EFalse; |
|
5382 |
|
5383 // Check ultra low memory mode here |
|
5384 if (iHuiEnv->MemoryLevel() <= EHuiMemoryLevelLowest) |
|
5385 { |
|
5386 if (!aScreen->iSwRenderingTarget) |
|
5387 { |
|
5388 // screen owns this bitmap |
|
5389 aScreen->iSwRenderingTarget = new CFbsBitmap; |
|
5390 if (aScreen->iSwRenderingTarget) |
|
5391 { |
|
5392 aScreen->iSwRenderingTarget->Create(aScreen->Size(), EColor16MA); |
|
5393 modified = ETrue; |
|
5394 } |
|
5395 } |
|
5396 |
|
5397 if (aScreen->iSwRenderingTarget) |
|
5398 { |
|
5399 if (aScreen->iSwRenderingTarget->SizeInPixels() != aScreen->Size()) |
|
5400 { |
|
5401 aScreen->iSwRenderingTarget->Resize(aScreen->Size()); |
|
5402 modified = ETrue; |
|
5403 } |
|
5404 // For tests |
|
5405 //TUint32* data = aScreen->iSwRenderingTarget->DataAddress(); |
|
5406 } |
|
5407 } |
|
5408 else |
|
5409 { |
|
5410 delete aScreen->iSwRenderingTarget; |
|
5411 aScreen->iSwRenderingTarget = NULL; |
|
5412 modified = ETrue; |
|
5413 } |
|
5414 |
|
5415 return modified; |
|
5416 } |
|
5417 |
|
5418 // --------------------------------------------------------------------------- |
|
5419 // --------------------------------------------------------------------------- |
|
5420 // |
|
5421 void CAlfBridge::SetMemoryLevel(THuiMemoryLevel aMemoryLevel) |
|
5422 { |
|
5423 iCurrentMemoryLevel = aMemoryLevel; |
|
5424 DoUpdateMemoryLevel(); |
|
5425 } |
|
5426 |
|
5427 // --------------------------------------------------------------------------- |
|
5428 // --------------------------------------------------------------------------- |
|
5429 // |
|
5430 void CAlfBridge::SetLowMemory(TBool aEnabled) |
|
5431 { |
|
5432 iLowMemoryMode = aEnabled; |
|
5433 DoUpdateMemoryLevel(); |
|
5434 } |
|
5435 |
|
5436 // --------------------------------------------------------------------------- |
|
5437 // --------------------------------------------------------------------------- |
|
5438 // |
|
5439 TInt CAlfBridge::ForceSwRendering(TBool aEnabled) |
|
5440 { |
|
5441 iForcedSwRendering = aEnabled; |
|
5442 DoUpdateMemoryLevel(); |
|
5443 return KErrNone; |
|
5444 } |
|
5445 |
|
5446 // --------------------------------------------------------------------------- |
|
5447 // This decides memory level for core toolkit. This should the only place |
|
5448 // where core toolkit memory level is modified. |
|
5449 // --------------------------------------------------------------------------- |
|
5450 // |
|
5451 void CAlfBridge::DoUpdateMemoryLevel() |
|
5452 { |
|
5453 THuiMemoryLevel memoryLevel = iCurrentMemoryLevel; |
|
5454 if ( iLowMemoryMode && ( memoryLevel > EHuiMemoryLevelLow ) ) |
|
5455 { |
|
5456 memoryLevel = EHuiMemoryLevelLow; |
|
5457 } |
|
5458 if ( iForcedSwRendering && ( memoryLevel > EHuiMemoryLevelLowest ) ) |
|
5459 { |
|
5460 // For now, we use memory level to force SW rendering |
|
5461 // to be used. |
|
5462 memoryLevel = EHuiMemoryLevelLowest; |
|
5463 } |
|
5464 |
|
5465 if ( memoryLevel != iHuiEnv->MemoryLevel() ) |
|
5466 { |
|
5467 __ALFLOGSTRING1("CAlfBridge::DoUpdateMemoryLevel -> %d", memoryLevel); |
|
5468 if ( memoryLevel <= EHuiMemoryLevelLowest) |
|
5469 { |
|
5470 LowMemoryCancelAllEffects(); |
|
5471 } |
|
5472 |
|
5473 iHuiEnv->NotifyMemoryLevel(memoryLevel); |
|
5474 if (memoryLevel <= EHuiMemoryLevelLowest) |
|
5475 { |
|
5476 TRAP_IGNORE(EnableSwRenderingL(ETrue)); |
|
5477 } |
|
5478 else |
|
5479 { |
|
5480 TRAP_IGNORE(EnableSwRenderingL(EFalse)); |
|
5481 } |
|
5482 } |
|
5483 } |
|
5484 |
|
5485 // --------------------------------------------------------------------------- |
|
5486 // --------------------------------------------------------------------------- |
|
5487 // |
|
5488 void CAlfBridge::LowMemoryCancelAllEffects() |
|
5489 { |
|
5490 __ALFLOGSTRING("CAlfBridge::LowMemoryCancelAllEffects"); |
|
5491 iLayoutSwitchEffectCoordinator->Cancel(); |
|
5492 HandleGfxStopEvent( EFalse ); |
|
5493 __ALFLOGSTRING("CAlfBridge::LowMemoryCancelAllEffects done"); |
|
5494 } |
|
5495 |
|
5496 // --------------------------------------------------------------------------- |
|
5497 // --------------------------------------------------------------------------- |
|
5498 // |
|
5499 void CAlfBridge::NotifyRosterDrawStart(CHuiDisplay& /*aDisplay*/) |
|
5500 { |
|
5501 // Do nothing |
|
5502 } |
|
5503 |
|
5504 // --------------------------------------------------------------------------- |
|
5505 // --------------------------------------------------------------------------- |
|
5506 // |
|
5507 void CAlfBridge::NotifyRosterDrawEnd(CHuiDisplay& aDisplay) |
|
5508 { |
|
5509 TInt screenNumber = ResolveScreenNumber(aDisplay); |
|
5510 TRAP_IGNORE(UploadSwRenderingTargetL(iAlfScreens[screenNumber])); |
|
5511 } |
|
5512 |
|
5513 // end of file |