First public contribution.
1 // Copyright (c) 2006-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Surface Manager API
24 #ifndef __SURFACEMANAGER_H__
25 #define __SURFACEMANAGER_H__
27 #ifndef __KERNEL_MODE__
33 #include <pixelformats.h>
34 #include <graphics/surface.h>
36 class RSurfaceManagerDriver;
39 RSurface Manager User API.
50 /** Integer key value */
52 /** Is the value modifiable */
55 inline void Set(TUid aKey,TInt aValue,TBool aMutable);
66 class TSurfaceCreationAttributes
69 /** Width and height of the surface in pixels. */
71 /** Number of buffers in the surface. */
73 /** The pixel format. */
74 TUidPixelFormat iPixelFormat;
75 /** Minimum or required number of bytes between start of one line and
78 /** Minimum or required offset to the first buffer from the base of the
79 chunk. Typically this will be set to 0. The value specified for the
80 offset must comply with the alignment specified in iAlignment.
82 If iAlignment is page aligned, this value will be rounded up to a
83 multiple of the page size when the surface is created, therefore the
84 surface info must be queried for the actual value used. */
85 TInt iOffsetToFirstBuffer;
86 /** Alignment applied to the base address of each buffer in the surface:
87 1, 2, 4, 8 ,16, 32, 64 bytes or EPageAligned. */
89 /** Require physically contiguous memory. This value will be ignored if
90 using a chunk which already exists. */
92 /** Caching attribute to create chunk memory. This value will be
93 ignored if using a chunk which already exists. */
94 TCacheAttribute iCacheAttrib;
95 /** Minimum or required offset between the start of one buffer and the
96 start of the next one in bytes. When set to 0 the surface manager will
97 choose how buffers are laid out within the chunk. If it is too small
98 and doesn't fit with the alignment, CreateSurface() will return
100 TInt iOffsetBetweenBuffers;
101 /** Array of hints which should be associated with the surface. This
102 array must not contain duplicate hint keys. */
103 THintPair* iSurfaceHints;
104 /** Number of hints in the array iSurfaceHints. The number should not
105 exceed the maximum number supported by the surface manager, see
106 GetSurfaceManagerAttrib(EMaxNumberOfHints). */
108 /** Should the surface be mappable. If EFalse any call to MapSurface()
109 will fail with KErrNotSupported -- Note, some architectures may not
110 support mappable surfaces. */
113 inline TSurfaceCreationAttributes();
116 class TSurfaceInfoV01
119 /** Width and height of the surface in pixels */
121 /** Number of buffers in the surface */
123 /** The pixel format */
124 TUidPixelFormat iPixelFormat;
125 /** Number of bytes between start of one line and start of next */
127 /** Has physically contiguous memory */
129 /** Specified if the underlying chunk is CPU cached or not */
130 TCacheAttribute iCacheAttrib;
131 /** ETrue if the surface can be mapped */
135 enum TSurfaceManagerAttrib
137 /** Maximum number of hints per surface */
138 EMaxNumberOfHints = 0x0
141 /** Package buf used to pass information about a surface from the driver */
142 typedef TPckgBuf<TSurfaceInfoV01> TInfoBuf;
143 /** Package buf used to pass the surface creation attributes to the device driver */
144 typedef TPckgBuf<TSurfaceCreationAttributes> TSurfaceCreationAttributesBuf;
148 /** Synchronize before non CPU hardware reads from the memory, i.e. if the
149 buffer is cached and may have been written to by the CPU, this type of
150 synchronisation should be used before a peripheral is used to read from the
152 ESyncBeforeNonCPURead,
153 /** Synchronize before non CPU hardware writes to the memory, i.e. if the
154 buffer is cached and may have been written to by the CPU, this type of
155 synchronisation should be used before a peripheral is used to write to the
157 ESyncBeforeNonCPUWrite,
158 /** Synchronize after non CPU hardware writes to the memory, i.e. if the
159 buffer is cached, this type of synchronisation should be used after a
160 peripheral has been used to write to the buffer's memory */
161 ESyncAfterNonCPUWrite
166 /** Specifies iAlignment is a page alignment */
171 #ifndef __KERNEL_MODE__
172 IMPORT_C RSurfaceManager();
173 IMPORT_C TInt Open();
174 IMPORT_C void Close();
175 IMPORT_C TInt CreateSurface(const TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId);
176 IMPORT_C TInt CreateSurface(const TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId, const RChunk& aChunkHandle);
177 IMPORT_C TInt OpenSurface(const TSurfaceId& aSurfaceId);
178 IMPORT_C TInt CloseSurface(const TSurfaceId& aSurfaceId);
179 IMPORT_C TInt MapSurface(const TSurfaceId& aSurfaceId, RChunk& aHandle);
180 IMPORT_C TInt SurfaceInfo(const TSurfaceId& aSurfaceId, TInfoBuf& aInfo);
181 IMPORT_C TInt SynchronizeCache(const TSurfaceId& aSurfaceId, TInt aBuffer, TSyncOperation aOperation);
182 IMPORT_C TInt GetSurfaceManagerAttrib(TSurfaceManagerAttrib aAttrib, TInt& aValue);
183 IMPORT_C TInt GetSurfaceHint(const TSurfaceId& aSurfaceId, THintPair& aHint);
184 IMPORT_C TInt SetSurfaceHint(const TSurfaceId& aSurfaceId, const THintPair& aHint);
185 IMPORT_C TInt AddSurfaceHint(const TSurfaceId&aSurface, const THintPair& aHint);
186 IMPORT_C TInt GetBufferOffset(const TSurfaceId& aSurfaceId, TInt aBuffer, TInt& aOffset);
187 #endif //__KERNEL_MODE__
189 inline RSurfaceManagerDriver& Driver();
191 TInt32 iDriverBuf[4];
199 Sets key, value and mutability of the hint.
200 @param aKeyUid The UID of the key
201 @param aValue The value of the hint
202 @param aMutable ETrue if the hint value is mutable
204 inline void RSurfaceManager::THintPair::Set(TUid aKeyUid,TInt aValue,TBool aMutable)
212 // TSurfaceCreationAttributes inline
216 Default constructor, zero initializes all attributes.
218 inline RSurfaceManager::TSurfaceCreationAttributes::TSurfaceCreationAttributes()
220 memclr(this, sizeof(TSurfaceCreationAttributes));
223 #endif //__SURFACEMANAGER_H__