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