|
1 /* |
|
2 * Copyright (c) 2003 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: SVG Implementation source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #if !defined(__E32BASE_H__) |
|
20 #include <e32base.h> |
|
21 #endif |
|
22 |
|
23 #include "GfxAffineTransform.h" |
|
24 #include "SVGTransformListImpl.h" |
|
25 |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 // --------------------------------------------------------------------------- |
|
30 CSvgTransformListImpl* CSvgTransformListImpl::NewL() |
|
31 { |
|
32 CSvgTransformListImpl* self = new ( ELeave ) CSvgTransformListImpl(); |
|
33 CleanupStack::PushL( self ); |
|
34 self->ConstructL(); |
|
35 CleanupStack::Pop(); |
|
36 |
|
37 return self; |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 // --------------------------------------------------------------------------- |
|
43 CSvgTransformListImpl* CSvgTransformListImpl::NewLC() |
|
44 { |
|
45 CSvgTransformListImpl* self = new ( ELeave ) CSvgTransformListImpl(); |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(); |
|
48 |
|
49 return self; |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 // --------------------------------------------------------------------------- |
|
55 CSvgTransformListImpl::~CSvgTransformListImpl() |
|
56 { |
|
57 iTransformations.Close(); |
|
58 iTransformAdditive.Close(); |
|
59 iTransformTypes.Close(); |
|
60 } |
|
61 |
|
62 // ******************************************************* |
|
63 // From SVG DOM |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 // --------------------------------------------------------------------------- |
|
68 TBool CSvgTransformListImpl::AppendItemL( TGfxAffineTransform& aTransform ) |
|
69 { |
|
70 iTransformations.AppendL( aTransform ); |
|
71 iTransformAdditive.AppendL( 2 ); // do nothing if not set Default: additive |
|
72 iTransformTypes.AppendL( 0 ); // Default: not animMotion |
|
73 iAvoidConsolidation = EFalse; |
|
74 return ETrue; |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 // --------------------------------------------------------------------------- |
|
81 TBool CSvgTransformListImpl::AppendItemL( TGfxAffineTransform& aTransform, |
|
82 TInt32 aAdditive, |
|
83 TInt32 aSrcAnimMotion ) |
|
84 { |
|
85 iTransformations.AppendL( aTransform ); |
|
86 iTransformAdditive.AppendL( aAdditive ); |
|
87 iTransformTypes.AppendL( aSrcAnimMotion ); |
|
88 iAvoidConsolidation = EFalse; |
|
89 return ETrue; |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 // --------------------------------------------------------------------------- |
|
96 void CSvgTransformListImpl::Clear() |
|
97 { |
|
98 iTransformations.Reset(); |
|
99 iAvoidConsolidation = EFalse; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 // --------------------------------------------------------------------------- |
|
105 TGfxAffineTransform CSvgTransformListImpl::Consolidate(TBool aOverwriteTrans) |
|
106 { |
|
107 if(!iAvoidConsolidation) |
|
108 { |
|
109 TInt numTransforms = iTransformations.Count(); |
|
110 TInt i; |
|
111 TGfxAffineTransform tr,tr2,tr3; |
|
112 TGfxAffineTransform tmpAnimMotion; |
|
113 TInt32 tmpAdditive; |
|
114 TInt32 tmpAnimType; |
|
115 |
|
116 for ( i = 0; i < numTransforms; i++ ) |
|
117 { |
|
118 tmpAdditive = iTransformAdditive[i]; |
|
119 tmpAnimType = iTransformTypes[i]; |
|
120 if ( tmpAnimType == 0 ) |
|
121 { |
|
122 tr.Concatenate( iTransformations[i]); |
|
123 } |
|
124 } |
|
125 |
|
126 // first find the animate Motion |
|
127 |
|
128 for ( i = numTransforms-1 ; i > -1 ; i-- ) |
|
129 { |
|
130 tmpAdditive = iTransformAdditive[i]; |
|
131 tmpAnimType = iTransformTypes[i]; |
|
132 if ( tmpAnimType == 1 && tmpAdditive == 0 ) |
|
133 { |
|
134 { |
|
135 // overwrite the previous animTrans transforms, |
|
136 // but not the previous animMotion transforms |
|
137 //tr = iTransformations[i]; |
|
138 tr2.Concatenate( iTransformations[i] ); |
|
139 //i--; |
|
140 break; |
|
141 } |
|
142 } |
|
143 } |
|
144 i++; |
|
145 for ( ;i < numTransforms; i++ ) |
|
146 { |
|
147 if ( 1 == iTransformTypes[i] ) |
|
148 { |
|
149 /*tmpAnimMotion = iTransformations[i];*/ |
|
150 tr.Concatenate(tmpAnimMotion); |
|
151 tr2.Concatenate( iTransformations[i] ); |
|
152 } |
|
153 } |
|
154 |
|
155 |
|
156 |
|
157 for ( i = 0; i < numTransforms; i++ ) |
|
158 { |
|
159 tmpAdditive = iTransformAdditive[i]; |
|
160 tmpAnimType = iTransformTypes[i]; |
|
161 |
|
162 if ( tmpAnimType == 2 ) |
|
163 { |
|
164 // if matrix is additive, continue calculation |
|
165 if ( !aOverwriteTrans) |
|
166 { |
|
167 tr3.Concatenate( iTransformations[i] ); |
|
168 } |
|
169 else |
|
170 { |
|
171 // overwrite the previous animTrans transforms, |
|
172 // but not the previous animMotion transforms |
|
173 //tr = tmpAnimMotion; |
|
174 tr = tmpAnimMotion; |
|
175 tr3 = iTransformations[i]; |
|
176 } |
|
177 } |
|
178 |
|
179 } |
|
180 |
|
181 |
|
182 tr.Concatenate(tr2); |
|
183 tr.Concatenate(tr3); |
|
184 /*Saving Conslidated Matrix for Later use*/ |
|
185 iConsolidatedMatrix.iM00 = tr.iM00; |
|
186 iConsolidatedMatrix.iM01 = tr.iM01; |
|
187 iConsolidatedMatrix.iM02 = tr.iM02; |
|
188 iConsolidatedMatrix.iM10 = tr.iM10; |
|
189 iConsolidatedMatrix.iM11 = tr.iM11; |
|
190 iConsolidatedMatrix.iM12 = tr.iM12; |
|
191 iConsolidatedMatrix.iTransType = tr.iTransType; |
|
192 |
|
193 iAvoidConsolidation = ETrue; |
|
194 } |
|
195 return iConsolidatedMatrix; |
|
196 |
|
197 } |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 // --------------------------------------------------------------------------- |
|
205 TGfxAffineTransform CSvgTransformListImpl::GetItem( TInt aIndex ) |
|
206 { |
|
207 if(aIndex < iTransformations.Count()) |
|
208 { |
|
209 return iTransformations[aIndex]; |
|
210 } |
|
211 else |
|
212 { |
|
213 // what does this means. |
|
214 TGfxAffineTransform a; |
|
215 return a; |
|
216 |
|
217 } |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 // --------------------------------------------------------------------------- |
|
223 TInt CSvgTransformListImpl::NumberOfItems() |
|
224 { |
|
225 return iTransformations.Count(); |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 // --------------------------------------------------------------------------- |
|
231 TGfxAffineTransform CSvgTransformListImpl::InitializeL( TGfxAffineTransform& aNewItem ) |
|
232 { |
|
233 iTransformations.Reset(); |
|
234 iTransformations.AppendL( aNewItem ); |
|
235 iAvoidConsolidation = EFalse; |
|
236 return aNewItem; |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 // --------------------------------------------------------------------------- |
|
242 TGfxAffineTransform CSvgTransformListImpl::ReplaceItem( TGfxAffineTransform newItem, |
|
243 int aIndex ) |
|
244 { |
|
245 if(aIndex < iTransformations.Count()) |
|
246 { |
|
247 iTransformations[ aIndex ] = newItem; |
|
248 } |
|
249 iAvoidConsolidation = EFalse; |
|
250 return newItem; |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 // --------------------------------------------------------------------------- |
|
256 void CSvgTransformListImpl::SetAdditive( TInt32 additive, TInt32 index ) |
|
257 { |
|
258 iTransformAdditive[ index ] = additive; |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 // --------------------------------------------------------------------------- |
|
264 CSvgTransformListImpl* CSvgTransformListImpl::CloneL() |
|
265 { |
|
266 CSvgTransformListImpl* retValue = CSvgTransformListImpl::NewL(); |
|
267 |
|
268 CleanupStack::PushL(retValue); |
|
269 TInt i; |
|
270 // copy iTransformations |
|
271 retValue->iTransformations.Reset(); |
|
272 TInt transformationCnt = this->iTransformations.Count(); |
|
273 for (i=0; i<transformationCnt; i++) |
|
274 retValue->iTransformations.AppendL(this->iTransformations[i]); |
|
275 { |
|
276 } |
|
277 |
|
278 // copy iTransformAdditive |
|
279 retValue->iTransformAdditive.Reset(); |
|
280 TInt transformAdditiveCnt = this->iTransformAdditive.Count(); |
|
281 for (i=0; i<transformAdditiveCnt; i++) |
|
282 { |
|
283 retValue->iTransformAdditive.AppendL(this->iTransformAdditive[i]); |
|
284 } |
|
285 |
|
286 // copy iTransformTypes |
|
287 retValue->iTransformTypes.Reset(); |
|
288 TInt transformTypesCnt = this->iTransformTypes.Count(); |
|
289 for (i=0; i<transformTypesCnt; i++) |
|
290 { |
|
291 retValue->iTransformTypes.AppendL(this->iTransformTypes[i]); |
|
292 } |
|
293 CleanupStack::Pop(); |
|
294 return retValue; |
|
295 } |
|
296 |
|
297 // ******************************************************* |
|
298 // Private |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // |
|
302 // --------------------------------------------------------------------------- |
|
303 void CSvgTransformListImpl::ConstructL() |
|
304 { |
|
305 TGfxAffineTransform tr; |
|
306 iTransformations.AppendL( tr ); |
|
307 |
|
308 iTransformAdditive.AppendL( 2 ); // pass |
|
309 |
|
310 iTransformTypes.AppendL( 0 ); |
|
311 } |
|
312 |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 // --------------------------------------------------------------------------- |
|
316 CSvgTransformListImpl::CSvgTransformListImpl() : iTransformations( 1 ), |
|
317 iTransformAdditive( 1 ), |
|
318 iTransformTypes( 1 ) |
|
319 |
|
320 { |
|
321 } |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // |
|
328 // --------------------------------------------------------------------------- |
|
329 void CSvgTransformListImpl::SetAvoidConsolidation(TBool aAvoidConsolidation) |
|
330 { |
|
331 iAvoidConsolidation = aAvoidConsolidation; |
|
332 } |