1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicscomposition/openwfsupport/inc/streammap.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,190 @@
1.4 +// Copyright (c) 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 +// streammap.h: defines COpenWfcStreamMap
1.18 +//
1.19 +//
1.20 +
1.21 +#ifndef STREAMMAP_H
1.22 +#define STREAMMAP_H
1.23 +
1.24 +#include <e32base.h>
1.25 +#include <e32std.h> //for RFastLock
1.26 +#include <e32hashtab.h> //for RHashMap
1.27 +
1.28 +class CSurfaceStream;
1.29 +class TSurfaceId;
1.30 +class MSurfaceUpdateServerProvider;
1.31 +class CExtensionContainer;
1.32 +class RSurfaceManager;
1.33 +
1.34 +NONSHARABLE_CLASS(COpenWfcStreamMap): public CBase
1.35 + {
1.36 + public:
1.37 + /**
1.38 + * Returns a reference to the singleton instance.
1.39 + *
1.40 + * @return The pointer to the singleton instance
1.41 + */
1.42 + IMPORT_C static COpenWfcStreamMap& InstanceL();
1.43 + /**
1.44 + * Look up a specified TSurfaceId key in the associative array and return a pointer to the
1.45 + * corresponding to a native stream. The reference counter of the native stream is incremented by one.
1.46 + *
1.47 + * @param aSurfaceId The TSurfaceId key to look up
1.48 + * @return A pointer to the corresponding native stream, if the specified TSurfacId was found
1.49 + * NULL if the look up did not succeed
1.50 + */
1.51 + CSurfaceStream* Find(const TSurfaceId& aSurfaceId);
1.52 + /**
1.53 + * Look up a specified TSurfaceId key in the associative array and return a pointer to the
1.54 + * corresponding to a native stream. The reference of the native stream is incremented by one.
1.55 + * If no native stream is found a new native stream instance is created.
1.56 + *
1.57 + * @param aSurfaceId The TSurfaceId key to look up
1.58 + * @return A pointer to the corresponding native stream, if the specified TSurfacId was found
1.59 + * NULL if the look up did not succeed
1.60 + */
1.61 + CSurfaceStream* AcquireL(const TSurfaceId& aSurfaceId);
1.62 + /**
1.63 + * Query the number of elements stored in the stream hash map.
1.64 + *
1.65 + * @return The number of the key-value pairs stored
1.66 + */
1.67 + IMPORT_C TInt Count();
1.68 +
1.69 + public:
1.70 +
1.71 + /**
1.72 + * Register a screen number for surface update notifications.
1.73 + *
1.74 + * @param aScreenNum The screen for which we enable the notification mechanism
1.75 + * @param aPriority The priority associated with the screen
1.76 + * @param aPriority The internal version
1.77 + * @return KErrNone if operation is completed successfully
1.78 + */
1.79 + TInt RegisterScreenNotifications(TInt aScreenNum, TInt aPriority,TInt aInternalVersion);
1.80 +
1.81 + /**
1.82 + * Retieves the screen updater associate with the specified screen
1.83 + *
1.84 + * @param aScreenNum The screen number
1.85 + * @return Pointer to screen updater id successful or NULL otherwise
1.86 + */
1.87 + CExtensionContainer* RegisteredScreenNotifications(TInt aScreenNum);
1.88 +
1.89 + /**
1.90 + * Unregister the screen updater
1.91 + *
1.92 + * @param aScreenNum The screen number
1.93 + * @return KErrNone if operation is completed successfully
1.94 + */
1.95 + TInt UnregisterScreenNotifications(TInt aScreenNum);
1.96 +
1.97 + /**
1.98 + * Returns a reference to the surface manager.
1.99 + *
1.100 + * @return A reference to the local SurfaceManager
1.101 + */
1.102 + IMPORT_C RSurfaceManager& SurfaceManager();
1.103 +
1.104 + /**
1.105 + * Returns a pointer to the main heap
1.106 + *
1.107 + * @return A pointer to the main heap
1.108 + */
1.109 + IMPORT_C RHeap* GetMainHeap();
1.110 +
1.111 + /**
1.112 + * Sets the main heap
1.113 + */
1.114 + void SetMainHeap();
1.115 +
1.116 + protected:
1.117 + friend class CSurfaceStream;
1.118 + /**
1.119 + * Destroys the specified native stream IF the native stream reference counter is zero.
1.120 + * The counter reference of the native stream is tested prior its destruction and
1.121 + * if positive the destruction will not happen
1.122 + *
1.123 + * @param aStream The stream to be destroyed
1.124 + * @return KErrNone if the native stream is removed
1.125 + * KErrArgument if the parameter is invalid
1.126 + * KErrInUse if the stream has a owner
1.127 + * KErrNotFound if the TSurfaceId key was not found
1.128 + */
1.129 + TInt LockDestroy(CSurfaceStream* aStream);
1.130 + /**
1.131 + * Constructor
1.132 + */
1.133 + COpenWfcStreamMap();
1.134 + /**
1.135 + * Destructor.
1.136 + */
1.137 + ~COpenWfcStreamMap();
1.138 + private:
1.139 + /**
1.140 + * Auxilliary private class to insure the release of a lock
1.141 + */
1.142 + class Guard
1.143 + {
1.144 + public:
1.145 + Guard(RFastLock& aLock);
1.146 + ~Guard();
1.147 + private:
1.148 + RFastLock& iLock;
1.149 + };
1.150 + private:
1.151 + /**
1.152 + * Symbian constructor used with two stage construction pattern
1.153 + */
1.154 + void ConstructL();
1.155 + /**
1.156 + Forms a 32-bit hash value from a TSurfaceId.
1.157 +
1.158 + @param aHashKey The 64-bit key to be hashed.
1.159 + @return 32-bit hash value.
1.160 + */
1.161 + static TUint32 HashFunction(const TSurfaceId& aHashKey);
1.162 +
1.163 + static TInt COpenWfcStreamMap::DeleteSingleton(TAny* aData);
1.164 + private:
1.165 + /**
1.166 + * Mutex used for controlling the access to the native streams map
1.167 + */
1.168 + RFastLock iMutex;
1.169 + /**
1.170 + * Native stream map
1.171 + */
1.172 + RHashMap<TSurfaceId, CSurfaceStream*> iMap;
1.173 + /**
1.174 + * Initial HashMap size
1.175 + */
1.176 + static const TInt iInitialSize = 0;
1.177 + /**
1.178 + * Singleton instance placeholder
1.179 + */
1.180 + static COpenWfcStreamMap* pInstance;
1.181 + /**
1.182 + * Surface manager
1.183 + */
1.184 + RSurfaceManager* iSurfaceManager;
1.185 +
1.186 + RHeap *iMainHeap; //< --This points to main thread's heap--
1.187 +
1.188 + RHashMap<TInt32, CExtensionContainer*> iRegisteredUpdaters; //< Proxy objects for handing surface update notifications.
1.189 +
1.190 + MSurfaceUpdateServerProvider* iSurfUpdateServ; // Pointer to the surface update server
1.191 + };
1.192 +
1.193 +#endif /* STREAMMAP_H */