|
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 // Graphics Resource - drawable implementation |
|
15 // |
|
16 |
|
17 #include "sgdriver.h" |
|
18 |
|
19 EXPORT_C TInt RSgDrawable::Open(TSgDrawableId aId, const TSgAttributeArrayBase* aAttributes) |
|
20 { |
|
21 if (iImpl) |
|
22 { |
|
23 return KErrInUse; |
|
24 } |
|
25 __ASSERT_ALWAYS(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
26 return gPls.iDriver->FindAndOpenImage(aId, aAttributes, iImpl); |
|
27 } |
|
28 |
|
29 EXPORT_C void RSgDrawable::Close() |
|
30 { |
|
31 if (iImpl) |
|
32 { |
|
33 __ASSERT_ALWAYS(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
34 __ASSERT_ALWAYS(gPls.iDriver->CheckImage(iImpl), Panic(ESgPanicBadDrawableHandle)); |
|
35 static_cast<XSgImage*>(iImpl)->Close(); |
|
36 iImpl = NULL; |
|
37 } |
|
38 } |
|
39 |
|
40 EXPORT_C TSgDrawableId RSgDrawable::Id() const |
|
41 { |
|
42 if (!iImpl) |
|
43 { |
|
44 return KSgNullDrawableId; |
|
45 } |
|
46 __ASSERT_ALWAYS(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
47 __ASSERT_ALWAYS(gPls.iDriver->CheckImage(iImpl), Panic(ESgPanicBadDrawableHandle)); |
|
48 return static_cast<XSgImage*>(iImpl)->Id(); |
|
49 } |
|
50 |
|
51 EXPORT_C TUid RSgDrawable::DrawableType() const |
|
52 { |
|
53 if (!iImpl) |
|
54 { |
|
55 return KNullUid; |
|
56 } |
|
57 __ASSERT_ALWAYS(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
58 __ASSERT_ALWAYS(gPls.iDriver->CheckImage(iImpl), Panic(ESgPanicBadDrawableHandle)); |
|
59 return static_cast<XSgImage*>(iImpl)->DrawableType(); |
|
60 } |
|
61 |
|
62 EXPORT_C TInt RSgDrawable::GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr) const |
|
63 { |
|
64 aInterfacePtr = NULL; |
|
65 if (!iImpl) |
|
66 { |
|
67 return KErrBadHandle; |
|
68 } |
|
69 __ASSERT_ALWAYS(gPls.iDriver, Panic(ESgPanicNoDriver)); |
|
70 __ASSERT_ALWAYS(gPls.iDriver->CheckImage(iImpl), Panic(ESgPanicBadDrawableHandle)); |
|
71 return static_cast<XSgImage*>(iImpl)->GetInterface(aInterfaceUid, aInterfacePtr); |
|
72 } |