sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "sgdriver.h"
|
sl@0
|
17 |
#include "sgresourceadapter.h"
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@publishedPartner
|
sl@0
|
22 |
@prototype
|
sl@0
|
23 |
@deprecated
|
sl@0
|
24 |
|
sl@0
|
25 |
Default constructor.
|
sl@0
|
26 |
|
sl@0
|
27 |
@pre None.
|
sl@0
|
28 |
@post This RSgDrawable handle is null.
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
EXPORT_C RSgDrawable::RSgDrawable()
|
sl@0
|
31 |
: iImpl(NULL)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
iHandleType = KSgDrawableTypeUid;
|
sl@0
|
34 |
}
|
sl@0
|
35 |
|
sl@0
|
36 |
|
sl@0
|
37 |
/**
|
sl@0
|
38 |
@publishedPartner
|
sl@0
|
39 |
@prototype
|
sl@0
|
40 |
@deprecated
|
sl@0
|
41 |
|
sl@0
|
42 |
Opens a new handle to a drawable resource.
|
sl@0
|
43 |
|
sl@0
|
44 |
@param aId The unique identifier of the drawable resource.
|
sl@0
|
45 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
46 |
calling process.
|
sl@0
|
47 |
@pre This RSgDrawable handle is null.
|
sl@0
|
48 |
@pre aId identifies an existing drawable resource.
|
sl@0
|
49 |
@post This RSgDrawable handle references the drawable resource specified by
|
sl@0
|
50 |
its unique identifier. The reference count for the drawable resource is
|
sl@0
|
51 |
incremented by one.
|
sl@0
|
52 |
@return KErrNone if successful.
|
sl@0
|
53 |
@return KErrInUse if this RSgDrawable handle was not null.
|
sl@0
|
54 |
@return KErrArgument if aId is the null drawable resource identifier.
|
sl@0
|
55 |
@return KErrNotFound if aId cannot be found to refer to an existing drawable resource.
|
sl@0
|
56 |
@return KErrPermissionDenied if this process is not permitted to access the drawable
|
sl@0
|
57 |
resource specified by aId.
|
sl@0
|
58 |
@return KErrNoMemory if there is not enough system memory.
|
sl@0
|
59 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
60 |
for use in the context of the calling process.
|
sl@0
|
61 |
*/
|
sl@0
|
62 |
EXPORT_C TInt RSgDrawable::Open(const TSgDrawableId& aId)
|
sl@0
|
63 |
{
|
sl@0
|
64 |
#ifdef _DEBUG
|
sl@0
|
65 |
gPls.iMutex.Wait();
|
sl@0
|
66 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
67 |
#endif
|
sl@0
|
68 |
TInt err = gPls.iDriver->OpenDrawable(aId, KSgDefaultOpenMode, iHandleType, iImpl);
|
sl@0
|
69 |
#ifdef _DEBUG
|
sl@0
|
70 |
gPls.iMutex.Signal();
|
sl@0
|
71 |
#endif
|
sl@0
|
72 |
return err;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
|
sl@0
|
76 |
/**
|
sl@0
|
77 |
@internalTechnology
|
sl@0
|
78 |
@prototype
|
sl@0
|
79 |
|
sl@0
|
80 |
Opens a new handle to a drawable resource. This overload of Open() is intended for
|
sl@0
|
81 |
the adaptation layer of renderers to be able to request special options when opening
|
sl@0
|
82 |
a drawable resource.
|
sl@0
|
83 |
|
sl@0
|
84 |
@param aId The unique identifier of the drawable resource.
|
sl@0
|
85 |
@param aMode Flags controlling how the drawable resource is opened. The bits of this
|
sl@0
|
86 |
argument are defined by the enumeration TSgDrawableOpenModes.
|
sl@0
|
87 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
88 |
calling process.
|
sl@0
|
89 |
@pre This RSgDrawable handle is null.
|
sl@0
|
90 |
@pre aId identifies an existing drawable resource.
|
sl@0
|
91 |
@pre All of the requested opening options in aMode are supported.
|
sl@0
|
92 |
@post This RSgDrawable handle references the drawable resource specified by
|
sl@0
|
93 |
its unique identifier. The reference count for the drawable resource is
|
sl@0
|
94 |
incremented by one.
|
sl@0
|
95 |
@return KErrNone if successful.
|
sl@0
|
96 |
@return KErrInUse if this RSgDrawable handle was not null.
|
sl@0
|
97 |
@return KErrArgument if aId is the null drawable resource identifier.
|
sl@0
|
98 |
@return KErrNotFound if aId cannot be found to refer to an existing drawable resource.
|
sl@0
|
99 |
@return KErrPermissionDenied if this process is not permitted to access the drawable
|
sl@0
|
100 |
resource specified by aId.
|
sl@0
|
101 |
@return KErrNotSupported if any of the requested opening options in aMode is not
|
sl@0
|
102 |
supported.
|
sl@0
|
103 |
@return KErrNoMemory if there is not enough system memory.
|
sl@0
|
104 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
105 |
for use in the context of the calling process.
|
sl@0
|
106 |
@see TSgDrawableOpenModes
|
sl@0
|
107 |
*/
|
sl@0
|
108 |
EXPORT_C TInt RSgDrawable::Open(const TSgDrawableId& aId, TUint32 aMode)
|
sl@0
|
109 |
{
|
sl@0
|
110 |
#ifdef _DEBUG
|
sl@0
|
111 |
gPls.iMutex.Wait();
|
sl@0
|
112 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
113 |
#endif
|
sl@0
|
114 |
TInt err = gPls.iDriver->OpenDrawable(aId, aMode, iHandleType, iImpl);
|
sl@0
|
115 |
#ifdef _DEBUG
|
sl@0
|
116 |
gPls.iMutex.Signal();
|
sl@0
|
117 |
#endif
|
sl@0
|
118 |
return err;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
|
sl@0
|
122 |
/**
|
sl@0
|
123 |
@publishedPartner
|
sl@0
|
124 |
@prototype
|
sl@0
|
125 |
@deprecated
|
sl@0
|
126 |
|
sl@0
|
127 |
Closes a handle to a drawable resource. If there are no remaining handles to the
|
sl@0
|
128 |
drawable resource, then it can be destroyed by the Graphics Resource driver.
|
sl@0
|
129 |
Calling Close() on a null handle is allowed but has no effect.
|
sl@0
|
130 |
|
sl@0
|
131 |
@pre If this RSgDrawable handle is not null then the Graphics Resource driver is
|
sl@0
|
132 |
initialised for use in the context of the calling process.
|
sl@0
|
133 |
@pre This RSgDrawable handle is valid.
|
sl@0
|
134 |
@post This RSgDrawable handle is null. The reference count for the previously
|
sl@0
|
135 |
referenced drawable resource, if any, is decremented by one.
|
sl@0
|
136 |
@panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
|
sl@0
|
137 |
@panic SGRES 5 in debug builds if this RSgDrawable handle is not null and the Graphics
|
sl@0
|
138 |
Resource driver is not initialised for use in the context of the calling process.
|
sl@0
|
139 |
*/
|
sl@0
|
140 |
EXPORT_C void RSgDrawable::Close()
|
sl@0
|
141 |
{
|
sl@0
|
142 |
if (iImpl)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
#ifdef _DEBUG
|
sl@0
|
145 |
gPls.iMutex.Wait();
|
sl@0
|
146 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
147 |
__ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
|
sl@0
|
148 |
#endif
|
sl@0
|
149 |
iImpl->Close();
|
sl@0
|
150 |
iImpl = NULL;
|
sl@0
|
151 |
#ifdef _DEBUG
|
sl@0
|
152 |
gPls.iMutex.Signal();
|
sl@0
|
153 |
#endif
|
sl@0
|
154 |
}
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
|
sl@0
|
158 |
/**
|
sl@0
|
159 |
@publishedPartner
|
sl@0
|
160 |
@prototype
|
sl@0
|
161 |
@deprecated
|
sl@0
|
162 |
|
sl@0
|
163 |
Retrieves the unique identifier of a drawable resource. The unique identifier can be
|
sl@0
|
164 |
used to share the drawable resource with another process.
|
sl@0
|
165 |
|
sl@0
|
166 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
167 |
calling process.
|
sl@0
|
168 |
@pre This RSgDrawable handle is valid.
|
sl@0
|
169 |
@post None.
|
sl@0
|
170 |
@return The unique identifier of the drawable resource or the null drawable resource
|
sl@0
|
171 |
identifier if this RSgDrawable handle is null.
|
sl@0
|
172 |
@panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
|
sl@0
|
173 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
174 |
for use in the context of the calling process.
|
sl@0
|
175 |
*/
|
sl@0
|
176 |
EXPORT_C const TSgDrawableId& RSgDrawable::Id() const
|
sl@0
|
177 |
{
|
sl@0
|
178 |
if (!iImpl)
|
sl@0
|
179 |
{
|
sl@0
|
180 |
return KSgNullDrawableId;
|
sl@0
|
181 |
}
|
sl@0
|
182 |
#ifdef _DEBUG
|
sl@0
|
183 |
gPls.iMutex.Wait();
|
sl@0
|
184 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
185 |
__ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
|
sl@0
|
186 |
#endif
|
sl@0
|
187 |
const TSgDrawableId& id = iImpl->Id();
|
sl@0
|
188 |
#ifdef _DEBUG
|
sl@0
|
189 |
gPls.iMutex.Signal();
|
sl@0
|
190 |
#endif
|
sl@0
|
191 |
return id;
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
|
sl@0
|
195 |
/**
|
sl@0
|
196 |
@publishedPartner
|
sl@0
|
197 |
@prototype
|
sl@0
|
198 |
@deprecated
|
sl@0
|
199 |
|
sl@0
|
200 |
Tests whether this RSgDrawable handle is null.
|
sl@0
|
201 |
|
sl@0
|
202 |
@pre None.
|
sl@0
|
203 |
@post None.
|
sl@0
|
204 |
@return ETrue, if this RSgDrawable handle is null, EFalse otherwise.
|
sl@0
|
205 |
*/
|
sl@0
|
206 |
EXPORT_C TBool RSgDrawable::IsNull() const
|
sl@0
|
207 |
{
|
sl@0
|
208 |
return iImpl == NULL;
|
sl@0
|
209 |
}
|
sl@0
|
210 |
|
sl@0
|
211 |
|
sl@0
|
212 |
/**
|
sl@0
|
213 |
@publishedPartner
|
sl@0
|
214 |
@prototype
|
sl@0
|
215 |
@deprecated
|
sl@0
|
216 |
|
sl@0
|
217 |
Retrieves the run-time type of a drawable resource as a globally unique identifier.
|
sl@0
|
218 |
|
sl@0
|
219 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
220 |
calling process.
|
sl@0
|
221 |
@pre This RSgDrawable handle is valid.
|
sl@0
|
222 |
@post None.
|
sl@0
|
223 |
@return The run-time type of the drawable resource as a globally unique identifier
|
sl@0
|
224 |
or the null globally unique identifier if this RSgDrawable handle is null.
|
sl@0
|
225 |
@panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
|
sl@0
|
226 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
227 |
for use in the context of the calling process.
|
sl@0
|
228 |
@see RSgDrawable::HandleType()
|
sl@0
|
229 |
*/
|
sl@0
|
230 |
EXPORT_C TUid RSgDrawable::DrawableType() const
|
sl@0
|
231 |
{
|
sl@0
|
232 |
if (!iImpl)
|
sl@0
|
233 |
{
|
sl@0
|
234 |
return KNullUid;
|
sl@0
|
235 |
}
|
sl@0
|
236 |
#ifdef _DEBUG
|
sl@0
|
237 |
gPls.iMutex.Wait();
|
sl@0
|
238 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
239 |
__ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
|
sl@0
|
240 |
#endif
|
sl@0
|
241 |
TUid type = iImpl->DrawableType();
|
sl@0
|
242 |
#ifdef _DEBUG
|
sl@0
|
243 |
gPls.iMutex.Signal();
|
sl@0
|
244 |
#endif
|
sl@0
|
245 |
return type;
|
sl@0
|
246 |
}
|
sl@0
|
247 |
|
sl@0
|
248 |
|
sl@0
|
249 |
/**
|
sl@0
|
250 |
@internalComponent
|
sl@0
|
251 |
|
sl@0
|
252 |
Makes an extension interface available on a drawable resource. The extension interface
|
sl@0
|
253 |
is specified by globally unique identifier.
|
sl@0
|
254 |
|
sl@0
|
255 |
@param aInterfaceUid Globally unique identifier of the interface to be made available.
|
sl@0
|
256 |
@param aInterfacePtr On return, a pointer to the specified interface.
|
sl@0
|
257 |
@pre The Graphics Resource driver is initialised for use in the context of the
|
sl@0
|
258 |
calling process.
|
sl@0
|
259 |
@pre This RSgDrawable handle is valid and not null.
|
sl@0
|
260 |
@pre The specified interface is supported on the drawable resource.
|
sl@0
|
261 |
@post The specified interface is available until this RSgDrawable handle is closed.
|
sl@0
|
262 |
@return KErrNone if successful.
|
sl@0
|
263 |
@return KErrBadHandle if this RSgDrawable handle is null.
|
sl@0
|
264 |
@return KErrExtensionNotSupported if the specified interface is not supported on
|
sl@0
|
265 |
the drawable resource.
|
sl@0
|
266 |
@return KErrNoMemory if there is not enough system memory.
|
sl@0
|
267 |
@panic SGRES 2 in debug builds if this RSgDrawable handle is invalid.
|
sl@0
|
268 |
@panic SGRES 5 in debug builds if the Graphics Resource driver is not initialised
|
sl@0
|
269 |
for use in the context of the calling process.
|
sl@0
|
270 |
@see RSgDrawable::GetInterface<M>(M*&)
|
sl@0
|
271 |
@see RSgDrawable::GetInterface<M>(const M*&) const
|
sl@0
|
272 |
*/
|
sl@0
|
273 |
EXPORT_C TInt RSgDrawable::GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr) const
|
sl@0
|
274 |
{
|
sl@0
|
275 |
if (!iImpl)
|
sl@0
|
276 |
{
|
sl@0
|
277 |
return KErrBadHandle;
|
sl@0
|
278 |
}
|
sl@0
|
279 |
#ifdef _DEBUG
|
sl@0
|
280 |
gPls.iMutex.Wait();
|
sl@0
|
281 |
__ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver));
|
sl@0
|
282 |
__ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle));
|
sl@0
|
283 |
#endif
|
sl@0
|
284 |
TInt err = iImpl->GetInterface(aInterfaceUid, aInterfacePtr);
|
sl@0
|
285 |
#ifdef _DEBUG
|
sl@0
|
286 |
gPls.iMutex.Signal();
|
sl@0
|
287 |
#endif
|
sl@0
|
288 |
return err;
|
sl@0
|
289 |
}
|