First public contribution.
1 // Copyright (c) 2007-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.
17 #include "sgimagecollectionadapter.h"
23 const TSurfaceId KNullSurfaceId = {0, 0, 0, 0};
34 @post This RSgImageCollection handle is null.
36 EXPORT_C RSgImageCollection::RSgImageCollection()
46 Creates an image collection with the specified attributes. The number of images in
47 the collection cannot be changed after creation. The images in the collection have
48 identical attributes. The initial contents of all the images are undefined.
50 @param aInfo The image attributes of the collection to be created.
51 @param aImageCount The number of images in the collection to be created.
52 @pre The Graphics Resource driver is initialised for use in the context of the
54 @pre This RSgImageCollection handle is null.
55 @pre aInfo is supported and specifies mutable images.
56 @pre aImageCount is greater than zero.
57 @post This RSgImageCollection handle references a newly created image collection with
58 the specified attributes. The initial reference count for the image collection
60 @return KErrNone if successful.
61 @return KErrInUse if this RSgImageCollection handle was not null.
62 @return KErrArgument if aInfo is invalid or if aImageCount is negative or zero.
63 @return KErrTooBig if the size specified in aInfo is too large.
64 @return KErrNotSupported if aInfo is not supported or does not specify mutable images.
65 @return KErrNoMemory if there is not enough system memory.
66 @return KErrNoSpecializedMemory if there is not enough specialised graphics memory.
67 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
68 for use in the context of the calling process.
70 EXPORT_C TInt RSgImageCollection::Create(const TSgImageInfo& aInfo, TInt aImageCount)
74 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
76 TInt err = gPls.iDriver->CreateImageCollection(aInfo, aImageCount, iImpl);
89 Creates a set of image collections that share a single memory chunk. The number of
90 images in each collection is the same and cannot be changed after creation. The images
91 in each collection have identical attributes. The initial contents of all the images
94 Care must be taken when using image collections created in this way. In particular,
95 writing to the Nth image of one collection may invalidate the contents of the Nth image
96 of all other collections, but will not affect any other images.
98 @param aInfos An array of aCollectionCount elements with the image attributes of each
99 of the collections to be created.
100 @param aImageCount The number of images in each of the collections to be created.
101 @param aCollections On return, an array of RSgImageCollection handles that reference
102 newly created image collections with the specified attributes.
103 @param aCollectionCount The number of image collections to be created.
104 @pre The Graphics Resource driver is initialised for use in the context of the
106 @pre All the elements of aInfos are supported and specify mutable images.
107 @pre aImageCount is greater than zero.
108 @pre All the RSgImageCollection handles in aCollections are null.
109 @pre aCollectionCount is greater than zero.
110 @post The initial reference count for each of the newly created image collections is one.
111 @return KErrNone if successful.
112 @return KErrInUse if any of the RSgImageCollection handles in aCollections was not null.
113 @return KErrArgument if any element of aInfos is invalid, if aImageCount is negative
114 or zero, or if aCollectionCount is negative or zero.
115 @return KErrTooBig if any of the sizes specified in aInfos is too large.
116 @return KErrNotSupported if any element of aInfos is not supported or does not specify
118 @return KErrNoMemory if there is not enough system memory.
119 @return KErrNoSpecializedMemory if there is not enough specialised graphics memory.
120 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
121 for use in the context of the calling process.
123 EXPORT_C TInt RSgImageCollection::Create(const TSgImageInfo aInfos[], TInt aImageCount,
124 RSgImageCollection aCollections[], TInt aCollectionCount)
128 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
130 TInt err = gPls.iDriver->CreateImageCollections(aInfos, aImageCount,
131 reinterpret_cast<MSgImageCollectionAdapter**>(aCollections), aCollectionCount);
133 gPls.iMutex.Signal();
144 Closes a handle to an image collection. If there are no remaining handles to
145 the image collection, then it can be destroyed by the Graphics Resource driver.
146 Calling Close() on a null handle is allowed but has no effect.
148 @pre If this RSgImageCollection handle is not null then the Graphics Resource
149 driver is initialised for use in the context of the calling process.
150 @pre This RSgImageCollection handle is valid.
151 @post This RSgImageCollection handle is null. The reference count for the
152 previously referenced image collection, if any, is decremented by one.
153 @panic SGRES 4 in debug builds if this RSgImageCollection handle is invalid.
154 @panic SGRES 5 in debug builds if this RSgImageCollection handle is not null
155 and the Graphics Resource driver is not initialised for use in the
156 context of the calling process.
158 EXPORT_C void RSgImageCollection::Close()
164 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
165 __ASSERT_DEBUG(gPls.iDriver->CheckImageCollection(*iImpl), Panic(ESgPanicBadImageCollectionHandle));
170 gPls.iMutex.Signal();
181 Retrieves the surface identifier of an image collection.
183 @pre The Graphics Resource driver is initialised for use in the context of the
185 @pre This RSgImageCollection handle is valid.
187 @return The surface identifier of the image collection or the null surface identifier
188 if this RSgImageCollection handle is null.
189 @panic SGRES 4 in debug builds if this RSgImageCollection handle is invalid.
190 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
191 for use in the context of the calling process.
193 EXPORT_C const TSurfaceId& RSgImageCollection::SurfaceId() const
197 return KNullSurfaceId;
201 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
202 __ASSERT_DEBUG(gPls.iDriver->CheckImageCollection(*iImpl), Panic(ESgPanicBadImageCollectionHandle));
204 const TSurfaceId& id = iImpl->SurfaceId();
206 gPls.iMutex.Signal();
217 Tests whether this RSgImageCollection handle is null.
221 @return ETrue, if this RSgImageCollection handle is null, EFalse otherwise.
223 EXPORT_C TBool RSgImageCollection::IsNull() const
225 return iImpl == NULL;
234 Retrieves the values of the attributes of the images in an image collection. This
235 function can also retrieve the values of selected user-defined attributes attached
236 to an image collection by passing in the globally unique identifiers of the
237 user-defined attributes to be retrieved.
239 @param aInfo On input, the globally unique identifiers of the user-defined attributes
240 to be retrieved from the image collection, if any. On return, the values of
241 the attributes of the images in the collection and the values of the selected
242 user-defined attributes.
243 @pre The Graphics Resource driver is initialised for use in the context of the
245 @pre This RSgImageCollection handle is valid and not null.
246 @pre If aInfo.iUserAttributes is not null then it points to an array of
247 aInfo.iUserAttributeCount elements with globally unique identifiers
248 corresponding to user-defined attributes attached to the image collection.
250 @return KErrNone if successful.
251 @return KErrBadHandle if this RSgImageCollection handle is null.
252 @return KErrNotFound if any of the user-defined attributes to be retrieved from the
253 image collection cannot be found.
254 @panic SGRES 4 in debug builds if this RSgImageCollection handle is invalid.
255 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
256 for use in the context of the calling process.
258 EXPORT_C TInt RSgImageCollection::GetInfo(TSgImageInfo& aInfo) const
262 return KErrBadHandle;
266 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
267 __ASSERT_DEBUG(gPls.iDriver->CheckImageCollection(*iImpl), Panic(ESgPanicBadImageCollectionHandle));
269 TInt err = iImpl->GetInfo(aInfo);
271 gPls.iMutex.Signal();
282 Retrieves the number of images in an image collection.
284 @pre The Graphics Resource driver is initialised for use in the context of the
286 @pre This RSgImageCollection handle is valid.
288 @return The number of images in the image collection or zero if this RSgImageCollection
290 @panic SGRES 4 in debug builds if this RSgImageCollection handle is invalid.
291 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
292 for use in the context of the calling process.
294 EXPORT_C TInt RSgImageCollection::Count() const
302 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
303 __ASSERT_DEBUG(gPls.iDriver->CheckImageCollection(*iImpl), Panic(ESgPanicBadImageCollectionHandle));
305 TInt count = iImpl->Count();
307 gPls.iMutex.Signal();
318 Opens a new handle to one of the images in an image collection.
320 @param aIndex The index of the image within the image collection.
321 @param aResult On return, an RSgImage handle that references the specified image in
323 @pre The Graphics Resource driver is initialised for use in the context of the
325 @pre This RSgImageCollection handle is valid and not null.
326 @pre aIndex is greater than or equal to zero and less than the number of images in
328 @pre aResult is a null handle.
329 @post The reference count for the image collection is incremented by one.
330 @return KErrNone if successful.
331 @return KErrBadHandle if this RSgImageCollection handle is null.
332 @return KErrInUse if aResult was not a null handle.
333 @return KErrArgument if aIndex is invalid.
334 @return KErrNoMemory if there is not enough system memory.
335 @panic SGRES 4 in debug builds if this RSgImageCollection handle is invalid.
336 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
337 for use in the context of the calling process.
339 EXPORT_C TInt RSgImageCollection::OpenImage(TInt aIndex, RSgImage& aResult)
343 return KErrBadHandle;
347 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
348 __ASSERT_DEBUG(gPls.iDriver->CheckImageCollection(*iImpl), Panic(ESgPanicBadImageCollectionHandle));
350 TInt err = iImpl->OpenImage(aIndex, aResult.iImpl);
352 gPls.iMutex.Signal();