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 "sgresourceadapter.h"
28 @post This RSgDrawable handle is null.
30 EXPORT_C RSgDrawable::RSgDrawable()
33 iHandleType = KSgDrawableTypeUid;
42 Opens a new handle to a drawable resource.
44 @param aId The unique identifier of the drawable resource.
45 @pre The Graphics Resource driver is initialised for use in the context of the
47 @pre This RSgDrawable handle is null.
48 @pre aId identifies an existing drawable resource.
49 @post This RSgDrawable handle references the drawable resource specified by
50 its unique identifier. The reference count for the drawable resource is
52 @return KErrNone if successful.
53 @return KErrInUse if this RSgDrawable handle was not null.
54 @return KErrArgument if aId is the null drawable resource identifier.
55 @return KErrNotFound if aId cannot be found to refer to an existing drawable resource.
56 @return KErrPermissionDenied if this process is not permitted to access the drawable
57 resource specified by aId.
58 @return KErrNoMemory if there is not enough system memory.
59 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
60 for use in the context of the calling process.
62 EXPORT_C TInt RSgDrawable::Open(const TSgDrawableId& aId)
66 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
68 TInt err = gPls.iDriver->OpenDrawable(aId, KSgDefaultOpenMode, iHandleType, iImpl);
80 Opens a new handle to a drawable resource. This overload of Open() is intended for
81 the adaptation layer of renderers to be able to request special options when opening
84 @param aId The unique identifier of the drawable resource.
85 @param aMode Flags controlling how the drawable resource is opened. The bits of this
86 argument are defined by the enumeration TSgDrawableOpenModes.
87 @pre The Graphics Resource driver is initialised for use in the context of the
89 @pre This RSgDrawable handle is null.
90 @pre aId identifies an existing drawable resource.
91 @pre All of the requested opening options in aMode are supported.
92 @post This RSgDrawable handle references the drawable resource specified by
93 its unique identifier. The reference count for the drawable resource is
95 @return KErrNone if successful.
96 @return KErrInUse if this RSgDrawable handle was not null.
97 @return KErrArgument if aId is the null drawable resource identifier.
98 @return KErrNotFound if aId cannot be found to refer to an existing drawable resource.
99 @return KErrPermissionDenied if this process is not permitted to access the drawable
100 resource specified by aId.
101 @return KErrNotSupported if any of the requested opening options in aMode is not
103 @return KErrNoMemory if there is not enough system memory.
104 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
105 for use in the context of the calling process.
106 @see TSgDrawableOpenModes
108 EXPORT_C TInt RSgDrawable::Open(const TSgDrawableId& aId, TUint32 aMode)
112 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
114 TInt err = gPls.iDriver->OpenDrawable(aId, aMode, iHandleType, iImpl);
116 gPls.iMutex.Signal();
127 Closes a handle to a drawable resource. If there are no remaining handles to the
128 drawable resource, then it can be destroyed by the Graphics Resource driver.
129 Calling Close() on a null handle is allowed but has no effect.
131 @pre If this RSgDrawable handle is not null then the Graphics Resource driver is
132 initialised for use in the context of the calling process.
133 @pre This RSgDrawable handle is valid.
134 @post This RSgDrawable handle is null. The reference count for the previously
135 referenced drawable resource, if any, is decremented by one.
136 @panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
137 @panic SGRES 5 in debug builds if this RSgDrawable handle is not null and the Graphics
138 Resource driver is not initialised for use in the context of the calling process.
140 EXPORT_C void RSgDrawable::Close()
146 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
147 __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
152 gPls.iMutex.Signal();
163 Retrieves the unique identifier of a drawable resource. The unique identifier can be
164 used to share the drawable resource with another process.
166 @pre The Graphics Resource driver is initialised for use in the context of the
168 @pre This RSgDrawable handle is valid.
170 @return The unique identifier of the drawable resource or the null drawable resource
171 identifier if this RSgDrawable handle is null.
172 @panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
173 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
174 for use in the context of the calling process.
176 EXPORT_C const TSgDrawableId& RSgDrawable::Id() const
180 return KSgNullDrawableId;
184 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
185 __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
187 const TSgDrawableId& id = iImpl->Id();
189 gPls.iMutex.Signal();
200 Tests whether this RSgDrawable handle is null.
204 @return ETrue, if this RSgDrawable handle is null, EFalse otherwise.
206 EXPORT_C TBool RSgDrawable::IsNull() const
208 return iImpl == NULL;
217 Retrieves the run-time type of a drawable resource as a globally unique identifier.
219 @pre The Graphics Resource driver is initialised for use in the context of the
221 @pre This RSgDrawable handle is valid.
223 @return The run-time type of the drawable resource as a globally unique identifier
224 or the null globally unique identifier if this RSgDrawable handle is null.
225 @panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
226 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
227 for use in the context of the calling process.
228 @see RSgDrawable::HandleType()
230 EXPORT_C TUid RSgDrawable::DrawableType() const
238 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
239 __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
241 TUid type = iImpl->DrawableType();
243 gPls.iMutex.Signal();
252 Makes an extension interface available on a drawable resource. The extension interface
253 is specified by globally unique identifier.
255 @param aInterfaceUid Globally unique identifier of the interface to be made available.
256 @param aInterfacePtr On return, a pointer to the specified interface.
257 @pre The Graphics Resource driver is initialised for use in the context of the
259 @pre This RSgDrawable handle is valid and not null.
260 @pre The specified interface is supported on the drawable resource.
261 @post The specified interface is available until this RSgDrawable handle is closed.
262 @return KErrNone if successful.
263 @return KErrBadHandle if this RSgDrawable handle is null.
264 @return KErrExtensionNotSupported if the specified interface is not supported on
265 the drawable resource.
266 @return KErrNoMemory if there is not enough system memory.
267 @panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
268 @panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
269 for use in the context of the calling process.
270 @see RSgDrawable::GetInterface<M>(M*&)
271 @see RSgDrawable::GetInterface<M>(const M*&) const
273 EXPORT_C TInt RSgDrawable::GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr) const
277 return KErrBadHandle;
281 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
282 __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
284 TInt err = iImpl->GetInterface(aInterfaceUid, aInterfacePtr);
286 gPls.iMutex.Signal();