|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "sgdriver.h" |
|
17 #include "sgresourceadapter.h" |
|
18 |
|
19 |
|
20 /** |
|
21 @publishedPartner |
|
22 @prototype |
|
23 @deprecated |
|
24 |
|
25 Default constructor. |
|
26 |
|
27 @pre None. |
|
28 @post This RSgDrawable handle is null. |
|
29 */ |
|
30 EXPORT_C RSgDrawable::RSgDrawable() |
|
31 : iImpl(NULL) |
|
32 { |
|
33 iHandleType = KSgDrawableTypeUid; |
|
34 } |
|
35 |
|
36 |
|
37 /** |
|
38 @publishedPartner |
|
39 @prototype |
|
40 @deprecated |
|
41 |
|
42 Opens a new handle to a drawable resource. |
|
43 |
|
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 |
|
46 calling process. |
|
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 |
|
51 incremented by one. |
|
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. |
|
61 */ |
|
62 EXPORT_C TInt RSgDrawable::Open(const TSgDrawableId& aId) |
|
63 { |
|
64 #ifdef _DEBUG |
|
65 gPls.iMutex.Wait(); |
|
66 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
67 #endif |
|
68 TInt err = gPls.iDriver->OpenDrawable(aId, KSgDefaultOpenMode, iHandleType, iImpl); |
|
69 #ifdef _DEBUG |
|
70 gPls.iMutex.Signal(); |
|
71 #endif |
|
72 return err; |
|
73 } |
|
74 |
|
75 |
|
76 /** |
|
77 @internalTechnology |
|
78 @prototype |
|
79 |
|
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 |
|
82 a drawable resource. |
|
83 |
|
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 |
|
88 calling process. |
|
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 |
|
94 incremented by one. |
|
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 |
|
102 supported. |
|
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 |
|
107 */ |
|
108 EXPORT_C TInt RSgDrawable::Open(const TSgDrawableId& aId, TUint32 aMode) |
|
109 { |
|
110 #ifdef _DEBUG |
|
111 gPls.iMutex.Wait(); |
|
112 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
113 #endif |
|
114 TInt err = gPls.iDriver->OpenDrawable(aId, aMode, iHandleType, iImpl); |
|
115 #ifdef _DEBUG |
|
116 gPls.iMutex.Signal(); |
|
117 #endif |
|
118 return err; |
|
119 } |
|
120 |
|
121 |
|
122 /** |
|
123 @publishedPartner |
|
124 @prototype |
|
125 @deprecated |
|
126 |
|
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. |
|
130 |
|
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. |
|
139 */ |
|
140 EXPORT_C void RSgDrawable::Close() |
|
141 { |
|
142 if (iImpl) |
|
143 { |
|
144 #ifdef _DEBUG |
|
145 gPls.iMutex.Wait(); |
|
146 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
147 __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle)); |
|
148 #endif |
|
149 iImpl->Close(); |
|
150 iImpl = NULL; |
|
151 #ifdef _DEBUG |
|
152 gPls.iMutex.Signal(); |
|
153 #endif |
|
154 } |
|
155 } |
|
156 |
|
157 |
|
158 /** |
|
159 @publishedPartner |
|
160 @prototype |
|
161 @deprecated |
|
162 |
|
163 Retrieves the unique identifier of a drawable resource. The unique identifier can be |
|
164 used to share the drawable resource with another process. |
|
165 |
|
166 @pre The Graphics Resource driver is initialised for use in the context of the |
|
167 calling process. |
|
168 @pre This RSgDrawable handle is valid. |
|
169 @post None. |
|
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. |
|
175 */ |
|
176 EXPORT_C const TSgDrawableId& RSgDrawable::Id() const |
|
177 { |
|
178 if (!iImpl) |
|
179 { |
|
180 return KSgNullDrawableId; |
|
181 } |
|
182 #ifdef _DEBUG |
|
183 gPls.iMutex.Wait(); |
|
184 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
185 __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle)); |
|
186 #endif |
|
187 const TSgDrawableId& id = iImpl->Id(); |
|
188 #ifdef _DEBUG |
|
189 gPls.iMutex.Signal(); |
|
190 #endif |
|
191 return id; |
|
192 } |
|
193 |
|
194 |
|
195 /** |
|
196 @publishedPartner |
|
197 @prototype |
|
198 @deprecated |
|
199 |
|
200 Tests whether this RSgDrawable handle is null. |
|
201 |
|
202 @pre None. |
|
203 @post None. |
|
204 @return ETrue, if this RSgDrawable handle is null, EFalse otherwise. |
|
205 */ |
|
206 EXPORT_C TBool RSgDrawable::IsNull() const |
|
207 { |
|
208 return iImpl == NULL; |
|
209 } |
|
210 |
|
211 |
|
212 /** |
|
213 @publishedPartner |
|
214 @prototype |
|
215 @deprecated |
|
216 |
|
217 Retrieves the run-time type of a drawable resource as a globally unique identifier. |
|
218 |
|
219 @pre The Graphics Resource driver is initialised for use in the context of the |
|
220 calling process. |
|
221 @pre This RSgDrawable handle is valid. |
|
222 @post None. |
|
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() |
|
229 */ |
|
230 EXPORT_C TUid RSgDrawable::DrawableType() const |
|
231 { |
|
232 if (!iImpl) |
|
233 { |
|
234 return KNullUid; |
|
235 } |
|
236 #ifdef _DEBUG |
|
237 gPls.iMutex.Wait(); |
|
238 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
239 __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle)); |
|
240 #endif |
|
241 TUid type = iImpl->DrawableType(); |
|
242 #ifdef _DEBUG |
|
243 gPls.iMutex.Signal(); |
|
244 #endif |
|
245 return type; |
|
246 } |
|
247 |
|
248 |
|
249 /** |
|
250 @internalComponent |
|
251 |
|
252 Makes an extension interface available on a drawable resource. The extension interface |
|
253 is specified by globally unique identifier. |
|
254 |
|
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 |
|
258 calling process. |
|
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 |
|
272 */ |
|
273 EXPORT_C TInt RSgDrawable::GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr) const |
|
274 { |
|
275 if (!iImpl) |
|
276 { |
|
277 return KErrBadHandle; |
|
278 } |
|
279 #ifdef _DEBUG |
|
280 gPls.iMutex.Wait(); |
|
281 __ASSERT_DEBUG(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
282 __ASSERT_DEBUG(gPls.iDriver->CheckDrawable(*iImpl), Panic(ESgPanicBadDrawableHandle)); |
|
283 #endif |
|
284 TInt err = iImpl->GetInterface(aInterfaceUid, aInterfacePtr); |
|
285 #ifdef _DEBUG |
|
286 gPls.iMutex.Signal(); |
|
287 #endif |
|
288 return err; |
|
289 } |