|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #if !defined(__WINDOWELEMENTSET_H__) |
|
17 #define __WINDOWELEMENTSET_H__ |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 */ |
|
23 |
|
24 #include <graphics/wselement.h> |
|
25 |
|
26 class CBase; |
|
27 class CWsClientWindow; |
|
28 class TSurfaceConfiguration; |
|
29 class MWsScene; |
|
30 |
|
31 class TAttributes |
|
32 { |
|
33 public: |
|
34 TAttributes(){iFlags = 0;} |
|
35 enum |
|
36 { |
|
37 EConcealed = 0x00000001, |
|
38 EDrawnOver = 0x00000002, |
|
39 EDrawnOverLast = 0x01000000, |
|
40 }; |
|
41 //flag accessors |
|
42 inline TBool Concealed() const {return iFlags&EConcealed;} |
|
43 inline void SetConcealed(TBool aSetting = ETrue) {aSetting?iFlags|=EConcealed:iFlags&=~EConcealed;} |
|
44 inline TBool DrawnOver() const {return iFlags&EDrawnOver;} |
|
45 inline void SetDrawnOver(TBool aSetting = ETrue) {aSetting?iFlags|=EDrawnOver:iFlags&=~EDrawnOver;} |
|
46 inline TBool DrawnOverLast() const {return iFlags&EDrawnOverLast;} |
|
47 inline void SetDrawnOverLast(TBool aSetting = ETrue) |
|
48 { iFlags= aSetting? iFlags|EDrawnOverLast:iFlags&~EDrawnOverLast; } |
|
49 inline TInt Flags()const |
|
50 { return iFlags; } |
|
51 TBool Destroy(MWsScene& aScene, TBool aUnregister); |
|
52 public: |
|
53 TInt DebugFlags()const { return iFlags; } |
|
54 protected: |
|
55 TUint iFlags; |
|
56 public: |
|
57 MWsElement* iElement; |
|
58 }; |
|
59 |
|
60 class TBackgroundAttributes : public TAttributes |
|
61 { |
|
62 public: |
|
63 enum |
|
64 { |
|
65 EExplicitExtent = 0x00010000, |
|
66 //EAbsoluteExtent = 0x00020000, //This would be used to represent wallpaper or DSA per window |
|
67 EExplicitViewPort = 0x00040000, |
|
68 }; |
|
69 //flag accessors |
|
70 inline TBool ExplicitExtent() const {return iFlags&EExplicitExtent;} |
|
71 inline void SetExplicitExtent(TBool aSetting = ETrue) |
|
72 { iFlags= aSetting? iFlags|EExplicitExtent:iFlags&~EExplicitExtent;} |
|
73 //Absolute extent functionality is currently not required or used |
|
74 // inline TBool AbsoluteExtent() const {return iFlags&EAbsoluteExtent;} |
|
75 // inline void SetAbsoluteExtent(TBool aSetting = ETrue) |
|
76 // { iFlags= aSetting? iFlags|EAbsoluteExtent:iFlags&~EAbsoluteExtent;} |
|
77 inline TBool ExplicitViewPort() const {return iFlags&EExplicitViewPort;} |
|
78 inline void SetExplicitViewPort(TBool aSetting = ETrue) |
|
79 { iFlags = aSetting ? iFlags|EExplicitViewPort : iFlags&~EExplicitExtent;} |
|
80 }; |
|
81 |
|
82 class TPlacedAttributes : public TAttributes |
|
83 { |
|
84 public: |
|
85 enum |
|
86 { |
|
87 EUnassigned = 0x00010000, |
|
88 ELockedConfig = 0x00020000, |
|
89 EChangedClip = 0x00040000, |
|
90 EOverlapping = 0x00080000, |
|
91 }; |
|
92 //flag accessors |
|
93 inline TBool Unassigned() const {return iFlags&EUnassigned ;} |
|
94 inline void SetUnassigned(TBool aSetting = ETrue) |
|
95 { iFlags= aSetting? iFlags|EUnassigned :iFlags&~EUnassigned; } |
|
96 inline TBool LockedConfig() const {return iFlags&ELockedConfig ;} |
|
97 inline void SetLockedConfig(TBool aSetting = ETrue) |
|
98 {aSetting?iFlags|=ELockedConfig:iFlags&=~ELockedConfig;} |
|
99 inline TBool ChangedClip() const {return iFlags&EChangedClip;} |
|
100 inline void SetChangedClip(TBool aSetting = ETrue) |
|
101 {aSetting?iFlags|=EChangedClip:iFlags&=~EChangedClip;} |
|
102 inline TBool Overlapping() const {return iFlags&EOverlapping;} |
|
103 inline void SetOverlapping(TBool aSetting = ETrue) |
|
104 { iFlags= aSetting? iFlags|EOverlapping:iFlags&~EOverlapping; } |
|
105 inline void ClearRedrawFlags() |
|
106 { iFlags &= (~(EUnassigned|ELockedConfig|EChangedClip|EOverlapping)); } |
|
107 }; |
|
108 |
|
109 class CWindowElement : public CBase |
|
110 { |
|
111 friend class CWindowElementSet; |
|
112 public: |
|
113 enum |
|
114 { |
|
115 EFastPath = 0x00000001, |
|
116 EPauseComposition = 0x00000002, //assign flags this if pause is needed immediately |
|
117 EResort = 0x00000004, |
|
118 EFailed = 0x00010000, //cleanup failure needs to be reported separately |
|
119 }; |
|
120 |
|
121 CWindowElement(const CWsClientWindow& aWindow); |
|
122 |
|
123 TInt UnassignPlacedElements(const TRegion& aRegion,TInt aGcDrawingCount); |
|
124 void FlagAssignedElementsDrawnOver(TInt aGcDrawingCount); |
|
125 static TBool IsElementAMatch(MWsElement&,const TSurfaceConfiguration&,TInt); |
|
126 static TInt SetElement(MWsElement&,const TSurfaceConfiguration&,TBool); |
|
127 TBool InsertCache(TInt aIndexToInsert); |
|
128 static void NotifyReleasingSurface(TSurfaceId aSurfaceId); |
|
129 TInt AssignPlacedElement(TPlacedAttributes*& aPlacedAttributes, |
|
130 const TSurfaceConfiguration& aSurfaceConfiguration, |
|
131 const TRegion& aUserDefinedRegion, MWsScene& aScene,TInt aGcDrawingCount); |
|
132 |
|
133 TInt CleanUpPlacedElements(MWsScene& aScene,TInt aGcDrawingCount); |
|
134 void MoveToAboveGivenElement(MWsScene& aScene, MWsElement* aAboveElement); |
|
135 void UpdateElementExtent(const TPoint* aOffset); |
|
136 TBool SetVisibleRegion(const TRegion& aRegion, MWsScene& aScene); |
|
137 TInt ReleaseAllElements(); |
|
138 TBool SearchDuplicateSurfaceId(const TSurfaceId& aSurfaceId); |
|
139 void SetElementOpacity(TInt aOpacity, MWsScene& aScene); |
|
140 void ResubmitAllElementExtents(); |
|
141 MWsElement* Element() const; |
|
142 |
|
143 protected: |
|
144 TInt AssignRecycleElement(const TInt aIndex, |
|
145 const TSurfaceConfiguration& aSurfaceConfiguration, |
|
146 const TRegion& aUserDefinedRegion, |
|
147 MWsScene& aScene); |
|
148 TInt AssignCreateElement(const TSurfaceConfiguration& aSurfaceConfiguration, |
|
149 const TRegion& aUserDefinedRegion, |
|
150 MWsScene& aScene); |
|
151 TInt AssignExtendElement(const TInt aIndex, |
|
152 const TSurfaceConfiguration& aSurfaceConfiguration, |
|
153 const TRegion& aUserDefinedRegion, |
|
154 MWsScene& aScene); |
|
155 |
|
156 public: |
|
157 const CWsClientWindow& iWindow; |
|
158 private: |
|
159 TBackgroundAttributes iBackgroundElement; |
|
160 RArray<TPlacedAttributes> iPlacedElements; |
|
161 private: //The following are all exclusively used during window rendering |
|
162 RArray<RRegion> iCache; |
|
163 //memory of surfaces that need to be removed |
|
164 RArray<TSurfaceId> iRemovedSurfaces; |
|
165 TBool iRemovedSurfacesValid; |
|
166 |
|
167 RRegion iNonRedrawVisibleRegion; |
|
168 TInt iHighestReusedIndex; |
|
169 TInt iStartGcDrawingCount; |
|
170 TUint iFlags; |
|
171 }; |
|
172 |
|
173 /** |
|
174 Owns the set of elements and their associated identification information. Only |
|
175 references are provided for clients. |
|
176 */ |
|
177 class CWindowElementSet : public CBase |
|
178 { |
|
179 public: |
|
180 static CWindowElementSet* NewL(MWsScene& aScene); |
|
181 ~CWindowElementSet(); |
|
182 TBackgroundAttributes& AcquireBackgroundElementL(CWsClientWindow& aWindow); |
|
183 TInt ReleaseBackgroundElement(const CWsClientWindow&, TBool aWindowClosing = EFalse); |
|
184 TInt ReleaseAllElements(const CWsClientWindow&, TBool aWindowClosing = EFalse); |
|
185 TInt UnassignPlacedElements(const TRegion& aRedrawRegion, const CWsClientWindow& aWindow,TInt aGcDrawingCount); |
|
186 TInt AssignPlacedElement(TPlacedAttributes*&, const TSurfaceConfiguration&, const TRegion& aUserDefinedRegion, |
|
187 const CWsClientWindow&,TInt aGcDrawingCount); |
|
188 TInt CleanUpPlacedElements(const CWsClientWindow& aWindow,TInt aGcDrawingCount); |
|
189 TInt Count() const; |
|
190 TBackgroundAttributes* FindBackgroundElement(const CWsClientWindow&); |
|
191 TBool FindElements(const CWsClientWindow&,const TBackgroundAttributes*&,const RArray<TPlacedAttributes>*&); |
|
192 TInt RegisterSurface(const TSurfaceId& aSurface); |
|
193 void UnregisterSurface(const TSurfaceId& aSurface); |
|
194 TBool SortByZOrder(); |
|
195 TInt SetVisibleRegion(CWsClientWindow& aWindow); //cant be a const win as VisibleRegion() isnt const?? |
|
196 void UpdateElementExtent(const CWsClientWindow&, const TPoint* aOffset); |
|
197 static TInt GetConfiguration(TSurfaceConfiguration&,MWsElement&); |
|
198 TBool SearchDuplicateSurfaceId(const TSurfaceId& aSurfaceId); |
|
199 void SetElementOpacity(CWsClientWindow& aWindow, TInt aOpacity); |
|
200 void ResubmitAllElementExtents(); |
|
201 MWsElement* GetElementFromWindow(const CWsClientWindow& aWindow) const; |
|
202 |
|
203 public: |
|
204 const CWsClientWindow* DebugWindowAt(TUint aWin)const; |
|
205 const TBackgroundAttributes* DebugBackgroundAt(TUint aWin)const; |
|
206 const TPlacedAttributes* DebugPlacedAt(TUint aWin,TUint aPlace)const; |
|
207 //Note: The following methods are currently unused |
|
208 // const TPlacedAttributes* DebugPlacedAt(const CWsClientWindow& aWindow,TInt aPlace)const; |
|
209 // const RRegion* DebugCacheAt(TInt aWin,TInt aPlace)const; |
|
210 TInt DebugPlacedCountAt(TUint aWin)const; |
|
211 |
|
212 protected: |
|
213 CWindowElement* FindElement(const CWsClientWindow& aWindow) const; |
|
214 |
|
215 private: |
|
216 CWindowElementSet(MWsScene& aScene); |
|
217 TInt FindEntry(const CWsClientWindow& aWindow, TInt& aIndex, TBool aLinearSearch = EFalse) const; |
|
218 static TBool WindowMatch(const CWindowElement& aFirst, const CWindowElement& aSecond); |
|
219 static TInt WindowOrder(const CWindowElement& aFirst, const CWindowElement& aSecond); |
|
220 void DestroyWindowElementEntry(const TInt aWinElementIndex); |
|
221 |
|
222 private: |
|
223 RPointerArray<CWindowElement> iElements; |
|
224 MWsScene& iScene; |
|
225 }; |
|
226 |
|
227 /** Gc to element rotation function |
|
228 */ |
|
229 inline MWsElement::TElementRotation GcToElementRotation(CFbsBitGc::TGraphicsOrientation aGcRotation) |
|
230 { |
|
231 MWsElement::TElementRotation elementRotation = MWsElement::EElementAntiClockwise0; |
|
232 |
|
233 switch (aGcRotation) |
|
234 { |
|
235 case CFbsBitGc::EGraphicsOrientationRotated90: |
|
236 elementRotation = MWsElement::EElementAntiClockwise90; |
|
237 break; |
|
238 case CFbsBitGc::EGraphicsOrientationRotated180: |
|
239 elementRotation = MWsElement::EElementAntiClockwise180; |
|
240 break; |
|
241 case CFbsBitGc::EGraphicsOrientationRotated270: |
|
242 elementRotation = MWsElement::EElementAntiClockwise270; |
|
243 break; |
|
244 default: |
|
245 break; |
|
246 } |
|
247 return elementRotation; |
|
248 } |
|
249 |
|
250 #endif // !defined(__WINDOWELEMENTSET_H__) |