|
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 header file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _INC_CSVGANIMATIONBASE_ |
|
20 #define _INC_CSVGANIMATIONBASE_ |
|
21 |
|
22 #include <e32math.h> |
|
23 #include "SVGElementImpl.h" |
|
24 #include "SVGEventReceiver.h" |
|
25 #include "SVGEvent.h" |
|
26 #include "SVGSchemaData.h" |
|
27 #include "SVGAnimTimeController.h" |
|
28 |
|
29 #include "GfxFloatFixPt.h" |
|
30 #include "GfxRectangle2D.h" |
|
31 #include "GfxGeneralPath.h" |
|
32 |
|
33 #include "SVGSvgElementImpl.h" |
|
34 |
|
35 |
|
36 |
|
37 const TUint32 KRmask = 0xff0000; |
|
38 const TUint32 KGmask = 0x00ff00; |
|
39 const TUint32 KBmask = 0x0000ff; |
|
40 |
|
41 const TInt KBeginElementOffsetRatio = 66; |
|
42 |
|
43 // |
|
44 typedef TUint8 TAnimStatus; |
|
45 const TAnimStatus KAnimNotActive = 0; |
|
46 const TAnimStatus KAnimActive = 1; |
|
47 const TAnimStatus KAnimEnd = 2; |
|
48 const TAnimStatus KAnimFinished = 3; |
|
49 |
|
50 typedef TUint8 TAnimFill; |
|
51 const TAnimFill KAnimFillRemove = 0; |
|
52 const TAnimFill KAnimFillFreeze = 1; |
|
53 |
|
54 typedef TUint8 TAccumulate; |
|
55 const TAccumulate KAccumNone = 0; |
|
56 const TAccumulate KAccumSum = 1; |
|
57 |
|
58 typedef TUint8 TAdditive; |
|
59 const TAdditive KAdditiveReplace = 0; |
|
60 const TAdditive KAdditiveSum = 1; |
|
61 const TAdditive KAdditivePass = 2; |
|
62 |
|
63 typedef TUint8 TRestartMode; |
|
64 const TAccumulate KRestartAlways = 0; |
|
65 const TAccumulate KRestartWhenNotActive = 1; |
|
66 const TAccumulate KRestartNever = 2; |
|
67 |
|
68 |
|
69 const TUint16 KRepeatCountMax = 0xffff; |
|
70 |
|
71 class CSvgDocumentImpl; |
|
72 class MXmlElementOpt; |
|
73 |
|
74 |
|
75 /** |
|
76 * Class description goes here. |
|
77 * |
|
78 * @lib SVGEngine.lib |
|
79 * @since 1.0 |
|
80 */ |
|
81 class CSvgAnimationBase : public CSvgElementImpl |
|
82 { |
|
83 public: |
|
84 friend class CSvgAnimTimeController; |
|
85 // function used by decoder to set the begin time list. |
|
86 void SaveBeginTimeToList(TInt aTimeInMilliseconds); |
|
87 |
|
88 void AddEndTime( TInt32 aEndTime ); |
|
89 void SetBeginTimeList(RArray<TInt32>*& aList); |
|
90 |
|
91 void SetBeginTime(TInt32 aTime); |
|
92 |
|
93 void SetAbsoluteBeginTime(TInt32 aTime); |
|
94 |
|
95 void SetDurationTime(TInt32 aTime); |
|
96 |
|
97 TBool GetFromFlag(); |
|
98 TUint16 GetAttributeId(); |
|
99 |
|
100 void SetFromFlag(); |
|
101 void SetFromInt(TInt32 aValue); |
|
102 void SetFromFloat(TFloatFixPt aValue); |
|
103 void SetFromPathL(CGfxGeneralPath*& aPath); |
|
104 void SetFromViewBox(TGfxRectangle2D aValue); |
|
105 |
|
106 void SetToFlag(); |
|
107 void SetToInt(TInt32 aValue); |
|
108 void SetToFloat(TFloatFixPt aValue); |
|
109 void SetToPath(CGfxGeneralPath*& aPath); |
|
110 void SetToViewBox(TGfxRectangle2D aValue); |
|
111 |
|
112 void SetByFlag(); |
|
113 |
|
114 CSvgElementImpl*& GetTargetElem(); |
|
115 |
|
116 void SetAnimFreeze(); |
|
117 |
|
118 void SetValuesFlag(); |
|
119 void SetIntValuesArray( RArray<TInt32>*& aArray); |
|
120 void SetFloatValuesArray( RArray<TFloatFixPt>*& aArray); |
|
121 void SetPathValuesArray( RPointerArray<CGfxGeneralPath>*& aArray); |
|
122 void SetViewBoxValuesArray( RArray<TGfxRectangle2D>*& aArray); |
|
123 void ResetFloatValuesArray(); |
|
124 |
|
125 void SetRepeatCount(TReal32 aCount); |
|
126 void SetRepeatDuration(TUint32 aDur); |
|
127 |
|
128 void SetEndTime(TInt32 aTime); |
|
129 |
|
130 void SetRestartMode(TRestartMode aMode); |
|
131 void SetAccumulate(TAccumulate aValue); |
|
132 void SetAdditive(TAdditive aValue); |
|
133 |
|
134 void SetCalcMode(TAnimCalcMode aMode); |
|
135 |
|
136 void SetKeyTimeArray(RArray<CSvgAnimTimeController::TKeyTime>*& aArray); |
|
137 void SetAnimTimeArray(RArray<TUint32>*& aArray); |
|
138 void SetKeyTimeFlag(); |
|
139 CGfxGeneralPath* GetPathAttribute(TInt aAttributeId); |
|
140 void SetPathAttribute(TInt aAttributeId, CGfxGeneralPath* aPathHandle); |
|
141 |
|
142 /*Function added for Forward reference support*/ |
|
143 TInt SetRefElemById(const TDesC& aName); |
|
144 void CheckBeginTime(); |
|
145 // functions added for JSR-226 |
|
146 |
|
147 |
|
148 |
|
149 /** |
|
150 * Need method description |
|
151 * |
|
152 * @since 1.0 |
|
153 * @param |
|
154 * @return |
|
155 */ |
|
156 TInt GetAttributeFloat( const TInt aNameId, |
|
157 TFloatFixPt& aValue ); |
|
158 |
|
159 /** |
|
160 * Need method description |
|
161 * |
|
162 * @since 1.0 |
|
163 * @param |
|
164 * @return |
|
165 */ |
|
166 TInt SetAttributeFloatL( const TInt aNameId, |
|
167 const TFloatFixPt aValue ); |
|
168 |
|
169 /** |
|
170 * Need method description |
|
171 * |
|
172 * @since 1.0 |
|
173 * @param |
|
174 * @return |
|
175 */ |
|
176 TInt SetAttributeIntL( const TInt aNameId, |
|
177 const TInt32 aValue ); |
|
178 /** |
|
179 * Need method description |
|
180 * |
|
181 * @since 1.0 |
|
182 * @param |
|
183 * @return |
|
184 */ |
|
185 TInt GetAttributeIntL( const TInt aNameId, |
|
186 TInt32& aValue ); |
|
187 |
|
188 |
|
189 // End of functions for Decoder |
|
190 |
|
191 |
|
192 /** |
|
193 * Need method description |
|
194 * |
|
195 * @since 1.0 |
|
196 * @param |
|
197 * @return |
|
198 */ |
|
199 virtual ~CSvgAnimationBase(); |
|
200 |
|
201 class TEventListItem |
|
202 { |
|
203 public: |
|
204 |
|
205 TInt32 iTime; |
|
206 TInt32 iOffset; |
|
207 TReal32 iRepeatValue; |
|
208 CSvgElementImpl* iTargetElement; |
|
209 HBufC* iReferenceElemeId; |
|
210 TUint16 iAccessKeyCode; |
|
211 TUint16 iDummy; // Series 60 3.0 Byte Alignment |
|
212 TSvgEvent iEvent; |
|
213 |
|
214 }; |
|
215 CArrayFixFlat<TEventListItem>* iEventList; |
|
216 CArrayFixFlat<TEventListItem>* iEndTimeList; |
|
217 |
|
218 // for decoder |
|
219 void SetEventList(CArrayFixFlat<TEventListItem>*& aEventList); |
|
220 |
|
221 void SetEndTimeList(CArrayFixFlat<TEventListItem>*& aTimeList); |
|
222 TBool IsSelfDependentForBegin(); |
|
223 |
|
224 |
|
225 void SetFromValuesL(); |
|
226 // From SVG DOM / MSvgAnimationElement |
|
227 |
|
228 /** |
|
229 * Need method description |
|
230 * |
|
231 * @since 1.0 |
|
232 * @param |
|
233 * @return |
|
234 */ |
|
235 TUint32 SimpleDuration(); |
|
236 TUint32 CompleteDuration(); |
|
237 // From SVG DOM / MElementTimeControl |
|
238 |
|
239 /** |
|
240 * Need method description |
|
241 * |
|
242 * @since 1.0 |
|
243 * @param |
|
244 * @return |
|
245 */ |
|
246 TBool BeginElementL(); |
|
247 |
|
248 /** |
|
249 * Need method description |
|
250 * |
|
251 * @since 1.0 |
|
252 * @param |
|
253 * @return |
|
254 */ |
|
255 TBool BeginElementAtL( TFloatFixPt aOffset ); |
|
256 |
|
257 /** |
|
258 * Need method description |
|
259 * |
|
260 * @since 1.0 |
|
261 * @param |
|
262 * @return |
|
263 */ |
|
264 TBool EndElement(); |
|
265 |
|
266 /** |
|
267 * Need method description |
|
268 * |
|
269 * @since 1.0 |
|
270 * @param |
|
271 * @return |
|
272 */ |
|
273 TBool EndElementAt( TFloatFixPt aOffset ); |
|
274 |
|
275 |
|
276 // From MXmlElement API |
|
277 |
|
278 |
|
279 /** |
|
280 * Need method description |
|
281 * |
|
282 * @since 1.0 |
|
283 * @param |
|
284 * @return |
|
285 */ |
|
286 virtual TInt SetAttributeL( const TDesC& aName, |
|
287 const TDesC& aValue ); |
|
288 // From CSvgElementImpl |
|
289 |
|
290 |
|
291 /** |
|
292 * Need method description |
|
293 * |
|
294 * @since 1.0 |
|
295 * @param |
|
296 * @return |
|
297 */ |
|
298 MXmlElement* CloneL(MXmlElement* aParentElement); |
|
299 |
|
300 /** |
|
301 * Need method description |
|
302 * |
|
303 * @since 1.0 |
|
304 * @param |
|
305 * @return |
|
306 */ |
|
307 virtual void ReInitializeAnimation(); |
|
308 |
|
309 /** |
|
310 * Need method description |
|
311 * |
|
312 * @since 1.0 |
|
313 * @param |
|
314 * @return |
|
315 */ |
|
316 void GetAttrValueL(); |
|
317 |
|
318 /** |
|
319 * Need method description |
|
320 * |
|
321 * @since 1.0 |
|
322 * @param |
|
323 * @return |
|
324 */ |
|
325 void SetTarget( CSvgElementImpl* ); |
|
326 |
|
327 void SetAttributeId(const TUint16 aAtrId); |
|
328 |
|
329 // this is made a leaving function |
|
330 void ResetL(MSvgEvent* aEvent,CSvgAnimationBase* aElement); |
|
331 |
|
332 void SetAttributeType(const TUint8 aAtrType); |
|
333 virtual void SetOriginalValues_DOMReuse(); |
|
334 |
|
335 TAnimStatus GetAnimStatus(); |
|
336 void DeactivateAnimation(CSvgAnimationBase* aElement); |
|
337 void CheckForEndTimesAndFreezeL(CSvgAnimationBase* aElement); |
|
338 virtual void SetAccumulateValuesForSetMediaTime(); |
|
339 |
|
340 TInt32 GetAbsoluteBeginTime(); |
|
341 TInt32 GetEndTime(); |
|
342 void ResetAttrValueL(); |
|
343 |
|
344 /** |
|
345 * Need method description |
|
346 *returns if the animation element has fill value freeze or not |
|
347 * @since 3.2 |
|
348 * @param none |
|
349 * @return return True if animation element has fill value as freeze |
|
350 */ |
|
351 TBool IsFillFreeze(); |
|
352 |
|
353 void ResetTimes(); |
|
354 |
|
355 |
|
356 protected: |
|
357 |
|
358 /** |
|
359 * Need method description |
|
360 * |
|
361 * @since 1.0 |
|
362 * @param |
|
363 * @return |
|
364 */ |
|
365 CSvgAnimationBase( CSvgDocumentImpl* aDoc ); |
|
366 |
|
367 |
|
368 /** |
|
369 * Need method description |
|
370 * |
|
371 * @since 1.0 |
|
372 * @param |
|
373 * @return |
|
374 */ |
|
375 virtual void ConstructL( const TUint8 aElemID ); |
|
376 |
|
377 |
|
378 |
|
379 protected: |
|
380 |
|
381 /** |
|
382 * Need method description |
|
383 * |
|
384 * @since 1.0 |
|
385 * @param |
|
386 * @return |
|
387 */ |
|
388 static TFloatFixPt BlendFloat( TInt32 aAlpha, |
|
389 TFloatFixPt aV1, |
|
390 TFloatFixPt aV2 ); |
|
391 |
|
392 /** |
|
393 * Need method description |
|
394 * |
|
395 * @since 1.0 |
|
396 * @param |
|
397 * @return |
|
398 */ |
|
399 static TInt32 BlendInt( TInt32 aAlpha, |
|
400 TInt32 aV1, |
|
401 TInt32 aV2 ); |
|
402 |
|
403 /** |
|
404 * Need method description |
|
405 * |
|
406 * @since 1.0 |
|
407 * @param |
|
408 * @return |
|
409 */ |
|
410 static TUint32 BlendColor( TInt32 aAlpha, |
|
411 TUint32 aV1, |
|
412 TUint32 aV2 ); |
|
413 |
|
414 /** |
|
415 * Need method description |
|
416 * |
|
417 * @since 1.0 |
|
418 * @param |
|
419 * @return |
|
420 */ |
|
421 static TUint32 AddColor( TUint32 aV1, TUint32 aV2 ); |
|
422 |
|
423 |
|
424 /** |
|
425 * Need method description |
|
426 * |
|
427 * @since 1.0 |
|
428 * @param |
|
429 * @return |
|
430 */ |
|
431 static TUint32 SubtractColor( TUint32 aV1, |
|
432 TUint32 aV2 ); |
|
433 |
|
434 /** |
|
435 * Need method description |
|
436 * |
|
437 * @since 1.0 |
|
438 * @param |
|
439 * @return |
|
440 */ |
|
441 TBool ReceiveEventProcL( MSvgEvent* aEvent, |
|
442 CSvgAnimationBase* aAnimElement ); |
|
443 |
|
444 |
|
445 /** |
|
446 * Need method description |
|
447 * |
|
448 * @since 1.0 |
|
449 * @param |
|
450 * @return |
|
451 */ |
|
452 virtual TBool AnimProcL( MSvgTimerEvent* aEvent ) = 0; |
|
453 |
|
454 /** |
|
455 * Need method description |
|
456 * |
|
457 * @since 1.0 |
|
458 * @param |
|
459 * @return |
|
460 */ |
|
461 virtual void SetToOriginalL(); |
|
462 |
|
463 /** |
|
464 * Need method description |
|
465 * |
|
466 * @since 1.0 |
|
467 * @param |
|
468 * @return |
|
469 */ |
|
470 virtual void SetFillValueL(); |
|
471 |
|
472 /** |
|
473 * Need method description |
|
474 * |
|
475 * @since 1.0 |
|
476 * @param |
|
477 * @return |
|
478 */ |
|
479 virtual void SetToInitialValueL(); |
|
480 |
|
481 /** |
|
482 * Need method description |
|
483 * |
|
484 * @since 1.0 |
|
485 * @param |
|
486 * @return |
|
487 */ |
|
488 virtual void SetToEndValueL(); |
|
489 |
|
490 /** |
|
491 * Need method description |
|
492 * |
|
493 * @since 1.0 |
|
494 * @param |
|
495 * @return |
|
496 */ |
|
497 virtual void InitAnimationL(); |
|
498 |
|
499 /** |
|
500 * Need method description |
|
501 * |
|
502 * @since 1.0 |
|
503 * @param |
|
504 * @return |
|
505 */ |
|
506 virtual void ResetAnimationL() = 0; |
|
507 |
|
508 /** |
|
509 * Need method description |
|
510 * |
|
511 * @since 1.0 |
|
512 * @param |
|
513 * @return |
|
514 */ |
|
515 virtual void SetAccumulateValues(); |
|
516 |
|
517 |
|
518 /** |
|
519 * Need method description |
|
520 * |
|
521 * @since 1.0 |
|
522 * @param |
|
523 * @return |
|
524 */ |
|
525 TBool IsElementAttrs( const TDesC& aAttrName ); |
|
526 |
|
527 /** |
|
528 * Need method description |
|
529 * |
|
530 * @since 1.0 |
|
531 * @param |
|
532 * @return |
|
533 */ |
|
534 TBool IsPresentationAttrs( const TDesC& aAttrName ); |
|
535 |
|
536 public: |
|
537 /** |
|
538 * Need method description |
|
539 * |
|
540 * @since 1.0 |
|
541 * @param |
|
542 * @return |
|
543 */ |
|
544 void SetBeginByEventL( CSvgAnimationBase* aAnimElement, |
|
545 TInt32 aOffset, TBool aAddTime = EFalse); |
|
546 |
|
547 /** |
|
548 * Need method description |
|
549 * |
|
550 * @since 1.0 |
|
551 * @param |
|
552 * @return |
|
553 */ |
|
554 void SetEndByEvent( CSvgAnimationBase* aAnimElement, |
|
555 TInt32 aOffset ); |
|
556 |
|
557 void StoreRepeatId( const TDesC& aValue, TBool RepeatWasInBeginAtt ); |
|
558 |
|
559 void NotifyAnimationsRepeatingOnThisOneL( const TDesC* aId ); |
|
560 |
|
561 protected: |
|
562 /** |
|
563 * Need method description |
|
564 * |
|
565 * @since 1.0 |
|
566 * @param |
|
567 * @return |
|
568 */ |
|
569 TInt32 GetNumberOfEvents(const TDesC& aValue); |
|
570 |
|
571 /** |
|
572 * Need method description |
|
573 * |
|
574 * @since 1.0 |
|
575 * @param |
|
576 * @return |
|
577 */ |
|
578 TInt32 Duration(); |
|
579 |
|
580 void CopyL(CSvgAnimationBase* aAnimationBase); |
|
581 |
|
582 |
|
583 // to parse a viewBox attribute value. |
|
584 TBool ParseViewBoxValue(const TDesC& aValue, TGfxRectangle2D& aRect); |
|
585 |
|
586 private: |
|
587 /** |
|
588 * This function computes the distance between colours for the purpose |
|
589 * of animateColor element. Colours are treated as a 3D |
|
590 * point with r, g, b acting as axes. It modifies the iValuesFloat |
|
591 * array and each index contains the cummulative length(from start |
|
592 * colour) of the segment with same index |
|
593 * |
|
594 * @since s60 v3.1 |
|
595 * @param none. |
|
596 * @return none. |
|
597 */ |
|
598 void FindColorDistanceL(); |
|
599 |
|
600 public: |
|
601 TAnimStatus iAnimStatus; // before start, during animation, or end |
|
602 |
|
603 HBufC* iRepeatId; |
|
604 TBool iRepeatInBegin; |
|
605 |
|
606 protected: |
|
607 |
|
608 // basic animation attributes |
|
609 CSvgAnimTimeController* iAnimTime; |
|
610 CSvgElementImpl* iTargetElement; // default is parent element |
|
611 |
|
612 CGfxGeneralPath* iEndPath; |
|
613 RArray<TFloatFixPt>* iValuesFloat; |
|
614 CGfxGeneralPath* iOrgPath; |
|
615 CGfxGeneralPath* iFromPath; |
|
616 CGfxGeneralPath* iToPath; |
|
617 CGfxGeneralPath* iOrgFromPath; |
|
618 RPointerArray<CGfxGeneralPath>* iValuesPath; |
|
619 RArray<TInt32>* iValuesInt; |
|
620 |
|
621 TInt32 iEndOffset; |
|
622 TReal32 iRepeatCount; |
|
623 |
|
624 TReal32 iRepeatEndValue; |
|
625 |
|
626 TInt32 iAbsoluteBeginTime; |
|
627 |
|
628 // properties that will be modified over time |
|
629 TInt32 iPropInt; |
|
630 TFloatFixPt iPropFloat; |
|
631 |
|
632 // origianl value and animation value |
|
633 |
|
634 TInt32 iAttributeFlag; |
|
635 TInt32 iEndInt; |
|
636 |
|
637 TInt32 iOrgInt; |
|
638 TInt32 iFromInt; |
|
639 TInt32 iToInt; |
|
640 TInt32 iOrgFromInt; |
|
641 |
|
642 // for DOM Reuse |
|
643 TBool iIsBeginSet; |
|
644 |
|
645 TFloatFixPt iOrgFloat; |
|
646 TFloatFixPt iFromFloat; |
|
647 TFloatFixPt iToFloat; |
|
648 TFloatFixPt iOrgFromFloat; |
|
649 TFloatFixPt iEndFloat; |
|
650 |
|
651 //viewBox Animation |
|
652 |
|
653 TGfxRectangle2D iOrgViewBox; |
|
654 TGfxRectangle2D iFromViewBox; |
|
655 TGfxRectangle2D iToViewBox; |
|
656 TGfxRectangle2D iOrgFromViewBox; |
|
657 RArray<TGfxRectangle2D>* iValuesViewBox; |
|
658 TGfxRectangle2D iEndViewBox; |
|
659 //////// |
|
660 |
|
661 TInt iBeginTimeIndex; |
|
662 |
|
663 |
|
664 |
|
665 // TUint16 iEndAccessKeyCode; |
|
666 |
|
667 TUint16 iCurrentRepeatCount; |
|
668 // target attribute |
|
669 TUint16 iAttrId; |
|
670 TUint16 iDataType; |
|
671 |
|
672 /* CSvgElementImpl* iEndSyncElementId;*/ |
|
673 |
|
674 |
|
675 |
|
676 TUint8 iInitDone; |
|
677 TUint8 iTargetSet; |
|
678 TUint8 iNoFrom; |
|
679 TUint8 iHaveTo; |
|
680 TUint8 iHaveBy; |
|
681 TUint8 iHaveValues; |
|
682 |
|
683 |
|
684 |
|
685 /* TSvgEvent iEndReferenceEvent;*/ |
|
686 |
|
687 |
|
688 TAnimFill iFill; |
|
689 TUint8 iHadBegun; |
|
690 TRestartMode iAnimRestart; |
|
691 TAccumulate iAccumulate; |
|
692 TAdditive iAdditive; |
|
693 TAdditive iAdditiveOrg; |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 //deleted by memory manager so dont do it yourself |
|
700 CPaintCssValueImpl* iFromPaint; |
|
701 CPaintCssValueImpl* iToPaint; |
|
702 |
|
703 TUint8 iOverrideTime; |
|
704 |
|
705 |
|
706 TUint8 iRepeatCountSet; |
|
707 |
|
708 TBool iDoFreeze; |
|
709 |
|
710 //DOM Reusage |
|
711 |
|
712 TBool iCheckFirstAnim; |
|
713 |
|
714 |
|
715 |
|
716 TBool iKeyTimesPresent; |
|
717 |
|
718 // these are kept only up to the loading time. after that this memory is freed. |
|
719 |
|
720 |
|
721 /*HBufC* iEndReferenceElemeId;*/ |
|
722 TBool iIsUserSeek; |
|
723 TInt iEndTimeIndex; |
|
724 // TBool iHasEnded; |
|
725 |
|
726 TBool iIsEndEventSent; |
|
727 TInt iNegativeBeginTime; // Himanshu: stores negative begin value; |
|
728 static const TInt KIndefiniteAnimationDuration = 2147483647; |
|
729 }; |
|
730 |
|
731 |
|
732 #endif /* _INC_CSvgAnimationBase_ */ |