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