|
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 "SVGAnimateElementImpl.h" |
|
24 |
|
25 #include "SVGElementImpl.h" |
|
26 #include "SVGDocumentImpl.h" |
|
27 #include "SVGSchemaData.h" |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // Two phase construction |
|
34 // --------------------------------------------------------------------------- |
|
35 CSvgAnimateElementImpl* CSvgAnimateElementImpl::NewL( const TUint8 aElemID, |
|
36 CSvgDocumentImpl* aDoc ) |
|
37 { |
|
38 CSvgAnimateElementImpl* self = new ( ELeave ) |
|
39 CSvgAnimateElementImpl( aDoc ); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL( aElemID ); |
|
42 CleanupStack::Pop(); |
|
43 |
|
44 return self; |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 // --------------------------------------------------------------------------- |
|
50 CSvgAnimateElementImpl* CSvgAnimateElementImpl::NewLC( const TUint8 aElemID, |
|
51 CSvgDocumentImpl* aDoc ) |
|
52 { |
|
53 CSvgAnimateElementImpl* self = new ( ELeave ) |
|
54 CSvgAnimateElementImpl( aDoc ); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL( aElemID ); |
|
57 |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ******************************************************* |
|
62 // Protected |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 // --------------------------------------------------------------------------- |
|
67 void CSvgAnimateElementImpl::ConstructL( const TUint8 aElemID ) |
|
68 { |
|
69 CSvgAnimationBase::ConstructL( aElemID ); |
|
70 |
|
71 iReqAttrFlag=KSVG_ANIMATE_ELEMFLAG; |
|
72 iIsInheritedAttribute = EFalse; |
|
73 } |
|
74 |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 // --------------------------------------------------------------------------- |
|
80 CSvgAnimateElementImpl::~CSvgAnimateElementImpl() |
|
81 { |
|
82 } |
|
83 |
|
84 // ******************************************************* |
|
85 // Protected |
|
86 |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 // --------------------------------------------------------------------------- |
|
91 CSvgAnimateElementImpl::CSvgAnimateElementImpl( CSvgDocumentImpl* aDoc ) : CSvgAnimationBase( aDoc ) |
|
92 { |
|
93 } |
|
94 |
|
95 // ******************************************************* |
|
96 // From SVG DOM |
|
97 |
|
98 |
|
99 // ******************************************************* |
|
100 // From MSvgEventReceiver |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 // --------------------------------------------------------------------------- |
|
104 void CSvgAnimateElementImpl::ResetReferenceElementL() |
|
105 { |
|
106 if(iTargetElement != NULL ) |
|
107 { |
|
108 if( ((iTargetElement->iAnimateAttrSet == NULL) || (iTargetElement->iAnimateAttrSet->Find(iAttrId) == KErrNotFound) ) ) |
|
109 { |
|
110 if ( iInitDone && iAnimStatus != KAnimNotActive) |
|
111 { |
|
112 iCheckFirstAnim= ETrue; |
|
113 SetToOriginalL(); |
|
114 if( !(iTargetElement->iAnimateAttrSet) ) |
|
115 { |
|
116 iTargetElement->iAnimateAttrSet = new (ELeave) RArray<TUint32>(1); |
|
117 } |
|
118 iTargetElement->iAnimateAttrSet->AppendL((TUint32)(iAttrId)); |
|
119 } |
|
120 } |
|
121 } |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // From MSvgEventReceiver |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 TBool CSvgAnimateElementImpl::ReceiveEventL( MSvgEvent* aEvent ) |
|
129 { |
|
130 return CSvgAnimationBase::ReceiveEventProcL( aEvent, this ); |
|
131 } |
|
132 |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // From CSvgAnimationBase |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 TBool CSvgAnimateElementImpl::AnimProcL( MSvgTimerEvent* aEvent ) |
|
139 |
|
140 { |
|
141 |
|
142 if(iAnimStatus == KAnimActive && !iHadBegun) |
|
143 { |
|
144 SetFromValuesL(); |
|
145 iHadBegun = ETrue; |
|
146 |
|
147 } |
|
148 |
|
149 |
|
150 if((iAnimStatus != KAnimActive) || iDoFreeze) |
|
151 { |
|
152 if(iFill== KAnimFillFreeze && !iDoFreeze && iAnimStatus == KAnimFinished) |
|
153 { |
|
154 |
|
155 } |
|
156 else |
|
157 { |
|
158 CSvgAnimationBase::CheckForEndTimesAndFreezeL(this); |
|
159 return EFalse; |
|
160 } |
|
161 } |
|
162 |
|
163 // Calc alpha from time [0-255] |
|
164 TInt32 alpha; |
|
165 TInt32 valix, subanimtime; |
|
166 |
|
167 switch ( iDataType ) |
|
168 { |
|
169 // x, y, width, height, |
|
170 // rx, ry, cx, cy, radius |
|
171 // x1, y1, x2, y2 |
|
172 case KSvgTypeOpacity: |
|
173 case KSvgTypeLength: |
|
174 { |
|
175 iAnimTime->GetAnimTime( (aEvent->Time()-iNegativeBeginTime) , alpha, valix, subanimtime ); |
|
176 TFloatFixPt v1 = iFromFloat; |
|
177 TFloatFixPt v2 = iToFloat; |
|
178 TFloatFixPt lCurValue; |
|
179 if(iHaveBy && iCurrentRepeatCount > 0 && iAccumulate == KAccumSum ) |
|
180 { |
|
181 v1= KFloatFixZero; |
|
182 v2 = iToFloat - iFromFloat; |
|
183 } |
|
184 if ( iValuesFloat->Count() > 0 ) |
|
185 { |
|
186 |
|
187 // check for the range of valix |
|
188 if(valix >= iValuesFloat->Count() ) |
|
189 { |
|
190 valix = iValuesFloat->Count() - 1; |
|
191 } |
|
192 |
|
193 v1 = ( *iValuesFloat )[valix]; |
|
194 if ( valix + 1 >= iValuesFloat->Count() ) |
|
195 { |
|
196 v2 = ( *iValuesFloat )[valix]; |
|
197 } |
|
198 else |
|
199 { |
|
200 v2 = ( *iValuesFloat )[valix + 1]; |
|
201 } |
|
202 alpha = subanimtime; |
|
203 } |
|
204 lCurValue = BlendFloat( alpha, v1, v2 ); |
|
205 if( iAccumulate == KAccumSum && !iNoFrom ) |
|
206 { |
|
207 TFloatFixPt lRepeatCount((TInt) iCurrentRepeatCount) ; |
|
208 if(iValuesFloat->Count() > 0) |
|
209 { |
|
210 lCurValue += ((*iValuesFloat) [iValuesFloat->Count() -1]) * lRepeatCount ; |
|
211 } |
|
212 else |
|
213 { |
|
214 TFloatFixPt lRepeatCount((TInt) iCurrentRepeatCount) ; |
|
215 lCurValue += lRepeatCount * (v2); |
|
216 if(iHaveBy && iCurrentRepeatCount > 0) |
|
217 { |
|
218 lCurValue += iFromFloat; |
|
219 } |
|
220 } |
|
221 } |
|
222 if ( ( iFill == KAnimFillFreeze ) ) |
|
223 { |
|
224 iEndFloat = lCurValue; |
|
225 } |
|
226 if ( ( iAdditive == KAdditiveSum ) && !iNoFrom ) //. |
|
227 { |
|
228 TFloatFixPt lOrig; |
|
229 iTargetElement->GetAttributeFloat( iAttrId, lOrig ); |
|
230 lCurValue += lOrig; |
|
231 } |
|
232 iTargetElement->SetAttributeFloatL( iAttrId, lCurValue ); |
|
233 |
|
234 } |
|
235 break; |
|
236 case KSvgTypeList: |
|
237 case KSvgTypePath: |
|
238 { |
|
239 iAnimTime->GetAnimTime( (aEvent->Time()-iNegativeBeginTime), alpha, valix, subanimtime ); |
|
240 CGfxGeneralPath*v1 = iFromPath; |
|
241 CGfxGeneralPath*v2 = iToPath; |
|
242 |
|
243 if ( iValuesPath->Count() > 0 ) |
|
244 { |
|
245 |
|
246 // check for the range of valix |
|
247 if(valix >= iValuesPath->Count() ) |
|
248 { |
|
249 valix = iValuesPath->Count() - 1; |
|
250 } |
|
251 |
|
252 v1 = iValuesPath->operator[]( valix ); |
|
253 if ( valix + 1 >= iValuesPath->Count() ) |
|
254 { |
|
255 v2 = iValuesPath->operator[]( valix ); |
|
256 } |
|
257 else |
|
258 { |
|
259 v2 = iValuesPath->operator[]( valix + 1 ); |
|
260 } |
|
261 alpha = subanimtime; |
|
262 } |
|
263 |
|
264 CGfxGeneralPath*lCurPath = CGfxGeneralPath::NewLC(); |
|
265 |
|
266 BlendPathL( alpha, v1, v2, lCurPath ); |
|
267 |
|
268 if ( iAdditive == KAdditiveSum ) |
|
269 { |
|
270 AddPathsL( lCurPath, iOrgPath ); |
|
271 } |
|
272 else |
|
273 { |
|
274 // User current blended value |
|
275 } |
|
276 if ( ( iFill == KAnimFillFreeze ) ) |
|
277 { |
|
278 CopyPathsL( iEndPath, lCurPath ); |
|
279 } |
|
280 |
|
281 iTargetElement->SetAttributePathL( iAttrId, lCurPath ); |
|
282 |
|
283 CleanupStack::PopAndDestroy( 1 ); // lCurPath |
|
284 |
|
285 } |
|
286 break; |
|
287 case KSvgTypeTransform: |
|
288 break; |
|
289 |
|
290 case KSvgTypeColor: |
|
291 { |
|
292 iAnimTime->GetAnimTime((aEvent->Time()-iNegativeBeginTime), alpha, valix, subanimtime ); |
|
293 TInt32 v1 = iFromInt; |
|
294 TInt32 v2 = iToInt; |
|
295 TInt32 lCurValue; |
|
296 if(iHaveBy && iCurrentRepeatCount > 0 && iAccumulate == KAccumSum ) |
|
297 { |
|
298 v1= 0; |
|
299 v2 = SubtractColor(iToInt,iFromInt); |
|
300 } |
|
301 |
|
302 if ( iValuesInt->Count() > 0 ) |
|
303 { |
|
304 |
|
305 // check for the range of valix |
|
306 if(valix >= iValuesInt->Count() ) |
|
307 { |
|
308 valix = iValuesInt->Count() - 1; |
|
309 } |
|
310 |
|
311 v1 = ( *iValuesInt )[valix]; |
|
312 if ( valix + 1 >= iValuesInt->Count() ) |
|
313 { |
|
314 v2 = ( *iValuesInt )[valix]; |
|
315 } |
|
316 else |
|
317 { |
|
318 v2 = ( *iValuesInt )[valix + 1]; |
|
319 } |
|
320 alpha = subanimtime; |
|
321 } |
|
322 |
|
323 if ( iNoFrom ) //. This is to emulate Adobe. |
|
324 { |
|
325 if ( alpha > ( KTimeMax >> 1 ) ) |
|
326 { |
|
327 alpha = KTimeMax; |
|
328 } |
|
329 else |
|
330 { |
|
331 alpha = 0; |
|
332 } |
|
333 } |
|
334 |
|
335 lCurValue = BlendColor( alpha, v1, v2 ); |
|
336 if( iAccumulate == KAccumSum && !iNoFrom ) |
|
337 { |
|
338 |
|
339 |
|
340 if(iValuesInt->Count() > 0) |
|
341 { |
|
342 TInt32 ColorToAdd = 0; |
|
343 ColorToAdd = ((*iValuesInt) [iValuesInt->Count() -1]); |
|
344 for( TInt i=0 ; i< iCurrentRepeatCount ; i++) |
|
345 { |
|
346 lCurValue = AddColor( lCurValue, ColorToAdd ); |
|
347 } |
|
348 |
|
349 } |
|
350 else |
|
351 { |
|
352 for (TInt i=0; i<iCurrentRepeatCount;i++) |
|
353 { |
|
354 lCurValue = AddColor( lCurValue, v2 ) ; |
|
355 } |
|
356 |
|
357 if(iHaveBy && iCurrentRepeatCount > 0) |
|
358 { |
|
359 |
|
360 lCurValue = AddColor( lCurValue, iFromInt ); |
|
361 } |
|
362 |
|
363 } |
|
364 } |
|
365 |
|
366 // Fix for accum_addit_7.svg |
|
367 if ( ( iFill == KAnimFillFreeze ) ) |
|
368 { |
|
369 iEndInt = lCurValue; |
|
370 iEndInt = lCurValue; |
|
371 } |
|
372 if ( ( iAdditive == KAdditiveSum ) && !iNoFrom ) //. |
|
373 { |
|
374 TInt32 lOrig; |
|
375 iTargetElement->GetAttributeIntL( iAttrId, lOrig ); |
|
376 |
|
377 |
|
378 |
|
379 lCurValue = AddColor( lCurValue, lOrig ); |
|
380 } |
|
381 |
|
382 iTargetElement->SetAttributeIntL( iAttrId, lCurValue ); |
|
383 |
|
384 } |
|
385 break; |
|
386 case KSvgTypeTextAnchor: |
|
387 case KSvgTypeVisibility: |
|
388 case KSvgTypeGradientUnits: |
|
389 case KSvgTypeSpreadMethod: |
|
390 case KSvgTypeDisplay: |
|
391 { |
|
392 iAnimTime->GetAnimTimeForEnumeration( (aEvent->Time()-iNegativeBeginTime), alpha, valix, iKeyTimesPresent); |
|
393 TInt32 v1 = iFromInt; |
|
394 TInt32 v2 = iToInt; |
|
395 TInt32 lCurValue; |
|
396 if ( iValuesInt->Count() > 0 ) |
|
397 { |
|
398 |
|
399 // check for the range of valix |
|
400 if(valix >= iValuesInt->Count() ) |
|
401 { |
|
402 valix = iValuesInt->Count() - 1; |
|
403 } |
|
404 |
|
405 if(iKeyTimesPresent) |
|
406 { |
|
407 if ( valix < iValuesInt->Count() ) |
|
408 { |
|
409 lCurValue = (*iValuesInt)[valix]; |
|
410 } |
|
411 else |
|
412 { |
|
413 lCurValue = (*iValuesInt)[valix-1]; |
|
414 } |
|
415 } |
|
416 else |
|
417 { |
|
418 TInt index = ( alpha * iValuesInt->Count() / 255 ) ; |
|
419 if(index == iValuesInt->Count()) index--; |
|
420 if ( index >= 0 ) |
|
421 { |
|
422 lCurValue = (*iValuesInt)[index]; |
|
423 } |
|
424 else |
|
425 { |
|
426 lCurValue = (*iValuesInt)[0]; |
|
427 } |
|
428 } |
|
429 |
|
430 } |
|
431 |
|
432 else |
|
433 { |
|
434 if(alpha>=128) // average of 256 to determine which value should predominate |
|
435 { |
|
436 lCurValue = v2; |
|
437 } |
|
438 else |
|
439 { |
|
440 lCurValue = v1; |
|
441 } |
|
442 } |
|
443 if ( ( iFill == KAnimFillFreeze ) ) |
|
444 { |
|
445 iEndInt = lCurValue; |
|
446 } |
|
447 |
|
448 iTargetElement->SetAttributeIntL( iAttrId, lCurValue ); |
|
449 |
|
450 } |
|
451 break; |
|
452 |
|
453 case KSvgTypeViewBox: |
|
454 { |
|
455 DoViewBoxAnimProcL(aEvent); |
|
456 break; |
|
457 } |
|
458 } |
|
459 CSvgAnimationBase::CheckForEndTimesAndFreezeL(this); |
|
460 return ETrue; |
|
461 } |
|
462 |
|
463 |
|
464 // --------------------------------------------------------------------------- |
|
465 // |
|
466 // --------------------------------------------------------------------------- |
|
467 void CSvgAnimateElementImpl::BlendPathL( TInt32 aAlpha, |
|
468 CGfxGeneralPath* aFromPath, |
|
469 CGfxGeneralPath* aToPath, |
|
470 CGfxGeneralPath*& aBlendPath ) |
|
471 { |
|
472 if ( aFromPath && aToPath ) |
|
473 { |
|
474 aBlendPath->SetPointTypeArrayL( aFromPath->PointTypeArray() ); |
|
475 |
|
476 RArray<TFloatFixPt>* lCurPoints = new ( ELeave ) RArray<TFloatFixPt>( 20 ); |
|
477 CleanupStack::PushL( lCurPoints ); |
|
478 lCurPoints->AppendL(NULL); |
|
479 lCurPoints->Remove(0); |
|
480 |
|
481 RArray<TFloatFixPt>* fromPoints = aFromPath->PointCoordsArrayAll(); |
|
482 RArray<TFloatFixPt>* toPoints = aToPath->PointCoordsArrayAll(); |
|
483 |
|
484 TInt lFromcount = fromPoints->Count(); |
|
485 TInt lTocount = toPoints->Count(); |
|
486 TInt i = 0; |
|
487 TFloatFixPt lCurPoint; |
|
488 |
|
489 while (i < lFromcount && i < lTocount ) |
|
490 { |
|
491 lCurPoint = BlendFloat( aAlpha, |
|
492 fromPoints->operator[]( i ), |
|
493 toPoints->operator[]( i ) ); |
|
494 lCurPoints->AppendL( lCurPoint ); |
|
495 i++; |
|
496 } |
|
497 |
|
498 aBlendPath->SetPointCoordsArrayL( lCurPoints ); |
|
499 |
|
500 lCurPoints->Close(); |
|
501 CleanupStack::PopAndDestroy( 1 ); // lCurPoints |
|
502 } |
|
503 } |
|
504 |
|
505 |
|
506 // --------------------------------------------------------------------------- |
|
507 // |
|
508 // --------------------------------------------------------------------------- |
|
509 void CSvgAnimateElementImpl::AddPathsL( CGfxGeneralPath*& aPathResult, |
|
510 CGfxGeneralPath* aPath1 ) |
|
511 { |
|
512 RArray<TFloatFixPt>* lCurPoints = new ( ELeave ) RArray<TFloatFixPt>( 20 ); |
|
513 CleanupStack::PushL( lCurPoints ); |
|
514 lCurPoints->AppendL(NULL); |
|
515 lCurPoints->Remove(0); |
|
516 |
|
517 RArray<TFloatFixPt>* points1 = aPath1->PointCoordsArrayAll(); |
|
518 RArray<TFloatFixPt>* result = aPathResult->PointCoordsArrayAll(); |
|
519 TInt pcount = points1->Count(); |
|
520 TInt rcount = result->Count(); |
|
521 TInt i = 0; |
|
522 TFloatFixPt lCurPoint; |
|
523 |
|
524 while ( i < pcount && i < rcount ) |
|
525 { |
|
526 lCurPoint = points1->operator[]( i ) + result->operator[]( i ); |
|
527 lCurPoints->AppendL( lCurPoint ); |
|
528 i++; |
|
529 } |
|
530 |
|
531 aPathResult->SetPointCoordsArrayL( lCurPoints ); |
|
532 |
|
533 lCurPoints->Close(); |
|
534 CleanupStack::PopAndDestroy( 1 ); // lCurPoints |
|
535 } |
|
536 |
|
537 // --------------------------------------------------------------------------- |
|
538 // |
|
539 // --------------------------------------------------------------------------- |
|
540 void CSvgAnimateElementImpl::CopyPathsL( CGfxGeneralPath*& aPathResult, |
|
541 CGfxGeneralPath* aPath1 ) |
|
542 { |
|
543 RArray<TFloatFixPt>* lCurPoints = new ( ELeave ) RArray<TFloatFixPt>( 20 ); |
|
544 CleanupStack::PushL( lCurPoints ); |
|
545 |
|
546 lCurPoints->AppendL(NULL); |
|
547 lCurPoints->Remove(0); |
|
548 RArray<TFloatFixPt>* points1 = aPath1->PointCoordsArrayAll(); |
|
549 |
|
550 TInt count = points1->Count(); |
|
551 TInt i = 0; |
|
552 TFloatFixPt lCurPoint; |
|
553 |
|
554 while ( i < count ) |
|
555 { |
|
556 lCurPoint = points1->operator[]( i ); |
|
557 lCurPoints->AppendL( lCurPoint ); |
|
558 i++; |
|
559 } |
|
560 |
|
561 aPathResult->SetPointCoordsArrayL( lCurPoints ); |
|
562 |
|
563 lCurPoints->Close(); |
|
564 CleanupStack::PopAndDestroy( 1 ); // lCurPoints |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------------------------- |
|
568 // |
|
569 // --------------------------------------------------------------------------- |
|
570 void CSvgAnimateElementImpl::ResetAnimationL() |
|
571 { |
|
572 } |
|
573 |
|
574 // --------------------------------------------------------------------------- |
|
575 // |
|
576 // --------------------------------------------------------------------------- |
|
577 TInt CSvgAnimateElementImpl::SetAttributeIntL( const TInt aNameId, const TInt32 aValue) |
|
578 { |
|
579 return CSvgAnimationBase::SetAttributeIntL(aNameId,aValue); |
|
580 } |
|
581 |
|
582 // --------------------------------------------------------------------------- |
|
583 // |
|
584 // --------------------------------------------------------------------------- |
|
585 TInt CSvgAnimateElementImpl::GetAttributeIntL( const TInt aNameId, TInt32& aValue ) |
|
586 { |
|
587 return CSvgAnimationBase::GetAttributeIntL(aNameId,aValue); |
|
588 } |
|
589 |
|
590 // --------------------------------------------------------------------------- |
|
591 // |
|
592 // --------------------------------------------------------------------------- |
|
593 TInt CSvgAnimateElementImpl::SetAttributeFloatL(const TInt aNameId, TFloatFixPt aValue ) |
|
594 { |
|
595 return CSvgAnimationBase::SetAttributeFloatL(aNameId,aValue); |
|
596 } |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 // --------------------------------------------------------------------------- |
|
600 TInt CSvgAnimateElementImpl::GetAttributeFloat(const TInt aNameId, TFloatFixPt& aValue ) |
|
601 { |
|
602 return CSvgAnimationBase::GetAttributeFloat(aNameId,aValue); |
|
603 } |
|
604 // --------------------------------------------------------------------------- |
|
605 // |
|
606 // --------------------------------------------------------------------------- |
|
607 |
|
608 void CSvgAnimateElementImpl::ReInitializeAnimation() |
|
609 { |
|
610 |
|
611 if ( iAttrId == 0xffff ) |
|
612 return; |
|
613 |
|
614 CSvgAnimationBase::ReInitializeAnimation(); |
|
615 |
|
616 if(iCheckFirstAnim) |
|
617 { |
|
618 if(iIsInheritedAttribute) |
|
619 { |
|
620 iTargetElement->PointToParent(iAttrId); |
|
621 } |
|
622 else |
|
623 { |
|
624 TRAPD(error, SetToOriginalL()); |
|
625 |
|
626 if (error != KErrNone) |
|
627 { |
|
628 // error processing not processed |
|
629 return; |
|
630 } |
|
631 } |
|
632 } |
|
633 |
|
634 |
|
635 } |
|
636 // --------------------------------------------------------------------------- |
|
637 // |
|
638 // --------------------------------------------------------------------------- |
|
639 void CSvgAnimateElementImpl::SetOriginalValues_DOMReuse() |
|
640 { |
|
641 // calling base class function. |
|
642 CSvgAnimationBase::SetOriginalValues_DOMReuse(); |
|
643 |
|
644 } |
|
645 // --------------------------------------------------------------------------- |
|
646 // |
|
647 // --------------------------------------------------------------------------- |
|
648 CGfxGeneralPath* CSvgAnimateElementImpl::GetPathAttribute(TInt aAttributeId) |
|
649 { |
|
650 return CSvgAnimationBase::GetPathAttribute(aAttributeId); |
|
651 |
|
652 } |
|
653 // --------------------------------------------------------------------------- |
|
654 // |
|
655 // --------------------------------------------------------------------------- |
|
656 void CSvgAnimateElementImpl::SetPathAttribute(TInt aAttributeId, CGfxGeneralPath* aPathHandle) |
|
657 { |
|
658 |
|
659 CSvgAnimationBase::SetPathAttribute(aAttributeId, aPathHandle); |
|
660 |
|
661 } |
|
662 // --------------------------------------------------------------------------- |
|
663 // |
|
664 // --------------------------------------------------------------------------- |
|
665 void CSvgAnimateElementImpl::Reset(MSvgEvent* aEvent) |
|
666 { |
|
667 |
|
668 iIsUserSeek = ETrue; |
|
669 |
|
670 // first call the animation base function. |
|
671 TSvgTimerEvent* timerEvent = ( TSvgTimerEvent* ) aEvent; |
|
672 |
|
673 |
|
674 if((TInt32)timerEvent->Time() < iAbsoluteBeginTime) |
|
675 { |
|
676 // let it come to initial position. |
|
677 ((CSvgDocumentImpl*)iOwnerDocument)->iInitialDrawFlag = ETrue; |
|
678 ReInitializeAnimation(); |
|
679 return; |
|
680 } |
|
681 TRAPD(error,CSvgAnimationBase::ResetL( aEvent, this)); |
|
682 |
|
683 if (error != KErrNone) |
|
684 { |
|
685 // error processing not processed |
|
686 return; |
|
687 } |
|
688 } |
|
689 |
|
690 // --------------------------------------------------------------------------- |
|
691 // |
|
692 // --------------------------------------------------------------------------- |
|
693 ///////////////////////////////////////////// |
|
694 MXmlElement* CSvgAnimateElementImpl::CloneL(MXmlElement* |
|
695 aParentElement) |
|
696 { |
|
697 CSvgAnimateElementImpl* newElement = CSvgAnimateElementImpl::NewL( this->ElemID(), |
|
698 ((CSvgDocumentImpl*)iOwnerDocument) ); |
|
699 CleanupStack::PushL( newElement ); |
|
700 newElement->iParentNode = aParentElement; |
|
701 // copy the data |
|
702 // end copying data from this class. |
|
703 // this will get cloned setting the parent element to aParentElement; |
|
704 |
|
705 newElement->iOwnerDocument = this->iOwnerDocument; |
|
706 |
|
707 // set the target element this needs to be modified. |
|
708 newElement->iTargetElement = (CSvgElementImpl*)aParentElement; |
|
709 this->CopyL(newElement); |
|
710 CleanupStack::Pop(); |
|
711 return newElement; |
|
712 } |
|
713 // --------------------------------------------------------------------------- |
|
714 // |
|
715 // --------------------------------------------------------------------------- |
|
716 void CSvgAnimateElementImpl::CopyL(CSvgAnimateElementImpl* aDestElement ) |
|
717 { |
|
718 if(aDestElement) |
|
719 { |
|
720 // copy from superclass |
|
721 this->CSvgAnimationBase::CopyL(aDestElement); |
|
722 // copy reference to idoc (CSvgDocumentImpl) |
|
723 aDestElement->iOwnerDocument = this->iOwnerDocument; |
|
724 } |
|
725 } |
|
726 // --------------------------------------------------------------------------- |
|
727 // |
|
728 // --------------------------------------------------------------------------- |
|
729 void CSvgAnimateElementImpl::DeactivateAnimation() |
|
730 { |
|
731 CSvgAnimationBase::DeactivateAnimation(this); |
|
732 } |
|
733 // --------------------------------------------------------------------------- |
|
734 // |
|
735 // --------------------------------------------------------------------------- |
|
736 // for calculation of interpolated values for viewBox animation. |
|
737 void CSvgAnimateElementImpl::DoViewBoxAnimProcL(MSvgTimerEvent* aEvent) |
|
738 { |
|
739 |
|
740 TInt32 alpha; |
|
741 TInt32 valix; |
|
742 TInt32 subanimtime; |
|
743 TReal32 vBoxX=0; |
|
744 TReal32 vBoxY=0; |
|
745 TReal32 vBoxW=0; |
|
746 TReal32 vBoxH=0; |
|
747 |
|
748 iAnimTime->GetAnimTime( (aEvent->Time()-iNegativeBeginTime), alpha, valix, subanimtime ); |
|
749 TGfxRectangle2D v1 = iFromViewBox; |
|
750 TGfxRectangle2D v2 = iToViewBox; |
|
751 TGfxRectangle2D lCurValue; |
|
752 if(iHaveBy && iCurrentRepeatCount > 0 && iAccumulate == KAccumSum ) |
|
753 { |
|
754 v1= TGfxRectangle2D( vBoxX, vBoxY, vBoxW, vBoxH ); |
|
755 vBoxX = iToViewBox.iX - iFromViewBox.iX; |
|
756 vBoxY = iToViewBox.iY - iFromViewBox.iY; |
|
757 vBoxW = iToViewBox.iWidth - iFromViewBox.iWidth; |
|
758 vBoxH = iToViewBox.iHeight - iFromViewBox.iHeight; |
|
759 v2 = TGfxRectangle2D( vBoxX, vBoxY, vBoxW, vBoxH ); |
|
760 } |
|
761 |
|
762 if ( iValuesViewBox->Count() > 0 ) |
|
763 { |
|
764 |
|
765 // check for the range of valix |
|
766 if(valix >= iValuesViewBox->Count() ) |
|
767 { |
|
768 valix = iValuesViewBox->Count() - 1; |
|
769 } |
|
770 |
|
771 v1 = ( *iValuesViewBox )[valix]; |
|
772 if ( valix + 1 >= iValuesViewBox->Count() ) |
|
773 { |
|
774 v2 = ( *iValuesViewBox )[valix]; |
|
775 } |
|
776 else |
|
777 { |
|
778 v2 = ( *iValuesViewBox )[valix + 1]; |
|
779 } |
|
780 alpha = subanimtime; |
|
781 } |
|
782 |
|
783 // to get the interpolation of each values of the viewBox |
|
784 vBoxX = BlendFloat( alpha, v1.iX, v2.iX ); |
|
785 vBoxY = BlendFloat( alpha, v1.iY, v2.iY ); |
|
786 vBoxW = BlendFloat( alpha, v1.iWidth, v2.iWidth ); |
|
787 vBoxH = BlendFloat( alpha, v1.iHeight, v2.iHeight ); |
|
788 |
|
789 lCurValue = TGfxRectangle2D( vBoxX, vBoxY, vBoxW, vBoxH ); |
|
790 |
|
791 if( iAccumulate == KAccumSum && !iNoFrom) |
|
792 { |
|
793 TFloatFixPt lRepeatCount((TInt) iCurrentRepeatCount) ; |
|
794 if(iValuesViewBox->Count() > 0) |
|
795 { |
|
796 TGfxRectangle2D lVal= ((*iValuesViewBox) [iValuesViewBox->Count() -1]); |
|
797 |
|
798 lCurValue.iX += lVal.iX * lRepeatCount; |
|
799 lCurValue.iY += lVal.iY * lRepeatCount; |
|
800 lCurValue.iWidth += lVal.iWidth * lRepeatCount; |
|
801 lCurValue.iHeight += lVal.iHeight * lRepeatCount; |
|
802 } |
|
803 else |
|
804 { |
|
805 lCurValue.iX += v2.iX * lRepeatCount; |
|
806 lCurValue.iY += v2.iY * lRepeatCount; |
|
807 lCurValue.iWidth += v2.iWidth * lRepeatCount; |
|
808 lCurValue.iHeight += v2.iHeight * lRepeatCount; |
|
809 if(iHaveBy && iCurrentRepeatCount > 0) |
|
810 { |
|
811 lCurValue.iX += iFromViewBox.iX ; |
|
812 lCurValue.iY += iFromViewBox.iY ; |
|
813 lCurValue.iWidth += iFromViewBox.iWidth ; |
|
814 lCurValue.iHeight += iFromViewBox.iHeight ; |
|
815 } |
|
816 } |
|
817 } |
|
818 |
|
819 if ( ( iFill == KAnimFillFreeze ) ) |
|
820 { |
|
821 iEndViewBox = lCurValue; |
|
822 } |
|
823 if ( ( iAdditive == KAdditiveSum ) && !iNoFrom ) //. |
|
824 { |
|
825 TGfxRectangle2D lOrig; |
|
826 if(iTargetElement->ElemID() == KSvgSvgElement) |
|
827 { |
|
828 ((CSvgSvgElementImpl*)iTargetElement)->GetViewBox( lOrig ); |
|
829 } |
|
830 |
|
831 lCurValue.iX += lOrig.iX ; |
|
832 lCurValue.iY += lOrig.iY ; |
|
833 lCurValue.iWidth += lOrig.iWidth ; |
|
834 lCurValue.iHeight += lOrig.iHeight ; |
|
835 } |
|
836 |
|
837 // set the value to the target element. |
|
838 if(iTargetElement->ElemID() == KSvgSvgElement) |
|
839 { |
|
840 ((CSvgSvgElementImpl*)iTargetElement)->SetViewBoxL( lCurValue ); |
|
841 } |
|
842 } |
|
843 |
|
844 // --------------------------------------------------------------------------- |
|
845 // |
|
846 // --------------------------------------------------------------------------- |
|
847 |
|
848 TBool CSvgAnimateElementImpl::DoAnimProcL(MSvgEvent* aEvent) |
|
849 { |
|
850 return this->AnimProcL((MSvgTimerEvent*)aEvent); |
|
851 } |
|
852 // --------------------------------------------------------------------------- |
|
853 // |
|
854 // --------------------------------------------------------------------------- |
|
855 void CSvgAnimateElementImpl::InitAnimationL() |
|
856 { |
|
857 |
|
858 if(!iTargetElement) |
|
859 { |
|
860 // if target element is not found then remove it. |
|
861 ((CSvgDocumentImpl*)iOwnerDocument)->RemoveFromEventReceiverList(this); |
|
862 ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->UpdatePresentation(1); |
|
863 return; |
|
864 } |
|
865 |
|
866 if (!iHaveValues) |
|
867 { |
|
868 if (!iHaveTo && !iHaveBy) |
|
869 { |
|
870 ((CSvgDocumentImpl*)iOwnerDocument)->RemoveFromEventReceiverList(this ); |
|
871 ((CSvgDocumentImpl*)iOwnerDocument)->Engine()->UpdatePresentation(1); |
|
872 } |
|
873 } |
|
874 |
|
875 iIsInheritedAttribute = iTargetElement->IsInherited(iAttrId); |
|
876 CSvgAnimationBase::InitAnimationL(); |
|
877 SetFillValueL(); |
|
878 |
|
879 } |
|
880 // --------------------------------------------------------------------------- |
|
881 // |
|
882 // --------------------------------------------------------------------------- |
|
883 void CSvgAnimateElementImpl::SetToOriginalL() |
|
884 { |
|
885 |
|
886 // this is to make sure the inherited style attributes are made point back to the parent. |
|
887 if(iIsInheritedAttribute && iAnimStatus == KAnimFinished) |
|
888 { |
|
889 // only if the animation has finished |
|
890 iTargetElement->PointToParent(iAttrId); |
|
891 } |
|
892 else |
|
893 { |
|
894 CSvgAnimationBase::SetToOriginalL(); |
|
895 } |
|
896 } |
|
897 |
|
898 void CSvgAnimateElementImpl::Print( TBool aIsEncodeOn ) |
|
899 { |
|
900 if (!aIsEncodeOn) |
|
901 { |
|
902 #ifdef _DEBUG |
|
903 RDebug::Printf("<animate attributeType=\"hmmm\" attributeName=\"hmm\" from=\"%d\" to=\"%d\" dur=\"hmm\" repeatCount=\"hmm\"/>", |
|
904 /*iDataType,*/ (int)iFromFloat, (int)iToFloat/*, iRepeatCount*/); |
|
905 #endif |
|
906 } |
|
907 } |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |