os/graphics/graphicsresourceservices/graphicsresource/src/sgdrawable.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsresourceservices/graphicsresource/src/sgdrawable.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,289 @@
     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 "sgresourceadapter.h"
    1.21 +
    1.22 +
    1.23 +/**
    1.24 +@publishedPartner
    1.25 +@prototype
    1.26 +@deprecated
    1.27 +
    1.28 +Default constructor.
    1.29 +
    1.30 +@pre None.
    1.31 +@post This RSgDrawable handle is null.
    1.32 +*/
    1.33 +EXPORT_C RSgDrawable::RSgDrawable()
    1.34 +	: iImpl(NULL)
    1.35 +	{
    1.36 +	iHandleType = KSgDrawableTypeUid;
    1.37 +	}
    1.38 +
    1.39 +
    1.40 +/**
    1.41 +@publishedPartner
    1.42 +@prototype
    1.43 +@deprecated
    1.44 +
    1.45 +Opens a new handle to a drawable resource.
    1.46 +
    1.47 +@param aId The unique identifier of the drawable resource.
    1.48 +@pre The Graphics Resource driver is initialised for use in the context of the
    1.49 +     calling process.
    1.50 +@pre This RSgDrawable handle is null.
    1.51 +@pre aId identifies an existing drawable resource.
    1.52 +@post This RSgDrawable handle references the drawable resource specified by
    1.53 +      its unique identifier. The reference count for the drawable resource is
    1.54 +      incremented by one.
    1.55 +@return KErrNone if successful.
    1.56 +@return KErrInUse if this RSgDrawable handle was not null.
    1.57 +@return KErrArgument if aId is the null drawable resource identifier.
    1.58 +@return KErrNotFound if aId cannot be found to refer to an existing drawable resource.
    1.59 +@return KErrPermissionDenied if this process is not permitted to access the drawable
    1.60 +        resource specified by aId.
    1.61 +@return KErrNoMemory if there is not enough system memory.
    1.62 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
    1.63 +       for use in the context of the calling process.
    1.64 +*/
    1.65 +EXPORT_C TInt RSgDrawable::Open(const TSgDrawableId& aId)
    1.66 +	{
    1.67 +#ifdef _DEBUG
    1.68 +	gPls.iMutex.Wait();
    1.69 +	__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
    1.70 +#endif
    1.71 +	TInt err = gPls.iDriver->OpenDrawable(aId, KSgDefaultOpenMode, iHandleType, iImpl);
    1.72 +#ifdef _DEBUG
    1.73 +	gPls.iMutex.Signal();
    1.74 +#endif
    1.75 +	return err;
    1.76 +	}
    1.77 +
    1.78 +
    1.79 +/**
    1.80 +@internalTechnology
    1.81 +@prototype
    1.82 +
    1.83 +Opens a new handle to a drawable resource. This overload of Open() is intended for
    1.84 +the adaptation layer of renderers to be able to request special options when opening
    1.85 +a drawable resource.
    1.86 +
    1.87 +@param aId The unique identifier of the drawable resource.
    1.88 +@param aMode Flags controlling how the drawable resource is opened. The bits of this
    1.89 +       argument are defined by the enumeration TSgDrawableOpenModes.
    1.90 +@pre The Graphics Resource driver is initialised for use in the context of the
    1.91 +     calling process.
    1.92 +@pre This RSgDrawable handle is null.
    1.93 +@pre aId identifies an existing drawable resource.
    1.94 +@pre All of the requested opening options in aMode are supported.
    1.95 +@post This RSgDrawable handle references the drawable resource specified by
    1.96 +      its unique identifier. The reference count for the drawable resource is
    1.97 +      incremented by one.
    1.98 +@return KErrNone if successful.
    1.99 +@return KErrInUse if this RSgDrawable handle was not null.
   1.100 +@return KErrArgument if aId is the null drawable resource identifier.
   1.101 +@return KErrNotFound if aId cannot be found to refer to an existing drawable resource.
   1.102 +@return KErrPermissionDenied if this process is not permitted to access the drawable
   1.103 +        resource specified by aId.
   1.104 +@return KErrNotSupported if any of the requested opening options in aMode is not
   1.105 +        supported.
   1.106 +@return KErrNoMemory if there is not enough system memory.
   1.107 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
   1.108 +       for use in the context of the calling process.
   1.109 +@see TSgDrawableOpenModes
   1.110 +*/
   1.111 +EXPORT_C TInt RSgDrawable::Open(const TSgDrawableId& aId, TUint32 aMode)
   1.112 +	{
   1.113 +#ifdef _DEBUG
   1.114 +	gPls.iMutex.Wait();
   1.115 +	__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
   1.116 +#endif
   1.117 +	TInt err = gPls.iDriver->OpenDrawable(aId, aMode, iHandleType, iImpl);
   1.118 +#ifdef _DEBUG
   1.119 +	gPls.iMutex.Signal();
   1.120 +#endif
   1.121 +	return err;
   1.122 +	}
   1.123 +
   1.124 +
   1.125 +/**
   1.126 +@publishedPartner
   1.127 +@prototype
   1.128 +@deprecated
   1.129 +
   1.130 +Closes a handle to a drawable resource. If there are no remaining handles to the
   1.131 +drawable resource, then it can be destroyed by the Graphics Resource driver.
   1.132 +Calling Close() on a null handle is allowed but has no effect.
   1.133 +
   1.134 +@pre If this RSgDrawable handle is not null then the Graphics Resource driver is
   1.135 +     initialised for use in the context of the calling process.
   1.136 +@pre This RSgDrawable handle is valid.
   1.137 +@post This RSgDrawable handle is null. The reference count for the previously
   1.138 +      referenced drawable resource, if any, is decremented by one.
   1.139 +@panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
   1.140 +@panic SGRES 5 in debug builds if this RSgDrawable handle is not null and the Graphics
   1.141 +       Resource driver is not initialised for use in the context of the calling process.
   1.142 +*/
   1.143 +EXPORT_C void RSgDrawable::Close()
   1.144 +	{
   1.145 +	if (iImpl)
   1.146 +		{
   1.147 +#ifdef _DEBUG
   1.148 +		gPls.iMutex.Wait();
   1.149 +		__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
   1.150 +		__ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
   1.151 +#endif
   1.152 +		iImpl->Close();
   1.153 +		iImpl = NULL;
   1.154 +#ifdef _DEBUG
   1.155 +		gPls.iMutex.Signal();
   1.156 +#endif
   1.157 +		}
   1.158 +	}
   1.159 +
   1.160 +
   1.161 +/**
   1.162 +@publishedPartner
   1.163 +@prototype
   1.164 +@deprecated
   1.165 +
   1.166 +Retrieves the unique identifier of a drawable resource. The unique identifier can be
   1.167 +used to share the drawable resource with another process.
   1.168 +
   1.169 +@pre The Graphics Resource driver is initialised for use in the context of the
   1.170 +     calling process.
   1.171 +@pre This RSgDrawable handle is valid.
   1.172 +@post None.
   1.173 +@return The unique identifier of the drawable resource or the null drawable resource
   1.174 +        identifier if this RSgDrawable handle is null.
   1.175 +@panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
   1.176 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
   1.177 +       for use in the context of the calling process.
   1.178 +*/
   1.179 +EXPORT_C const TSgDrawableId& RSgDrawable::Id() const
   1.180 +	{
   1.181 +	if (!iImpl)
   1.182 +		{
   1.183 +		return KSgNullDrawableId;
   1.184 +		}
   1.185 +#ifdef _DEBUG
   1.186 +	gPls.iMutex.Wait();
   1.187 +	__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
   1.188 +	__ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
   1.189 +#endif
   1.190 +	const TSgDrawableId& id = iImpl->Id();
   1.191 +#ifdef _DEBUG
   1.192 +	gPls.iMutex.Signal();
   1.193 +#endif
   1.194 +	return id;
   1.195 +	}
   1.196 +
   1.197 +
   1.198 +/**
   1.199 +@publishedPartner
   1.200 +@prototype
   1.201 +@deprecated
   1.202 +
   1.203 +Tests whether this RSgDrawable handle is null.
   1.204 +
   1.205 +@pre None.
   1.206 +@post None.
   1.207 +@return ETrue, if this RSgDrawable handle is null, EFalse otherwise.
   1.208 +*/
   1.209 +EXPORT_C TBool RSgDrawable::IsNull() const
   1.210 +	{
   1.211 +	return iImpl == NULL;
   1.212 +	}
   1.213 +
   1.214 +
   1.215 +/**
   1.216 +@publishedPartner
   1.217 +@prototype
   1.218 +@deprecated
   1.219 +
   1.220 +Retrieves the run-time type of a drawable resource as a globally unique identifier.
   1.221 +
   1.222 +@pre The Graphics Resource driver is initialised for use in the context of the
   1.223 +     calling process.
   1.224 +@pre This RSgDrawable handle is valid.
   1.225 +@post None.
   1.226 +@return The run-time type of the drawable resource as a globally unique identifier
   1.227 +        or the null globally unique identifier if this RSgDrawable handle is null.
   1.228 +@panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
   1.229 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
   1.230 +       for use in the context of the calling process.
   1.231 +@see RSgDrawable::HandleType()
   1.232 +*/
   1.233 +EXPORT_C TUid RSgDrawable::DrawableType() const
   1.234 +	{
   1.235 +	if (!iImpl)
   1.236 +		{
   1.237 +		return KNullUid;
   1.238 +		}
   1.239 +#ifdef _DEBUG
   1.240 +	gPls.iMutex.Wait();
   1.241 +	__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
   1.242 +	__ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
   1.243 +#endif
   1.244 +	TUid type = iImpl->DrawableType();
   1.245 +#ifdef _DEBUG
   1.246 +	gPls.iMutex.Signal();
   1.247 +#endif
   1.248 +	return type;
   1.249 +	}
   1.250 +
   1.251 +
   1.252 +/**
   1.253 +@internalComponent
   1.254 +
   1.255 +Makes an extension interface available on a drawable resource. The extension interface
   1.256 +is specified by globally unique identifier.
   1.257 +
   1.258 +@param aInterfaceUid Globally unique identifier of the interface to be made available.
   1.259 +@param aInterfacePtr On return, a pointer to the specified interface.
   1.260 +@pre The Graphics Resource driver is initialised for use in the context of the
   1.261 +     calling process.
   1.262 +@pre This RSgDrawable handle is valid and not null.
   1.263 +@pre The specified interface is supported on the drawable resource.
   1.264 +@post The specified interface is available until this RSgDrawable handle is closed.
   1.265 +@return KErrNone if successful.
   1.266 +@return KErrBadHandle if this RSgDrawable handle is null.
   1.267 +@return KErrExtensionNotSupported if the specified interface is not supported on
   1.268 +        the drawable resource.
   1.269 +@return KErrNoMemory if there is not enough system memory.
   1.270 +@panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
   1.271 +@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
   1.272 +       for use in the context of the calling process.
   1.273 +@see RSgDrawable::GetInterface<M>(M*&)
   1.274 +@see RSgDrawable::GetInterface<M>(const M*&) const
   1.275 +*/
   1.276 +EXPORT_C TInt RSgDrawable::GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr) const
   1.277 +	{
   1.278 +	if (!iImpl)
   1.279 +		{
   1.280 +		return KErrBadHandle;
   1.281 +		}
   1.282 +#ifdef _DEBUG
   1.283 +	gPls.iMutex.Wait();
   1.284 +	__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
   1.285 +	__ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
   1.286 +#endif
   1.287 +	TInt err = iImpl->GetInterface(aInterfaceUid, aInterfacePtr);
   1.288 +#ifdef _DEBUG
   1.289 +	gPls.iMutex.Signal();
   1.290 +#endif
   1.291 +	return err;
   1.292 +	}