|
1 // Copyright (c) 2008-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 #ifndef OPENWFCWRAPPER_H_ |
|
17 #define OPENWFCWRAPPER_H_ |
|
18 |
|
19 #include <babitflags.h> |
|
20 #include <graphics/wsscene.h> |
|
21 #include <babitflags.h> |
|
22 #include <graphics/surface.h> |
|
23 #include "displaypolicy.h" |
|
24 |
|
25 // |
|
26 //OpenWFC stuff |
|
27 |
|
28 #include <e32std.h> |
|
29 #include <e32base.h> |
|
30 #include <e32hashtab.h> //for RHashMap |
|
31 #include <WF/wfc.h> |
|
32 #include <EGL/egl.h> |
|
33 #include <graphics/surfacemanager.h> |
|
34 #include <graphics/wsdisplaycontrol.h> |
|
35 |
|
36 // |
|
37 |
|
38 class COpenWfcJobManger; |
|
39 |
|
40 class TDisplayConfiguration; |
|
41 class CElementWrapper; |
|
42 |
|
43 class COpenWfcWrapper : public CBase, public MWsDisplayControl |
|
44 { |
|
45 friend class CElementWrapper; |
|
46 |
|
47 public: |
|
48 static COpenWfcWrapper* NewL(TInt aScreenNo, CDisplayPolicy* aDisplayPolicy); |
|
49 TInt SetUiSurface(const TSurfaceId& aNewUiSurface); |
|
50 ~COpenWfcWrapper(); |
|
51 |
|
52 MWsElement* CreateElementL(); |
|
53 void DestroyElement(MWsElement* aElement); |
|
54 void Compose(const TSurfaceId& aOffScreenTarget, const TPoint& aOrigin, |
|
55 MWsElement* aStart, MWsElement* aEnd, TRequestStatus* aCompleted); |
|
56 TInt AddElement(MWsElement* aElement, MWsElement* aAbove); |
|
57 void RemoveElement(MWsElement* aElement); |
|
58 void PauseCompositorIfNeeded(); |
|
59 void ResumeCompositorIfPaused(); |
|
60 void SetScreenRotation(MWsScene::TSceneRotation aRotation); |
|
61 MWsScene::TSceneRotation ScreenRotation() const; |
|
62 TSize ScreenSize() const; |
|
63 void Begin(const TRegion* aRegion); |
|
64 void End(); |
|
65 TBool CompositionDue (); |
|
66 void Compose(TRequestStatus* aCompleted); |
|
67 TInt FlushedSetConfiguration(const TDisplayConfiguration& aConfig); |
|
68 TBool WithinBeginEnd() { return iWithinBeginEnd; }; |
|
69 CDisplayPolicy* DisplayPolicy(); |
|
70 void FlushSceneElementChanges (); |
|
71 void RemoveElementFromSceneList(CElementWrapper* aElement); |
|
72 |
|
73 /*-------------------------------------------------------------------*//* |
|
74 * CBase interface implementation functions |
|
75 *//*-------------------------------------------------------------------*/ |
|
76 //Standard symbian interface extension mechanism |
|
77 virtual TInt Extension_ (TUint aExtensionId, TAny*& a0, TAny* a1); |
|
78 |
|
79 enum TInternalExtensionGuids |
|
80 { //These debug object interfaces need not be supported at runtime or on all platforms |
|
81 EExtensionDebugBackendGuid = 0x1028589A, |
|
82 EExtensionDebugContextGuid = 0x1028589B, |
|
83 EExtensionDebugDeviceGuid = 0x1028589C, |
|
84 EExtensionDebugElementGuid = 0x1028589D, |
|
85 EExtensionDebugSourceGuid = 0x1028589E, //F still spare when this was written... |
|
86 }; |
|
87 |
|
88 /** Get Extension Interface. |
|
89 * Implemented using the CBase::Extension_() mechanism |
|
90 * @param aExtensionId The GUID/ Well-known ID of the interface |
|
91 * @return pointer to the interface or NULL if not available |
|
92 **/ |
|
93 inline TAny* GetInterface(TUint aExtensionId); |
|
94 |
|
95 /** Get Extension Interface - templated helper. |
|
96 * Resolves the ID and returned pointer based on the class name. |
|
97 * Class name should support ETypeId intergral value, else use non-template version. |
|
98 * @param MClass The class of the interface with embedded GUID / Well known ID |
|
99 * @return pointer to the interface or NULL if not available |
|
100 **/ |
|
101 template <class MClass> MClass* GetInterface() |
|
102 { |
|
103 return static_cast<MClass*>(GetInterface(MClass::ETypeId)); |
|
104 } |
|
105 |
|
106 TInt RegisterSurface(const TSurfaceId& aSurface); |
|
107 TInt UnregisterSurface(const TSurfaceId& aSurface); |
|
108 void Compose(const TSurfaceId& aOffScreenTarget, TRequestStatus* aCompleted); |
|
109 virtual TBitFlags32 SupportedScreenRotations() const; |
|
110 void PauseComposition(); |
|
111 void ResumeComposition (); |
|
112 /*-------------------------------------------------------------------*//* |
|
113 * MWsDisplayControl/MDisplayControlBase interface implementation functions |
|
114 *//*-------------------------------------------------------------------*/ |
|
115 |
|
116 virtual TInt NumberOfResolutions()const ; |
|
117 virtual TInt GetResolutions(RArray<TResolution>& aResolutions)const ; |
|
118 virtual void GetConfiguration(TDisplayConfiguration& aConfig)const ; |
|
119 virtual TInt SetConfiguration(const TDisplayConfiguration& aConfig) ; |
|
120 virtual TInt PreferredDisplayVersion()const ; |
|
121 |
|
122 virtual void NotifyOnDisplayChange(TRequestStatus& aStatus); |
|
123 virtual void NotifyOnDisplayChangeCancel(); |
|
124 virtual void NotifyOnConfigChange(TRequestStatus& aStatus); |
|
125 virtual void NotifyOnConfigChangeCancel(); |
|
126 |
|
127 //"secret" methods available to element |
|
128 WFCDevice Device(){return iDevice;} |
|
129 WFCContext OnScreenContext() {return iOnScreenContext;} |
|
130 WFCSource IncEltRefRegSource(const TSurfaceId& aHashKey); //<@return registered source handle or NULL if not registered |
|
131 TInt DecEltRefRegSource(const TSurfaceId& aHashKey); //<@return 0=destroyed, +ve count left, -ve error |
|
132 |
|
133 static TInt TranslateOpenWfcError(WFCErrorCode error); |
|
134 static void DestroyAllContextElements(WFCDevice dev, WFCContext ctx); |
|
135 RSurfaceManager& SurfaceManager(){return iSurfaceManager;} |
|
136 EGLDisplay Display(){return iEGLDisplay;} |
|
137 |
|
138 private: |
|
139 COpenWfcWrapper(CDisplayPolicy* aDisplayPolicy); |
|
140 void ConstructL(TInt aScreenId); |
|
141 TInt AttachSurfaceToUiElement(CElementWrapper* aNewUiElement); |
|
142 void SetCompositionModified(); |
|
143 |
|
144 static TUint32 HashFunction(const TSurfaceId& aHashKey); |
|
145 void ComposeInternal(const TSurfaceId& aOffScreenTarget, |
|
146 const TPoint& aOrigin, |
|
147 MWsElement* aStart, |
|
148 MWsElement* aEnd, |
|
149 TRequestStatus* aCompleted); |
|
150 TBool IsValidSurface(const TSurfaceId& aSurface); |
|
151 |
|
152 private: |
|
153 TBool iPaused; |
|
154 TBool iWithinBeginEnd; |
|
155 TBool iCompositionModified; |
|
156 TBool iAllowCompositorPause; |
|
157 |
|
158 CElementWrapper* iUiElement1; |
|
159 CElementWrapper* iUiElement2; |
|
160 |
|
161 TSurfaceId iUiSurface; |
|
162 CDisplayPolicy* iDisplayPolicy; |
|
163 |
|
164 private: |
|
165 class OffScreenComposeGuard; |
|
166 |
|
167 struct SourceAndRef |
|
168 { |
|
169 WFCSource source; |
|
170 TInt sourceRef; |
|
171 TInt elementRef; |
|
172 }; |
|
173 RHashMap<TSurfaceId, SourceAndRef> iSourceMap; |
|
174 |
|
175 WFCDevice iDevice; |
|
176 WFCContext iOnScreenContext; |
|
177 EGLDisplay iEGLDisplay; |
|
178 WFCint iScreenNumber; |
|
179 static const TInt iInitialSourceMapSize = 0x0; |
|
180 CElementWrapper* iSceneElementList; //all elements visible in the scene hierarchy |
|
181 CElementWrapper* iRemoveElementList; //all elements removed from the scene hierarchy |
|
182 CElementWrapper* iCleanupElementList; //all elements currently allocated are destroyed on cleanup |
|
183 COpenWfcJobManger* iJobManager; |
|
184 MWsScene::TSceneRotation iRotation; |
|
185 TBool iAutonomousCompositionInitiated; |
|
186 MDisplayControlBase* iContextDisplayControl; |
|
187 RSurfaceManager iSurfaceManager; |
|
188 }; |
|
189 |
|
190 inline TAny* COpenWfcWrapper::GetInterface(TUint aExtensionId) |
|
191 { |
|
192 TAny* retVal=NULL; |
|
193 //Note that extension is intentionally not overloaded in CCompositionBackend |
|
194 if (this->Extension_(aExtensionId,retVal,NULL)<KErrNone) |
|
195 { |
|
196 return NULL; |
|
197 } |
|
198 else |
|
199 { |
|
200 return retVal; |
|
201 } |
|
202 } |
|
203 |
|
204 #endif /*OPENWFCWRAPPER_H_*/ |