First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined(__WINDOWELEMENTSET_H__)
17 #define __WINDOWELEMENTSET_H__
24 #include <graphics/wselement.h>
27 class CWsClientWindow;
28 class TSurfaceConfiguration;
34 TAttributes(){iFlags = 0;}
37 EConcealed = 0x00000001,
38 EDrawnOver = 0x00000002,
39 EDrawnOverLast = 0x01000000,
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
51 TBool Destroy(MWsScene& aScene, TBool aUnregister);
53 TInt DebugFlags()const { return iFlags; }
60 class TBackgroundAttributes : public TAttributes
65 EExplicitExtent = 0x00010000,
66 //EAbsoluteExtent = 0x00020000, //This would be used to represent wallpaper or DSA per window
67 EExplicitViewPort = 0x00040000,
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;}
82 class TPlacedAttributes : public TAttributes
87 EUnassigned = 0x00010000,
88 ELockedConfig = 0x00020000,
89 EChangedClip = 0x00040000,
90 EOverlapping = 0x00080000,
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)); }
109 class CWindowElement : public CBase
111 friend class CWindowElementSet;
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
121 CWindowElement(const CWsClientWindow& aWindow);
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);
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;
144 TInt AssignRecycleElement(const TInt aIndex,
145 const TSurfaceConfiguration& aSurfaceConfiguration,
146 const TRegion& aUserDefinedRegion,
148 TInt AssignCreateElement(const TSurfaceConfiguration& aSurfaceConfiguration,
149 const TRegion& aUserDefinedRegion,
151 TInt AssignExtendElement(const TInt aIndex,
152 const TSurfaceConfiguration& aSurfaceConfiguration,
153 const TRegion& aUserDefinedRegion,
157 const CWsClientWindow& iWindow;
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;
167 RRegion iNonRedrawVisibleRegion;
168 TInt iHighestReusedIndex;
169 TInt iStartGcDrawingCount;
174 Owns the set of elements and their associated identification information. Only
175 references are provided for clients.
177 class CWindowElementSet : public CBase
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);
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;
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;
213 CWindowElement* FindElement(const CWsClientWindow& aWindow) const;
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);
223 RPointerArray<CWindowElement> iElements;
227 /** Gc to element rotation function
229 inline MWsElement::TElementRotation GcToElementRotation(CFbsBitGc::TGraphicsOrientation aGcRotation)
231 MWsElement::TElementRotation elementRotation = MWsElement::EElementAntiClockwise0;
235 case CFbsBitGc::EGraphicsOrientationRotated90:
236 elementRotation = MWsElement::EElementAntiClockwise90;
238 case CFbsBitGc::EGraphicsOrientationRotated180:
239 elementRotation = MWsElement::EElementAntiClockwise180;
241 case CFbsBitGc::EGraphicsOrientationRotated270:
242 elementRotation = MWsElement::EElementAntiClockwise270;
247 return elementRotation;
250 #endif // !defined(__WINDOWELEMENTSET_H__)