sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "sgdriver.h" sl@0: #include "sgresourceadapter.h" sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: @deprecated sl@0: sl@0: Default constructor. sl@0: sl@0: @pre None. sl@0: @post This RSgDrawable handle is null. sl@0: */ sl@0: EXPORT_C RSgDrawable::RSgDrawable() sl@0: : iImpl(NULL) sl@0: { sl@0: iHandleType = KSgDrawableTypeUid; sl@0: } sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: @deprecated sl@0: sl@0: Opens a new handle to a drawable resource. sl@0: sl@0: @param aId The unique identifier of the drawable resource. sl@0: @pre The Graphics Resource driver is initialised for use in the context of the sl@0: calling process. sl@0: @pre This RSgDrawable handle is null. sl@0: @pre aId identifies an existing drawable resource. sl@0: @post This RSgDrawable handle references the drawable resource specified by sl@0: its unique identifier. The reference count for the drawable resource is sl@0: incremented by one. sl@0: @return KErrNone if successful. sl@0: @return KErrInUse if this RSgDrawable handle was not null. sl@0: @return KErrArgument if aId is the null drawable resource identifier. sl@0: @return KErrNotFound if aId cannot be found to refer to an existing drawable resource. sl@0: @return KErrPermissionDenied if this process is not permitted to access the drawable sl@0: resource specified by aId. sl@0: @return KErrNoMemory if there is not enough system memory. sl@0: @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised sl@0: for use in the context of the calling process. sl@0: */ sl@0: EXPORT_C TInt RSgDrawable::Open(const TSgDrawableId& aId) sl@0: { sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Wait(); sl@0: __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); sl@0: #endif sl@0: TInt err = gPls.iDriver->OpenDrawable(aId, KSgDefaultOpenMode, iHandleType, iImpl); sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Signal(); sl@0: #endif sl@0: return err; sl@0: } sl@0: sl@0: sl@0: /** sl@0: @internalTechnology sl@0: @prototype sl@0: sl@0: Opens a new handle to a drawable resource. This overload of Open() is intended for sl@0: the adaptation layer of renderers to be able to request special options when opening sl@0: a drawable resource. sl@0: sl@0: @param aId The unique identifier of the drawable resource. sl@0: @param aMode Flags controlling how the drawable resource is opened. The bits of this sl@0: argument are defined by the enumeration TSgDrawableOpenModes. sl@0: @pre The Graphics Resource driver is initialised for use in the context of the sl@0: calling process. sl@0: @pre This RSgDrawable handle is null. sl@0: @pre aId identifies an existing drawable resource. sl@0: @pre All of the requested opening options in aMode are supported. sl@0: @post This RSgDrawable handle references the drawable resource specified by sl@0: its unique identifier. The reference count for the drawable resource is sl@0: incremented by one. sl@0: @return KErrNone if successful. sl@0: @return KErrInUse if this RSgDrawable handle was not null. sl@0: @return KErrArgument if aId is the null drawable resource identifier. sl@0: @return KErrNotFound if aId cannot be found to refer to an existing drawable resource. sl@0: @return KErrPermissionDenied if this process is not permitted to access the drawable sl@0: resource specified by aId. sl@0: @return KErrNotSupported if any of the requested opening options in aMode is not sl@0: supported. sl@0: @return KErrNoMemory if there is not enough system memory. sl@0: @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised sl@0: for use in the context of the calling process. sl@0: @see TSgDrawableOpenModes sl@0: */ sl@0: EXPORT_C TInt RSgDrawable::Open(const TSgDrawableId& aId, TUint32 aMode) sl@0: { sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Wait(); sl@0: __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); sl@0: #endif sl@0: TInt err = gPls.iDriver->OpenDrawable(aId, aMode, iHandleType, iImpl); sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Signal(); sl@0: #endif sl@0: return err; sl@0: } sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: @deprecated sl@0: sl@0: Closes a handle to a drawable resource. If there are no remaining handles to the sl@0: drawable resource, then it can be destroyed by the Graphics Resource driver. sl@0: Calling Close() on a null handle is allowed but has no effect. sl@0: sl@0: @pre If this RSgDrawable handle is not null then the Graphics Resource driver is sl@0: initialised for use in the context of the calling process. sl@0: @pre This RSgDrawable handle is valid. sl@0: @post This RSgDrawable handle is null. The reference count for the previously sl@0: referenced drawable resource, if any, is decremented by one. sl@0: @panic SGRES 2 in debug builds if this RSgDrawable handle is invalid. sl@0: @panic SGRES 5 in debug builds if this RSgDrawable handle is not null and the Graphics sl@0: Resource driver is not initialised for use in the context of the calling process. sl@0: */ sl@0: EXPORT_C void RSgDrawable::Close() sl@0: { sl@0: if (iImpl) sl@0: { sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Wait(); sl@0: __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); sl@0: __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle)); sl@0: #endif sl@0: iImpl->Close(); sl@0: iImpl = NULL; sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Signal(); sl@0: #endif sl@0: } sl@0: } sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: @deprecated sl@0: sl@0: Retrieves the unique identifier of a drawable resource. The unique identifier can be sl@0: used to share the drawable resource with another process. sl@0: sl@0: @pre The Graphics Resource driver is initialised for use in the context of the sl@0: calling process. sl@0: @pre This RSgDrawable handle is valid. sl@0: @post None. sl@0: @return The unique identifier of the drawable resource or the null drawable resource sl@0: identifier if this RSgDrawable handle is null. sl@0: @panic SGRES 2 in debug builds if this RSgDrawable handle is invalid. sl@0: @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised sl@0: for use in the context of the calling process. sl@0: */ sl@0: EXPORT_C const TSgDrawableId& RSgDrawable::Id() const sl@0: { sl@0: if (!iImpl) sl@0: { sl@0: return KSgNullDrawableId; sl@0: } sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Wait(); sl@0: __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); sl@0: __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle)); sl@0: #endif sl@0: const TSgDrawableId& id = iImpl->Id(); sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Signal(); sl@0: #endif sl@0: return id; sl@0: } sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: @deprecated sl@0: sl@0: Tests whether this RSgDrawable handle is null. sl@0: sl@0: @pre None. sl@0: @post None. sl@0: @return ETrue, if this RSgDrawable handle is null, EFalse otherwise. sl@0: */ sl@0: EXPORT_C TBool RSgDrawable::IsNull() const sl@0: { sl@0: return iImpl == NULL; sl@0: } sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: @deprecated sl@0: sl@0: Retrieves the run-time type of a drawable resource as a globally unique identifier. sl@0: sl@0: @pre The Graphics Resource driver is initialised for use in the context of the sl@0: calling process. sl@0: @pre This RSgDrawable handle is valid. sl@0: @post None. sl@0: @return The run-time type of the drawable resource as a globally unique identifier sl@0: or the null globally unique identifier if this RSgDrawable handle is null. sl@0: @panic SGRES 2 in debug builds if this RSgDrawable handle is invalid. sl@0: @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised sl@0: for use in the context of the calling process. sl@0: @see RSgDrawable::HandleType() sl@0: */ sl@0: EXPORT_C TUid RSgDrawable::DrawableType() const sl@0: { sl@0: if (!iImpl) sl@0: { sl@0: return KNullUid; sl@0: } sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Wait(); sl@0: __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); sl@0: __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle)); sl@0: #endif sl@0: TUid type = iImpl->DrawableType(); sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Signal(); sl@0: #endif sl@0: return type; sl@0: } sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: Makes an extension interface available on a drawable resource. The extension interface sl@0: is specified by globally unique identifier. sl@0: sl@0: @param aInterfaceUid Globally unique identifier of the interface to be made available. sl@0: @param aInterfacePtr On return, a pointer to the specified interface. sl@0: @pre The Graphics Resource driver is initialised for use in the context of the sl@0: calling process. sl@0: @pre This RSgDrawable handle is valid and not null. sl@0: @pre The specified interface is supported on the drawable resource. sl@0: @post The specified interface is available until this RSgDrawable handle is closed. sl@0: @return KErrNone if successful. sl@0: @return KErrBadHandle if this RSgDrawable handle is null. sl@0: @return KErrExtensionNotSupported if the specified interface is not supported on sl@0: the drawable resource. sl@0: @return KErrNoMemory if there is not enough system memory. sl@0: @panic SGRES 2 in debug builds if this RSgDrawable handle is invalid. sl@0: @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised sl@0: for use in the context of the calling process. sl@0: @see RSgDrawable::GetInterface(M*&) sl@0: @see RSgDrawable::GetInterface(const M*&) const sl@0: */ sl@0: EXPORT_C TInt RSgDrawable::GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr) const sl@0: { sl@0: if (!iImpl) sl@0: { sl@0: return KErrBadHandle; sl@0: } sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Wait(); sl@0: __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); sl@0: __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle)); sl@0: #endif sl@0: TInt err = iImpl->GetInterface(aInterfaceUid, aInterfacePtr); sl@0: #ifdef _DEBUG sl@0: gPls.iMutex.Signal(); sl@0: #endif sl@0: return err; sl@0: }