|
1 /* |
|
2 * Copyright (c) 2007 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: Implementation of CSAnimSvgPlugin class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <SVGEngineInterfaceImpl.h> |
|
20 |
|
21 #include "sanimsvgplugin.h" |
|
22 #include "assert.h" |
|
23 #include "trace.h" |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CSAnimSvgPlugin::NewL |
|
29 // |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CSAnimSvgPlugin* CSAnimSvgPlugin::NewL( TAny* aConstructionParameters ) |
|
33 { |
|
34 FUNC_LOG; |
|
35 |
|
36 CSAnimSvgPlugin* self = |
|
37 new( ELeave ) CSAnimSvgPlugin( aConstructionParameters ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CSAnimSvgPlugin::~CSAnimSvgPlugin |
|
47 // |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CSAnimSvgPlugin::~CSAnimSvgPlugin() |
|
51 { |
|
52 FUNC_LOG; |
|
53 |
|
54 delete iImage; |
|
55 delete iMask; |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CSAnimSvgPlugin::Load |
|
61 // |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 void CSAnimSvgPlugin::Load( |
|
65 RFs& /*aFs*/, |
|
66 const TDesC& aFileName, |
|
67 TRequestStatus& aStatus ) |
|
68 { |
|
69 FUNC_LOG; |
|
70 INFO_1( "File name: %S", &aFileName ); |
|
71 |
|
72 delete iEngine; |
|
73 iEngine = NULL; |
|
74 delete iMask; |
|
75 iMask = NULL; |
|
76 delete iImage; |
|
77 iImage = NULL; |
|
78 |
|
79 TRAPD( errorCode, LoadL( aFileName ) ); |
|
80 ERROR( errorCode, "Failed to load image file" ); |
|
81 SetClientRequest( aStatus ); |
|
82 CompleteClientRequest( errorCode ); |
|
83 } |
|
84 |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CSAnimSvgPlugin::Start |
|
88 // |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CSAnimSvgPlugin::Start( TRequestStatus& aStatus ) |
|
92 { |
|
93 FUNC_LOG; |
|
94 ASSERT_TRACE( iEngine, SAnimPanic::ENotInitialized ); |
|
95 |
|
96 SetClientRequest( aStatus ); |
|
97 |
|
98 TBool isAnimation = iEngine->SvgHasAnimation( iEngine->SvgDocument() ); |
|
99 if ( isAnimation ) |
|
100 { |
|
101 INFO( "SVG animation" ); |
|
102 |
|
103 iEngine->AddAnimationListener( this ); |
|
104 } |
|
105 |
|
106 MSvgError* error = NULL; |
|
107 iEngine->Start( error ); |
|
108 TInt errorCode = SvgToSymbianErr( error ); |
|
109 if ( errorCode != KErrNone ) |
|
110 { |
|
111 CompleteClientRequest( errorCode ); |
|
112 } |
|
113 else if ( !isAnimation ) |
|
114 { |
|
115 CompleteClientRequest( KErrNone ); |
|
116 } |
|
117 } |
|
118 |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CSAnimSvgPlugin::Cancel |
|
122 // |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 void CSAnimSvgPlugin::Cancel() |
|
126 { |
|
127 FUNC_LOG; |
|
128 |
|
129 CompleteClientRequest( KErrCancel ); |
|
130 if ( iEngine ) |
|
131 { |
|
132 iEngine->Stop(); |
|
133 } |
|
134 } |
|
135 |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // CSAnimSvgPlugin::BackroundColour |
|
139 // |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 TRgb CSAnimSvgPlugin::BackroundColour() const |
|
143 { |
|
144 FUNC_LOG; |
|
145 |
|
146 return KRgbWhite; |
|
147 } |
|
148 |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CSAnimSvgPlugin::UpdateScreen |
|
152 // |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CSAnimSvgPlugin::UpdateScreen() |
|
156 { |
|
157 FUNC_LOG; |
|
158 |
|
159 if ( iImage && iMask ) |
|
160 { |
|
161 iEngine->GenerateMask( iMask ); |
|
162 iObserver.UpdateScreen( *iImage, *iMask ); |
|
163 } |
|
164 } |
|
165 |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CSAnimSvgPlugin::AnimationStarted |
|
169 // |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 TBool CSAnimSvgPlugin::AnimationStarted( TBool /*isAnimationIndefinite*/ ) |
|
173 { |
|
174 FUNC_LOG; |
|
175 return EFalse; |
|
176 } |
|
177 |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // CSAnimSvgPlugin::AnimationPaused |
|
181 // |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 TBool CSAnimSvgPlugin::AnimationPaused() |
|
185 { |
|
186 FUNC_LOG; |
|
187 return EFalse; |
|
188 } |
|
189 |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // CSAnimSvgPlugin::AnimationEnded |
|
193 // |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 TBool CSAnimSvgPlugin::AnimationEnded() |
|
197 { |
|
198 FUNC_LOG; |
|
199 |
|
200 CompleteClientRequest( KErrNone ); |
|
201 return EFalse; |
|
202 } |
|
203 |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CSAnimSvgPlugin::CSAnimSvgPlugin |
|
207 // |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 CSAnimSvgPlugin::CSAnimSvgPlugin( TAny* aConstructionParameters ) |
|
211 : CSAnimSvgPluginBase( aConstructionParameters ) |
|
212 { |
|
213 FUNC_LOG; |
|
214 } |
|
215 |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // CSAnimSvgPlugin::ConstructL |
|
219 // |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 void CSAnimSvgPlugin::ConstructL() |
|
223 { |
|
224 FUNC_LOG; |
|
225 } |
|
226 |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CSAnimSvgPlugin::LoadL |
|
230 // |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 void CSAnimSvgPlugin::LoadL( const TDesC& aFileName ) |
|
234 { |
|
235 FUNC_LOG; |
|
236 |
|
237 iImage = new ( ELeave ) CFbsBitmap(); |
|
238 User::LeaveIfError( iImage->Create( iSize, iDisplayMode ) ); |
|
239 iMask = new ( ELeave ) CFbsBitmap(); |
|
240 User::LeaveIfError( iMask->Create( iSize, EGray256 ) ); |
|
241 |
|
242 iEngine = CSvgEngineInterfaceImpl::NewL( iImage, this, iFontSpec ); |
|
243 iEngine->SetBackgroundColor( KRgbWhite.Internal() ); |
|
244 iEngine->SetDRMMode( EFalse ); |
|
245 |
|
246 TInt errorCode = SvgToSymbianErr( iEngine->Load( aFileName ) ); |
|
247 ERROR( errorCode, "Failed to load SVG file" ); |
|
248 User::LeaveIfError( errorCode ); |
|
249 } |