os/graphics/windowing/windowserverplugins/openwfc/inc/openwfcwrapper.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserverplugins/openwfc/inc/openwfcwrapper.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,205 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef OPENWFCWRAPPER_H_
    1.20 +#define OPENWFCWRAPPER_H_
    1.21 +
    1.22 +#include <babitflags.h>
    1.23 +#include <graphics/wsscene.h>
    1.24 +#include <babitflags.h>
    1.25 +#include <graphics/surface.h>
    1.26 +#include "displaypolicy.h"
    1.27 +
    1.28 +//
    1.29 +//OpenWFC stuff
    1.30 +
    1.31 +#include <e32std.h>
    1.32 +#include <e32base.h>
    1.33 +#include <e32hashtab.h>     //for RHashMap
    1.34 +#include <WF/wfc.h>
    1.35 +#include <EGL/egl.h>
    1.36 +#include <graphics/surfacemanager.h>
    1.37 +#include <graphics/wsdisplaycontrol.h>
    1.38 +
    1.39 +//
    1.40 +
    1.41 +class COpenWfcJobManger;
    1.42 +
    1.43 +class TDisplayConfiguration;
    1.44 +class CElementWrapper;
    1.45 +
    1.46 +class COpenWfcWrapper : public CBase, public MWsDisplayControl
    1.47 +	{
    1.48 +friend class CStdRenderStage;
    1.49 +friend class CElementWrapper;
    1.50 +
    1.51 +public:
    1.52 +	static COpenWfcWrapper* NewL(TInt aScreenNo, CDisplayPolicy* aDisplayPolicy);
    1.53 +	TInt SetUiSurface(const TSurfaceId& aNewUiSurface);
    1.54 +	~COpenWfcWrapper();
    1.55 +	
    1.56 +	MWsElement* CreateElementL();
    1.57 +	void DestroyElement(MWsElement* aElement);
    1.58 +	void Compose(const TSurfaceId& aOffScreenTarget, const TPoint& aOrigin,
    1.59 +	             MWsElement* aStart, MWsElement* aEnd, TRequestStatus* aCompleted);
    1.60 +	TInt AddElement(MWsElement* aElement, MWsElement* aAbove);
    1.61 +	void RemoveElement(MWsElement* aElement);
    1.62 +	void PauseCompositorIfNeeded();
    1.63 +	void ResumeCompositorIfPaused();
    1.64 +	void SetScreenRotation(MWsScene::TSceneRotation aRotation);
    1.65 +	MWsScene::TSceneRotation ScreenRotation() const;
    1.66 +	TSize ScreenSize() const;
    1.67 +	void Begin(const TRegion* aRegion);
    1.68 +	void End();	
    1.69 +	TBool CompositionDue ();
    1.70 +	void Compose(TRequestStatus* aCompleted);
    1.71 +	TInt FlushedSetConfiguration(const TDisplayConfiguration& aConfig);
    1.72 +    TBool WithinBeginEnd() { return iWithinBeginEnd; };
    1.73 +	CDisplayPolicy* DisplayPolicy();
    1.74 +    void FlushSceneElementChanges ();
    1.75 +    void RemoveElementFromSceneList(CElementWrapper* aElement);
    1.76 +	
    1.77 +    /*-------------------------------------------------------------------*//*
    1.78 +     * CBase interface implementation functions
    1.79 +     *//*-------------------------------------------------------------------*/
    1.80 +    //Standard symbian interface extension mechanism
    1.81 +    virtual TInt        Extension_              (TUint aExtensionId, TAny*& a0, TAny* a1);
    1.82 +
    1.83 +    enum    TInternalExtensionGuids
    1.84 +        {   //These debug object interfaces need not be supported at runtime or on all platforms
    1.85 +        EExtensionDebugBackendGuid  =   0x1028589A,
    1.86 +        EExtensionDebugContextGuid  =   0x1028589B,
    1.87 +        EExtensionDebugDeviceGuid   =   0x1028589C,
    1.88 +        EExtensionDebugElementGuid  =   0x1028589D,
    1.89 +        EExtensionDebugSourceGuid   =   0x1028589E, //F still spare when this was written...
    1.90 +        };
    1.91 +    
    1.92 +    /**    Get Extension Interface.
    1.93 +     *  Implemented using the CBase::Extension_() mechanism 
    1.94 +     *  @param  aExtensionId    The GUID/ Well-known ID of the interface
    1.95 +     *  @return pointer to the interface or NULL if not available
    1.96 +     **/
    1.97 +    inline TAny* GetInterface(TUint aExtensionId);
    1.98 +
    1.99 +    /** Get Extension Interface - templated helper.
   1.100 +     *  Resolves the ID and returned pointer based on the class name.
   1.101 +     *  Class name should support ETypeId intergral value, else use non-template version. 
   1.102 +     *  @param  MClass  The class of the interface with embedded GUID / Well known ID 
   1.103 +     *  @return pointer to the interface or NULL if not available
   1.104 +     **/
   1.105 +    template <class MClass> MClass* GetInterface()
   1.106 +    {
   1.107 +        return static_cast<MClass*>(GetInterface(MClass::ETypeId));
   1.108 +    }
   1.109 +    
   1.110 +    TInt RegisterSurface(const TSurfaceId& aSurface);
   1.111 +    TInt UnregisterSurface(const TSurfaceId& aSurface);
   1.112 +    void Compose(const TSurfaceId& aOffScreenTarget, TRequestStatus* aCompleted);
   1.113 +    virtual TBitFlags32 SupportedScreenRotations() const;
   1.114 +    void PauseComposition();
   1.115 +    void ResumeComposition ();
   1.116 +	/*-------------------------------------------------------------------*//*
   1.117 +	* MWsDisplayControl/MDisplayControlBase interface implementation functions
   1.118 +	*//*-------------------------------------------------------------------*/
   1.119 +
   1.120 +    virtual TInt NumberOfResolutions()const ;
   1.121 +    virtual TInt GetResolutions(RArray<TResolution>& aResolutions)const ;
   1.122 +    virtual void GetConfiguration(TDisplayConfiguration& aConfig)const ;
   1.123 +    virtual TInt SetConfiguration(const TDisplayConfiguration& aConfig) ;
   1.124 +    virtual TInt PreferredDisplayVersion()const ;
   1.125 +
   1.126 +    virtual void NotifyOnDisplayChange(TRequestStatus& aStatus);
   1.127 +    virtual void NotifyOnDisplayChangeCancel();
   1.128 +    virtual void NotifyOnConfigChange(TRequestStatus& aStatus);
   1.129 +    virtual void NotifyOnConfigChangeCancel();
   1.130 +
   1.131 +    //"secret" methods available to element
   1.132 +    WFCDevice Device(){return iDevice;}
   1.133 +    WFCContext OnScreenContext()   {return iOnScreenContext;}
   1.134 +    WFCSource IncEltRefRegSource(const TSurfaceId& aHashKey); //<@return registered source handle or NULL if not registered
   1.135 +    TInt DecEltRefRegSource(const TSurfaceId& aHashKey); //<@return 0=destroyed, +ve count left, -ve error
   1.136 +
   1.137 +    static TInt TranslateOpenWfcError(WFCErrorCode error);
   1.138 +    static void DestroyAllContextElements(WFCDevice dev, WFCContext ctx);
   1.139 +    RSurfaceManager& SurfaceManager(){return iSurfaceManager;}
   1.140 +    EGLDisplay Display(){return iEGLDisplay;}
   1.141 +    
   1.142 +private:
   1.143 +    COpenWfcWrapper(CDisplayPolicy* aDisplayPolicy);
   1.144 +	void ConstructL(TInt aScreenId);
   1.145 +	TInt AttachSurfaceToUiElement(CElementWrapper* aNewUiElement);
   1.146 +	void SetCompositionModified();
   1.147 +	
   1.148 +    static TUint32 HashFunction(const TSurfaceId& aHashKey);
   1.149 +    void  ComposeInternal(const TSurfaceId&  aOffScreenTarget,
   1.150 +                                 const TPoint&      aOrigin,
   1.151 +                                 MWsElement*      aStart,
   1.152 +                                 MWsElement*      aEnd,
   1.153 +                                 TRequestStatus*    aCompleted);
   1.154 +    TBool IsValidSurface(const TSurfaceId& aSurface);
   1.155 +
   1.156 +private:
   1.157 +	TBool iPaused;
   1.158 +	TBool iWithinBeginEnd;
   1.159 +	TBool iCompositionModified;
   1.160 +	TBool iAllowCompositorPause;
   1.161 +	
   1.162 +	CElementWrapper* iUiElement1;
   1.163 +	CElementWrapper* iUiElement2;
   1.164 +	
   1.165 +	TSurfaceId iUiSurface;
   1.166 +	CDisplayPolicy* iDisplayPolicy;
   1.167 +	
   1.168 +private:
   1.169 +    class OffScreenComposeGuard;
   1.170 +    
   1.171 +    struct SourceAndRef
   1.172 +        {
   1.173 +        WFCSource source;
   1.174 +        TInt sourceRef;
   1.175 +        TInt elementRef;
   1.176 +        };
   1.177 +    RHashMap<TSurfaceId, SourceAndRef> iSourceMap;
   1.178 +    
   1.179 +    WFCDevice iDevice;
   1.180 +    WFCContext iOnScreenContext;
   1.181 +    EGLDisplay iEGLDisplay;
   1.182 +    WFCint iScreenNumber;
   1.183 +    static const TInt iInitialSourceMapSize = 0x0;
   1.184 +    CElementWrapper* iSceneElementList;      //all elements visible in the scene hierarchy
   1.185 +    CElementWrapper* iRemoveElementList;     //all elements removed from the scene hierarchy
   1.186 +    CElementWrapper* iCleanupElementList;    //all elements currently allocated are destroyed on cleanup
   1.187 +    COpenWfcJobManger* iJobManager;
   1.188 +    MWsScene::TSceneRotation iRotation;
   1.189 +    TBool iAutonomousCompositionInitiated;
   1.190 +    MDisplayControlBase* iContextDisplayControl;
   1.191 +    RSurfaceManager iSurfaceManager;
   1.192 +	};
   1.193 +
   1.194 +inline TAny* COpenWfcWrapper::GetInterface(TUint aExtensionId)
   1.195 +    {
   1.196 +    TAny*   retVal=NULL;
   1.197 +    //Note that extension is intentionally not overloaded in CCompositionBackend
   1.198 +    if (this->Extension_(aExtensionId,retVal,NULL)<KErrNone)
   1.199 +        {
   1.200 +        return NULL;
   1.201 +        }
   1.202 +    else
   1.203 +        {
   1.204 +        return retVal;
   1.205 +        }
   1.206 +    }
   1.207 +
   1.208 +#endif /*OPENWFCWRAPPER_H_*/