|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CAlfDrawer implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <alf/alfdrawer.h> |
|
22 #include "alfcrppluginclient.h" |
|
23 |
|
24 #include <coemain.h> |
|
25 #include <w32std.h> |
|
26 |
|
27 // Class to hold internal alf drawer data. |
|
28 NONSHARABLE_CLASS( CAlfDrawer::TAlfDrawerData ) |
|
29 { |
|
30 public: |
|
31 TAlfDrawerData(); |
|
32 |
|
33 public: |
|
34 CAlfCrpPluginClient* iClient; |
|
35 }; |
|
36 |
|
37 // Creates CAlfCrpPluginClient instance, returns error code. |
|
38 static TInt CreateAlfCrpClient(CAlfCrpPluginClient*& aClient); |
|
39 // Creates CAlfCrpPluginClient instance. |
|
40 static CAlfCrpPluginClient* CreateAlfCrpClientL(); |
|
41 |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // NewL |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 EXPORT_C CAlfDrawer* CAlfDrawer::NewL() |
|
48 { |
|
49 CAlfDrawer* self = new (ELeave) CAlfDrawer; |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop( self ); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // Destructor |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 EXPORT_C CAlfDrawer::~CAlfDrawer() |
|
61 { |
|
62 if ( iData ) |
|
63 { |
|
64 delete iData->iClient; |
|
65 delete iData; |
|
66 } |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // Finish |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 EXPORT_C TInt CAlfDrawer::Finish() |
|
74 { |
|
75 // First perform RWsSession finish operation to ensure |
|
76 // that all drawing commands have been issued to renderstage. |
|
77 TInt err = CCoeEnv::Static()->WsSession().Finish(); |
|
78 |
|
79 // Then create CRP instance (if needed). |
|
80 if ( err == KErrNone && !iData->iClient ) |
|
81 { |
|
82 err = CreateAlfCrpClient( iData->iClient ); |
|
83 } |
|
84 |
|
85 // Finally, wait until alf side has finished rendering. |
|
86 if ( err == KErrNone && iData->iClient ) |
|
87 { |
|
88 iData->iClient->Synchronize(); |
|
89 } |
|
90 |
|
91 return err; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // Constructor |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 CAlfDrawer::CAlfDrawer() |
|
99 { |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // ConstructL |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CAlfDrawer::ConstructL() |
|
107 { |
|
108 iData = new (ELeave) TAlfDrawerData; |
|
109 CreateAlfCrpClient( iData->iClient ); |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // Constructor |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 CAlfDrawer::TAlfDrawerData::TAlfDrawerData() |
|
117 : iClient( NULL ) |
|
118 { |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CreateAlfCrpClient |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 static TInt CreateAlfCrpClient(CAlfCrpPluginClient*& aClient) |
|
126 { |
|
127 TRAPD(err, aClient = CreateAlfCrpClientL()); |
|
128 return err; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CreateAlfCrpClientL |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 static CAlfCrpPluginClient* CreateAlfCrpClientL() |
|
136 { |
|
137 CAlfCrpPluginClient* client = new (ELeave) CAlfCrpPluginClient; |
|
138 CleanupStack::PushL( client ); |
|
139 client->ConstructL(); |
|
140 CleanupStack::Pop( client ); |
|
141 return client; |
|
142 } |
|
143 |