|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef HUIFXEFFECT_H_ |
|
21 #define HUIFXEFFECT_H_ |
|
22 |
|
23 #include "HuiFxEngine.h" |
|
24 #include <uiacceltk/HuiGc.h> |
|
25 |
|
26 //FORWARD DECLARATIONS |
|
27 class CHuiFxLayer; |
|
28 class CHuiFxGroupLayer; |
|
29 class MHuiEffectable; |
|
30 // Hui Effect Flags |
|
31 // The flags must be 1 bit flags to allow several to be set simultaneously (if needed) |
|
32 const TInt KHuiFlagsNone = 0x00000000; |
|
33 const TInt KHuiFadeEffectFlag = 0x00000001; |
|
34 const TInt KHuiFxEffectDisableMarginsFlag = 0x2; |
|
35 const TInt KHuiFxEffectExcludeChildrenFlag = 0x4; |
|
36 const TInt KHuiFxWaitGroupSyncronization = 0x8; |
|
37 const TInt KHuiFxDelayRunUntilFirstFrameHasBeenDrawn = 0x10; |
|
38 const TInt KHuiFxDisableBackground = 0x20; |
|
39 const TInt KHuiFxAlwaysBlend = 0x40; |
|
40 |
|
41 class MAlfGfxEffectObserver |
|
42 { |
|
43 public: |
|
44 /** |
|
45 * Function to be called when CHuiFxEffect class effect has ended |
|
46 * @param aHandle handle of the effect, given when the effect is started |
|
47 */ |
|
48 virtual void AlfGfxEffectEndCallBack( TInt aHandle ) = 0; |
|
49 }; |
|
50 |
|
51 class CHuiFxEffect : public CBase |
|
52 { |
|
53 public: |
|
54 IMPORT_C virtual ~CHuiFxEffect(); |
|
55 IMPORT_C static CHuiFxEffect* NewL(CHuiFxEngine& aEngine); |
|
56 IMPORT_C void AddLayerL(const CHuiFxLayer* aLayer); // takes ownership |
|
57 IMPORT_C void AdvanceTime(TReal32 aElapsedTime); |
|
58 IMPORT_C TBool Draw(CHuiGc& aGc, const TRect& aDisplayRect); |
|
59 IMPORT_C CHuiFxEngine& Engine() const; |
|
60 IMPORT_C TBool VisualArea(TRect& aRect) const; |
|
61 IMPORT_C TBool Changed(); |
|
62 IMPORT_C void SetEffectEndObserver( MAlfGfxEffectObserver* aEffectEndObserver, TInt aHandle ); |
|
63 void NotifyEffectEndObserver(); |
|
64 |
|
65 IMPORT_C TBool IsAnimated() const; |
|
66 IMPORT_C TBool IsTransformed() const; |
|
67 TBool IsSemitransparent() const; |
|
68 |
|
69 |
|
70 public: // effect cache methods |
|
71 IMPORT_C CHuiFxEffect *CloneL() const; |
|
72 IMPORT_C void SetExtRect( TRect *aExtRect ); |
|
73 IMPORT_C void SetVisual( CHuiVisual *aVisual ); |
|
74 IMPORT_C void SetVisual( MHuiEffectable *aVisual ); |
|
75 IMPORT_C void SetEngine( CHuiFxEngine *aEngine ); |
|
76 |
|
77 IMPORT_C void SetEffectFlags( TInt aFlags ); |
|
78 IMPORT_C void SetEffectGroup(TInt aGroupId); |
|
79 IMPORT_C TInt EffectFlags(); |
|
80 IMPORT_C TInt GroupId(); |
|
81 |
|
82 // Effect cached render target methods |
|
83 TBool IsCachedRenderTargetSupported() const; |
|
84 TBool IsCachedRenderTargetPreferred() const; |
|
85 |
|
86 void ForceCachedRenderTargetUsage(TBool aUseCachedRenderTarget); |
|
87 |
|
88 void PrepareCachedRenderTarget(const TPoint& aPosition, const TSize& aSize, TBool aClear, TBool aEnableBackground); |
|
89 void ReleaseCachedRenderTarget(); |
|
90 |
|
91 /* |
|
92 * CachedDraw is typically much faster than normal draw as it keeps effect result in pre-rendered format |
|
93 * instead of doing it on-the-fly as normal draw. There are however few issues that must be noted: |
|
94 * |
|
95 * - If visual content has changed, caller is then responsible for setting param aRefreshCachedRenderTarget=ETrue |
|
96 * so that effect gets refreshed. |
|
97 * - Caching does not make sense for animated effects, this method automatically defaults to normal |
|
98 * drawing if the effect is animated |
|
99 * - All renderers do not (yet) support cached drawing |
|
100 * - If memory is low, cached drawing may not succed. |
|
101 * |
|
102 * @param aGc |
|
103 * @param aDisplayRect |
|
104 * @param aRefreshCachedRenderTarget ETrue makes sure that effect is rendered, EFalse may use cached |
|
105 * result if it is otherwise possible. |
|
106 * @param aOpaque, can be used for optimization so that when set to ETrue content behind visual is |
|
107 * not read from drawing surface. |
|
108 * @param aClipRegion If region contains rects, final composition to display is clipped according to |
|
109 * defined region. |
|
110 * |
|
111 * @return ETrue if drawing was done, otherwise EFalse |
|
112 */ |
|
113 TBool CachedDraw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aRefreshCachedRenderTarget, TBool aOpaque, const TRegion& aClipRegion, TInt aAlpha = 255); |
|
114 TBool CachedDraw(CHuiGc& aGc, const TRect& aDisplayRect, TBool aRefreshCachedRenderTarget, TBool aOpaque); |
|
115 |
|
116 void FxmlVisualInputs(RArray<THuiFxVisualSrcType> &aArray); |
|
117 private: |
|
118 |
|
119 TBool IsAppliedToBackground(); |
|
120 TBool IsFiltered() const; |
|
121 |
|
122 |
|
123 protected: |
|
124 CHuiFxEffect( CHuiFxEngine& aEngine ); |
|
125 void ConstructL(); |
|
126 |
|
127 CHuiFxGroupLayer* iRoot; |
|
128 CHuiFxEngine* iEngine; |
|
129 // The observer that wants to be called when the effect finishes |
|
130 // If no observer has been set, the pointer is NULL |
|
131 // This pointer is not owned, so it must not be deleted |
|
132 MAlfGfxEffectObserver* iEffectEndObserver; |
|
133 // The effect handle that will be returned to the observer when effect finishes |
|
134 TInt iHandle; |
|
135 // The flags will indicate special cases that will need special handling (like fade) |
|
136 TInt iFlags; |
|
137 // Cached render target which holds the effect result in pre-rendered format |
|
138 CHuiFxRenderbuffer* iCachedRenderTarget; |
|
139 |
|
140 TBool iForcedUseCachedRenderTarget; |
|
141 |
|
142 // Used for syncronizing effect start of effects with same group id. |
|
143 // See also KHuiFxWaitGroupSyncronization |
|
144 TInt iGroupId; |
|
145 |
|
146 TInt iFramesDrawn; |
|
147 }; |
|
148 |
|
149 #endif /*HUIFXEFFECT_H_*/ |