sl@0
|
1 |
// Copyright (c) 2007-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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "sgdriver.h"
|
sl@0
|
17 |
#include "sgimageadapter.h"
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@publishedPartner
|
sl@0
|
22 |
@prototype
|
sl@0
|
23 |
@deprecated
|
sl@0
|
24 |
|
sl@0
|
25 |
Default constructor.
|
sl@0
|
26 |
|
sl@0
|
27 |
@pre None.
|
sl@0
|
28 |
@post All the data members of this instance of TSgImageInfo are zero, false or null.
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
EXPORT_C TSgImageInfo::TSgImageInfo()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
Mem::FillZ(this, sizeof(TSgImageInfo));
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
|
sl@0
|
36 |
/**
|
sl@0
|
37 |
@publishedPartner
|
sl@0
|
38 |
@prototype
|
sl@0
|
39 |
@deprecated
|
sl@0
|
40 |
|
sl@0
|
41 |
Default constructor.
|
sl@0
|
42 |
|
sl@0
|
43 |
@pre None.
|
sl@0
|
44 |
@post This RSgImage handle is null.
|
sl@0
|
45 |
*/
|
sl@0
|
46 |
EXPORT_C RSgImage::RSgImage()
|
sl@0
|
47 |
{
|
sl@0
|
48 |
iHandleType = KSgImageTypeUid;
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
|
sl@0
|
52 |
/**
|
sl@0
|
53 |
@publishedPartner
|
sl@0
|
54 |
@prototype
|
sl@0
|
55 |
@deprecated
|
sl@0
|
56 |
|
sl@0
|
57 |
Creates an image with the specified attributes and, optionally, the specified
|
sl@0
|
58 |
initial contents.
|
sl@0
|
59 |
|
sl@0
|
60 |
@param aInfo The attributes of the image to be created.
|
sl@0
|
61 |
@param aDataAddress The base address of the pixel data used to populate the new image.
|
sl@0
|
62 |
If this value is null, the initial contents of the image are undefined.
|
sl@0
|
63 |
If aInfo specifies that the new image is constant, this value must not be null.
|
sl@0
|
64 |
@param aDataStride The number of bytes between rows of the pixel data used to populate
|
sl@0
|
65 |
the new image.
|
sl@0
|
66 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
67 |
calling process.
|
sl@0
|
68 |
@pre This RSgImage handle is null.
|
sl@0
|
69 |
@pre aInfo is supported.
|
sl@0
|
70 |
@post This RSgImage handle references a newly created image with the specified
|
sl@0
|
71 |
attributes and initial contents. The initial reference count for the image
|
sl@0
|
72 |
is one.
|
sl@0
|
73 |
@return KErrNone if successful.
|
sl@0
|
74 |
@return KErrInUse if this RSgImage handle was not null.
|
sl@0
|
75 |
@return KErrArgument if aInfo is invalid.
|
sl@0
|
76 |
@return KErrNoInitializationData if aInfo requests a constant image and aDataAddress
|
sl@0
|
77 |
is null.
|
sl@0
|
78 |
@return KErrTooBig if the size specified in aInfo is too large.
|
sl@0
|
79 |
@return KErrNotSupported if aInfo is not supported.
|
sl@0
|
80 |
@return KErrNoMemory if there is not enough system memory.
|
sl@0
|
81 |
@return KErrNoSpecializedMemory if there is not enough specialised graphics memory.
|
sl@0
|
82 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
83 |
for use in the context of the calling process.
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
EXPORT_C TInt RSgImage::Create(const TSgImageInfo& aInfo, const TAny* aDataAddress, TInt aDataStride)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
#ifdef _DEBUG
|
sl@0
|
88 |
gPls.iMutex.Wait();
|
sl@0
|
89 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
90 |
#endif
|
sl@0
|
91 |
TInt err = gPls.iDriver->CreateImage(aInfo, aDataAddress, aDataStride, iImpl);
|
sl@0
|
92 |
#ifdef _DEBUG
|
sl@0
|
93 |
gPls.iMutex.Signal();
|
sl@0
|
94 |
#endif
|
sl@0
|
95 |
return err;
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
|
sl@0
|
99 |
/**
|
sl@0
|
100 |
@publishedPartner
|
sl@0
|
101 |
@prototype
|
sl@0
|
102 |
@deprecated
|
sl@0
|
103 |
|
sl@0
|
104 |
Creates an image with the specified attributes and initial contents copied from an
|
sl@0
|
105 |
existing image. The size and the pixel format of the image to be created must be the
|
sl@0
|
106 |
same as the size and the pixel format of the existing image.
|
sl@0
|
107 |
|
sl@0
|
108 |
@param aInfo The attributes of the image to be created.
|
sl@0
|
109 |
@param aImage A handle to the existing image to be copied.
|
sl@0
|
110 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
111 |
calling process.
|
sl@0
|
112 |
@pre This RSgImage handle is null.
|
sl@0
|
113 |
@pre aInfo is supported.
|
sl@0
|
114 |
@pre aImage is a valid and not null handle.
|
sl@0
|
115 |
@pre The size and the pixel format specified in aInfo must be the same as the size
|
sl@0
|
116 |
and the pixel format of aImage.
|
sl@0
|
117 |
@post This RSgImage handle references a newly created image with the specified
|
sl@0
|
118 |
attributes and initial contents. The initial reference count for the image
|
sl@0
|
119 |
is one.
|
sl@0
|
120 |
@return KErrNone if successful.
|
sl@0
|
121 |
@return KErrInUse if this RSgImage handle was not null.
|
sl@0
|
122 |
@return KErrArgument if aInfo is invalid or if aImage is a null handle.
|
sl@0
|
123 |
@return KErrNotSupported if aInfo is not supported or if the size and the pixel format
|
sl@0
|
124 |
specified in aInfo are not the same as the size and the pixel format of aImage.
|
sl@0
|
125 |
@return KErrNoMemory if there is not enough system memory.
|
sl@0
|
126 |
@return KErrNoSpecializedMemory if there is not enough specialised graphics memory.
|
sl@0
|
127 |
@panic SGRES 3 in debug builds if aImage is an invalid handle.
|
sl@0
|
128 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
129 |
for use in the context of the calling process.
|
sl@0
|
130 |
*/
|
sl@0
|
131 |
EXPORT_C TInt RSgImage::Create(const TSgImageInfo& aInfo, const RSgImage& aImage)
|
sl@0
|
132 |
{
|
sl@0
|
133 |
#ifdef _DEBUG
|
sl@0
|
134 |
gPls.iMutex.Wait();
|
sl@0
|
135 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
136 |
#endif
|
sl@0
|
137 |
TInt err = gPls.iDriver->CreateImage(aInfo, static_cast<MSgImageAdapter*>(aImage.iImpl), iImpl);
|
sl@0
|
138 |
#ifdef _DEBUG
|
sl@0
|
139 |
gPls.iMutex.Signal();
|
sl@0
|
140 |
#endif
|
sl@0
|
141 |
return err;
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
|
sl@0
|
145 |
/**
|
sl@0
|
146 |
@publishedPartner
|
sl@0
|
147 |
@prototype
|
sl@0
|
148 |
@deprecated
|
sl@0
|
149 |
|
sl@0
|
150 |
Retrieves the values of the attributes of an image. This function can also retrieve
|
sl@0
|
151 |
the values of selected user-defined attributes attached to an image by passing in
|
sl@0
|
152 |
the globally unique identifiers of the user-defined attributes to be retrieved.
|
sl@0
|
153 |
|
sl@0
|
154 |
@param aInfo On input, the globally unique identifiers of the user-defined attributes
|
sl@0
|
155 |
to be retrieved from the image, if any. On return, the values of the attributes
|
sl@0
|
156 |
of the image and the values of the selected user-defined attributes.
|
sl@0
|
157 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
158 |
calling process.
|
sl@0
|
159 |
@pre This RSgImage handle is valid and not null.
|
sl@0
|
160 |
@pre If aInfo.iUserAttributes is not null then it points to an array of
|
sl@0
|
161 |
aInfo.iUserAttributeCount elements with globally unique identifiers
|
sl@0
|
162 |
corresponding to user-defined attributes attached to the image.
|
sl@0
|
163 |
@post None.
|
sl@0
|
164 |
@return KErrNone if successful.
|
sl@0
|
165 |
@return KErrBadHandle if this RSgImage handle is null.
|
sl@0
|
166 |
@return KErrNotFound if any of the user-defined attributes to be retrieved from the
|
sl@0
|
167 |
image cannot be found.
|
sl@0
|
168 |
@panic SGRES 3 in debug builds if this RSgImage handle is invalid.
|
sl@0
|
169 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
170 |
for use in the context of the calling process.
|
sl@0
|
171 |
@see TSgImageInfo
|
sl@0
|
172 |
*/
|
sl@0
|
173 |
EXPORT_C TInt RSgImage::GetInfo(TSgImageInfo& aInfo) const
|
sl@0
|
174 |
{
|
sl@0
|
175 |
if (!iImpl)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
return KErrBadHandle;
|
sl@0
|
178 |
}
|
sl@0
|
179 |
#ifdef _DEBUG
|
sl@0
|
180 |
gPls.iMutex.Wait();
|
sl@0
|
181 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
182 |
__ASSERT_DEBUG(gPls.iDriver->CheckImage(*iImpl), Panic(ESgPanicBadImageHandle));
|
sl@0
|
183 |
#endif
|
sl@0
|
184 |
TInt err = static_cast<MSgImageAdapter*>(iImpl)->GetInfo(aInfo);
|
sl@0
|
185 |
#ifdef _DEBUG
|
sl@0
|
186 |
gPls.iMutex.Signal();
|
sl@0
|
187 |
#endif
|
sl@0
|
188 |
return err;
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
|
sl@0
|
192 |
/**
|
sl@0
|
193 |
@publishedPartner
|
sl@0
|
194 |
@prototype
|
sl@0
|
195 |
@deprecated
|
sl@0
|
196 |
|
sl@0
|
197 |
Temporarily makes the pixel data of an image accessible for reading by the CPU.
|
sl@0
|
198 |
Undefined behaviour occurs if the CPU tries to modify the pixel data.
|
sl@0
|
199 |
|
sl@0
|
200 |
When finished with the pixel data, the caller must end the mapping by calling Unmap()
|
sl@0
|
201 |
on this RSgImage handle.
|
sl@0
|
202 |
|
sl@0
|
203 |
If an image is shared across processes, only the creator process is allowed to map
|
sl@0
|
204 |
the image for access to its pixel data.
|
sl@0
|
205 |
|
sl@0
|
206 |
Depending upon the hardware architecture, whilst an image is mapped the GPU may be
|
sl@0
|
207 |
denied access to the pixel data, so this function may cause GPU operations that use
|
sl@0
|
208 |
this image to fail if proper synchronisation is not provided by means of the
|
sl@0
|
209 |
mechanisms available from the different rendering pipelines or from specialised
|
sl@0
|
210 |
synchronisation objects. Likewise, if the GPU is using the image at the time this
|
sl@0
|
211 |
function is called, the mapping may fail with KErrInUse. Note that even if operations
|
sl@0
|
212 |
do not fail, the results are not guaranteed to be correct unless proper synchronisation
|
sl@0
|
213 |
is provided.
|
sl@0
|
214 |
|
sl@0
|
215 |
@param aDataAddress On return, the base address of the pixel data in the address
|
sl@0
|
216 |
space of the calling process.
|
sl@0
|
217 |
@param aDataStride On return, the number of bytes between rows of the pixel data.
|
sl@0
|
218 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
219 |
calling process.
|
sl@0
|
220 |
@pre This RSgImage handle is valid and not null.
|
sl@0
|
221 |
@pre The image is not mapped yet.
|
sl@0
|
222 |
@pre The image was created with CPU access ESgCpuAccessReadOnly or ESgCpuAccessReadWrite.
|
sl@0
|
223 |
@pre The image was created by the calling process.
|
sl@0
|
224 |
@post The pixel data of the image is directly accessible in the address space of the
|
sl@0
|
225 |
calling process for reading only, until Unmap() is called.
|
sl@0
|
226 |
@return KErrNone if successful.
|
sl@0
|
227 |
@return KErrBadHandle if this RSgImage handle is null.
|
sl@0
|
228 |
@return KErrInUse if the image is already mapped or in exclusive use by the GPU.
|
sl@0
|
229 |
@return KErrAccessDenied if the image was not created with CPU access ESgCpuAccessReadOnly
|
sl@0
|
230 |
or ESgCpuAccessReadWrite.
|
sl@0
|
231 |
@return KErrPermissionDenied if the image was created by another process.
|
sl@0
|
232 |
@return KErrNoMemory if there is not enough system memory.
|
sl@0
|
233 |
@panic SGRES 3 in debug builds if this RSgImage handle is invalid.
|
sl@0
|
234 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
235 |
for use in the context of the calling process.
|
sl@0
|
236 |
*/
|
sl@0
|
237 |
EXPORT_C TInt RSgImage::MapReadOnly(const TAny*& aDataAddress, TInt& aDataStride) const
|
sl@0
|
238 |
{
|
sl@0
|
239 |
if (!iImpl)
|
sl@0
|
240 |
{
|
sl@0
|
241 |
return KErrBadHandle;
|
sl@0
|
242 |
}
|
sl@0
|
243 |
#ifdef _DEBUG
|
sl@0
|
244 |
gPls.iMutex.Wait();
|
sl@0
|
245 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
246 |
__ASSERT_DEBUG(gPls.iDriver->CheckImage(*iImpl), Panic(ESgPanicBadImageHandle));
|
sl@0
|
247 |
#endif
|
sl@0
|
248 |
TInt err = static_cast<MSgImageAdapter*>(iImpl)->MapReadOnly(aDataAddress, aDataStride);
|
sl@0
|
249 |
#ifdef _DEBUG
|
sl@0
|
250 |
gPls.iMutex.Signal();
|
sl@0
|
251 |
#endif
|
sl@0
|
252 |
return err;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
|
sl@0
|
255 |
|
sl@0
|
256 |
/**
|
sl@0
|
257 |
@publishedPartner
|
sl@0
|
258 |
@prototype
|
sl@0
|
259 |
@deprecated
|
sl@0
|
260 |
|
sl@0
|
261 |
Temporarily makes the pixel data of an image accessible for writing by the CPU.
|
sl@0
|
262 |
Any pre-existing content is discarded, meaning that the mapped memory initially
|
sl@0
|
263 |
contains undefined pixel data.
|
sl@0
|
264 |
|
sl@0
|
265 |
When finished with the pixel data, the caller must end the mapping by calling Unmap()
|
sl@0
|
266 |
on this RSgImage handle. The caller is required to write to every pixel of the image
|
sl@0
|
267 |
before unmapping.
|
sl@0
|
268 |
|
sl@0
|
269 |
If an image is shared across processes, only the creator process is allowed to map
|
sl@0
|
270 |
the image for access to its pixel data.
|
sl@0
|
271 |
|
sl@0
|
272 |
Depending upon the hardware architecture, whilst an image is mapped the GPU may be
|
sl@0
|
273 |
denied access to the pixel data, so this function may cause GPU operations that use
|
sl@0
|
274 |
this image to fail if proper synchronisation is not provided by means of the
|
sl@0
|
275 |
mechanisms available from the different rendering pipelines or from specialised
|
sl@0
|
276 |
synchronisation objects. Likewise, if the GPU is using the image at the time this
|
sl@0
|
277 |
function is called, the mapping may fail with KErrInUse. Note that even if operations
|
sl@0
|
278 |
do not fail, the results are not guaranteed to be correct unless proper synchronisation
|
sl@0
|
279 |
is provided.
|
sl@0
|
280 |
|
sl@0
|
281 |
@param aDataAddress On return, the base address of the pixel data in the address
|
sl@0
|
282 |
space of the calling process.
|
sl@0
|
283 |
@param aDataStride On return, the number of bytes between rows of the pixel data.
|
sl@0
|
284 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
285 |
calling process.
|
sl@0
|
286 |
@pre This RSgImage handle is valid and not null.
|
sl@0
|
287 |
@pre The image is not mapped yet.
|
sl@0
|
288 |
@pre The image was created with CPU access ESgCpuAccessWriteOnly or ESgCpuAccessReadWrite.
|
sl@0
|
289 |
@pre The image was created by the calling process.
|
sl@0
|
290 |
@post The pixel data of the image is directly accessible in the address space of the
|
sl@0
|
291 |
calling process for writing only, until Unmap() is called.
|
sl@0
|
292 |
@return KErrNone if successful.
|
sl@0
|
293 |
@return KErrBadHandle if this RSgImage handle is null.
|
sl@0
|
294 |
@return KErrInUse if the image is already mapped or in exclusive use by the GPU.
|
sl@0
|
295 |
@return KErrAccessDenied if the image was not created with CPU access ESgCpuAccessWriteOnly
|
sl@0
|
296 |
or ESgCpuAccessReadWrite.
|
sl@0
|
297 |
@return KErrPermissionDenied if the image was created by another process.
|
sl@0
|
298 |
@return KErrNoMemory if there is not enough system memory.
|
sl@0
|
299 |
@panic SGRES 3 in debug builds if this RSgImage handle is invalid.
|
sl@0
|
300 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
301 |
for use in the context of the calling process.
|
sl@0
|
302 |
*/
|
sl@0
|
303 |
EXPORT_C TInt RSgImage::MapWriteOnly(TAny*& aDataAddress, TInt& aDataStride)
|
sl@0
|
304 |
{
|
sl@0
|
305 |
if (!iImpl)
|
sl@0
|
306 |
{
|
sl@0
|
307 |
return KErrBadHandle;
|
sl@0
|
308 |
}
|
sl@0
|
309 |
#ifdef _DEBUG
|
sl@0
|
310 |
gPls.iMutex.Wait();
|
sl@0
|
311 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
312 |
__ASSERT_DEBUG(gPls.iDriver->CheckImage(*iImpl), Panic(ESgPanicBadImageHandle));
|
sl@0
|
313 |
#endif
|
sl@0
|
314 |
TInt err = static_cast<MSgImageAdapter*>(iImpl)->MapWriteOnly(aDataAddress, aDataStride);
|
sl@0
|
315 |
#ifdef _DEBUG
|
sl@0
|
316 |
gPls.iMutex.Signal();
|
sl@0
|
317 |
#endif
|
sl@0
|
318 |
return err;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
|
sl@0
|
322 |
/**
|
sl@0
|
323 |
@publishedPartner
|
sl@0
|
324 |
@prototype
|
sl@0
|
325 |
@deprecated
|
sl@0
|
326 |
|
sl@0
|
327 |
Temporarily makes the pixel data of an image accessible for reading and writing
|
sl@0
|
328 |
by the CPU.
|
sl@0
|
329 |
|
sl@0
|
330 |
When finished with the pixel data, the caller must end the mapping by calling Unmap()
|
sl@0
|
331 |
on this RSgImage handle. Any modification performed by the CPU will be retained upon
|
sl@0
|
332 |
unmapping.
|
sl@0
|
333 |
|
sl@0
|
334 |
If an image is shared across processes, only the creator process is allowed to map
|
sl@0
|
335 |
the image for access to its pixel data.
|
sl@0
|
336 |
|
sl@0
|
337 |
Depending upon the hardware architecture, whilst an image is mapped the GPU may be
|
sl@0
|
338 |
denied access to the pixel data, so this function may cause GPU operations that use
|
sl@0
|
339 |
this image to fail if proper synchronisation is not provided by means of the
|
sl@0
|
340 |
mechanisms available from the different rendering pipelines or from specialised
|
sl@0
|
341 |
synchronisation objects. Likewise, if the GPU is using the image at the time this
|
sl@0
|
342 |
function is called, the mapping may fail with KErrInUse. Note that even if operations
|
sl@0
|
343 |
do not fail, the results are not guaranteed to be correct unless proper synchronisation
|
sl@0
|
344 |
is provided.
|
sl@0
|
345 |
|
sl@0
|
346 |
@param aDataAddress On return, the base address of the pixel data in the address
|
sl@0
|
347 |
space of the calling process.
|
sl@0
|
348 |
@param aDataStride On return, the number of bytes between rows of the pixel data.
|
sl@0
|
349 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
350 |
calling process.
|
sl@0
|
351 |
@pre This RSgImage handle is valid and not null.
|
sl@0
|
352 |
@pre The image is not mapped yet.
|
sl@0
|
353 |
@pre The image was created with CPU access ESgCpuAccessReadWrite.
|
sl@0
|
354 |
@pre The image was created by the calling process.
|
sl@0
|
355 |
@post The pixel data of the image is directly accessible in the address space of the
|
sl@0
|
356 |
calling process for reading and writing, until Unmap() is called.
|
sl@0
|
357 |
@return KErrNone if successful.
|
sl@0
|
358 |
@return KErrBadHandle if this RSgImage handle is null.
|
sl@0
|
359 |
@return KErrInUse if the image is already mapped or in exclusive use by the GPU.
|
sl@0
|
360 |
@return KErrAccessDenied if the image was not created with CPU access
|
sl@0
|
361 |
ESgCpuAccessReadWrite.
|
sl@0
|
362 |
@return KErrPermissionDenied if the image was created by another process.
|
sl@0
|
363 |
@return KErrNoMemory if there is not enough system memory.
|
sl@0
|
364 |
@panic SGRES 3 in debug builds if this RSgImage handle is invalid.
|
sl@0
|
365 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
366 |
for use in the context of the calling process.
|
sl@0
|
367 |
*/
|
sl@0
|
368 |
EXPORT_C TInt RSgImage::MapReadWrite(TAny*& aDataAddress, TInt& aDataStride)
|
sl@0
|
369 |
{
|
sl@0
|
370 |
if (!iImpl)
|
sl@0
|
371 |
{
|
sl@0
|
372 |
return KErrBadHandle;
|
sl@0
|
373 |
}
|
sl@0
|
374 |
#ifdef _DEBUG
|
sl@0
|
375 |
gPls.iMutex.Wait();
|
sl@0
|
376 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
377 |
__ASSERT_DEBUG(gPls.iDriver->CheckImage(*iImpl), Panic(ESgPanicBadImageHandle));
|
sl@0
|
378 |
#endif
|
sl@0
|
379 |
TInt err = static_cast<MSgImageAdapter*>(iImpl)->MapReadWrite(aDataAddress, aDataStride);
|
sl@0
|
380 |
#ifdef _DEBUG
|
sl@0
|
381 |
gPls.iMutex.Signal();
|
sl@0
|
382 |
#endif
|
sl@0
|
383 |
return err;
|
sl@0
|
384 |
}
|
sl@0
|
385 |
|
sl@0
|
386 |
|
sl@0
|
387 |
/**
|
sl@0
|
388 |
@publishedPartner
|
sl@0
|
389 |
@prototype
|
sl@0
|
390 |
@deprecated
|
sl@0
|
391 |
|
sl@0
|
392 |
Makes the pixel data of an image no longer accessible by the CPU. If the image was
|
sl@0
|
393 |
mapped for writing by the CPU, any written data is retained and any subsequent usage
|
sl@0
|
394 |
of the image by the GPU will reflect its new state.
|
sl@0
|
395 |
|
sl@0
|
396 |
If the last handle to an image in a process is closed while the image is still mapped
|
sl@0
|
397 |
by the process then the image will be automatically unmapped.
|
sl@0
|
398 |
|
sl@0
|
399 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
400 |
calling process.
|
sl@0
|
401 |
@pre This RSgImage handle is valid and not null.
|
sl@0
|
402 |
@pre The image is mapped for CPU access by a previous call to MapReadOnly(),
|
sl@0
|
403 |
MapWriteOnly() or MapReadWrite().
|
sl@0
|
404 |
@post The GPU is guaranteed to be able to get access to the image.
|
sl@0
|
405 |
@post The address range in the calling process used for the mapping is no longer
|
sl@0
|
406 |
valid. Attempts by the calling process to access any address in this range
|
sl@0
|
407 |
will result in undefined behaviour.
|
sl@0
|
408 |
@return KErrNone if successful.
|
sl@0
|
409 |
@return KErrBadHandle if this RSgImage handle is null.
|
sl@0
|
410 |
@return KErrGeneral if the image was not mapped for CPU access.
|
sl@0
|
411 |
@panic SGRES 3 in debug builds if this RSgImage handle is invalid.
|
sl@0
|
412 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
413 |
for use in the context of the calling process.
|
sl@0
|
414 |
*/
|
sl@0
|
415 |
EXPORT_C TInt RSgImage::Unmap() const
|
sl@0
|
416 |
{
|
sl@0
|
417 |
if (!iImpl)
|
sl@0
|
418 |
{
|
sl@0
|
419 |
return KErrBadHandle;
|
sl@0
|
420 |
}
|
sl@0
|
421 |
#ifdef _DEBUG
|
sl@0
|
422 |
gPls.iMutex.Wait();
|
sl@0
|
423 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
424 |
__ASSERT_DEBUG(gPls.iDriver->CheckImage(*iImpl), Panic(ESgPanicBadImageHandle));
|
sl@0
|
425 |
#endif
|
sl@0
|
426 |
TInt err = static_cast<MSgImageAdapter*>(iImpl)->Unmap();
|
sl@0
|
427 |
#ifdef _DEBUG
|
sl@0
|
428 |
gPls.iMutex.Signal();
|
sl@0
|
429 |
#endif
|
sl@0
|
430 |
return err;
|
sl@0
|
431 |
}
|
sl@0
|
432 |
|
sl@0
|
433 |
|
sl@0
|
434 |
/**
|
sl@0
|
435 |
@publishedPartner
|
sl@0
|
436 |
@prototype
|
sl@0
|
437 |
@deprecated
|
sl@0
|
438 |
|
sl@0
|
439 |
Retrieves the list of image pixel formats supported on this device for a specified
|
sl@0
|
440 |
usage. This function is often called before creating images.
|
sl@0
|
441 |
|
sl@0
|
442 |
@param aInfo The image attributes. aInfo.iPixelFormat is ignored.
|
sl@0
|
443 |
@param aPixelFormats A pointer to an array that on return will contain the supported
|
sl@0
|
444 |
pixel formats. If this parameter is null, then this function will just
|
sl@0
|
445 |
return the number of supported pixel formats in aCount.
|
sl@0
|
446 |
@param aCount On input, the number of elements in the array pointed to by aPixelFormats
|
sl@0
|
447 |
if not null, ignored otherwise. On return, the actual number of supported pixel
|
sl@0
|
448 |
formats. If this number is greater than the number of elements in the array,
|
sl@0
|
449 |
then the array will be filled with as many pixel formats as it can hold and the
|
sl@0
|
450 |
function will return KErrOverflow.
|
sl@0
|
451 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
452 |
calling process.
|
sl@0
|
453 |
@pre aInfo is valid.
|
sl@0
|
454 |
@pre If aPixelFormats is not null then aCount is greater than zero.
|
sl@0
|
455 |
@post None.
|
sl@0
|
456 |
@return KErrNone if successful.
|
sl@0
|
457 |
@return KErrArgument if aInfo is invalid or if aPixelFormats is not null and aCount
|
sl@0
|
458 |
is negative.
|
sl@0
|
459 |
@return KErrOverflow if the actual number of supported pixel formats is greater than
|
sl@0
|
460 |
the number of elements in the array pointed to by aPixelFormats.
|
sl@0
|
461 |
@return KErrNoMemory if there is not enough system memory.
|
sl@0
|
462 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
463 |
for use in the context of the calling process.
|
sl@0
|
464 |
*/
|
sl@0
|
465 |
EXPORT_C TInt RSgImage::GetPixelFormats(const TSgImageInfo& aInfo, TUidPixelFormat* aPixelFormats, TInt& aCount)
|
sl@0
|
466 |
{
|
sl@0
|
467 |
#ifdef _DEBUG
|
sl@0
|
468 |
gPls.iMutex.Wait();
|
sl@0
|
469 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
470 |
#endif
|
sl@0
|
471 |
TInt err = gPls.iDriver->GetPixelFormats(aInfo, aPixelFormats, aCount);
|
sl@0
|
472 |
#ifdef _DEBUG
|
sl@0
|
473 |
gPls.iMutex.Signal();
|
sl@0
|
474 |
#endif
|
sl@0
|
475 |
return err;
|
sl@0
|
476 |
}
|