74 |
74 |
75 EXPORT_C CHuiFxEffect::~CHuiFxEffect() |
75 EXPORT_C CHuiFxEffect::~CHuiFxEffect() |
76 { |
76 { |
77 delete iRoot; |
77 delete iRoot; |
78 iRoot = NULL; |
78 iRoot = NULL; |
79 |
|
80 NotifyEffectEndObserver(); |
79 NotifyEffectEndObserver(); |
81 |
80 |
82 ReleaseCachedRenderTarget(); |
81 ReleaseCachedRenderTarget(); |
83 |
82 |
84 iEngine->RemoveEffect(this); |
83 iEngine->RemoveEffect(this); |
|
84 if (iEngine && iGroupId != KErrNotFound && !iNotifiedEffectReady) |
|
85 { |
|
86 // if effect was deleted before it was drawn, the group must be notified. If this was the last effect in the group |
|
87 // the group will be removed by the EffectReadyToStart |
|
88 // effect group does not not know, which effects have notified about themselves. thus iNotifiedEffectReady flag is used. |
|
89 iNotifiedEffectReady = ETrue; |
|
90 iEngine->NotifyEffectReady(iGroupId); |
|
91 } |
|
92 |
85 #ifdef HUIFX_TRACE |
93 #ifdef HUIFX_TRACE |
86 RDebug::Print(_L("CHuiFxEffect::~CHuiFxEffect - 0x%x"), this); |
94 RDebug::Print(_L("CHuiFxEffect::~CHuiFxEffect - 0x%x"), this); |
87 #endif |
95 #endif |
88 } |
96 } |
89 |
97 |
90 void CHuiFxEffect::NotifyEffectEndObserver() |
98 void CHuiFxEffect::NotifyEffectEndObserver() |
91 { |
99 { |
92 if ( iEffectEndObserver ) |
100 // fade effect should not have observers |
|
101 if (iFlags & KHuiFadeEffectFlag) |
|
102 { |
|
103 return; |
|
104 } |
|
105 if (iEffectEndObserver) |
93 { |
106 { |
94 // The callback can be called only once when the effect finishes |
107 // The callback can be called only once when the effect finishes |
95 iEffectEndObserver->AlfGfxEffectEndCallBack( iHandle ); |
108 MAlfGfxEffectObserver* effectEndObserver = iEffectEndObserver; |
96 iEffectEndObserver = NULL; |
109 iEffectEndObserver = NULL; |
97 iHandle = 0; |
110 // Note: The call below may synchronously delete me (CHuiFxEffect instance) |
|
111 effectEndObserver->AlfGfxEffectEndCallBack( iHandle ); |
98 } |
112 } |
99 } |
113 } |
100 |
114 |
101 EXPORT_C void CHuiFxEffect::AddLayerL(const CHuiFxLayer* aLayer) |
115 EXPORT_C void CHuiFxEffect::AddLayerL(const CHuiFxLayer* aLayer) |
102 { |
116 { |
306 aGc.PushClip(); |
320 aGc.PushClip(); |
307 aGc.Clip(aClipRegion); |
321 aGc.Clip(aClipRegion); |
308 } |
322 } |
309 |
323 |
310 // Write cached buffer to the display |
324 // Write cached buffer to the display |
311 if (cachedRenderTargetNeedsRefresh) |
325 |
312 { |
326 iEngine->Composite(aGc, *iCachedRenderTarget, targetRect.iTl, aOpaque && !(EffectFlags() & KHuiFxAlwaysBlend), aAlpha); |
313 iEngine->Composite(aGc, *iCachedRenderTarget, targetRect.iTl, aOpaque && !(EffectFlags() & KHuiFxAlwaysBlend), aAlpha); |
327 |
314 } |
|
315 |
328 |
316 if (aClipRegion.Count()) |
329 if (aClipRegion.Count()) |
317 { |
330 { |
318 aGc.PopClip(); |
331 aGc.PopClip(); |
319 } |
332 } |
435 } |
448 } |
436 |
449 |
437 EXPORT_C void CHuiFxEffect::SetEffectEndObserver( MAlfGfxEffectObserver* aEffectEndObserver, TInt aHandle ) |
450 EXPORT_C void CHuiFxEffect::SetEffectEndObserver( MAlfGfxEffectObserver* aEffectEndObserver, TInt aHandle ) |
438 { |
451 { |
439 iEffectEndObserver = aEffectEndObserver; |
452 iEffectEndObserver = aEffectEndObserver; |
440 iHandle = aHandle; |
453 |
|
454 if (aHandle != 0) // override handle only if someone is interested |
|
455 { |
|
456 iHandle = aHandle; |
|
457 } |
441 } |
458 } |
442 |
459 |
443 EXPORT_C void CHuiFxEffect::SetEffectFlags( TInt aFlags ) |
460 EXPORT_C void CHuiFxEffect::SetEffectFlags( TInt aFlags ) |
444 { |
461 { |
445 iFlags = aFlags; |
462 iFlags = aFlags; |
446 } |
463 } |
447 |
464 |
|
465 void CHuiFxEffect::SetEffectFlag( TInt aFlag ) |
|
466 { |
|
467 #ifdef HUIFX_TRACE |
|
468 RDebug::Printf("CHuiFxEffect::SetEffectFlag - Setting flag 0x%x for 0x%x, before: iFlags: 0x%x", aFlag, this, iFlags); |
|
469 #endif |
|
470 iFlags |= aFlag; |
|
471 } |
|
472 |
|
473 void CHuiFxEffect::ClearEffectFlag( TInt aFlag ) |
|
474 { |
|
475 #ifdef HUIFX_TRACE |
|
476 RDebug::Printf("CHuiFxEffect::ClearEffectFlag - Clearing flag 0x%x for 0x%x, before: iFlags: 0x%x", aFlag, this, iFlags); |
|
477 #endif |
|
478 iFlags &= ~aFlag; |
|
479 } |
|
480 |
448 EXPORT_C void CHuiFxEffect::SetEffectGroup(TInt aGroupId) |
481 EXPORT_C void CHuiFxEffect::SetEffectGroup(TInt aGroupId) |
449 { |
482 { |
450 iGroupId = aGroupId; |
483 iGroupId = aGroupId; |
451 } |
484 } |
452 |
485 |
460 return iGroupId; |
493 return iGroupId; |
461 } |
494 } |
462 |
495 |
463 EXPORT_C void CHuiFxEffect::AdvanceTime(TReal32 aElapsedTime) |
496 EXPORT_C void CHuiFxEffect::AdvanceTime(TReal32 aElapsedTime) |
464 { |
497 { |
|
498 #ifdef HUIFX_TRACE |
|
499 RDebug::Printf("CHuiFxEffect::AdvanceTime 0x%x, aElapsed time: %f, Total elapsed time: %f, Frames drawn: %d, iFlags: 0x%x, iGroup %d, iHandle: %d", |
|
500 this, |
|
501 aElapsedTime, |
|
502 iElapsedTime, |
|
503 iFramesDrawn, |
|
504 iFlags, |
|
505 iGroupId, |
|
506 iHandle); |
|
507 #endif |
|
508 // KHuiFxDelayRunUntilFirstFrameHasBeenDrawn flag is for giving effect chance to run |
|
509 // its whole timeline by starting the time only when first frame has been drawn. |
465 if (iFlags & KHuiFxDelayRunUntilFirstFrameHasBeenDrawn) |
510 if (iFlags & KHuiFxDelayRunUntilFirstFrameHasBeenDrawn) |
466 { |
511 { |
|
512 // Sometimes the effect does not get any frames. Force the time to start, because |
|
513 // otherwise will jam itself and possible the group, where the effect is. |
|
514 if (iElapsedTime > 0.2 && iFramesDrawn == 0) |
|
515 { |
|
516 iFramesDrawn = 1; |
|
517 #ifdef HUIFX_TRACE |
|
518 RDebug::Printf("CHuiFxEffect::AdvanceTime - Not drawn, but cannot wait. release 0x%x in time %f", this, iElapsedTime); |
|
519 #endif |
|
520 } |
|
521 |
467 if (iFramesDrawn) |
522 if (iFramesDrawn) |
468 { |
523 { |
|
524 if (iFlags & KHuiFxReadyAndWaitingGroupToStartSyncronized) |
|
525 { |
|
526 // this has drawn atleast once, but all the effect in this group have not drawn. Must hang on little more. |
|
527 return; |
|
528 } |
|
529 |
|
530 if (iFlags & KHuiFxWaitGroupToStartSyncronized) |
|
531 { |
|
532 // Group has been started, waiting the others in the group to be drawn |
|
533 ClearEffectFlag(KHuiFxWaitGroupToStartSyncronized); |
|
534 SetEffectFlag(KHuiFxReadyAndWaitingGroupToStartSyncronized); |
|
535 // NotifyEffectReady will clear KHuiFxReadyAndWaitingGroupToStartSyncronized flag |
|
536 // if all items in the group are ready. |
|
537 iEngine->NotifyEffectReady(iGroupId); |
|
538 iNotifiedEffectReady = ETrue; |
|
539 return; |
|
540 } |
|
541 |
469 if (iFramesDrawn == 1) |
542 if (iFramesDrawn == 1) |
470 { |
543 { |
471 aElapsedTime = 0; |
544 aElapsedTime = 0; |
472 iFramesDrawn++; |
545 iFramesDrawn++; |
473 } |
546 } |
474 iRoot->AdvanceTime(aElapsedTime); |
547 iRoot->AdvanceTime(aElapsedTime); |
475 } |
|
476 else |
|
477 { |
|
478 } |
548 } |
479 } |
549 } |
480 else |
550 else |
481 { |
551 { |
482 iRoot->AdvanceTime(aElapsedTime); |
552 iRoot->AdvanceTime(aElapsedTime); |
483 } |
553 } |
|
554 iElapsedTime += aElapsedTime; |
484 } |
555 } |
485 |
556 |
486 EXPORT_C TBool CHuiFxEffect::IsAnimated() const |
557 EXPORT_C TBool CHuiFxEffect::IsAnimated() const |
487 { |
558 { |
488 if (iRoot && iRoot->IsAnimated()) |
559 if (iRoot && iRoot->IsAnimated()) |