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