sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Surface Manager API
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@file
|
sl@0
|
20 |
@publishedPartner
|
sl@0
|
21 |
@prototype
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
#ifndef __SURFACEMANAGER_H__
|
sl@0
|
25 |
#define __SURFACEMANAGER_H__
|
sl@0
|
26 |
|
sl@0
|
27 |
#ifndef __KERNEL_MODE__
|
sl@0
|
28 |
#include <e32std.h>
|
sl@0
|
29 |
#endif
|
sl@0
|
30 |
|
sl@0
|
31 |
#include <e32cmn.h>
|
sl@0
|
32 |
#include <e32ver.h>
|
sl@0
|
33 |
#include <pixelformats.h>
|
sl@0
|
34 |
#include <graphics/surface.h>
|
sl@0
|
35 |
|
sl@0
|
36 |
class RSurfaceManagerDriver;
|
sl@0
|
37 |
|
sl@0
|
38 |
/**
|
sl@0
|
39 |
RSurface Manager User API.
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
class RSurfaceManager
|
sl@0
|
42 |
{
|
sl@0
|
43 |
public:
|
sl@0
|
44 |
|
sl@0
|
45 |
class THintPair
|
sl@0
|
46 |
{
|
sl@0
|
47 |
public:
|
sl@0
|
48 |
/** UID key number */
|
sl@0
|
49 |
TUid iKey;
|
sl@0
|
50 |
/** Integer key value */
|
sl@0
|
51 |
TInt iValue;
|
sl@0
|
52 |
/** Is the value modifiable */
|
sl@0
|
53 |
TBool iMutable;
|
sl@0
|
54 |
public:
|
sl@0
|
55 |
inline void Set(TUid aKey,TInt aValue,TBool aMutable);
|
sl@0
|
56 |
};
|
sl@0
|
57 |
|
sl@0
|
58 |
enum TCacheAttribute
|
sl@0
|
59 |
{
|
sl@0
|
60 |
/** CPU cached */
|
sl@0
|
61 |
ECached = 0,
|
sl@0
|
62 |
/** Non CPU cached */
|
sl@0
|
63 |
ENotCached = 1
|
sl@0
|
64 |
};
|
sl@0
|
65 |
|
sl@0
|
66 |
class TSurfaceCreationAttributes
|
sl@0
|
67 |
{
|
sl@0
|
68 |
public:
|
sl@0
|
69 |
/** Width and height of the surface in pixels. */
|
sl@0
|
70 |
TSize iSize;
|
sl@0
|
71 |
/** Number of buffers in the surface. */
|
sl@0
|
72 |
TInt iBuffers;
|
sl@0
|
73 |
/** The pixel format. */
|
sl@0
|
74 |
TUidPixelFormat iPixelFormat;
|
sl@0
|
75 |
/** Minimum or required number of bytes between start of one line and
|
sl@0
|
76 |
start of next. */
|
sl@0
|
77 |
TInt iStride;
|
sl@0
|
78 |
/** Minimum or required offset to the first buffer from the base of the
|
sl@0
|
79 |
chunk. Typically this will be set to 0. The value specified for the
|
sl@0
|
80 |
offset must comply with the alignment specified in iAlignment.
|
sl@0
|
81 |
|
sl@0
|
82 |
If iAlignment is page aligned, this value will be rounded up to a
|
sl@0
|
83 |
multiple of the page size when the surface is created, therefore the
|
sl@0
|
84 |
surface info must be queried for the actual value used. */
|
sl@0
|
85 |
TInt iOffsetToFirstBuffer;
|
sl@0
|
86 |
/** Alignment applied to the base address of each buffer in the surface:
|
sl@0
|
87 |
1, 2, 4, 8 ,16, 32, 64 bytes or EPageAligned. */
|
sl@0
|
88 |
TInt iAlignment;
|
sl@0
|
89 |
/** Require physically contiguous memory. This value will be ignored if
|
sl@0
|
90 |
using a chunk which already exists. */
|
sl@0
|
91 |
TBool iContiguous;
|
sl@0
|
92 |
/** Caching attribute to create chunk memory. This value will be
|
sl@0
|
93 |
ignored if using a chunk which already exists. */
|
sl@0
|
94 |
TCacheAttribute iCacheAttrib;
|
sl@0
|
95 |
/** Minimum or required offset between the start of one buffer and the
|
sl@0
|
96 |
start of the next one in bytes. When set to 0 the surface manager will
|
sl@0
|
97 |
choose how buffers are laid out within the chunk. If it is too small
|
sl@0
|
98 |
and doesn't fit with the alignment, CreateSurface() will return
|
sl@0
|
99 |
KErrArgument. */
|
sl@0
|
100 |
TInt iOffsetBetweenBuffers;
|
sl@0
|
101 |
/** Array of hints which should be associated with the surface. This
|
sl@0
|
102 |
array must not contain duplicate hint keys. */
|
sl@0
|
103 |
THintPair* iSurfaceHints;
|
sl@0
|
104 |
/** Number of hints in the array iSurfaceHints. The number should not
|
sl@0
|
105 |
exceed the maximum number supported by the surface manager, see
|
sl@0
|
106 |
GetSurfaceManagerAttrib(EMaxNumberOfHints). */
|
sl@0
|
107 |
TInt iHintCount;
|
sl@0
|
108 |
/** Should the surface be mappable. If EFalse any call to MapSurface()
|
sl@0
|
109 |
will fail with KErrNotSupported -- Note, some architectures may not
|
sl@0
|
110 |
support mappable surfaces. */
|
sl@0
|
111 |
TBool iMappable;
|
sl@0
|
112 |
public:
|
sl@0
|
113 |
inline TSurfaceCreationAttributes();
|
sl@0
|
114 |
};
|
sl@0
|
115 |
|
sl@0
|
116 |
class TSurfaceInfoV01
|
sl@0
|
117 |
{
|
sl@0
|
118 |
public:
|
sl@0
|
119 |
/** Width and height of the surface in pixels */
|
sl@0
|
120 |
TSize iSize;
|
sl@0
|
121 |
/** Number of buffers in the surface */
|
sl@0
|
122 |
TInt iBuffers;
|
sl@0
|
123 |
/** The pixel format */
|
sl@0
|
124 |
TUidPixelFormat iPixelFormat;
|
sl@0
|
125 |
/** Number of bytes between start of one line and start of next */
|
sl@0
|
126 |
TInt iStride;
|
sl@0
|
127 |
/** Has physically contiguous memory */
|
sl@0
|
128 |
TBool iContiguous;
|
sl@0
|
129 |
/** Specified if the underlying chunk is CPU cached or not */
|
sl@0
|
130 |
TCacheAttribute iCacheAttrib;
|
sl@0
|
131 |
/** ETrue if the surface can be mapped */
|
sl@0
|
132 |
TBool iMappable;
|
sl@0
|
133 |
};
|
sl@0
|
134 |
|
sl@0
|
135 |
enum TSurfaceManagerAttrib
|
sl@0
|
136 |
{
|
sl@0
|
137 |
/** Maximum number of hints per surface */
|
sl@0
|
138 |
EMaxNumberOfHints = 0x0
|
sl@0
|
139 |
};
|
sl@0
|
140 |
|
sl@0
|
141 |
/** Package buf used to pass information about a surface from the driver */
|
sl@0
|
142 |
typedef TPckgBuf<TSurfaceInfoV01> TInfoBuf;
|
sl@0
|
143 |
/** Package buf used to pass the surface creation attributes to the device driver */
|
sl@0
|
144 |
typedef TPckgBuf<TSurfaceCreationAttributes> TSurfaceCreationAttributesBuf;
|
sl@0
|
145 |
|
sl@0
|
146 |
enum TSyncOperation
|
sl@0
|
147 |
{
|
sl@0
|
148 |
/** Synchronize before non CPU hardware reads from the memory, i.e. if the
|
sl@0
|
149 |
buffer is cached and may have been written to by the CPU, this type of
|
sl@0
|
150 |
synchronisation should be used before a peripheral is used to read from the
|
sl@0
|
151 |
buffer's memory */
|
sl@0
|
152 |
ESyncBeforeNonCPURead,
|
sl@0
|
153 |
/** Synchronize before non CPU hardware writes to the memory, i.e. if the
|
sl@0
|
154 |
buffer is cached and may have been written to by the CPU, this type of
|
sl@0
|
155 |
synchronisation should be used before a peripheral is used to write to the
|
sl@0
|
156 |
buffer's memory */
|
sl@0
|
157 |
ESyncBeforeNonCPUWrite,
|
sl@0
|
158 |
/** Synchronize after non CPU hardware writes to the memory, i.e. if the
|
sl@0
|
159 |
buffer is cached, this type of synchronisation should be used after a
|
sl@0
|
160 |
peripheral has been used to write to the buffer's memory */
|
sl@0
|
161 |
ESyncAfterNonCPUWrite
|
sl@0
|
162 |
};
|
sl@0
|
163 |
|
sl@0
|
164 |
enum TPageAlignment
|
sl@0
|
165 |
{
|
sl@0
|
166 |
/** Specifies iAlignment is a page alignment */
|
sl@0
|
167 |
EPageAligned = -1
|
sl@0
|
168 |
};
|
sl@0
|
169 |
|
sl@0
|
170 |
public:
|
sl@0
|
171 |
#ifndef __KERNEL_MODE__
|
sl@0
|
172 |
IMPORT_C RSurfaceManager();
|
sl@0
|
173 |
IMPORT_C TInt Open();
|
sl@0
|
174 |
IMPORT_C void Close();
|
sl@0
|
175 |
IMPORT_C TInt CreateSurface(const TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId);
|
sl@0
|
176 |
IMPORT_C TInt CreateSurface(const TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId, const RChunk& aChunkHandle);
|
sl@0
|
177 |
IMPORT_C TInt OpenSurface(const TSurfaceId& aSurfaceId);
|
sl@0
|
178 |
IMPORT_C TInt CloseSurface(const TSurfaceId& aSurfaceId);
|
sl@0
|
179 |
IMPORT_C TInt MapSurface(const TSurfaceId& aSurfaceId, RChunk& aHandle);
|
sl@0
|
180 |
IMPORT_C TInt SurfaceInfo(const TSurfaceId& aSurfaceId, TInfoBuf& aInfo);
|
sl@0
|
181 |
IMPORT_C TInt SynchronizeCache(const TSurfaceId& aSurfaceId, TInt aBuffer, TSyncOperation aOperation);
|
sl@0
|
182 |
IMPORT_C TInt GetSurfaceManagerAttrib(TSurfaceManagerAttrib aAttrib, TInt& aValue);
|
sl@0
|
183 |
IMPORT_C TInt GetSurfaceHint(const TSurfaceId& aSurfaceId, THintPair& aHint);
|
sl@0
|
184 |
IMPORT_C TInt SetSurfaceHint(const TSurfaceId& aSurfaceId, const THintPair& aHint);
|
sl@0
|
185 |
IMPORT_C TInt AddSurfaceHint(const TSurfaceId&aSurface, const THintPair& aHint);
|
sl@0
|
186 |
IMPORT_C TInt GetBufferOffset(const TSurfaceId& aSurfaceId, TInt aBuffer, TInt& aOffset);
|
sl@0
|
187 |
#endif //__KERNEL_MODE__
|
sl@0
|
188 |
private:
|
sl@0
|
189 |
inline RSurfaceManagerDriver& Driver();
|
sl@0
|
190 |
private:
|
sl@0
|
191 |
TInt32 iDriverBuf[4];
|
sl@0
|
192 |
};
|
sl@0
|
193 |
|
sl@0
|
194 |
//
|
sl@0
|
195 |
// THintPair inline
|
sl@0
|
196 |
//
|
sl@0
|
197 |
|
sl@0
|
198 |
/**
|
sl@0
|
199 |
Sets key, value and mutability of the hint.
|
sl@0
|
200 |
@param aKeyUid The UID of the key
|
sl@0
|
201 |
@param aValue The value of the hint
|
sl@0
|
202 |
@param aMutable ETrue if the hint value is mutable
|
sl@0
|
203 |
*/
|
sl@0
|
204 |
inline void RSurfaceManager::THintPair::Set(TUid aKeyUid,TInt aValue,TBool aMutable)
|
sl@0
|
205 |
{
|
sl@0
|
206 |
iKey = aKeyUid;
|
sl@0
|
207 |
iValue = aValue;
|
sl@0
|
208 |
iMutable = aMutable;
|
sl@0
|
209 |
}
|
sl@0
|
210 |
|
sl@0
|
211 |
//
|
sl@0
|
212 |
// TSurfaceCreationAttributes inline
|
sl@0
|
213 |
//
|
sl@0
|
214 |
|
sl@0
|
215 |
/**
|
sl@0
|
216 |
Default constructor, zero initializes all attributes.
|
sl@0
|
217 |
*/
|
sl@0
|
218 |
inline RSurfaceManager::TSurfaceCreationAttributes::TSurfaceCreationAttributes()
|
sl@0
|
219 |
{
|
sl@0
|
220 |
memclr(this, sizeof(TSurfaceCreationAttributes));
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
#endif //__SURFACEMANAGER_H__
|