1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicshwdrivers/surfacemgr/src/surfacemanager_dev.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,169 @@
1.4 +// Copyright (c) 2006-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 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @publishedPartner
1.22 + @prototype
1.23 +*/
1.24 +
1.25 +#ifndef __SURFACEMANAGER_DEV_H__
1.26 +#define __SURFACEMANAGER_DEV_H__
1.27 +
1.28 +#include <graphics/surface.h>
1.29 +#include "surfacemanagerdriver.h"
1.30 +
1.31 +#if 0
1.32 +#define TRACE(x) x
1.33 +#else
1.34 +#define TRACE(x)
1.35 +#endif
1.36 +
1.37 +/** Maximum number of HintPairs per surface */
1.38 +const TInt KMaxHintsPerSurface = 16;
1.39 +
1.40 +/** Maximum number of elements in the table. This value must be a power of 2 */
1.41 +#define KMaxLists 16
1.42 +
1.43 +/**
1.44 + Logical Device (factory class) for Surface manager
1.45 +*/
1.46 +class DSurfaceManagerFactory : public DLogicalDevice
1.47 + {
1.48 +public:
1.49 + DSurfaceManagerFactory();
1.50 + TInt Install();
1.51 + void GetCaps(TDes8& aDes) const;
1.52 + TInt Create(DLogicalChannelBase*& aChannel);
1.53 + };
1.54 +
1.55 +
1.56 +/**
1.57 + Logical Channel class for SurfaceManager
1.58 +*/
1.59 +class DSurfaceManagerChannel : public DLogicalChannelBase
1.60 + {
1.61 +public:
1.62 + DSurfaceManagerChannel();
1.63 + ~DSurfaceManagerChannel();
1.64 +
1.65 + // Inherited from DLogicalChannelBase
1.66 + TInt DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
1.67 + TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
1.68 +private:
1.69 + // Implementation for the different kinds of messages sent through RBusLogicalChannel
1.70 + TInt DoControl(TInt aFunction, TAny* a1, TAny* a2);
1.71 +
1.72 +private:
1.73 + DProcess* iOwner;
1.74 + };
1.75 +
1.76 +
1.77 +/**
1.78 +Class to hold a reference count and process pointer.
1.79 +Each surface has a linked list of these owning processes.
1.80 +The surface manager has a linked list of these to track connections.
1.81 +@internalTechnology
1.82 +*/
1.83 +class TProcessListItem
1.84 + {
1.85 +public:
1.86 + TProcessListItem* iNext; //pointer to next one in list
1.87 + DProcess* iOwningProcess; //pointer to the process object which is being reference counted
1.88 + TInt iCount; //reference count
1.89 + };
1.90 +
1.91 +
1.92 +/**
1.93 +Class to hold the information about a surface.
1.94 +Each surface has a linked list of owners. The surfaces are arranged in a linked list,
1.95 +with these objects being elements in the list.
1.96 +@internalTechnology
1.97 +*/
1.98 +class TSurface //one of these per surface
1.99 + {
1.100 +public:
1.101 + TSurface* iNext; //singly linked list, points to next surface
1.102 + TSurfaceId iId; //the surface id
1.103 + TSize iSize; //pixel width/height
1.104 + TInt iBuffers; //number of buffers
1.105 + TUidPixelFormat iPixelFormat; //pixel format
1.106 + TInt iStride; //offset from start of one line to the next, in bytes
1.107 + TInt iOffsetToFirstBuffer; //offset between the start of the surface memory and the start of the first pixel buffer
1.108 + TInt iOffsetBetweenBuffers; //offset between pixel buffers
1.109 + TInt iAlignment; //byte alignment of the pixel buffers
1.110 + TBool iContiguous; //if it is in contiguous physical memory
1.111 + DChunk* iChunk; //ptr to the shared chunk
1.112 + RSurfaceManager::TCacheAttribute iCacheAttrib; //Caching attribute to create chunks memory
1.113 + RSurfaceManager::THintPair iSurfaceHints[KMaxHintsPerSurface]; //Arbitrary key-value pairs associated with a surface
1.114 + TBool iMappable; //Is the Surface Mappable
1.115 + TProcessListItem* iOwners; //owner list. Singly linked list, points to next surface owner
1.116 +
1.117 +public:
1.118 + TProcessListItem* ProcessOwnerInfo(const DProcess* aProcess);
1.119 + };
1.120 +
1.121 +
1.122 +
1.123 +
1.124 +/**
1.125 +Surface manager extension object.
1.126 +There is one static instance of this in the kernel extension.
1.127 +@internalTechnology
1.128 +*/
1.129 +class DSurfaceManager : public DBase
1.130 + {
1.131 +public:
1.132 + TInt CreateSurface(const TDesC8* aConfig, TSurfaceId* aId);
1.133 + TInt SurfaceInfo(const TSurfaceId* aId, TDes8* aInfo);
1.134 + TInt OpenSurface(const TSurfaceId* aId);
1.135 + TInt CloseSurface(const TSurfaceId* aId);
1.136 + TInt MapSurface(const TSurfaceId* aId);
1.137 + TInt AddConnection(const DProcess* iProcess);
1.138 + void RemoveConnection(const DProcess* iProcess);
1.139 + TInt CreateSurface(RSurfaceManagerDriver::TDeviceParam* aParam, TInt aChunkHandle);
1.140 + TInt SynchronizeCache(RSurfaceManagerDriver::TDeviceParam* aId, RSurfaceManager::TSyncOperation aOperation);
1.141 + TInt GetSurfaceHint(const TSurfaceId* aSurfaceId, RSurfaceManager::THintPair* aHintPair);
1.142 + TInt SetSurfaceHint(const TSurfaceId* aSurfaceId, const RSurfaceManager::THintPair* aHintPair);
1.143 + TInt AddSurfaceHint(const TSurfaceId* aSurfaceId, const RSurfaceManager::THintPair* aHintPair);
1.144 + TInt GetBufferOffset(RSurfaceManagerDriver::TDeviceParam* aParam,TUint* aOffset);
1.145 + TInt GetSurfaceManagerAttrib(RSurfaceManager::TSurfaceManagerAttrib* aAttrib,TInt* aValue);
1.146 +private:
1.147 + void GenerateSurfaceId(TSurfaceId& aId);
1.148 + TInt CreateSurfaceChunk(const RSurfaceManager::TSurfaceCreationAttributes& attribs);
1.149 + TInt ValidateAndCalculateChunkSize(RSurfaceManager::TSurfaceCreationAttributes& aAttribs, TInt& aOffset,
1.150 + TUint& aActualBufferSize, const TBool aNewChunk = EFalse);
1.151 + TInt ValidatePhysicalMemory(DChunk* aChunk, const RSurfaceManager::TSurfaceCreationAttributes& aAttribs,
1.152 + TUint aBuffersize, TUint32& aMapAttr, TBool &aIsContiguous);
1.153 + TSurface* FindSurfaceById(const TSurfaceId& aId);
1.154 + void CloseSurfaceHandlesForProcess(const DProcess* iProcess);
1.155 + TProcessListItem* FindConnectedProcess(const DProcess* aProcess);
1.156 + TInt FindHintKey(const RSurfaceManager::THintPair* aHints, TUint32 aKey) const;
1.157 + TBool SortHints(RSurfaceManager::THintPair* aHints, TInt aNumberOfHints) const;
1.158 + TInt InsertHintKey(RSurfaceManager::THintPair* aHints, const RSurfaceManager::THintPair& aHintPair) const;
1.159 +
1.160 +private:
1.161 + TSurface* iSurfacesIndex[KMaxLists]; // A table with elements pointing to the head of each singly linked list
1.162 + NFastMutex iMutex; // Mutex to protect access to surface lists
1.163 + TProcessListItem* iConnectedProcesses; //reference counted list of processes connected to the driver
1.164 + };
1.165 +
1.166 +
1.167 +#endif
1.168 +
1.169 +
1.170 +
1.171 +
1.172 +