|
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 "directgdidriver.h" |
|
17 #include <graphics/directgdiimagetarget.h> |
|
18 #include "directgdipaniccodes.h" |
|
19 |
|
20 /** |
|
21 Default constructor. |
|
22 Only for embedding instances of RDirectGdiImageTarget into other classes as data members. |
|
23 Before a RDirectGdiImageTarget can be used the other constructor must be called. |
|
24 */ |
|
25 EXPORT_C RDirectGdiImageTarget::RDirectGdiImageTarget() |
|
26 : iDriver(NULL), iHandle(KNullHandle) |
|
27 { |
|
28 } |
|
29 |
|
30 /** |
|
31 Constructor. |
|
32 |
|
33 @param aDriver The CDirectGdiDriver for this thread. |
|
34 |
|
35 @pre CDirectGdiDriver object has been initialised from the calling thread. |
|
36 @post This handle class has a pointer to the CDirectGdiDriver object for this |
|
37 thread, and is not associated with any DirectGDI adaptation specific resource. |
|
38 */ |
|
39 EXPORT_C RDirectGdiImageTarget::RDirectGdiImageTarget(CDirectGdiDriver& aDriver) |
|
40 : iDriver(&aDriver), iHandle(KNullHandle) |
|
41 { |
|
42 } |
|
43 |
|
44 /** |
|
45 Creates a DirectGDI adaptation-specific resource from the given image resource |
|
46 so it can be used as a target of DirectGDI rendering. |
|
47 |
|
48 @param aImage The image resource. |
|
49 |
|
50 @pre The CDirectGdiDriver object has been set. The image resource has been |
|
51 fully constructed and created with the correct usage that allows it to |
|
52 be used as a DirectGDI target. |
|
53 @post The DirectGDI adaptation-specific resource that is bound to the given |
|
54 image resource is created and this handle is now associated with it. |
|
55 The reference counter on the image resource is incremented. |
|
56 |
|
57 @return KErrNone if successful, KErrArgument if the image resource is not valid, |
|
58 KErrAlreadyExists if this handle is already associated with a DirectGDI |
|
59 specific resource, KErrNotSupported if the image resource is not created |
|
60 with the correct usage, otherwise one of the system-wide error codes. |
|
61 */ |
|
62 EXPORT_C TInt RDirectGdiImageTarget::Create(const RSgImage& aImage) |
|
63 { |
|
64 GRAPHICS_ASSERT_ALWAYS(iDriver, EDirectGdiPanicImageTargetWithoutDriver); |
|
65 return iDriver->CreateImageTarget(*this, aImage); |
|
66 } |
|
67 |
|
68 /** |
|
69 Destroys the DirectGDI adaptation-specific resource associated with this handle. |
|
70 Calling this method on a handle that is not associated with any DirectGDI |
|
71 adaptation-specific resource will do nothing. Once Close() is called, this handle can be reused. |
|
72 |
|
73 @pre The CDirectGdiDriver object for this handle has been set. |
|
74 @post The DirectGDI specific resource associated with this handle will be destroyed |
|
75 (at any time preferred by the adaptation). This handle is no longer associated |
|
76 with a DirectGDI specific resource. The reference counter of the underlying |
|
77 image resource is decremented. |
|
78 */ |
|
79 EXPORT_C void RDirectGdiImageTarget::Close() |
|
80 { |
|
81 if (iHandle != KNullHandle) |
|
82 { |
|
83 GRAPHICS_ASSERT_ALWAYS(iDriver, EDirectGdiPanicImageTargetWithoutDriver); |
|
84 iDriver->CloseImageTarget(*this); |
|
85 } |
|
86 } |