os/graphics/windowing/windowserverplugins/openwfc/inc/openwfcwrapper.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     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 CStdRenderStage;
    46 friend class CElementWrapper;
    47 
    48 public:
    49 	static COpenWfcWrapper* NewL(TInt aScreenNo, CDisplayPolicy* aDisplayPolicy);
    50 	TInt SetUiSurface(const TSurfaceId& aNewUiSurface);
    51 	~COpenWfcWrapper();
    52 	
    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);
    65 	void End();	
    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);
    73 	
    74     /*-------------------------------------------------------------------*//*
    75      * CBase interface implementation functions
    76      *//*-------------------------------------------------------------------*/
    77     //Standard symbian interface extension mechanism
    78     virtual TInt        Extension_              (TUint aExtensionId, TAny*& a0, TAny* a1);
    79 
    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...
    87         };
    88     
    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
    93      **/
    94     inline TAny* GetInterface(TUint aExtensionId);
    95 
    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
   101      **/
   102     template <class MClass> MClass* GetInterface()
   103     {
   104         return static_cast<MClass*>(GetInterface(MClass::ETypeId));
   105     }
   106     
   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 	*//*-------------------------------------------------------------------*/
   116 
   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 ;
   122 
   123     virtual void NotifyOnDisplayChange(TRequestStatus& aStatus);
   124     virtual void NotifyOnDisplayChangeCancel();
   125     virtual void NotifyOnConfigChange(TRequestStatus& aStatus);
   126     virtual void NotifyOnConfigChangeCancel();
   127 
   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
   133 
   134     static TInt TranslateOpenWfcError(WFCErrorCode error);
   135     static void DestroyAllContextElements(WFCDevice dev, WFCContext ctx);
   136     RSurfaceManager& SurfaceManager(){return iSurfaceManager;}
   137     EGLDisplay Display(){return iEGLDisplay;}
   138     
   139 private:
   140     COpenWfcWrapper(CDisplayPolicy* aDisplayPolicy);
   141 	void ConstructL(TInt aScreenId);
   142 	TInt AttachSurfaceToUiElement(CElementWrapper* aNewUiElement);
   143 	void SetCompositionModified();
   144 	
   145     static TUint32 HashFunction(const TSurfaceId& aHashKey);
   146     void  ComposeInternal(const TSurfaceId&  aOffScreenTarget,
   147                                  const TPoint&      aOrigin,
   148                                  MWsElement*      aStart,
   149                                  MWsElement*      aEnd,
   150                                  TRequestStatus*    aCompleted);
   151     TBool IsValidSurface(const TSurfaceId& aSurface);
   152 
   153 private:
   154 	TBool iPaused;
   155 	TBool iWithinBeginEnd;
   156 	TBool iCompositionModified;
   157 	TBool iAllowCompositorPause;
   158 	
   159 	CElementWrapper* iUiElement1;
   160 	CElementWrapper* iUiElement2;
   161 	
   162 	TSurfaceId iUiSurface;
   163 	CDisplayPolicy* iDisplayPolicy;
   164 	
   165 private:
   166     class OffScreenComposeGuard;
   167     
   168     struct SourceAndRef
   169         {
   170         WFCSource source;
   171         TInt sourceRef;
   172         TInt elementRef;
   173         };
   174     RHashMap<TSurfaceId, SourceAndRef> iSourceMap;
   175     
   176     WFCDevice iDevice;
   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;
   189 	};
   190 
   191 inline TAny* COpenWfcWrapper::GetInterface(TUint aExtensionId)
   192     {
   193     TAny*   retVal=NULL;
   194     //Note that extension is intentionally not overloaded in CCompositionBackend
   195     if (this->Extension_(aExtensionId,retVal,NULL)<KErrNone)
   196         {
   197         return NULL;
   198         }
   199     else
   200         {
   201         return retVal;
   202         }
   203     }
   204 
   205 #endif /*OPENWFCWRAPPER_H_*/