sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef OPENWFCJOBMANAGER_H_ sl@0: #define OPENWFCJOBMANAGER_H_ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: class COpenWfcWrapper; sl@0: class COpenWfcMonitorThread; sl@0: class TOpenWfcJob; sl@0: sl@0: #if defined(ENABLE_JQ_LOGGING) sl@0: #define JQLOG(X) RDebug::Printf X sl@0: #else sl@0: #define JQLOG(X) sl@0: #endif sl@0: sl@0: /** sl@0: * Controls the OpenWF composition sl@0: */ sl@0: class COpenWfcJobManger : public CBase sl@0: { sl@0: private: sl@0: sl@0: enum EOpenWfcJobId sl@0: { sl@0: EOpenWfcInvalidJobId = 0, sl@0: EOpenWfcComposeJobId, sl@0: EOpenWfcPauseCompositionJobId, sl@0: EOpenWfcResumeCompositionJobId, sl@0: }; sl@0: sl@0: /** sl@0: * Stores the parameters associated with a composition sl@0: */ sl@0: struct TComposeRequestDetails sl@0: { sl@0: TComposeRequestDetails(); sl@0: void Set(TRequestStatus* aCommitRequest, TThreadId aCallingThread); sl@0: void Reset(); sl@0: TRequestStatus* iCommitRequest; sl@0: TThreadId iCallingThread; sl@0: TDblQueLink iDlink; sl@0: }; sl@0: sl@0: /** sl@0: * Auxilliary class to insure the release of a lock sl@0: */ sl@0: class Guard sl@0: { sl@0: public: sl@0: Guard(RMutex& aLock); sl@0: ~Guard(); sl@0: private: sl@0: RMutex& iLock; sl@0: }; sl@0: sl@0: public: sl@0: /** sl@0: * Two-phased constructor. sl@0: */ sl@0: static COpenWfcJobManger* NewL(COpenWfcWrapper& aOpenWfcWrapper, sl@0: WFCDevice aDevice, sl@0: WFCContext aContext, sl@0: TInt aManagerId); sl@0: sl@0: /** sl@0: * Two-phased constructor. sl@0: */ sl@0: static COpenWfcJobManger* NewLC(COpenWfcWrapper& aOpenWfcWrapper, sl@0: WFCDevice aDevice, sl@0: WFCContext aContext, sl@0: TInt aManagerId); sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: virtual ~COpenWfcJobManger(); sl@0: sl@0: /** sl@0: * Request to compose the specified scene sl@0: * sl@0: * @param aCompleted The notification to be returned when the composition completes sl@0: * @param aUpdatePolicy Update policy to be used sl@0: * @param the Pointer to the first element from the element list containing the scene to be used by the next commit sl@0: * sl@0: */ sl@0: void ComposeRequest(TRequestStatus* aCompleted); sl@0: sl@0: /** sl@0: * Request to pause the composition sl@0: */ sl@0: void CompositionPauseRequest(); sl@0: /** sl@0: * Request to resume the composition sl@0: */ sl@0: void CompositionResumeRequest(); sl@0: sl@0: /** sl@0: * Appends to the compose details list the first detail object from the compose detail list sl@0: * sl@0: * @return NULL if the compose detail pool is empty or a pointer to the appended detail object sl@0: */ sl@0: TComposeRequestDetails* AppendDetailsFromPool(); sl@0: sl@0: /** sl@0: * Executes an outstanding command, if any. sl@0: * sl@0: */ sl@0: void DoExecuteJob(); sl@0: sl@0: private: sl@0: /** sl@0: * Executes a compose request. sl@0: * Intended to be invoked by a job sl@0: * sl@0: * @param Reference to the invoking job sl@0: */ sl@0: void DoComposeJob(); sl@0: sl@0: /** sl@0: * Executes a pause composition request sl@0: * Intended to be invoked by a job sl@0: * sl@0: * @param Reference to the invoking job sl@0: */ sl@0: void DoPauseCompositionJob(); sl@0: sl@0: /** sl@0: * Executes a resume composition request. sl@0: * Intended to be invoked by a job sl@0: * sl@0: * @param Reference to the invoking job sl@0: */ sl@0: void DoResumeCompositionJob(); sl@0: sl@0: /** sl@0: * Private constructor sl@0: */ sl@0: COpenWfcJobManger(COpenWfcWrapper& aOpenWfcWrapper, sl@0: WFCDevice aDevice, sl@0: WFCContext aContext, sl@0: TInt aManagerId); sl@0: sl@0: /** sl@0: * Symbian constructor used with the two stage construction pattern sl@0: */ sl@0: void ConstructL(); sl@0: sl@0: /** sl@0: * Implements a fence operation sl@0: */ sl@0: void Fence(); sl@0: sl@0: /** sl@0: * Waits until the sync is signalled sl@0: */ sl@0: void WaitForSync(); sl@0: sl@0: /** sl@0: * Activates the composition on the current context sl@0: */ sl@0: void Activate(); sl@0: sl@0: /** sl@0: * Deactivates the composition on the current context sl@0: */ sl@0: void Deactivate(); sl@0: sl@0: /** sl@0: * Execute a composition on the current context sl@0: */ sl@0: void Compose(); sl@0: sl@0: /** sl@0: * Execute a commit on the current context sl@0: */ sl@0: void Commit(); sl@0: sl@0: /** sl@0: * Completes all the outstanding requests stored locally sl@0: */ sl@0: void CompleteComposeRequests(TInt aResult); sl@0: sl@0: /** sl@0: * Completes all the outstanding pause/resumerequests requests sl@0: */ sl@0: void CompletePauseResumeRequest(TInt aResult); sl@0: sl@0: private: sl@0: // sl@0: TDblQue iComposeDetailsPool; sl@0: TDblQueIter iComposeDetailsPoolIter; sl@0: TDblQue iComposeDetailsList; sl@0: TDblQueIter iComposeDetailsListIter; sl@0: RMutex iJobLock; sl@0: RMutex iCommandLock; sl@0: COpenWfcWrapper& iOpenWfcWrapper; sl@0: WFCDevice iDevice; sl@0: WFCContext iContext; sl@0: volatile TBool iCompositionPaused; sl@0: volatile TBool iPausedComposePending; sl@0: COpenWfcMonitorThread* iThreadManager; sl@0: TInt iManagerId; sl@0: EGLSyncKHR iSync; sl@0: EGLDisplay iEglDisplay; sl@0: TRequestStatus iPauseResumeRequestStatus; sl@0: TThreadId iPauseResumeThread; sl@0: EOpenWfcJobId iOutstandingJob; sl@0: static const TInt KComposeDetailsPoolSize = 16; sl@0: }; sl@0: sl@0: inline void COpenWfcJobManger::Fence() sl@0: { sl@0: wfcFence(iDevice, iContext, iEglDisplay, iSync); sl@0: } sl@0: sl@0: inline void COpenWfcJobManger::WaitForSync() sl@0: { sl@0: EGLTimeKHR timeout = (EGLTimeKHR) EGL_FOREVER_KHR; sl@0: eglClientWaitSyncKHR(iEglDisplay, iSync, 0, timeout); sl@0: } sl@0: sl@0: inline void COpenWfcJobManger::Activate() sl@0: { sl@0: wfcActivate(iDevice, iContext); sl@0: } sl@0: sl@0: inline void COpenWfcJobManger::Deactivate() sl@0: { sl@0: wfcDeactivate(iDevice, iContext); sl@0: } sl@0: sl@0: inline void COpenWfcJobManger::Compose() sl@0: { sl@0: wfcCompose(iDevice, iContext, WFC_TRUE); sl@0: } sl@0: sl@0: inline void COpenWfcJobManger::Commit() sl@0: { sl@0: wfcCommit(iDevice, iContext, WFC_TRUE); sl@0: } sl@0: sl@0: #endif /* OPENWFCJOBMANAGER_H_ */