|
1 /* |
|
2 * Copyright (c) 2004-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: Animates effect queues. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <hal.h> |
|
21 #include <hal_data.h> |
|
22 #include <AknsUtils.h> |
|
23 #include <babitflags.h> |
|
24 |
|
25 #include <hwrmlightdomaincrkeys.h> |
|
26 |
|
27 #include "AknsRlEffectPlugin.h" |
|
28 #include "AknsRlCommand.h" |
|
29 |
|
30 #include "AknsAppSkinInstance.h" |
|
31 #include "AknsAlAnimatorBmp.h" |
|
32 #include "AknsAlShared.h" |
|
33 #include "AknsAlAnimationFactory.h" |
|
34 #include "AknsAlEffectContext.h" |
|
35 #include "AknsAlDataAccess.h" |
|
36 #include <AknsEffectAnim.h> // For the animation state enum |
|
37 |
|
38 #include "AknsDebug.h" |
|
39 |
|
40 // CONSTANTS |
|
41 |
|
42 const TInt KAlMaxDeltaTime = 65536; // In milliseconds, ~65 seconds |
|
43 |
|
44 // =============================== HELPERS ===================================== |
|
45 /** |
|
46 * Utility class for binding size changes to animation value parameters. |
|
47 */ |
|
48 NONSHARABLE_CLASS( CAknsAlSizeBoundParam ): |
|
49 public CBase, |
|
50 public MAknsRlParameterIterator |
|
51 { |
|
52 private: |
|
53 // Internal flag indices |
|
54 enum TFlag |
|
55 { |
|
56 EFlagW = 0, |
|
57 EFlagH = 1, |
|
58 EFlagIter = 2 |
|
59 }; |
|
60 |
|
61 protected: |
|
62 CAknsAlSizeBoundParam(); |
|
63 void ConstructL( MAknsAlAnimationValue* aValue, |
|
64 const TDesC& aName, TInt aFlags ); |
|
65 |
|
66 public: |
|
67 ~CAknsAlSizeBoundParam(); |
|
68 static CAknsAlSizeBoundParam* NewL( MAknsAlAnimationValue* aValue, |
|
69 const TDesC& aName, TInt aFlags ); |
|
70 void SizeChangedL( const TSize& aNewSize ); |
|
71 |
|
72 public: // Implementation of MAknsRlParameterIterator |
|
73 TBool HasNext(); |
|
74 const TAknsRlParameterData* NextL(); |
|
75 |
|
76 private: |
|
77 // Referenced only |
|
78 MAknsAlAnimationValue* iAnimationValue; |
|
79 // Owned |
|
80 HBufC* iName; |
|
81 /// Combines the x, y, xy flags with interator flag. |
|
82 TBitFlags32 iFlags; |
|
83 TAknsRlParameterData iIteratorData; |
|
84 // Stores the current size |
|
85 TBuf16<2> iSize; |
|
86 }; |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CAknsAlSizeBoundParam::CAknsAlSizeBoundParam |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 CAknsAlSizeBoundParam::CAknsAlSizeBoundParam() |
|
93 { |
|
94 // Derived from CBase -> members are zeroed |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CAknsAlSizeBoundParam::ConstructL |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CAknsAlSizeBoundParam::ConstructL( MAknsAlAnimationValue* aValue, |
|
102 const TDesC& aName, TInt aFlags ) |
|
103 { |
|
104 if( NULL == aValue ) |
|
105 User::Leave( KErrArgument ); |
|
106 |
|
107 iAnimationValue = aValue; |
|
108 iName = aName.AllocL(); |
|
109 iFlags.SetValue( aFlags ); |
|
110 |
|
111 iSize.SetLength( 2 ); |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CAknsAlSizeBoundParam::~CAknsAlSizeBoundParam |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 CAknsAlSizeBoundParam::~CAknsAlSizeBoundParam() |
|
119 { |
|
120 delete iName; //lint |
|
121 iAnimationValue = NULL; // Removes lint nag |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CAknsAlSizeBoundParam::NewL |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 CAknsAlSizeBoundParam* CAknsAlSizeBoundParam::NewL( |
|
129 MAknsAlAnimationValue* aValue, |
|
130 const TDesC& aName, |
|
131 TInt aFlags ) |
|
132 { |
|
133 CAknsAlSizeBoundParam* self = new(ELeave) CAknsAlSizeBoundParam(); |
|
134 CleanupStack::PushL( self ); |
|
135 self->ConstructL( aValue, aName, aFlags ); |
|
136 CleanupStack::Pop( self ); |
|
137 return self; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CAknsAlSizeBoundParam::SizeChangedL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CAknsAlSizeBoundParam::SizeChangedL( const TSize& aNewSize ) |
|
145 { |
|
146 iSize[0] = TInt16( aNewSize.iWidth ); |
|
147 iSize[1] = TInt16( aNewSize.iHeight ); |
|
148 |
|
149 // Push the changed parameter to animation value |
|
150 iFlags.Set( EFlagIter ); |
|
151 iAnimationValue->SetParametersL( *this ); |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CAknsAlSizeBoundParam::HasNext |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 TBool CAknsAlSizeBoundParam::HasNext() |
|
159 { |
|
160 if( !iFlags.IsSet( EFlagIter ) ) |
|
161 return ETrue; |
|
162 |
|
163 return EFalse; |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CAknsAlSizeBoundParam::NextL |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 const TAknsRlParameterData* CAknsAlSizeBoundParam::NextL() |
|
171 { |
|
172 if( iFlags.IsSet( EFlagIter ) ) |
|
173 User::Leave( KErrOverflow ); |
|
174 |
|
175 iIteratorData.iName = iName; |
|
176 |
|
177 if( iFlags.IsSet( EFlagW ) && iFlags.IsSet( EFlagH ) ) |
|
178 { |
|
179 iIteratorData.iType = EAknsRlParameterTypeString; |
|
180 iIteratorData.iString = &iSize; |
|
181 } |
|
182 else if( iFlags.IsSet( EFlagW ) ) |
|
183 { |
|
184 iIteratorData.iType = EAknsRlParameterTypeNumber; |
|
185 iIteratorData.iNumber = iSize[0]; |
|
186 } |
|
187 else // Must be EFlagH |
|
188 { |
|
189 iIteratorData.iType = EAknsRlParameterTypeNumber; |
|
190 iIteratorData.iNumber = iSize[1]; |
|
191 } |
|
192 |
|
193 // Mark the iterator flag |
|
194 iFlags.Set( EFlagIter ); |
|
195 |
|
196 return &iIteratorData; |
|
197 } |
|
198 |
|
199 // ============================ MEMBER FUNCTIONS =============================== |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CAknsAlAnimatorBmp::CAknsAlAnimatorBmp |
|
203 // C++ default constructor can NOT contain any code, that might leave. |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 CAknsAlAnimatorBmp::CAknsAlAnimatorBmp( MAknsEffectAnimObserver* aObserver ): |
|
207 iObserver( aObserver ) |
|
208 { |
|
209 // Derived from CBase, members zeroed |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CAknsAlAnimatorBmp::ConstructL |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 void CAknsAlAnimatorBmp::ConstructL() |
|
217 { |
|
218 iState = EAknsAnimStateStopped; |
|
219 |
|
220 iTimer = CPeriodic::NewL( CActive::EPriorityIdle ); |
|
221 |
|
222 User::LeaveIfError( HAL::Get( HALData::ESystemTickPeriod, iMsPerTick ) ); |
|
223 // HAL returns microseconds, convert to milliseconds |
|
224 iMsPerTick = iMsPerTick / 1000; |
|
225 |
|
226 iContext = CAknsAlEffectContext::NewL(); |
|
227 |
|
228 iLightsClient = CHWRMLight::NewL( this ); |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // Destructor |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 CAknsAlAnimatorBmp::~CAknsAlAnimatorBmp() |
|
236 { |
|
237 /*lint -save -e1551 */ // No exceptions are thrown |
|
238 // Release effect filters |
|
239 TInt count = iAnimationCommands.Count(); |
|
240 for( TInt i=0; i < count; i++ ) |
|
241 { |
|
242 // Activate effects |
|
243 CAknsAlAnimationCommand* cmd = iAnimationCommands[i]; |
|
244 MAknsRlEffect* effect = cmd->Effect(); |
|
245 effect->Deactivate(); |
|
246 effect->Release(); |
|
247 } |
|
248 |
|
249 delete iTimer; |
|
250 delete iContext; |
|
251 |
|
252 iPreprocessCommands.ResetAndDestroy(); |
|
253 iAnimationCommands.ResetAndDestroy(); |
|
254 iValueContainers.ResetAndDestroy(); |
|
255 iTimingModels.ResetAndDestroy(); |
|
256 iSizeBoundParams.ResetAndDestroy(); |
|
257 |
|
258 delete iLightsClient; |
|
259 /*lint -restore */ |
|
260 } |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // CAknsAlAnimatorBmp::NewL |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 CAknsAlAnimatorBmp* CAknsAlAnimatorBmp::NewL( MAknsEffectAnimObserver* aObserver ) |
|
267 { |
|
268 if( !aObserver ) |
|
269 User::Leave( KErrArgument ); |
|
270 |
|
271 CAknsAlAnimatorBmp* self = new(ELeave) CAknsAlAnimatorBmp( aObserver ); |
|
272 CleanupStack::PushL(self); |
|
273 self->ConstructL(); |
|
274 CleanupStack::Pop(); |
|
275 return self; |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CAknsAlAnimatorBmp::ConstructFromSkinL |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 TBool CAknsAlAnimatorBmp::ConstructFromSkinL( const TAknsItemID& aItemID ) |
|
283 { |
|
284 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
285 if( NULL == skin ) |
|
286 User::Leave( KErrBadHandle ); |
|
287 |
|
288 // TODO: We need to pass skin server session to bitmap context (it is |
|
289 // required by ApplyGfx plugin). This is bad style but this is currently |
|
290 // the only way to do it (without BC break). In ideal case you could query |
|
291 // the server session via the skin instance interface. Note that by |
|
292 // referring to AppSkinInstance we create an unwanted dependency to other |
|
293 // parts of skin library. Fortunately, there is no need to link |
|
294 // AppSkinInstance as we are using the session member directly. |
|
295 CAknsAppSkinInstance* appSkin = static_cast<CAknsAppSkinInstance*>(skin); //lint !e1774 dynamic_cast not allowed |
|
296 iContext->SetSkinSrvSession( &appSkin->iSession ); |
|
297 |
|
298 // Query animation instructions from skin |
|
299 CAknsItemData* item = skin->GetCachedItemData( aItemID, EAknsITAnimation ); |
|
300 if( !item ) |
|
301 return EFalse; // Item was not found |
|
302 |
|
303 // Querying EAknsITAnimation quarantees that the pointer is of right type |
|
304 CAknsAnimationItemData* skinData = static_cast<CAknsAnimationItemData*>( item ); //lint !e1774 dynamic_cast not allowed |
|
305 |
|
306 // Morphing animations are not for highlights |
|
307 if( skinData->Morphing() ) |
|
308 { |
|
309 return EFalse; // Item was found, but we ignore morphing animations |
|
310 } |
|
311 |
|
312 iMinimumInterval = skinData->MinInterval(); |
|
313 |
|
314 iInputLayerMode = skinData->InputLayerMode(); |
|
315 iInputLayerIndex = skinData->InputLayer(); |
|
316 iOutputLayerMode = skinData->OutputLayerMode(); |
|
317 iOutputLayerIndex = skinData->OutputLayer(); |
|
318 |
|
319 CreateTimingModelsL( *skinData ); |
|
320 CreateAnimationValueContainersL( *skinData ); |
|
321 CreatePreprocessCommandsL( *skinData ); |
|
322 CreateAnimationCommandsL( *skinData ); |
|
323 CreateSizeBoundParamsL( *skinData ); |
|
324 |
|
325 return ETrue; |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CAknsAlAnimatorBmp::ConstructFromItemL |
|
330 // Testing time functionality only. |
|
331 // ----------------------------------------------------------------------------- |
|
332 // |
|
333 TBool CAknsAlAnimatorBmp::ConstructFromItemL( const CAknsAnimationItemData& aData, |
|
334 RAknsSrvSession* aSession ) |
|
335 { |
|
336 // Morphing animations are not for highlights |
|
337 if( aData.Morphing() ) |
|
338 { |
|
339 return EFalse; // Item was found, but we ignore morphing animations |
|
340 } |
|
341 |
|
342 iContext->SetSkinSrvSession( aSession ); |
|
343 |
|
344 iMinimumInterval = aData.MinInterval(); |
|
345 |
|
346 iInputLayerMode = aData.InputLayerMode(); |
|
347 iInputLayerIndex = aData.InputLayer(); |
|
348 iOutputLayerMode = aData.OutputLayerMode(); |
|
349 iOutputLayerIndex = aData.OutputLayer(); |
|
350 |
|
351 CreateTimingModelsL( aData ); |
|
352 CreateAnimationValueContainersL( aData ); |
|
353 CreatePreprocessCommandsL( aData ); |
|
354 CreateAnimationCommandsL( aData ); |
|
355 CreateSizeBoundParamsL( aData ); |
|
356 |
|
357 return ETrue; |
|
358 } |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // CAknsAlAnimatorBmp::BeginConfigLayersL |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 void CAknsAlAnimatorBmp::BeginConfigLayersL( const TSize& aLayerSize, |
|
365 TDisplayMode aRgbMode ) |
|
366 { |
|
367 if( RenderError() ) |
|
368 User::Leave( iRenderError ); |
|
369 |
|
370 // Make sure we have a valid size |
|
371 if( aLayerSize.iWidth < KAknsAlAnimMinimumWidth || |
|
372 aLayerSize.iHeight < KAknsAlAnimMinimumHeight ) |
|
373 User::Leave( KErrArgument ); |
|
374 |
|
375 // Configure |
|
376 iContext->ConfigureL( aLayerSize, aRgbMode, |
|
377 iInputLayerIndex, |
|
378 iInputLayerMode ); |
|
379 } |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // CAknsAlAnimatorBmp::EndConfigLayersL |
|
383 // ----------------------------------------------------------------------------- |
|
384 // |
|
385 void CAknsAlAnimatorBmp::EndConfigLayersL( TBool aAboutToStart ) |
|
386 { |
|
387 // Do the preprocessing step |
|
388 PreprocessL(); |
|
389 |
|
390 // Because layer size may have changed and some layers may have been lost |
|
391 // we need to restart the animation (while preserving its state). |
|
392 TInt originalState = iState; |
|
393 |
|
394 if( EAknsAnimStateRunning == originalState ) |
|
395 { |
|
396 // Starting will also stop animation first |
|
397 StartAnimationL( EFalse, ETrue ); |
|
398 User::LeaveIfError( UpdateOutput() ); |
|
399 } |
|
400 else // Animation must be stopped, paused or finished |
|
401 { |
|
402 // Starting will also stop animation first |
|
403 StartAnimationL( EFalse, EFalse ); |
|
404 User::LeaveIfError( UpdateOutput() ); |
|
405 iState = originalState; |
|
406 |
|
407 if( ( EAknsAnimStateStopped == originalState ) && !aAboutToStart ) |
|
408 { |
|
409 // Stopping releases input layers and plugins |
|
410 StopAndRelease( ETrue, ETrue ); |
|
411 } |
|
412 } |
|
413 |
|
414 // Check if we need to restore idling |
|
415 if( EAknsAnimStatePaused == iState && iIdling ) |
|
416 { |
|
417 // Restart the idle timer |
|
418 if ( iTimer->IsActive() ) |
|
419 { |
|
420 iTimer->Cancel(); |
|
421 } |
|
422 iTimer->Start( 0, iIdlingInterval * 1000, TCallBack( TimerTimeoutCallback, this ) ); |
|
423 } |
|
424 |
|
425 iSizeKnown = ETrue; |
|
426 } |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // CAknsAlAnimatorBmp::StartAnimation |
|
430 // ----------------------------------------------------------------------------- |
|
431 // |
|
432 TInt CAknsAlAnimatorBmp::StartAnimation() |
|
433 { |
|
434 CancelIdling(); |
|
435 |
|
436 if( RenderError() ) |
|
437 { |
|
438 return iRenderError; |
|
439 } |
|
440 |
|
441 TRAPD( err, StartAnimationL( ETrue, ETrue ) ); |
|
442 if( err ) |
|
443 { |
|
444 StopAndRelease( ETrue, ETrue ); |
|
445 return err; |
|
446 } |
|
447 |
|
448 iState = EAknsAnimStateRunning; |
|
449 return KErrNone; |
|
450 } |
|
451 |
|
452 // ----------------------------------------------------------------------------- |
|
453 // CAknsAlAnimatorBmp::StopAnimation |
|
454 // ----------------------------------------------------------------------------- |
|
455 // |
|
456 TInt CAknsAlAnimatorBmp::StopAnimation() |
|
457 { |
|
458 CancelIdling(); |
|
459 |
|
460 if( RenderError() ) |
|
461 return iRenderError; |
|
462 |
|
463 if( EAknsAnimStatePaused == iState || |
|
464 EAknsAnimStateRunning == iState || |
|
465 EAknsAnimStateFinished == iState ) |
|
466 { |
|
467 // Stopping releases input layers and plugins |
|
468 StopAndRelease( ETrue, ETrue ); |
|
469 iState = EAknsAnimStateStopped; |
|
470 } |
|
471 |
|
472 return KErrNone; |
|
473 } |
|
474 |
|
475 // ----------------------------------------------------------------------------- |
|
476 // CAknsAlAnimatorBmp::PauseAnimation |
|
477 // ----------------------------------------------------------------------------- |
|
478 // |
|
479 TInt CAknsAlAnimatorBmp::PauseAnimation() |
|
480 { |
|
481 CancelIdling(); |
|
482 |
|
483 if( RenderError() ) |
|
484 return iRenderError; |
|
485 |
|
486 if( EAknsAnimStateRunning == iState ) |
|
487 { |
|
488 iTimer->Cancel(); |
|
489 iState = EAknsAnimStatePaused; |
|
490 } |
|
491 |
|
492 return KErrNone; |
|
493 } |
|
494 |
|
495 // ----------------------------------------------------------------------------- |
|
496 // CAknsAlAnimatorBmp::ContinueAnimationL |
|
497 // ----------------------------------------------------------------------------- |
|
498 // |
|
499 TInt CAknsAlAnimatorBmp::ContinueAnimation() |
|
500 { |
|
501 CancelIdling(); |
|
502 |
|
503 if( RenderError() ) |
|
504 return iRenderError; |
|
505 |
|
506 if( EAknsAnimStatePaused == iState ) |
|
507 { |
|
508 iLastFrameTicks = User::TickCount(); |
|
509 |
|
510 if ( iTimer->IsActive() ) |
|
511 { |
|
512 iTimer->Cancel(); |
|
513 } |
|
514 iTimer->Start( 0, iMinimumInterval * 1000, TCallBack( TimerTimeoutCallback, this ) ); |
|
515 iState = EAknsAnimStateRunning; |
|
516 } |
|
517 |
|
518 return KErrNone; |
|
519 } |
|
520 |
|
521 // ----------------------------------------------------------------------------- |
|
522 // CAknsAlAnimatorBmp::State |
|
523 // ----------------------------------------------------------------------------- |
|
524 // |
|
525 TInt CAknsAlAnimatorBmp::State() const |
|
526 { |
|
527 return iState; |
|
528 } |
|
529 |
|
530 // ----------------------------------------------------------------------------- |
|
531 // CAknsAlAnimatorBmp::OutputRgb |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 CFbsBitmap* CAknsAlAnimatorBmp::OutputRgb() const |
|
535 { |
|
536 return iContext->RgbBitmap( iOutputLayerIndex ); |
|
537 } |
|
538 |
|
539 // ----------------------------------------------------------------------------- |
|
540 // CAknsAlAnimatorBmp::OutputAlpha |
|
541 // ----------------------------------------------------------------------------- |
|
542 // |
|
543 CFbsBitmap* CAknsAlAnimatorBmp::OutputAlpha() const |
|
544 { |
|
545 return iContext->AlphaBitmap( iOutputLayerIndex ); |
|
546 } |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // CAknsAlAnimatorBmp::InputRgbGc |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 CFbsBitGc* CAknsAlAnimatorBmp::InputRgbGc() const |
|
553 { |
|
554 return iContext->RgbGc( iInputLayerIndex ); |
|
555 } |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // CAknsAlAnimatorBmp::InputAlphaGc |
|
559 // ----------------------------------------------------------------------------- |
|
560 // |
|
561 CFbsBitGc* CAknsAlAnimatorBmp::InputAlphaGc() const |
|
562 { |
|
563 return iContext->AlphaGc( iInputLayerIndex ); |
|
564 } |
|
565 |
|
566 // ----------------------------------------------------------------------------- |
|
567 // CAknsAlAnimatorBmp::UpdateOutput |
|
568 // ----------------------------------------------------------------------------- |
|
569 // |
|
570 TInt CAknsAlAnimatorBmp::UpdateOutput() |
|
571 { |
|
572 return Render( EFalse ); |
|
573 } |
|
574 |
|
575 // ----------------------------------------------------------------------------- |
|
576 // CAknsAlAnimatorBmp::SetIdling |
|
577 // ----------------------------------------------------------------------------- |
|
578 // |
|
579 void CAknsAlAnimatorBmp::SetIdling( TInt aIntervalMs ) |
|
580 { |
|
581 if( EAknsAnimStateRunning == iState || iIdling ) |
|
582 { |
|
583 iTimer->Cancel(); |
|
584 iIdling = ETrue; |
|
585 iState = EAknsAnimStatePaused; |
|
586 iIdlingInterval = aIntervalMs; |
|
587 |
|
588 if ( iTimer->IsActive() ) |
|
589 { |
|
590 iTimer->Cancel(); |
|
591 } |
|
592 iTimer->Start( 0, iIdlingInterval * 1000, TCallBack( TimerTimeoutCallback, this ) ); |
|
593 } |
|
594 } |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // CAknsAlAnimatorBmp::IsIdling |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 TBool CAknsAlAnimatorBmp::IsIdling() const |
|
601 { |
|
602 return iIdling; |
|
603 } |
|
604 |
|
605 // ----------------------------------------------------------------------------- |
|
606 // CAknsAlAnimatorBmp::CancelIdling |
|
607 // ----------------------------------------------------------------------------- |
|
608 // |
|
609 void CAknsAlAnimatorBmp::CancelIdling() |
|
610 { |
|
611 if( iIdling ) |
|
612 { |
|
613 iTimer->Cancel(); |
|
614 iIdling = EFalse; |
|
615 } |
|
616 } |
|
617 |
|
618 // ----------------------------------------------------------------------------- |
|
619 // CAknsAlAnimatorBmp::LayerSize |
|
620 // ----------------------------------------------------------------------------- |
|
621 // |
|
622 TSize CAknsAlAnimatorBmp::LayerSize() const |
|
623 { |
|
624 return iContext->LayerSize(); |
|
625 } |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // CAknsAlAnimatorBmp::NeedsInputLayer |
|
629 // ----------------------------------------------------------------------------- |
|
630 // |
|
631 TBool CAknsAlAnimatorBmp::NeedsInputLayer() const |
|
632 { |
|
633 if( iInputLayerIndex >= 0 && |
|
634 !iContext->RgbBitmap( iInputLayerIndex ) ) |
|
635 { |
|
636 return ETrue; |
|
637 } |
|
638 |
|
639 // input layers created in preprocess step are needed too |
|
640 for (TInt i = 0; i <KAknsAlEffectContextLayerN; i++ ) |
|
641 { |
|
642 if ( iPreprocessInputLayers & (1 << i) ) // layers bitpacked - use bitwise and |
|
643 { |
|
644 if ( !iContext->RgbBitmap( i ) ) |
|
645 { |
|
646 return ETrue; |
|
647 } |
|
648 } |
|
649 } |
|
650 |
|
651 return EFalse; |
|
652 } |
|
653 |
|
654 // ----------------------------------------------------------------------------- |
|
655 // CAknsAlAnimatorBmp::RenderError |
|
656 // ----------------------------------------------------------------------------- |
|
657 // |
|
658 TBool CAknsAlAnimatorBmp::RenderError() const |
|
659 { |
|
660 return (KErrNone != iRenderError) ? ETrue: EFalse; |
|
661 } |
|
662 |
|
663 // ----------------------------------------------------------------------------- |
|
664 // CAknsAlAnimatorBmp::StartAnimationL |
|
665 // ----------------------------------------------------------------------------- |
|
666 // |
|
667 void CAknsAlAnimatorBmp::StartAnimationL( TBool aReset, TBool aStartTimer ) |
|
668 { |
|
669 // Don't release input layers, do release plugins because we will activate |
|
670 // them here. |
|
671 StopAndRelease( EFalse, ETrue ); |
|
672 |
|
673 TInt i; |
|
674 if( aReset ) |
|
675 { |
|
676 // Make sure animation models are at the beginning of the animation |
|
677 for( i=0; i < iTimingModels.Count(); i++ ) |
|
678 iTimingModels[i]->Begin(); |
|
679 |
|
680 // Make sure animation values are at the begining of the animation |
|
681 for( i=0; i < iValueContainers.Count(); i++ ) |
|
682 iValueContainers[i]->Begin(); |
|
683 } |
|
684 |
|
685 // Resizing causes restart and initially we must apply size bound |
|
686 // parameters too. |
|
687 TInt count = iSizeBoundParams.Count(); |
|
688 for( i=0; i < count; i++ ) |
|
689 { |
|
690 CAknsAlSizeBoundParam* param = iSizeBoundParams[i]; |
|
691 param->SizeChangedL( iContext->LayerSize() ); |
|
692 } |
|
693 |
|
694 // Activate and parametrize effect filters |
|
695 count = iAnimationCommands.Count(); |
|
696 for( i=0; i < count; i++ ) |
|
697 { |
|
698 // Activate effect |
|
699 CAknsAlAnimationCommand* cmd = iAnimationCommands[i]; |
|
700 MAknsRlEffect* effect = cmd->Effect(); |
|
701 effect->InitializeL(); |
|
702 effect->ActivateL( iContext ); |
|
703 |
|
704 // Parametrize effect |
|
705 MAknsRlParameterIterator* iter = cmd->ParameterIterator(); |
|
706 if( iter ) |
|
707 { |
|
708 effect->SetParametersL( *iter ); |
|
709 } |
|
710 } |
|
711 |
|
712 // Start timer |
|
713 if( aStartTimer ) |
|
714 { |
|
715 iLastFrameTicks = User::TickCount(); |
|
716 if ( iTimer->IsActive() ) |
|
717 { |
|
718 iTimer->Cancel(); |
|
719 } |
|
720 iTimer->Start( 0, iMinimumInterval * 1000, TCallBack( TimerTimeoutCallback, this ) ); |
|
721 } |
|
722 } |
|
723 |
|
724 // ----------------------------------------------------------------------------- |
|
725 // CAknsAlAnimatorBmp::StopAndRelease |
|
726 // ----------------------------------------------------------------------------- |
|
727 // |
|
728 void CAknsAlAnimatorBmp::StopAndRelease( TBool aReleaseInputLayers, |
|
729 TBool aReleasePlugins ) |
|
730 { |
|
731 // Stop timer |
|
732 iTimer->Cancel(); |
|
733 |
|
734 // Release effect filters |
|
735 if( aReleasePlugins ) |
|
736 { |
|
737 TInt count = iAnimationCommands.Count(); |
|
738 for( TInt i=0; i < count; i++ ) |
|
739 { |
|
740 // Activate effects |
|
741 CAknsAlAnimationCommand* cmd = iAnimationCommands[i]; |
|
742 MAknsRlEffect* effect = cmd->Effect(); |
|
743 effect->Deactivate(); |
|
744 effect->Release(); |
|
745 } |
|
746 } |
|
747 |
|
748 // Release input layers, output layer is still available (even if the |
|
749 // animation is stopped we must be able to draw the last frame). |
|
750 if( aReleaseInputLayers ) |
|
751 { |
|
752 iContext->ReleaseInputLayers( iOutputLayerIndex ); |
|
753 } |
|
754 } |
|
755 |
|
756 // ----------------------------------------------------------------------------- |
|
757 // CAknsAlAnimatorBmp::Tick |
|
758 // ----------------------------------------------------------------------------- |
|
759 // |
|
760 void CAknsAlAnimatorBmp::Tick() |
|
761 { |
|
762 if( RenderError() ) |
|
763 return; |
|
764 |
|
765 if( iIdling && iObserver ) |
|
766 { |
|
767 iObserver->AnimFrameReady( KErrNone, 0 ); |
|
768 return; |
|
769 } |
|
770 |
|
771 TBool isFinished = EFalse; |
|
772 TInt i; |
|
773 |
|
774 //--------------------------------- |
|
775 // Check if the animation has been finished |
|
776 TInt count = iTimingModels.Count(); |
|
777 for( i=0; i < count; i++ ) |
|
778 { |
|
779 isFinished = isFinished | iTimingModels[i]->IsFinished(); |
|
780 } |
|
781 |
|
782 if( isFinished ) |
|
783 { |
|
784 // No need to do rendering, animation became finished on the last tick |
|
785 // -> last rendered frame is valid. Cancelling the timer is enough as |
|
786 // we don't release input layers or plugins. |
|
787 iTimer->Cancel(); |
|
788 iState = EAknsAnimStateFinished; |
|
789 return; |
|
790 } |
|
791 |
|
792 //--------------------------------- |
|
793 // Determine the delta time |
|
794 TInt now = User::TickCount(); |
|
795 TInt deltaTime = ( now - iLastFrameTicks ) * iMsPerTick; |
|
796 iLastFrameTicks = now; |
|
797 |
|
798 // The range for delta time is (0, 65536]. It cannot be 0 and 65536 is the |
|
799 // maximum limit caused by the fixed point calculations. |
|
800 if( deltaTime <= 0 ) |
|
801 deltaTime = 1; |
|
802 if( deltaTime > KAlMaxDeltaTime ) |
|
803 deltaTime = KAlMaxDeltaTime; |
|
804 |
|
805 //--------------------------------- |
|
806 // Update timing models |
|
807 count = iTimingModels.Count(); |
|
808 for( i=0; i < count; i++ ) |
|
809 { |
|
810 iTimingModels[i]->Tick( deltaTime ); |
|
811 } |
|
812 |
|
813 //--------------------------------- |
|
814 // Step 2: Tick the animation |
|
815 count = iValueContainers.Count(); |
|
816 for( i=0; i < count; i++ ) |
|
817 { |
|
818 CAknsAlAnimationValueContainer* container = iValueContainers[i]; |
|
819 container->Tick( deltaTime ); |
|
820 } |
|
821 |
|
822 // Render the animation (skipped if layers are not ok) |
|
823 if( iSizeKnown ) |
|
824 { |
|
825 TInt err = Render( ETrue ); |
|
826 if( KErrNone != err ) |
|
827 { |
|
828 iRenderError = err; |
|
829 } |
|
830 } |
|
831 } |
|
832 |
|
833 // ----------------------------------------------------------------------------- |
|
834 // CAknsAlAnimatorBmp::Render |
|
835 // ----------------------------------------------------------------------------- |
|
836 // |
|
837 TInt CAknsAlAnimatorBmp::Render( TBool aNotify ) |
|
838 { |
|
839 // Cannot render when state is invalid |
|
840 if( RenderError() ) |
|
841 { |
|
842 if( iObserver && aNotify ) |
|
843 { |
|
844 iObserver->AnimFrameReady( iRenderError, 0 ); |
|
845 } |
|
846 return iRenderError; |
|
847 } |
|
848 |
|
849 // State is valid, we can try rendering |
|
850 TInt err = ApplyCommands( iAnimationCommands, ETrue ); |
|
851 |
|
852 if( KErrNone != err ) |
|
853 { |
|
854 #if defined(_DEBUG) |
|
855 RDebug::Printf("ANIM CAknsAlAnimatorBmp, ApplyCommands failed %d, stopping...", err); |
|
856 #endif |
|
857 StopAnimation(); // Failed animation cannot run |
|
858 } |
|
859 |
|
860 // Inform observer about new frame |
|
861 if( iObserver && aNotify ) |
|
862 { |
|
863 iObserver->AnimFrameReady( err, 0 ); |
|
864 } |
|
865 |
|
866 return err; |
|
867 } |
|
868 |
|
869 // ----------------------------------------------------------------------------- |
|
870 // CAknsAlAnimatorBmp::PreprocessL |
|
871 // ----------------------------------------------------------------------------- |
|
872 // |
|
873 void CAknsAlAnimatorBmp::PreprocessL() |
|
874 { |
|
875 TInt i; |
|
876 TInt count = iPreprocessCommands.Count(); |
|
877 for( i=0; i < count; i++ ) |
|
878 { |
|
879 // Activate effect |
|
880 CAknsAlAnimationCommand* cmd = iPreprocessCommands[i]; |
|
881 MAknsRlEffect* effect = cmd->Effect(); |
|
882 effect->InitializeL(); |
|
883 effect->ActivateL( iContext ); |
|
884 |
|
885 // No untrapped leaves after this line before deactivation & release |
|
886 |
|
887 // Parametrize effect |
|
888 MAknsRlParameterIterator* iter = cmd->ParameterIterator(); |
|
889 if( iter ) |
|
890 { |
|
891 TRAPD( paramErr, effect->SetParametersL( *iter ) ); |
|
892 if( paramErr ) |
|
893 { |
|
894 effect->Deactivate(); |
|
895 effect->Release(); |
|
896 AKNS_TRACE_ERROR1("CAknsAlAnimatorBmp::PreprocessL Bad params for effect %d", i); |
|
897 User::Leave( paramErr ); |
|
898 } |
|
899 } |
|
900 |
|
901 TAknsRlRenderOpParam opParam = cmd->LayerConfig(); |
|
902 |
|
903 TAknsRlEffectCaps caps; |
|
904 effect->GetCapabilities( caps ); |
|
905 |
|
906 TBool opPossible = ETrue; |
|
907 if( !(caps.iInputLayerASupport&opParam.iInputLayerAStatus) ) |
|
908 opPossible = EFalse; |
|
909 if( !(caps.iInputLayerBSupport&opParam.iInputLayerBStatus) ) |
|
910 opPossible = EFalse; |
|
911 if( !(caps.iOutputLayerSupport&opParam.iOutputLayerStatus) ) |
|
912 opPossible = EFalse; |
|
913 if( opParam.iOutputLayerStatus == KAknsRlLayerNone ) |
|
914 opPossible = EFalse; |
|
915 |
|
916 TInt effectRet = KErrArgument; |
|
917 |
|
918 if( opPossible ) |
|
919 { |
|
920 effectRet = KAknsRlRenderIncomplete; |
|
921 while( effectRet == KAknsRlRenderIncomplete ) |
|
922 { |
|
923 effectRet = effect->Render( opParam ); |
|
924 } |
|
925 } |
|
926 #if defined(_DEBUG) |
|
927 else |
|
928 { |
|
929 AKNS_TRACE_ERROR1("CAknsAlAnimatorBmp::PreprocessL Effect not executed %d", i); |
|
930 } |
|
931 #endif |
|
932 |
|
933 // Deactivation, leaves are OK after this |
|
934 effect->Deactivate(); |
|
935 effect->Release(); |
|
936 |
|
937 #if defined(_DEBUG) |
|
938 if( effectRet ) |
|
939 { |
|
940 AKNS_TRACE_ERROR2("CAknsAlAnimatorBmp::PreprocessL error %d for %d", effectRet, i); |
|
941 } |
|
942 #endif |
|
943 |
|
944 User::LeaveIfError( effectRet ); |
|
945 } |
|
946 |
|
947 iPreprocessInputLayers = 0; |
|
948 // we have to save input layers created in preprocess step |
|
949 for (i = 0; i <KAknsAlEffectContextLayerN; i++ ) |
|
950 { |
|
951 if( iContext->RgbBitmap( i ) ) |
|
952 { |
|
953 iPreprocessInputLayers |= 1 << i; |
|
954 } |
|
955 } |
|
956 } |
|
957 // ----------------------------------------------------------------------------- |
|
958 // CAknsAlAnimatorBmp::ApplyCommands |
|
959 // ----------------------------------------------------------------------------- |
|
960 // |
|
961 TInt CAknsAlAnimatorBmp::ApplyCommands( |
|
962 RPointerArray<CAknsAlAnimationCommand>& aCommands, |
|
963 TBool aApplyNamedReferences ) const |
|
964 { |
|
965 TInt count = aCommands.Count(); |
|
966 TAknsRlEffectCaps caps; |
|
967 TBool opPossible = EFalse; |
|
968 for( TInt i=0; i < count; i++ ) |
|
969 { |
|
970 CAknsAlAnimationCommand* cmd = aCommands[i]; |
|
971 MAknsRlEffect* effect = cmd->Effect(); |
|
972 |
|
973 TAknsRlRenderOpParam opParam = cmd->LayerConfig(); |
|
974 |
|
975 effect->GetCapabilities( caps ); |
|
976 |
|
977 opPossible = ETrue; |
|
978 |
|
979 if( !(caps.iInputLayerASupport&opParam.iInputLayerAStatus) ) |
|
980 opPossible = EFalse; |
|
981 if( !(caps.iInputLayerBSupport&opParam.iInputLayerBStatus) ) |
|
982 opPossible = EFalse; |
|
983 if( !(caps.iOutputLayerSupport&opParam.iOutputLayerStatus) ) |
|
984 opPossible = EFalse; |
|
985 if( opParam.iOutputLayerStatus == KAknsRlLayerNone ) |
|
986 opPossible = EFalse; |
|
987 |
|
988 TInt effectRet = KErrArgument; |
|
989 |
|
990 if( opPossible ) |
|
991 { |
|
992 if( aApplyNamedReferences ) |
|
993 { |
|
994 // Apply time bound parameters |
|
995 MAknsRlParameterIterator* iter = cmd->NamedReferenceIterator(); |
|
996 if( iter ) |
|
997 { |
|
998 TRAPD( paramErr, effect->SetParametersL( *iter ) ); |
|
999 if( paramErr ) |
|
1000 return paramErr; |
|
1001 } |
|
1002 } |
|
1003 |
|
1004 // Render effect |
|
1005 effectRet = KAknsRlRenderIncomplete; |
|
1006 while( effectRet == KAknsRlRenderIncomplete ) |
|
1007 { |
|
1008 effectRet = effect->Render( opParam ); |
|
1009 } |
|
1010 } |
|
1011 #if defined(_DEBUG) |
|
1012 else |
|
1013 { |
|
1014 AKNS_TRACE_ERROR1("CAknsAlAnimatorBmp::ApplyCommands Effect not executed %d", i); |
|
1015 } |
|
1016 #endif |
|
1017 |
|
1018 #if defined(_DEBUG) |
|
1019 if( effectRet ) |
|
1020 { |
|
1021 AKNS_TRACE_ERROR2("CAknsAlAnimatorBmp::ApplyCommands error %d for %d", effectRet, i); |
|
1022 } |
|
1023 #endif |
|
1024 |
|
1025 if( KErrNone != effectRet ) |
|
1026 return effectRet; |
|
1027 } |
|
1028 |
|
1029 return KErrNone; |
|
1030 } |
|
1031 |
|
1032 // ----------------------------------------------------------------------------- |
|
1033 // CAknsAlAnimatorBmp::FindTimingModelById |
|
1034 // ----------------------------------------------------------------------------- |
|
1035 // |
|
1036 MAknsAlTimingModel* CAknsAlAnimatorBmp::FindTimingModelById( TInt aId ) const |
|
1037 { |
|
1038 if( 0 <= aId && aId < iTimingModels.Count() ) |
|
1039 return iTimingModels[ aId ]; |
|
1040 |
|
1041 return NULL; |
|
1042 } |
|
1043 |
|
1044 // ----------------------------------------------------------------------------- |
|
1045 // CAknsAlAnimatorBmp::FindContainerById |
|
1046 // ----------------------------------------------------------------------------- |
|
1047 // |
|
1048 CAknsAlAnimationValueContainer* CAknsAlAnimatorBmp::FindContainerById( TInt aId ) const |
|
1049 { |
|
1050 if( 0 <= aId && aId < iValueContainers.Count() ) |
|
1051 return iValueContainers[ aId ]; |
|
1052 |
|
1053 return NULL; |
|
1054 } |
|
1055 |
|
1056 // ----------------------------------------------------------------------------- |
|
1057 // CAknsAlAnimatorBmp::CreateTimingModelsL |
|
1058 // ----------------------------------------------------------------------------- |
|
1059 // |
|
1060 void CAknsAlAnimatorBmp::CreateTimingModelsL( |
|
1061 const CAknsAnimationItemData& aSkinData ) |
|
1062 { |
|
1063 MAknsAlIterator* iter = aSkinData.TimingModelIteratorL(); |
|
1064 CleanupStack::PushL( TCleanupItem( MAknsAlIterator::CleanupOp, iter ) ); |
|
1065 |
|
1066 while( iter->HasNext() ) |
|
1067 { |
|
1068 const TAknsAlTimingModelData* item = |
|
1069 static_cast<const TAknsAlTimingModelData*>( iter->NextL() ); |
|
1070 MAknsAlTimingModel* model = |
|
1071 AknsAlAnimationFactory::CreateTimingModelL( item->iTimingModelUid ); |
|
1072 if( !model ) |
|
1073 { |
|
1074 User::Leave( KErrNotFound ); |
|
1075 } |
|
1076 |
|
1077 CleanupStack::PushL( TCleanupItem( MAknsAlTimingModel::CleanupOp, model ) ); |
|
1078 |
|
1079 if( item->iParamIterator ) |
|
1080 model->SetParametersL( *item->iParamIterator ); |
|
1081 |
|
1082 User::LeaveIfError( iTimingModels.Append( model ) ); |
|
1083 |
|
1084 CleanupStack::Pop(); // Model |
|
1085 } |
|
1086 |
|
1087 CleanupStack::PopAndDestroy(); // iter |
|
1088 } |
|
1089 |
|
1090 // ----------------------------------------------------------------------------- |
|
1091 // CAknsAlAnimatorBmp::CreateAnimationValueContainersL |
|
1092 // ----------------------------------------------------------------------------- |
|
1093 // |
|
1094 void CAknsAlAnimatorBmp::CreateAnimationValueContainersL( |
|
1095 const CAknsAnimationItemData& aSkinData ) |
|
1096 { |
|
1097 MAknsAlIterator* iter = aSkinData.AnimationValueIteratorL(); |
|
1098 CleanupStack::PushL( TCleanupItem( MAknsAlIterator::CleanupOp, iter ) ); |
|
1099 |
|
1100 while( iter->HasNext() ) |
|
1101 { |
|
1102 const TAknsAlAnimationValueData* data = |
|
1103 static_cast<const TAknsAlAnimationValueData*>( iter->NextL() ); |
|
1104 |
|
1105 // Create animation value |
|
1106 MAknsAlAnimationValue* value = |
|
1107 AknsAlAnimationFactory::CreateAnimationValueL( data->iAnimationValueUid ); |
|
1108 if( !value ) |
|
1109 { |
|
1110 User::Leave( KErrNotFound ); |
|
1111 } |
|
1112 |
|
1113 CleanupStack::PushL( TCleanupItem( MAknsAlAnimationValue::CleanupOp, value ) ); |
|
1114 |
|
1115 if( data->iParamIterator ) |
|
1116 value->SetParametersL( *data->iParamIterator ); |
|
1117 |
|
1118 // Fetch timing model |
|
1119 MAknsAlTimingModel* timing = FindTimingModelById( data->iTimingModelId ); |
|
1120 if( !timing ) |
|
1121 User::Leave( KErrNotFound ); |
|
1122 |
|
1123 // Create the container |
|
1124 CAknsAlAnimationValueContainer* container = |
|
1125 CAknsAlAnimationValueContainer::NewL( value, timing ); |
|
1126 |
|
1127 CleanupStack::Pop( value ); // Animation value is now owned by container |
|
1128 |
|
1129 CleanupStack::PushL( container ); |
|
1130 User::LeaveIfError( iValueContainers.Append( container ) ); |
|
1131 CleanupStack::Pop( container ); |
|
1132 } |
|
1133 |
|
1134 CleanupStack::PopAndDestroy(); // iter |
|
1135 } |
|
1136 |
|
1137 // ----------------------------------------------------------------------------- |
|
1138 // CAknsAlAnimatorBmp::CreatePreprocessCommandsL |
|
1139 // ----------------------------------------------------------------------------- |
|
1140 // |
|
1141 void CAknsAlAnimatorBmp::CreatePreprocessCommandsL( |
|
1142 const CAknsAnimationItemData& aSkinData ) |
|
1143 { |
|
1144 MAknsRlCommandIterator* iter = aSkinData.PreprocessCommandIteratorL(); |
|
1145 CleanupStack::PushL( TCleanupItem( MAknsRlCommandIterator::CleanupOperation, iter ) ); |
|
1146 |
|
1147 while( iter->HasNext() ) |
|
1148 { |
|
1149 const TAknsRlCommandData* data = iter->NextL(); |
|
1150 CAknsAlAnimationCommand* command = CAknsAlAnimationCommand::NewL(); |
|
1151 CleanupStack::PushL( command ); |
|
1152 |
|
1153 // Step 1: Create the plugin |
|
1154 CAknsRlEffectPlugin* plugin = |
|
1155 AknsAlAnimationFactory::CreateEffectPluginL( data->iEffectUid ); |
|
1156 if( !plugin ) |
|
1157 { |
|
1158 User::Leave( KErrNotFound ); |
|
1159 } |
|
1160 |
|
1161 command->SetPlugin( plugin ); |
|
1162 |
|
1163 // Step 2: Assign layer configuration |
|
1164 command->SetLayerConfig( data->iLayerConf ); |
|
1165 |
|
1166 // Step 3: Add initial parameters |
|
1167 if( data->iParamIterator ) |
|
1168 { |
|
1169 MAknsRlParameterIterator* paramIter = data->iParamIterator; |
|
1170 while( paramIter->HasNext() ) |
|
1171 { |
|
1172 const TAknsRlParameterData* param = paramIter->NextL(); |
|
1173 command->AddParameterL( *param ); |
|
1174 } |
|
1175 } |
|
1176 |
|
1177 // Preprocess commands don't have named references |
|
1178 User::LeaveIfError( iPreprocessCommands.Append( command ) ); |
|
1179 CleanupStack::Pop( command ); |
|
1180 } |
|
1181 |
|
1182 CleanupStack::PopAndDestroy(); // iter |
|
1183 } |
|
1184 |
|
1185 // ----------------------------------------------------------------------------- |
|
1186 // CAknsAlAnimatorBmp::CreateAnimationCommandsL |
|
1187 // ----------------------------------------------------------------------------- |
|
1188 // |
|
1189 void CAknsAlAnimatorBmp::CreateAnimationCommandsL( |
|
1190 const CAknsAnimationItemData& aSkinData ) |
|
1191 { |
|
1192 MAknsAlIterator* iter = aSkinData.CommandIteratorL(); |
|
1193 CleanupStack::PushL( TCleanupItem( MAknsAlIterator::CleanupOp, iter ) ); |
|
1194 |
|
1195 while( iter->HasNext() ) |
|
1196 { |
|
1197 const TAknsAlAnimationCommandData* data = |
|
1198 static_cast<const TAknsAlAnimationCommandData*>( iter->NextL() ); |
|
1199 |
|
1200 CAknsAlAnimationCommand* command = CAknsAlAnimationCommand::NewL(); |
|
1201 CleanupStack::PushL( command ); |
|
1202 |
|
1203 // Step 1: Create the plugin |
|
1204 CAknsRlEffectPlugin* plugin = |
|
1205 AknsAlAnimationFactory::CreateEffectPluginL( data->iEffectUid ); |
|
1206 if( !plugin ) |
|
1207 { |
|
1208 User::Leave( KErrNotFound ); |
|
1209 } |
|
1210 command->SetPlugin( plugin ); |
|
1211 |
|
1212 // Step 2: Assign layer configuration |
|
1213 command->SetLayerConfig( data->iLayerConf ); |
|
1214 |
|
1215 // Step 3: Add initial parameters |
|
1216 if( data->iParamIterator ) |
|
1217 { |
|
1218 MAknsRlParameterIterator* paramIter = data->iParamIterator; |
|
1219 while( paramIter->HasNext() ) |
|
1220 { |
|
1221 const TAknsRlParameterData* param = paramIter->NextL(); |
|
1222 command->AddParameterL( *param ); |
|
1223 } |
|
1224 } |
|
1225 |
|
1226 // Step 4: Add named references |
|
1227 if( data->iNamedReferenceIterator ) |
|
1228 { |
|
1229 MAknsAlIterator* refIter = data->iNamedReferenceIterator; |
|
1230 while( refIter->HasNext() ) |
|
1231 { |
|
1232 const TAknsAlNamedReferenceData* ref = |
|
1233 static_cast<const TAknsAlNamedReferenceData*>( refIter->NextL() ); |
|
1234 |
|
1235 CAknsAlAnimationValueContainer* container = FindContainerById( ref->iAnimationValueId ); |
|
1236 if( !container ) |
|
1237 User::Leave( KErrNotFound ); |
|
1238 |
|
1239 command->AddNamedReferenceL( *ref->iName, |
|
1240 container->AnimationValue() ); |
|
1241 } |
|
1242 } |
|
1243 |
|
1244 User::LeaveIfError( iAnimationCommands.Append( command ) ); |
|
1245 CleanupStack::Pop( command ); |
|
1246 } |
|
1247 |
|
1248 CleanupStack::PopAndDestroy(); // iter |
|
1249 } |
|
1250 |
|
1251 // ----------------------------------------------------------------------------- |
|
1252 // CAknsAlAnimatorBmp::CreateSizeBoundParamsL |
|
1253 // ----------------------------------------------------------------------------- |
|
1254 // |
|
1255 void CAknsAlAnimatorBmp::CreateSizeBoundParamsL( |
|
1256 const CAknsAnimationItemData& aSkinData ) |
|
1257 { |
|
1258 MAknsAlIterator* iter = aSkinData.SizeBoundParamIteratorL(); |
|
1259 CleanupStack::PushL( TCleanupItem( MAknsAlIterator::CleanupOp, iter ) ); |
|
1260 |
|
1261 while( iter->HasNext() ) |
|
1262 { |
|
1263 const TAknsAlSizeBoundParameterData* data = |
|
1264 static_cast<const TAknsAlSizeBoundParameterData*>( iter->NextL() ); |
|
1265 |
|
1266 if( !data->iName ) |
|
1267 User::Leave( KErrBadHandle ); |
|
1268 |
|
1269 CAknsAlAnimationValueContainer* container = FindContainerById( data->iAnimationValueId ); |
|
1270 if( !container ) |
|
1271 User::Leave( KErrNotFound ); |
|
1272 |
|
1273 CAknsAlSizeBoundParam* param = |
|
1274 CAknsAlSizeBoundParam::NewL( container->AnimationValue(), |
|
1275 *data->iName, |
|
1276 data->iParamFlags ); |
|
1277 |
|
1278 CleanupStack::PushL( param ); |
|
1279 User::LeaveIfError( iSizeBoundParams.Append( param ) ); |
|
1280 CleanupStack::Pop( param ); |
|
1281 } |
|
1282 |
|
1283 CleanupStack::PopAndDestroy(); // iter |
|
1284 } |
|
1285 |
|
1286 // ----------------------------------------------------------------------------- |
|
1287 // CAknsAlAnimatorBmp::TimerTimeoutCallback |
|
1288 // ----------------------------------------------------------------------------- |
|
1289 // |
|
1290 TInt CAknsAlAnimatorBmp::TimerTimeoutCallback(TAny *aPtr) |
|
1291 { |
|
1292 CAknsAlAnimatorBmp* render = reinterpret_cast<CAknsAlAnimatorBmp*>( aPtr ); |
|
1293 render->Tick(); |
|
1294 |
|
1295 return ETrue; // Continue running |
|
1296 } |
|
1297 |
|
1298 // ----------------------------------------------------------------------------- |
|
1299 // Callback interface for lights status. |
|
1300 // ----------------------------------------------------------------------------- |
|
1301 // |
|
1302 void CAknsAlAnimatorBmp::LightStatusChanged( TInt aTarget, |
|
1303 CHWRMLight::TLightStatus aStatus ) |
|
1304 { |
|
1305 if ( aTarget == CHWRMLight::EPrimaryDisplay || |
|
1306 aTarget == CHWRMLight::EPrimaryDisplayAndKeyboard ) |
|
1307 { |
|
1308 if ( aStatus == CHWRMLight::ELightOff ) |
|
1309 { |
|
1310 PauseAnimation(); // don't care about errors in here |
|
1311 } |
|
1312 else if ( aStatus == CHWRMLight::ELightOn ) |
|
1313 { |
|
1314 ContinueAnimation(); |
|
1315 } |
|
1316 } |
|
1317 } |
|
1318 |
|
1319 // End of File |