43 |
43 |
44 struct CHuiVisual::THuiVisualPrivateData |
44 struct CHuiVisual::THuiVisualPrivateData |
45 { |
45 { |
46 public: // Functions |
46 public: // Functions |
47 // Constructor: initialize the data |
47 // Constructor: initialize the data |
48 THuiVisualPrivateData() : iTacticons(), iDropShadow(NULL) |
48 THuiVisualPrivateData() |
49 { |
49 : iTacticons(), iDropShadow(NULL), iEffect(NULL), |
50 iEffect = NULL; |
50 iEffectParser(NULL), iEffectable(NULL), iStoredRenderBuffer(NULL), |
51 iEffectParser = NULL; |
51 iStoredRenderBufferModificationsEnabled(ETrue), |
|
52 iFreezed(EFalse) |
|
53 { |
52 } |
54 } |
53 |
55 |
54 // Destructor: destruct the data |
56 // Destructor: destruct the data |
55 ~THuiVisualPrivateData() |
57 ~THuiVisualPrivateData() |
56 { |
58 { |
80 class CHuiEffectable : public CBase, public MHuiEffectable |
82 class CHuiEffectable : public CBase, public MHuiEffectable |
81 { |
83 { |
82 public: // from MHuiEffectable |
84 public: // from MHuiEffectable |
83 CHuiEffectable(CHuiVisual *aVisual) : iVisual(aVisual) { } |
85 CHuiEffectable(CHuiVisual *aVisual) : iVisual(aVisual) { } |
84 void EffectSetEffect(CHuiFxEffect* aEffect); |
86 void EffectSetEffect(CHuiFxEffect* aEffect); |
85 TReal32 EffectOpacityTarget() const; |
87 TReal32 EffectOpacity() const; |
86 void EffectSetOpacity(TReal32 aOpacity); |
88 void EffectSetOpacityAdditive(TReal32 aOpacity, TBool aReplace); |
87 void EffectDrawSelf( CHuiGc &aGc, const TRect & aDisplayRect) const; |
89 void EffectDrawSelf( CHuiGc &aGc, const TRect & aDisplayRect) const; |
88 THuiRealRect EffectDisplayRect() const __SOFTFP; |
90 THuiRealRect EffectDisplayRect() const __SOFTFP; |
89 void SetLoadingEffect(TBool aLoading); |
91 void SetLoadingEffect(TBool aLoading); |
90 void EffectSetSource( TBool aIsInput1 ); |
92 void EffectSetSource( TBool aIsInput1 ); |
91 TBool EffectGetSource() const; |
93 TBool EffectGetSource() const; |
92 |
94 TBool EffectReadyToDrawNextFrame() const; |
|
95 |
|
96 |
93 private: |
97 private: |
94 CHuiVisual *iVisual; |
98 CHuiVisual *iVisual; |
95 TBool iIsInput1; |
99 TBool iIsInput1; |
96 }; |
100 }; |
97 void CHuiEffectable::EffectSetEffect(CHuiFxEffect* aEffect) |
101 void CHuiEffectable::EffectSetEffect(CHuiFxEffect* aEffect) |
105 TBool CHuiEffectable::EffectGetSource() const |
109 TBool CHuiEffectable::EffectGetSource() const |
106 { |
110 { |
107 return iIsInput1; |
111 return iIsInput1; |
108 } |
112 } |
109 |
113 |
110 TReal32 CHuiEffectable::EffectOpacityTarget() const |
114 TBool CHuiEffectable::EffectReadyToDrawNextFrame() const |
111 { |
115 { |
112 return iVisual->iOpacity.Target(); |
116 return iVisual->EffectReadyToDrawNextFrame(); |
113 } |
117 } |
114 |
118 |
115 void CHuiEffectable::EffectSetOpacity(TReal32 aOpacity) |
119 TReal32 CHuiEffectable::EffectOpacity() const |
116 { |
120 { |
117 iVisual->iOpacity.Set( aOpacity ); |
121 return iVisual->iEffectOpacity; |
|
122 } |
|
123 |
|
124 void CHuiEffectable::EffectSetOpacityAdditive(TReal32 aOpacity, TBool aReplace) |
|
125 { |
|
126 if( aReplace || aOpacity > iVisual->iEffectOpacity) |
|
127 { |
|
128 iVisual->iEffectOpacity = aOpacity; |
|
129 } |
118 } |
130 } |
119 |
131 |
120 void CHuiEffectable::EffectDrawSelf( CHuiGc &aGc, const TRect & aDisplayRect) const |
132 void CHuiEffectable::EffectDrawSelf( CHuiGc &aGc, const TRect & aDisplayRect) const |
121 { |
133 { |
122 iVisual->DrawSelf(aGc, aDisplayRect); |
134 iVisual->DrawSelf(aGc, aDisplayRect); |
182 TBool CHuiVisual::Freezed() const |
194 TBool CHuiVisual::Freezed() const |
183 { |
195 { |
184 return iVisualData->iFreezed; |
196 return iVisualData->iFreezed; |
185 } |
197 } |
186 |
198 |
|
199 EXPORT_C TBool CHuiVisual::EffectReadyToDrawNextFrame() const |
|
200 { |
|
201 return ETrue; |
|
202 } |
|
203 |
187 EXPORT_C CHuiVisual* CHuiVisual::AddNewL(CHuiControl& aOwnerControl, |
204 EXPORT_C CHuiVisual* CHuiVisual::AddNewL(CHuiControl& aOwnerControl, |
188 CHuiLayout* aParentLayout) |
205 CHuiLayout* aParentLayout) |
189 { |
206 { |
190 CHuiVisual* visual = STATIC_CAST(CHuiVisual*, |
207 CHuiVisual* visual = STATIC_CAST(CHuiVisual*, |
191 aOwnerControl.AppendVisualL(EHuiVisualTypeVisual, aParentLayout)); |
208 aOwnerControl.AppendVisualL(EHuiVisualTypeVisual, aParentLayout)); |
193 } |
210 } |
194 |
211 |
195 |
212 |
196 EXPORT_C CHuiVisual::CHuiVisual(MHuiVisualOwner& aOwner) |
213 EXPORT_C CHuiVisual::CHuiVisual(MHuiVisualOwner& aOwner) |
197 : iOpacity(1.f), |
214 : iOpacity(1.f), |
|
215 iEffectOpacity(1.f), |
198 iOwner(&aOwner), |
216 iOwner(&aOwner), |
199 // Set the maximum size to unlimited. |
217 // Set the maximum size to unlimited. |
200 iMaxSize(TSize(KMaxTInt, KMaxTInt)), |
218 iMaxSize(TSize(KMaxTInt, KMaxTInt)), |
201 iPadding(0), |
219 iPadding(0), |
202 iDisplayRectFrameNumber(KMaxTUint), |
220 iDisplayRectFrameNumber(KMaxTUint), |
915 // Flag to know what we did |
935 // Flag to know what we did |
916 TBool didDrawEffect = EFalse; |
936 TBool didDrawEffect = EFalse; |
917 |
937 |
918 if (canUseEffectDrawing) |
938 if (canUseEffectDrawing) |
919 { |
939 { |
920 // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing |
940 Effectable()->EffectSetOpacityAdditive(0.0f, ETrue); |
921 TBool transparent = !(Flags() & EHuiVisualFlagOpaqueHint); |
941 // PrepareDrawL will update iEffectOpacity for current frame |
922 TBool refreshCache = Changed(); |
942 if(iVisualData->iEffect->PrepareDrawL(aGc, displayRect)) |
923 didDrawEffect = iVisualData->iEffect->CachedDraw(aGc, displayRect, refreshCache, !transparent); |
943 { |
|
944 if(iEffectOpacity <= 0.f) |
|
945 { |
|
946 if(Clipping()) |
|
947 { |
|
948 aGc.PopClip(); |
|
949 } |
|
950 |
|
951 // Draw foreground brushes (over the content). |
|
952 DrawBrushes(aGc, EHuiBrushLayerForeground); |
|
953 |
|
954 // Undo local transformation. |
|
955 Transform(aGc, EFalse); |
|
956 EnterLocalProjection(aGc, EFalse); |
|
957 return; |
|
958 } |
|
959 // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing |
|
960 TBool transparent = !(Flags() & EHuiVisualFlagOpaqueHint); |
|
961 TBool refreshCache = Changed(); |
|
962 didDrawEffect = iVisualData->iEffect->CachedDraw(aGc, displayRect, refreshCache, !transparent); |
|
963 } |
924 } |
964 } |
925 |
965 |
926 if (!didDrawEffect) |
966 if (!didDrawEffect) |
927 { |
967 { |
928 // Draw the visual instead if the effect failed |
968 // Draw the visual instead if the effect failed |