os/graphics/windowing/windowserver/nonnga/SERVER/Direct.H
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2000-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 // Definition of Direct Screen Access class
    15 // 
    16 //
    17 
    18 #ifndef __DIRECT_H__
    19 #define __DIRECT_H__
    20 
    21 #include <e32std.h>
    22 #include <e32base.h>
    23 #include <w32std.h>
    24 #include "w32cmd.h"
    25 #include "OBJECT.H"
    26 #include "CLIENT.H"
    27 #include <e32msgqueue.h>
    28 
    29 class CWsClientWindow;
    30 class CWsDirectScreenAccess;
    31 class CDsaMsgQueue;
    32 
    33 NONSHARABLE_CLASS(CWsAbortDirect) : public CActive
    34 	{
    35 public:
    36 	CWsAbortDirect(CWsDirectScreenAccess* aDirect,CDsaMsgQueue* aParent);
    37 	~CWsAbortDirect();
    38 	void Started();
    39 	void Complete(TInt aReason);
    40 private:
    41 	//Pure virtual function from CActive
    42 	void RunL();
    43 	void DoCancel();
    44 private:
    45 	CWsDirectScreenAccess* iDirect;
    46 	CDsaMsgQueue* iParent;
    47 	};
    48 
    49 NONSHARABLE_CLASS(CDsaMsgQueue) : public CBase
    50 {
    51 	public:
    52 		static CDsaMsgQueue* NewL(CWsDirectScreenAccess* aDirect);
    53 		~CDsaMsgQueue();
    54 		TInt CreateSendQueue();
    55 		TInt CreateRecQueue();
    56 		RMsgQueueBase* SendQueue();
    57 		RMsgQueueBase* RecQueue();
    58 		void Cancel();
    59 		void Complete();
    60 		void CompleteAbort();
    61 		void Started();
    62 		TInt Send(TInt aData);
    63 		TInt ReceiveData();
    64 		TRequestStatus& Status()
    65 		{
    66 			return iAborted->iStatus;
    67 		}
    68 		
    69 	private:
    70 		CDsaMsgQueue();
    71 		void ConstructL(CWsDirectScreenAccess* aDirect);
    72 	private:
    73 		RMsgQueueBase iSendQueue;
    74 		RMsgQueueBase iRecQueue;
    75 		CWsAbortDirect* iAborted;
    76 	};
    77 
    78 class CWsDirectScreenAccess : public CWsScreenObject
    79 	{
    80 public:
    81 	enum TStatus
    82 		{
    83 		EDirectStatusTimeNotCreated,
    84 		EDirectStatusNone,
    85 		EDirectStatusInitialising,
    86 		EDirectStatusRunning,
    87 		EDirectStatusCompleted,
    88 		EDirectStatusCanceling,
    89 		EDirectStatusAbortedWindow,
    90 		EDirectStatusAbortedGlobal,
    91 		EDirectStatusAborted=EDirectStatusAbortedWindow,
    92 		};		
    93 public:
    94 	static CWsDirectScreenAccess* NewL(CWsClient* aOwner);
    95 	~CWsDirectScreenAccess();
    96 	void Request(TInt handle);
    97 	void GetRegion(TInt aNumRects);
    98 	void Cancel();
    99 	void Aborted();
   100 	void AbortNow();
   101 	TInt GetSendQueue();
   102 	TInt GetRecQueue();
   103 	void SignalAbort(RDirectScreenAccess::TTerminationReasons aReason);
   104 	inline TRequestStatus& AbortStatus() {return iMsgQueue->Status();}
   105 	void CancelAbortObject();
   106 	void Abort();
   107 	//Pure virtual function from CWsObject
   108 	void CommandL(TInt aOpcode, const TAny* aCmdData);
   109 	inline TBool IsVisible() const;
   110 	TBool IsAbortRequired(const TRegion& aTopVisibleRegion) const;
   111 	inline RWsRegion& VisibleRegion();
   112 	inline CWsClientWindow* ClientWindow() const;
   113 public:
   114 	TSglQueLink iLink;
   115 	TSglQueLink iMultipleDSALink;
   116 	TSglQueLink iAbortLink; // Used to build a list of DSA objects that need to be aborted on a specific window
   117 private:
   118 	inline CWsDirectScreenAccess(CWsClient* aOwner): CWsScreenObject(aOwner,WS_HANDLE_DIRECT, aOwner->Screen()) {}
   119 	void ConstructL();
   120 	void Initiate();
   121 	void Terminate1();
   122 	void Terminate2();
   123 	void CorrectScreen();
   124 #if defined(_DEBUG)
   125 	TBool OnQueue();
   126 #endif
   127 private:
   128 	CWsClientWindow* iWin;
   129 	RWsRegion iVisible;
   130 	CDsaMsgQueue* iMsgQueue;
   131 	TStatus iStatus;
   132 	RDirectScreenAccess::TTerminationReasons iAbortReason;
   133 public:
   134 	TBool IsSyncTimeoutPending() const;
   135 	inline RRegion& RegionUnderSync();
   136 public:
   137 	class CDSARegionSyncTimer : public CTimer
   138 		{
   139 		
   140 		public:
   141 			enum TConsts
   142 				{
   143 				KRegionSyncTimeoutMicrosec = 100000 // 0.1 sec
   144 				};
   145 		
   146 		public:
   147 			static CDSARegionSyncTimer* NewL(CWsDirectScreenAccess& aDSA);
   148 		
   149 		private:
   150 			void RunL();
   151 			CDSARegionSyncTimer(CWsDirectScreenAccess& aDSA);
   152 		
   153 		private:
   154 			CWsDirectScreenAccess&	iDSA;
   155 		};
   156 
   157 private:
   158 	void	DeleteRegionSyncWatchcat();
   159 	void	CancelFrozenRegion();
   160 	void 	RegionSyncTimeout();
   161 	
   162 private:
   163 	CDSARegionSyncTimer*	iRegionSync;
   164 	RRegion		iFrozenRegion;
   165 	
   166 	friend class CWsDirectScreenAccess::CDSARegionSyncTimer;
   167 	};
   168 
   169 inline TBool CWsDirectScreenAccess::IsVisible() const
   170 	{
   171 	return !iVisible.IsEmpty();
   172 	}
   173 
   174 inline CWsClientWindow* CWsDirectScreenAccess::ClientWindow() const
   175 	{
   176 	return iWin;
   177 	}
   178 
   179 inline RRegion& CWsDirectScreenAccess::RegionUnderSync() 
   180 	{
   181 	return iFrozenRegion;
   182 	}
   183 #endif