1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsresourceservices/graphicsresource/src/sgimagecollection.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,355 @@
1.4 +// Copyright (c) 2007-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 +//
1.18 +
1.19 +#include "sgdriver.h"
1.20 +#include "sgimagecollectionadapter.h"
1.21 +
1.22 +
1.23 +/**
1.24 +@internalComponent
1.25 +*/
1.26 +const TSurfaceId KNullSurfaceId = {0, 0, 0, 0};
1.27 +
1.28 +
1.29 +/**
1.30 +@publishedPartner
1.31 +@prototype
1.32 +@deprecated
1.33 +
1.34 +Default constructor.
1.35 +
1.36 +@pre None.
1.37 +@post This RSgImageCollection handle is null.
1.38 +*/
1.39 +EXPORT_C RSgImageCollection::RSgImageCollection()
1.40 + : iImpl(NULL)
1.41 + {}
1.42 +
1.43 +
1.44 +/**
1.45 +@publishedPartner
1.46 +@prototype
1.47 +@deprecated
1.48 +
1.49 +Creates an image collection with the specified attributes. The number of images in
1.50 +the collection cannot be changed after creation. The images in the collection have
1.51 +identical attributes. The initial contents of all the images are undefined.
1.52 +
1.53 +@param aInfo The image attributes of the collection to be created.
1.54 +@param aImageCount The number of images in the collection to be created.
1.55 +@pre The Graphics Resource driver is initialised for use in the context of the
1.56 + calling process.
1.57 +@pre This RSgImageCollection handle is null.
1.58 +@pre aInfo is supported and specifies mutable images.
1.59 +@pre aImageCount is greater than zero.
1.60 +@post This RSgImageCollection handle references a newly created image collection with
1.61 + the specified attributes. The initial reference count for the image collection
1.62 + is one.
1.63 +@return KErrNone if successful.
1.64 +@return KErrInUse if this RSgImageCollection handle was not null.
1.65 +@return KErrArgument if aInfo is invalid or if aImageCount is negative or zero.
1.66 +@return KErrTooBig if the size specified in aInfo is too large.
1.67 +@return KErrNotSupported if aInfo is not supported or does not specify mutable images.
1.68 +@return KErrNoMemory if there is not enough system memory.
1.69 +@return KErrNoSpecializedMemory if there is not enough specialised graphics memory.
1.70 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
1.71 + for use in the context of the calling process.
1.72 +*/
1.73 +EXPORT_C TInt RSgImageCollection::Create(const TSgImageInfo& aInfo, TInt aImageCount)
1.74 + {
1.75 +#ifdef _DEBUG
1.76 + gPls.iMutex.Wait();
1.77 + __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
1.78 +#endif
1.79 + TInt err = gPls.iDriver->CreateImageCollection(aInfo, aImageCount, iImpl);
1.80 +#ifdef _DEBUG
1.81 + gPls.iMutex.Signal();
1.82 +#endif
1.83 + return err;
1.84 + }
1.85 +
1.86 +
1.87 +/**
1.88 +@publishedPartner
1.89 +@prototype
1.90 +@deprecated
1.91 +
1.92 +Creates a set of image collections that share a single memory chunk. The number of
1.93 +images in each collection is the same and cannot be changed after creation. The images
1.94 +in each collection have identical attributes. The initial contents of all the images
1.95 +are undefined.
1.96 +
1.97 +Care must be taken when using image collections created in this way. In particular,
1.98 +writing to the Nth image of one collection may invalidate the contents of the Nth image
1.99 +of all other collections, but will not affect any other images.
1.100 +
1.101 +@param aInfos An array of aCollectionCount elements with the image attributes of each
1.102 + of the collections to be created.
1.103 +@param aImageCount The number of images in each of the collections to be created.
1.104 +@param aCollections On return, an array of RSgImageCollection handles that reference
1.105 + newly created image collections with the specified attributes.
1.106 +@param aCollectionCount The number of image collections to be created.
1.107 +@pre The Graphics Resource driver is initialised for use in the context of the
1.108 + calling process.
1.109 +@pre All the elements of aInfos are supported and specify mutable images.
1.110 +@pre aImageCount is greater than zero.
1.111 +@pre All the RSgImageCollection handles in aCollections are null.
1.112 +@pre aCollectionCount is greater than zero.
1.113 +@post The initial reference count for each of the newly created image collections is one.
1.114 +@return KErrNone if successful.
1.115 +@return KErrInUse if any of the RSgImageCollection handles in aCollections was not null.
1.116 +@return KErrArgument if any element of aInfos is invalid, if aImageCount is negative
1.117 + or zero, or if aCollectionCount is negative or zero.
1.118 +@return KErrTooBig if any of the sizes specified in aInfos is too large.
1.119 +@return KErrNotSupported if any element of aInfos is not supported or does not specify
1.120 + mutable images.
1.121 +@return KErrNoMemory if there is not enough system memory.
1.122 +@return KErrNoSpecializedMemory if there is not enough specialised graphics memory.
1.123 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
1.124 + for use in the context of the calling process.
1.125 +*/
1.126 +EXPORT_C TInt RSgImageCollection::Create(const TSgImageInfo aInfos[], TInt aImageCount,
1.127 + RSgImageCollection aCollections[], TInt aCollectionCount)
1.128 + {
1.129 +#ifdef _DEBUG
1.130 + gPls.iMutex.Wait();
1.131 + __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
1.132 +#endif
1.133 + TInt err = gPls.iDriver->CreateImageCollections(aInfos, aImageCount,
1.134 + reinterpret_cast<MSgImageCollectionAdapter**>(aCollections), aCollectionCount);
1.135 +#ifdef _DEBUG
1.136 + gPls.iMutex.Signal();
1.137 +#endif
1.138 + return err;
1.139 + }
1.140 +
1.141 +
1.142 +/**
1.143 +@publishedPartner
1.144 +@prototype
1.145 +@deprecated
1.146 +
1.147 +Closes a handle to an image collection. If there are no remaining handles to
1.148 +the image collection, then it can be destroyed by the Graphics Resource driver.
1.149 +Calling Close() on a null handle is allowed but has no effect.
1.150 +
1.151 +@pre If this RSgImageCollection handle is not null then the Graphics Resource
1.152 + driver is initialised for use in the context of the calling process.
1.153 +@pre This RSgImageCollection handle is valid.
1.154 +@post This RSgImageCollection handle is null. The reference count for the
1.155 + previously referenced image collection, if any, is decremented by one.
1.156 +@panic SGRES 4 in debug builds if this RSgImageCollection handle is invalid.
1.157 +@panic SGRES 5 in debug builds if this RSgImageCollection handle is not null
1.158 + and the Graphics Resource driver is not initialised for use in the
1.159 + context of the calling process.
1.160 +*/
1.161 +EXPORT_C void RSgImageCollection::Close()
1.162 + {
1.163 + if (iImpl)
1.164 + {
1.165 +#ifdef _DEBUG
1.166 + gPls.iMutex.Wait();
1.167 + __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
1.168 + __ASSERT_DEBUG(gPls.iDriver->CheckImageCollection(*iImpl), Panic(ESgPanicBadImageCollectionHandle));
1.169 +#endif
1.170 + iImpl->Close();
1.171 + iImpl = NULL;
1.172 +#ifdef _DEBUG
1.173 + gPls.iMutex.Signal();
1.174 +#endif
1.175 + }
1.176 + }
1.177 +
1.178 +
1.179 +/**
1.180 +@publishedPartner
1.181 +@prototype
1.182 +@deprecated
1.183 +
1.184 +Retrieves the surface identifier of an image collection.
1.185 +
1.186 +@pre The Graphics Resource driver is initialised for use in the context of the
1.187 + calling process.
1.188 +@pre This RSgImageCollection handle is valid.
1.189 +@post None.
1.190 +@return The surface identifier of the image collection or the null surface identifier
1.191 + if this RSgImageCollection handle is null.
1.192 +@panic SGRES 4 in debug builds if this RSgImageCollection handle is invalid.
1.193 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
1.194 + for use in the context of the calling process.
1.195 +*/
1.196 +EXPORT_C const TSurfaceId& RSgImageCollection::SurfaceId() const
1.197 + {
1.198 + if (!iImpl)
1.199 + {
1.200 + return KNullSurfaceId;
1.201 + }
1.202 +#ifdef _DEBUG
1.203 + gPls.iMutex.Wait();
1.204 + __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
1.205 + __ASSERT_DEBUG(gPls.iDriver->CheckImageCollection(*iImpl), Panic(ESgPanicBadImageCollectionHandle));
1.206 +#endif
1.207 + const TSurfaceId& id = iImpl->SurfaceId();
1.208 +#ifdef _DEBUG
1.209 + gPls.iMutex.Signal();
1.210 +#endif
1.211 + return id;
1.212 + }
1.213 +
1.214 +
1.215 +/**
1.216 +@publishedPartner
1.217 +@prototype
1.218 +@deprecated
1.219 +
1.220 +Tests whether this RSgImageCollection handle is null.
1.221 +
1.222 +@pre None.
1.223 +@post None.
1.224 +@return ETrue, if this RSgImageCollection handle is null, EFalse otherwise.
1.225 +*/
1.226 +EXPORT_C TBool RSgImageCollection::IsNull() const
1.227 + {
1.228 + return iImpl == NULL;
1.229 + }
1.230 +
1.231 +
1.232 +/**
1.233 +@publishedPartner
1.234 +@prototype
1.235 +@deprecated
1.236 +
1.237 +Retrieves the values of the attributes of the images in an image collection. This
1.238 +function can also retrieve the values of selected user-defined attributes attached
1.239 +to an image collection by passing in the globally unique identifiers of the
1.240 +user-defined attributes to be retrieved.
1.241 +
1.242 +@param aInfo On input, the globally unique identifiers of the user-defined attributes
1.243 + to be retrieved from the image collection, if any. On return, the values of
1.244 + the attributes of the images in the collection and the values of the selected
1.245 + user-defined attributes.
1.246 +@pre The Graphics Resource driver is initialised for use in the context of the
1.247 + calling process.
1.248 +@pre This RSgImageCollection handle is valid and not null.
1.249 +@pre If aInfo.iUserAttributes is not null then it points to an array of
1.250 + aInfo.iUserAttributeCount elements with globally unique identifiers
1.251 + corresponding to user-defined attributes attached to the image collection.
1.252 +@post None.
1.253 +@return KErrNone if successful.
1.254 +@return KErrBadHandle if this RSgImageCollection handle is null.
1.255 +@return KErrNotFound if any of the user-defined attributes to be retrieved from the
1.256 + image collection cannot be found.
1.257 +@panic SGRES 4 in debug builds if this RSgImageCollection handle is invalid.
1.258 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
1.259 + for use in the context of the calling process.
1.260 +*/
1.261 +EXPORT_C TInt RSgImageCollection::GetInfo(TSgImageInfo& aInfo) const
1.262 + {
1.263 + if (!iImpl)
1.264 + {
1.265 + return KErrBadHandle;
1.266 + }
1.267 +#ifdef _DEBUG
1.268 + gPls.iMutex.Wait();
1.269 + __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
1.270 + __ASSERT_DEBUG(gPls.iDriver->CheckImageCollection(*iImpl), Panic(ESgPanicBadImageCollectionHandle));
1.271 +#endif
1.272 + TInt err = iImpl->GetInfo(aInfo);
1.273 +#ifdef _DEBUG
1.274 + gPls.iMutex.Signal();
1.275 +#endif
1.276 + return err;
1.277 + }
1.278 +
1.279 +
1.280 +/**
1.281 +@publishedPartner
1.282 +@prototype
1.283 +@deprecated
1.284 +
1.285 +Retrieves the number of images in an image collection.
1.286 +
1.287 +@pre The Graphics Resource driver is initialised for use in the context of the
1.288 + calling process.
1.289 +@pre This RSgImageCollection handle is valid.
1.290 +@post None.
1.291 +@return The number of images in the image collection or zero if this RSgImageCollection
1.292 + handle is null.
1.293 +@panic SGRES 4 in debug builds if this RSgImageCollection handle is invalid.
1.294 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
1.295 + for use in the context of the calling process.
1.296 +*/
1.297 +EXPORT_C TInt RSgImageCollection::Count() const
1.298 + {
1.299 + if (!iImpl)
1.300 + {
1.301 + return 0;
1.302 + }
1.303 +#ifdef _DEBUG
1.304 + gPls.iMutex.Wait();
1.305 + __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
1.306 + __ASSERT_DEBUG(gPls.iDriver->CheckImageCollection(*iImpl), Panic(ESgPanicBadImageCollectionHandle));
1.307 +#endif
1.308 + TInt count = iImpl->Count();
1.309 +#ifdef _DEBUG
1.310 + gPls.iMutex.Signal();
1.311 +#endif
1.312 + return count;
1.313 + }
1.314 +
1.315 +
1.316 +/**
1.317 +@publishedPartner
1.318 +@prototype
1.319 +@deprecated
1.320 +
1.321 +Opens a new handle to one of the images in an image collection.
1.322 +
1.323 +@param aIndex The index of the image within the image collection.
1.324 +@param aResult On return, an RSgImage handle that references the specified image in
1.325 + the collection.
1.326 +@pre The Graphics Resource driver is initialised for use in the context of the
1.327 + calling process.
1.328 +@pre This RSgImageCollection handle is valid and not null.
1.329 +@pre aIndex is greater than or equal to zero and less than the number of images in
1.330 + the collection.
1.331 +@pre aResult is a null handle.
1.332 +@post The reference count for the image collection is incremented by one.
1.333 +@return KErrNone if successful.
1.334 +@return KErrBadHandle if this RSgImageCollection handle is null.
1.335 +@return KErrInUse if aResult was not a null handle.
1.336 +@return KErrArgument if aIndex is invalid.
1.337 +@return KErrNoMemory if there is not enough system memory.
1.338 +@panic SGRES 4 in debug builds if this RSgImageCollection handle is invalid.
1.339 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
1.340 + for use in the context of the calling process.
1.341 +*/
1.342 +EXPORT_C TInt RSgImageCollection::OpenImage(TInt aIndex, RSgImage& aResult)
1.343 + {
1.344 + if (!iImpl)
1.345 + {
1.346 + return KErrBadHandle;
1.347 + }
1.348 +#ifdef _DEBUG
1.349 + gPls.iMutex.Wait();
1.350 + __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
1.351 + __ASSERT_DEBUG(gPls.iDriver->CheckImageCollection(*iImpl), Panic(ESgPanicBadImageCollectionHandle));
1.352 +#endif
1.353 + TInt err = iImpl->OpenImage(aIndex, aResult.iImpl);
1.354 +#ifdef _DEBUG
1.355 + gPls.iMutex.Signal();
1.356 +#endif
1.357 + return err;
1.358 + }