sl@0: // Copyright (c) 2006-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: /** sl@0: @file sl@0: @publishedPartner sl@0: @prototype sl@0: */ sl@0: sl@0: #ifndef __SURFACEMANAGER_DEV_H__ sl@0: #define __SURFACEMANAGER_DEV_H__ sl@0: sl@0: #include sl@0: #include "surfacemanagerdriver.h" sl@0: sl@0: #if 0 sl@0: #define TRACE(x) x sl@0: #else sl@0: #define TRACE(x) sl@0: #endif sl@0: sl@0: /** Maximum number of HintPairs per surface */ sl@0: const TInt KMaxHintsPerSurface = 16; sl@0: sl@0: /** Maximum number of elements in the table. This value must be a power of 2 */ sl@0: #define KMaxLists 16 sl@0: sl@0: /** sl@0: Logical Device (factory class) for Surface manager sl@0: */ sl@0: class DSurfaceManagerFactory : public DLogicalDevice sl@0: { sl@0: public: sl@0: DSurfaceManagerFactory(); sl@0: TInt Install(); sl@0: void GetCaps(TDes8& aDes) const; sl@0: TInt Create(DLogicalChannelBase*& aChannel); sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Logical Channel class for SurfaceManager sl@0: */ sl@0: class DSurfaceManagerChannel : public DLogicalChannelBase sl@0: { sl@0: public: sl@0: DSurfaceManagerChannel(); sl@0: ~DSurfaceManagerChannel(); sl@0: sl@0: // Inherited from DLogicalChannelBase sl@0: TInt DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer); sl@0: TInt Request(TInt aReqNo, TAny* a1, TAny* a2); sl@0: private: sl@0: // Implementation for the different kinds of messages sent through RBusLogicalChannel sl@0: TInt DoControl(TInt aFunction, TAny* a1, TAny* a2); sl@0: sl@0: private: sl@0: DProcess* iOwner; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Class to hold a reference count and process pointer. sl@0: Each surface has a linked list of these owning processes. sl@0: The surface manager has a linked list of these to track connections. sl@0: @internalTechnology sl@0: */ sl@0: class TProcessListItem sl@0: { sl@0: public: sl@0: TProcessListItem* iNext; //pointer to next one in list sl@0: DProcess* iOwningProcess; //pointer to the process object which is being reference counted sl@0: TInt iCount; //reference count sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Class to hold the information about a surface. sl@0: Each surface has a linked list of owners. The surfaces are arranged in a linked list, sl@0: with these objects being elements in the list. sl@0: @internalTechnology sl@0: */ sl@0: class TSurface //one of these per surface sl@0: { sl@0: public: sl@0: TSurface* iNext; //singly linked list, points to next surface sl@0: TSurfaceId iId; //the surface id sl@0: TSize iSize; //pixel width/height sl@0: TInt iBuffers; //number of buffers sl@0: TUidPixelFormat iPixelFormat; //pixel format sl@0: TInt iStride; //offset from start of one line to the next, in bytes sl@0: TInt iOffsetToFirstBuffer; //offset between the start of the surface memory and the start of the first pixel buffer sl@0: TInt iOffsetBetweenBuffers; //offset between pixel buffers sl@0: TInt iAlignment; //byte alignment of the pixel buffers sl@0: TBool iContiguous; //if it is in contiguous physical memory sl@0: DChunk* iChunk; //ptr to the shared chunk sl@0: RSurfaceManager::TCacheAttribute iCacheAttrib; //Caching attribute to create chunks memory sl@0: RSurfaceManager::THintPair iSurfaceHints[KMaxHintsPerSurface]; //Arbitrary key-value pairs associated with a surface sl@0: TBool iMappable; //Is the Surface Mappable sl@0: TProcessListItem* iOwners; //owner list. Singly linked list, points to next surface owner sl@0: sl@0: public: sl@0: TProcessListItem* ProcessOwnerInfo(const DProcess* aProcess); sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Surface manager extension object. sl@0: There is one static instance of this in the kernel extension. sl@0: @internalTechnology sl@0: */ sl@0: class DSurfaceManager : public DBase sl@0: { sl@0: public: sl@0: TInt CreateSurface(const TDesC8* aConfig, TSurfaceId* aId); sl@0: TInt SurfaceInfo(const TSurfaceId* aId, TDes8* aInfo); sl@0: TInt OpenSurface(const TSurfaceId* aId); sl@0: TInt CloseSurface(const TSurfaceId* aId); sl@0: TInt MapSurface(const TSurfaceId* aId); sl@0: TInt AddConnection(const DProcess* iProcess); sl@0: void RemoveConnection(const DProcess* iProcess); sl@0: TInt CreateSurface(RSurfaceManagerDriver::TDeviceParam* aParam, TInt aChunkHandle); sl@0: TInt SynchronizeCache(RSurfaceManagerDriver::TDeviceParam* aId, RSurfaceManager::TSyncOperation aOperation); sl@0: TInt GetSurfaceHint(const TSurfaceId* aSurfaceId, RSurfaceManager::THintPair* aHintPair); sl@0: TInt SetSurfaceHint(const TSurfaceId* aSurfaceId, const RSurfaceManager::THintPair* aHintPair); sl@0: TInt AddSurfaceHint(const TSurfaceId* aSurfaceId, const RSurfaceManager::THintPair* aHintPair); sl@0: TInt GetBufferOffset(RSurfaceManagerDriver::TDeviceParam* aParam,TUint* aOffset); sl@0: TInt GetSurfaceManagerAttrib(RSurfaceManager::TSurfaceManagerAttrib* aAttrib,TInt* aValue); sl@0: private: sl@0: void GenerateSurfaceId(TSurfaceId& aId); sl@0: TInt CreateSurfaceChunk(const RSurfaceManager::TSurfaceCreationAttributes& attribs); sl@0: TInt ValidateAndCalculateChunkSize(RSurfaceManager::TSurfaceCreationAttributes& aAttribs, TInt& aOffset, sl@0: TUint& aActualBufferSize, const TBool aNewChunk = EFalse); sl@0: TInt ValidatePhysicalMemory(DChunk* aChunk, const RSurfaceManager::TSurfaceCreationAttributes& aAttribs, sl@0: TUint aBuffersize, TUint32& aMapAttr, TBool &aIsContiguous); sl@0: TSurface* FindSurfaceById(const TSurfaceId& aId); sl@0: void CloseSurfaceHandlesForProcess(const DProcess* iProcess); sl@0: TProcessListItem* FindConnectedProcess(const DProcess* aProcess); sl@0: TInt FindHintKey(const RSurfaceManager::THintPair* aHints, TUint32 aKey) const; sl@0: TBool SortHints(RSurfaceManager::THintPair* aHints, TInt aNumberOfHints) const; sl@0: TInt InsertHintKey(RSurfaceManager::THintPair* aHints, const RSurfaceManager::THintPair& aHintPair) const; sl@0: sl@0: private: sl@0: TSurface* iSurfacesIndex[KMaxLists]; // A table with elements pointing to the head of each singly linked list sl@0: NFastMutex iMutex; // Mutex to protect access to surface lists sl@0: TProcessListItem* iConnectedProcesses; //reference counted list of processes connected to the driver sl@0: }; sl@0: sl@0: sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: