os/graphics/graphicscomposition/openwfsupport/inc/streammap.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 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 // streammap.h: defines COpenWfcStreamMap
    15 // 
    16 //
    17 
    18 #ifndef STREAMMAP_H
    19 #define STREAMMAP_H
    20 
    21 #include <e32base.h>
    22 #include <e32std.h>			//for RFastLock
    23 #include <e32hashtab.h>		//for RHashMap
    24 
    25 class CSurfaceStream;
    26 class TSurfaceId;
    27 class MSurfaceUpdateServerProvider;
    28 class CExtensionContainer;
    29 class RSurfaceManager;
    30 
    31 NONSHARABLE_CLASS(COpenWfcStreamMap): public CBase
    32 	{
    33 	public:
    34 		/**
    35 		 * Returns a reference to the singleton instance.
    36 		 * 
    37 		 * @return	The pointer to the singleton instance
    38 		 */
    39 		IMPORT_C static COpenWfcStreamMap& InstanceL();
    40 		/**
    41 		 * Look up a specified TSurfaceId key in the associative array and return a pointer to the
    42 		 * corresponding to a native stream. The reference counter of the native stream is incremented by one.
    43 		 * 
    44 		 * @param	aSurfaceId	The TSurfaceId key to look up
    45 		 * @return	A pointer to the corresponding native stream, if the specified TSurfacId was found
    46 		 * 			NULL if the look up did not succeed
    47 		 */
    48 		CSurfaceStream* Find(const TSurfaceId& aSurfaceId);
    49 		/**
    50 		 * Look up a specified TSurfaceId key in the associative array and return a pointer to the
    51 		 * corresponding to a native stream. The reference of the native stream is incremented by one.
    52 		 * If no native stream is found a new native stream instance is created.
    53 		 * 
    54 		 * @param	aSurfaceId	The TSurfaceId key to look up
    55 		 * @return	A pointer to the corresponding native stream, if the specified TSurfacId was found
    56 		 * 			NULL if the look up did not succeed
    57 		 */
    58 		CSurfaceStream* AcquireL(const TSurfaceId& aSurfaceId);
    59 		/**
    60 		 * Query the number of elements stored in the stream hash map.
    61 		 * 
    62 		 * @return	The number of the key-value pairs stored
    63 		 */
    64 		IMPORT_C TInt Count();
    65 		
    66 	public:
    67 	    
    68         /**
    69          * Register a screen number for surface update notifications.
    70          * 
    71          * @param   aScreenNum  The screen for which we enable the notification mechanism
    72          * @param   aPriority  The priority associated with the screen 
    73          * @param   aPriority  The internal version 
    74          * @return  KErrNone if operation is completed successfully
    75          */
    76         TInt    RegisterScreenNotifications(TInt aScreenNum, TInt aPriority,TInt aInternalVersion);
    77         
    78         /**
    79          * Retieves the screen updater associate with the specified screen
    80          * 
    81          * @param   aScreenNum  The screen number
    82          * @return  Pointer to screen updater id successful or NULL otherwise
    83          */
    84         CExtensionContainer*    RegisteredScreenNotifications(TInt aScreenNum);
    85         
    86         /**
    87          * Unregister the screen updater
    88          * 
    89          * @param   aScreenNum  The screen number
    90          * @return  KErrNone if operation is completed successfully
    91          */
    92         TInt    UnregisterScreenNotifications(TInt aScreenNum);
    93         
    94 		/**
    95 		 * Returns a reference to the surface manager.
    96 		 * 
    97 		 * @return	A reference to the local SurfaceManager
    98 		 */
    99         IMPORT_C RSurfaceManager& SurfaceManager();
   100 		
   101         /**
   102          * Returns a pointer to the main heap
   103          * 
   104          * @return  A pointer to the main heap
   105          */
   106 		IMPORT_C RHeap* GetMainHeap();
   107 		
   108         /**
   109          * Sets the main heap
   110         */
   111 		void SetMainHeap();
   112 		
   113 	protected:
   114 		friend class CSurfaceStream;
   115 		/**
   116 		 * Destroys the specified native stream IF the native stream reference counter is zero.
   117 		 * The counter reference of the native stream is tested prior its destruction and
   118 		 * if positive the destruction will not happen
   119 		 * 
   120 		 * @param	aStream	The stream to be destroyed
   121 		 * @return	KErrNone if the native stream is removed
   122 		 * 			KErrArgument if the parameter is invalid
   123 		 * 			KErrInUse if the stream has a owner
   124 		 * 			KErrNotFound if the TSurfaceId key was not found
   125 		 */
   126 		TInt LockDestroy(CSurfaceStream* aStream);
   127 		/**
   128 		 * Constructor
   129 		 */
   130 		COpenWfcStreamMap();
   131 		/**
   132 		 * Destructor.
   133 		 */
   134 		~COpenWfcStreamMap();
   135 	private:		
   136 		/**
   137 		 * Auxilliary private class to insure the release of a lock
   138 		 */
   139 		class Guard
   140 			{
   141 			public:
   142 			Guard(RFastLock& aLock);
   143 			~Guard();
   144 			private:
   145 				RFastLock& iLock;
   146 			};
   147 	private:
   148 		/**
   149 		 * Symbian constructor used with two stage construction pattern
   150 		 */
   151 		void ConstructL();
   152 		/**
   153 		Forms a 32-bit hash value from a TSurfaceId.
   154 
   155 		@param aHashKey The 64-bit key to be hashed.
   156 		@return 32-bit hash value.
   157 		*/
   158 		static TUint32 HashFunction(const TSurfaceId& aHashKey);
   159 		
   160 		static TInt COpenWfcStreamMap::DeleteSingleton(TAny* aData);
   161 	private:
   162 		/**
   163 		 * Mutex used for controlling the access to the native streams map
   164 		 */
   165 		RFastLock iMutex;
   166 		/**
   167 		 * Native stream map
   168 		 */
   169 		RHashMap<TSurfaceId, CSurfaceStream*> iMap;
   170 		/**
   171 		 * Initial HashMap size
   172 		 */
   173 		static const TInt iInitialSize = 0;
   174 		/**
   175 		 * Singleton instance placeholder
   176 		 */
   177 		static COpenWfcStreamMap* pInstance;
   178 		/**
   179 		 * Surface manager
   180 		 */
   181 		RSurfaceManager* iSurfaceManager;
   182 
   183 		RHeap *iMainHeap; //< --This points to main thread's heap--
   184 		
   185 		RHashMap<TInt32, CExtensionContainer*>	iRegisteredUpdaters; //< Proxy objects for handing surface update notifications.
   186 		
   187 		MSurfaceUpdateServerProvider*   iSurfUpdateServ;    // Pointer to the surface update server
   188 	};
   189 
   190 #endif /* STREAMMAP_H */