os/graphics/graphicshwdrivers/surfacemgr/inc/surfacemanager.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicshwdrivers/surfacemgr/inc/surfacemanager.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,223 @@
     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 +// Surface Manager API
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @publishedPartner
    1.24 + @prototype
    1.25 +*/
    1.26 +
    1.27 +#ifndef __SURFACEMANAGER_H__
    1.28 +#define __SURFACEMANAGER_H__
    1.29 +
    1.30 +#ifndef __KERNEL_MODE__
    1.31 +#include <e32std.h>
    1.32 +#endif
    1.33 +
    1.34 +#include <e32cmn.h>
    1.35 +#include <e32ver.h>
    1.36 +#include <pixelformats.h>
    1.37 +#include <graphics/surface.h>
    1.38 +
    1.39 +class RSurfaceManagerDriver;
    1.40 +
    1.41 +/**
    1.42 +RSurface Manager User API.
    1.43 +*/
    1.44 +class RSurfaceManager
    1.45 +	{
    1.46 +public:
    1.47 +
    1.48 +	class THintPair
    1.49 +		{
    1.50 +	public:
    1.51 +		/** UID key number */
    1.52 +		TUid iKey;
    1.53 +		/** Integer key value */
    1.54 +		TInt iValue;
    1.55 +		/** Is the value modifiable */
    1.56 +		TBool iMutable;
    1.57 +	public:
    1.58 +		inline void Set(TUid aKey,TInt aValue,TBool aMutable);
    1.59 +		};
    1.60 +	
    1.61 +	enum TCacheAttribute
    1.62 +		{
    1.63 +		/** CPU cached */
    1.64 +		ECached = 0,
    1.65 +		/** Non CPU cached */
    1.66 +		ENotCached = 1
    1.67 +		};
    1.68 +
    1.69 +	class TSurfaceCreationAttributes
    1.70 +		{
    1.71 +	public:
    1.72 +		/** Width and height of the surface in pixels. */
    1.73 +		TSize iSize;
    1.74 +		/** Number of buffers in the surface. */
    1.75 +		TInt iBuffers;
    1.76 +		/** The pixel format. */
    1.77 +		TUidPixelFormat iPixelFormat;
    1.78 +		/** Minimum or required number of bytes between start of one line and
    1.79 +		start of next. */
    1.80 +		TInt iStride;
    1.81 +		/** Minimum or required offset to the first buffer from the base of the
    1.82 +		chunk. Typically this will be set to 0. The value specified for the
    1.83 +		offset must comply with the alignment specified in iAlignment.
    1.84 +		
    1.85 +		If iAlignment is page aligned, this value will be rounded up to a
    1.86 +		multiple of the page size when the surface is created, therefore the
    1.87 +		surface info must be queried for the actual value used. */
    1.88 +		TInt iOffsetToFirstBuffer;
    1.89 +		/** Alignment applied to the base address of each buffer in the surface:
    1.90 +		1, 2, 4, 8 ,16, 32, 64 bytes or EPageAligned. */
    1.91 +		TInt iAlignment;
    1.92 +		/** Require physically contiguous memory. This value will be ignored if
    1.93 +		using a chunk which already exists. */
    1.94 +		TBool iContiguous;
    1.95 +		/** Caching attribute to create chunk memory. This value will be 
    1.96 +		ignored if using a chunk which already exists. */
    1.97 +		TCacheAttribute iCacheAttrib;
    1.98 +		/** Minimum or required offset between the start of one buffer and the
    1.99 +		start of the next one in bytes. When set to 0 the surface manager will
   1.100 +	   	choose how buffers are laid out within the chunk. If it is too small
   1.101 +		and doesn't fit with the alignment, CreateSurface() will return
   1.102 +		KErrArgument. */
   1.103 +		TInt iOffsetBetweenBuffers;
   1.104 +		/** Array of hints which should be associated with the surface. This
   1.105 +		array must not contain duplicate hint keys. */
   1.106 +		THintPair* iSurfaceHints;
   1.107 +		/** Number of hints in the array iSurfaceHints. The number should not
   1.108 +		exceed the maximum number supported by the surface manager, see 
   1.109 +		GetSurfaceManagerAttrib(EMaxNumberOfHints). */
   1.110 +		TInt iHintCount;
   1.111 +		/** Should the surface be mappable. If EFalse any call to MapSurface()
   1.112 +		will fail with KErrNotSupported -- Note, some architectures may not
   1.113 +		support mappable surfaces. */
   1.114 +		TBool iMappable;
   1.115 +	public:
   1.116 +		inline TSurfaceCreationAttributes();
   1.117 +		};
   1.118 +
   1.119 +	class TSurfaceInfoV01
   1.120 +		{
   1.121 +	public:
   1.122 +		/** Width and height of the surface in pixels */
   1.123 +		TSize iSize;
   1.124 +		/** Number of buffers in the surface */
   1.125 +		TInt iBuffers;
   1.126 +		/** The pixel format */
   1.127 +		TUidPixelFormat iPixelFormat;
   1.128 +		/** Number of bytes between start of one line and start of next */
   1.129 +		TInt iStride;
   1.130 +		/** Has physically contiguous memory */
   1.131 +		TBool iContiguous;
   1.132 +		/** Specified if the underlying chunk is CPU cached or not */
   1.133 +		TCacheAttribute iCacheAttrib;
   1.134 +		/** ETrue if the surface can be mapped */
   1.135 +		TBool iMappable;
   1.136 +		};
   1.137 +	
   1.138 +	enum TSurfaceManagerAttrib
   1.139 +		{
   1.140 +		/** Maximum number of hints per surface */
   1.141 +		EMaxNumberOfHints = 0x0 
   1.142 +		};
   1.143 +
   1.144 +	/** Package buf used to pass information about a surface from the driver */
   1.145 +	typedef TPckgBuf<TSurfaceInfoV01> TInfoBuf;
   1.146 +	/** Package buf used to pass the surface creation attributes to the device driver */
   1.147 +	typedef TPckgBuf<TSurfaceCreationAttributes> TSurfaceCreationAttributesBuf;
   1.148 +
   1.149 +	enum TSyncOperation
   1.150 +		{
   1.151 +		/** Synchronize before non CPU hardware reads from the memory, i.e. if the
   1.152 +		buffer is cached and may have been written to by the CPU, this type of
   1.153 +		synchronisation should be used before a peripheral is used to read from the
   1.154 +		buffer's memory */
   1.155 +		ESyncBeforeNonCPURead,
   1.156 +		/** Synchronize before non CPU hardware writes to the memory, i.e. if the
   1.157 +		buffer is cached and may have been written to by the CPU, this type of
   1.158 +		synchronisation should be used before a peripheral is used to write to the
   1.159 +		buffer's memory */
   1.160 +		ESyncBeforeNonCPUWrite,
   1.161 +		/** Synchronize after non CPU hardware writes to the memory, i.e. if the
   1.162 +		buffer is cached, this type of synchronisation should be used after a
   1.163 +		peripheral has been used to write to the buffer's memory */
   1.164 +		ESyncAfterNonCPUWrite
   1.165 +		};
   1.166 +
   1.167 +	enum TPageAlignment
   1.168 +		{
   1.169 +		/** Specifies iAlignment is a page alignment */
   1.170 +		EPageAligned = -1
   1.171 +		};
   1.172 +	
   1.173 +public:
   1.174 +#ifndef __KERNEL_MODE__
   1.175 +	IMPORT_C RSurfaceManager();
   1.176 +	IMPORT_C TInt Open();
   1.177 +	IMPORT_C void Close();
   1.178 +	IMPORT_C TInt CreateSurface(const TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId);
   1.179 +	IMPORT_C TInt CreateSurface(const TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId, const RChunk& aChunkHandle);
   1.180 +	IMPORT_C TInt OpenSurface(const TSurfaceId& aSurfaceId);
   1.181 +	IMPORT_C TInt CloseSurface(const TSurfaceId& aSurfaceId);
   1.182 +	IMPORT_C TInt MapSurface(const TSurfaceId& aSurfaceId, RChunk& aHandle);
   1.183 +	IMPORT_C TInt SurfaceInfo(const TSurfaceId& aSurfaceId, TInfoBuf& aInfo);
   1.184 +	IMPORT_C TInt SynchronizeCache(const TSurfaceId& aSurfaceId, TInt aBuffer, TSyncOperation aOperation);
   1.185 +	IMPORT_C TInt GetSurfaceManagerAttrib(TSurfaceManagerAttrib aAttrib, TInt& aValue);
   1.186 +	IMPORT_C TInt GetSurfaceHint(const TSurfaceId& aSurfaceId, THintPair& aHint);
   1.187 +	IMPORT_C TInt SetSurfaceHint(const TSurfaceId& aSurfaceId, const THintPair& aHint);
   1.188 +	IMPORT_C TInt AddSurfaceHint(const TSurfaceId&aSurface, const THintPair& aHint);
   1.189 +	IMPORT_C TInt GetBufferOffset(const TSurfaceId& aSurfaceId, TInt aBuffer, TInt& aOffset);
   1.190 +#endif	//__KERNEL_MODE__	
   1.191 +private:
   1.192 +	inline RSurfaceManagerDriver& Driver();
   1.193 +private:
   1.194 +	TInt32 iDriverBuf[4];
   1.195 +	};
   1.196 +
   1.197 +//
   1.198 +// THintPair inline
   1.199 +//
   1.200 +
   1.201 +/**
   1.202 +Sets key, value and mutability of the hint.
   1.203 +@param aKeyUid The UID of the key
   1.204 +@param aValue The value of the hint
   1.205 +@param aMutable ETrue if the hint value is mutable
   1.206 +*/
   1.207 +inline void RSurfaceManager::THintPair::Set(TUid aKeyUid,TInt aValue,TBool aMutable)
   1.208 +	{
   1.209 +	iKey = aKeyUid;
   1.210 +	iValue = aValue;
   1.211 +	iMutable = aMutable;
   1.212 +	}
   1.213 +
   1.214 +//
   1.215 +// TSurfaceCreationAttributes inline
   1.216 +//
   1.217 +
   1.218 +/**
   1.219 +Default constructor, zero initializes all attributes.
   1.220 +*/
   1.221 +inline RSurfaceManager::TSurfaceCreationAttributes::TSurfaceCreationAttributes()
   1.222 +	{
   1.223 +	memclr(this, sizeof(TSurfaceCreationAttributes));
   1.224 +	}
   1.225 +
   1.226 +#endif //__SURFACEMANAGER_H__