46
|
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 |
#include <e32math.h>
|
|
23 |
|
|
24 |
#include "SVGAnimateMotionElementImpl.h"
|
|
25 |
|
|
26 |
#include "SVGElementImpl.h"
|
|
27 |
#include "SVGDocumentImpl.h"
|
|
28 |
#include "SVGSchemaData.h"
|
|
29 |
|
|
30 |
#include "GfxGeneralPath.h"
|
|
31 |
#include "GfxFlatteningPathIterator.h"
|
|
32 |
#include "SVGPathDataParser.h"
|
|
33 |
#include "SVGPointLexer.h"
|
|
34 |
#include "SVGStringTokenizer.h"
|
|
35 |
|
|
36 |
_LIT( AUTO, "auto" );
|
|
37 |
_LIT( AUTOREVERSE, "auto-reverse" );
|
|
38 |
_LIT( SEMICOLON, ";" );
|
|
39 |
|
|
40 |
// *******************************************************
|
|
41 |
// Constructor/deconstructor
|
|
42 |
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
CSvgAnimateMotionElementImpl* CSvgAnimateMotionElementImpl::NewL( const TUint8 aElemID,
|
|
47 |
CSvgDocumentImpl* aDoc )
|
|
48 |
{
|
|
49 |
CSvgAnimateMotionElementImpl* self = new ( ELeave )
|
|
50 |
CSvgAnimateMotionElementImpl( aDoc );
|
|
51 |
CleanupStack::PushL( self );
|
|
52 |
self->ConstructL( aElemID );
|
|
53 |
CleanupStack::Pop();
|
|
54 |
|
|
55 |
return self;
|
|
56 |
}
|
|
57 |
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
CSvgAnimateMotionElementImpl* CSvgAnimateMotionElementImpl::NewLC( const TUint8 aElemID,
|
|
62 |
CSvgDocumentImpl* aDoc )
|
|
63 |
{
|
|
64 |
CSvgAnimateMotionElementImpl* self = new ( ELeave )
|
|
65 |
CSvgAnimateMotionElementImpl( aDoc );
|
|
66 |
CleanupStack::PushL( self );
|
|
67 |
self->ConstructL( aElemID );
|
|
68 |
|
|
69 |
return self;
|
|
70 |
}
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
void CSvgAnimateMotionElementImpl::ConstructL( const TUint8 aElemID )
|
|
75 |
{
|
|
76 |
CSvgAnimationBase::ConstructL( aElemID );
|
|
77 |
|
|
78 |
iMotionPath = CGfxGeneralPath::NewL();
|
|
79 |
iAnimTime->SetCalMode( KAnimCalcModePaced ); // animateMotion has differenr default
|
|
80 |
iReqAttrFlag=KSVG_AMINATEMO_ELEMFLAG;
|
|
81 |
}
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
CSvgAnimateMotionElementImpl::~CSvgAnimateMotionElementImpl()
|
|
89 |
{
|
|
90 |
if ( iMotionPath )
|
|
91 |
{
|
|
92 |
delete iMotionPath;
|
|
93 |
iMotionPath = NULL;
|
|
94 |
}
|
|
95 |
if ( iPathIterator )
|
|
96 |
{
|
|
97 |
delete iPathIterator;
|
|
98 |
iPathIterator = NULL;
|
|
99 |
}
|
|
100 |
}
|
|
101 |
|
|
102 |
// *******************************************************
|
|
103 |
// Private
|
|
104 |
|
|
105 |
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
CSvgAnimateMotionElementImpl::CSvgAnimateMotionElementImpl( CSvgDocumentImpl* aDoc ) : CSvgAnimationBase( aDoc ),
|
|
110 |
iCurrentSeg( 0,
|
|
111 |
0,
|
|
112 |
0,
|
|
113 |
0 ),
|
|
114 |
//iIsValues( EFalse ),
|
|
115 |
iPrevRotate(0)
|
|
116 |
|
|
117 |
{
|
|
118 |
iAttrId = KAtrTransform;
|
|
119 |
}
|
|
120 |
|
|
121 |
// *******************************************************
|
|
122 |
// From SVG DOM
|
|
123 |
|
|
124 |
|
|
125 |
// *******************************************************
|
|
126 |
// SVG Implementation
|
|
127 |
|
|
128 |
|
|
129 |
// *******************************************************
|
|
130 |
// From MSvgEventReceiver
|
|
131 |
// ---------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
// ---------------------------------------------------------------------------
|
|
134 |
void CSvgAnimateMotionElementImpl::ResetReferenceElementL()
|
|
135 |
{
|
|
136 |
if(iTargetElement != NULL )
|
|
137 |
{
|
|
138 |
if( ((iTargetElement->iAnimateAttrSet == NULL) ||
|
|
139 |
(iTargetElement->iAnimateAttrSet->Find(iAttrId) == KErrNotFound) ) )
|
|
140 |
{
|
|
141 |
if ( iInitDone )
|
|
142 |
{
|
|
143 |
iCheckFirstAnim= ETrue;
|
|
144 |
SetToOriginalL();
|
|
145 |
if( !(iTargetElement->iAnimateAttrSet) )
|
|
146 |
{
|
|
147 |
iTargetElement->iAnimateAttrSet = new (ELeave) RArray<TUint32>(1);
|
|
148 |
}
|
|
149 |
iTargetElement->iAnimateAttrSet->AppendL((TUint32)iAttrId);
|
|
150 |
}
|
|
151 |
}
|
|
152 |
}
|
|
153 |
}
|
|
154 |
// *******************************************************
|
|
155 |
// From MXmlElement
|
|
156 |
|
|
157 |
// ---------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
// ---------------------------------------------------------------------------
|
|
160 |
TInt CSvgAnimateMotionElementImpl::SetAttributeL( const TDesC& aName,
|
|
161 |
const TDesC& aValue )
|
|
162 |
{
|
|
163 |
_LIT( KTmpAttrName, "attributeName" );
|
|
164 |
_LIT( KTmpPath, "path" );
|
|
165 |
_LIT( KTmpRotate, "rotate" );
|
|
166 |
_LIT( KTmpFrom, "from" );
|
|
167 |
_LIT( KTmpTo, "to" );
|
|
168 |
_LIT( KTmpValues, "values" );
|
|
169 |
_LIT( KTmpBy, "by" );
|
|
170 |
|
|
171 |
|
|
172 |
if ( aName == KTmpAttrName )
|
|
173 |
{
|
|
174 |
// Ignore 'attributeName' attribute
|
|
175 |
}
|
|
176 |
else if ( aName == KTmpPath )
|
|
177 |
{
|
|
178 |
iMotionPath->Reset();
|
|
179 |
TSvgPathDataParser::ParsePathData( aValue, iMotionPath );
|
|
180 |
|
|
181 |
CGfxPathIterator* itr;
|
|
182 |
TFloatFixPt tmpcoords[6];
|
|
183 |
iMotionPath->GetPathIteratorL( &iIdentTransform, itr );
|
|
184 |
CleanupStack::PushL( itr );
|
|
185 |
|
|
186 |
while ( !itr->IsDone() )
|
|
187 |
{
|
|
188 |
switch ( itr->CurrentSegment( tmpcoords ) )
|
|
189 |
{
|
|
190 |
case EGfxSegMoveTo:
|
|
191 |
iToFloatX = tmpcoords[0];
|
|
192 |
iToFloatY = tmpcoords[1];
|
|
193 |
break;
|
|
194 |
case EGfxSegLineTo:
|
|
195 |
iToFloatX = tmpcoords[0];
|
|
196 |
iToFloatY = tmpcoords[1];
|
|
197 |
break;
|
|
198 |
case EGfxSegQuadTo:
|
|
199 |
iToFloatX = tmpcoords[2];
|
|
200 |
iToFloatY = tmpcoords[3];
|
|
201 |
break;
|
|
202 |
case EGfxSegCubicTo:
|
|
203 |
iToFloatX = tmpcoords[4];
|
|
204 |
iToFloatY = tmpcoords[5];
|
|
205 |
break;
|
|
206 |
case EGfxSegClose:
|
|
207 |
iToFloatX = tmpcoords[0]; //.
|
|
208 |
iToFloatY = tmpcoords[1];
|
|
209 |
}
|
|
210 |
|
|
211 |
itr->NextL();
|
|
212 |
}
|
|
213 |
iPathSeen = ETrue;
|
|
214 |
CleanupStack::PopAndDestroy();
|
|
215 |
if(iReqAttrFlag == KAtrSVGAmo && (iMotionPath->PointTypeArray())->Count() != 0 )
|
|
216 |
{
|
|
217 |
iReqAttrFlag = 0;
|
|
218 |
}
|
|
219 |
}
|
|
220 |
else if ( aName == KTmpRotate )
|
|
221 |
{
|
|
222 |
if ( aValue == AUTO )
|
|
223 |
{
|
|
224 |
iAnimMotionRotate = KAnimMotionRotateAuto;
|
|
225 |
}
|
|
226 |
else if ( aValue == AUTOREVERSE )
|
|
227 |
{
|
|
228 |
iAnimMotionRotate = KAnimMotionRotateAutoReverse;
|
|
229 |
}
|
|
230 |
else
|
|
231 |
{
|
|
232 |
TLex lString ( aValue );
|
|
233 |
if (lString.Val( iAnimMotionRotate )!= KErrNone)
|
|
234 |
{
|
|
235 |
iAnimMotionRotate= 0;
|
|
236 |
}
|
|
237 |
if ( iAnimMotionRotate < 0 )
|
|
238 |
{
|
|
239 |
// Note: A problem may occur if the value is less than -3600
|
|
240 |
iAnimMotionRotate += 3600;
|
|
241 |
}
|
|
242 |
iAnimMotionRotate %= 360;
|
|
243 |
}
|
|
244 |
}
|
|
245 |
else if ( aName == KTmpFrom )
|
|
246 |
{
|
|
247 |
if ( ! iHaveValues )
|
|
248 |
{
|
|
249 |
iNoFrom = EFalse;
|
|
250 |
iMotionPath->Reset();
|
|
251 |
TSvgPointLexer svgplex ( aValue );
|
|
252 |
TChar com;
|
|
253 |
TFloatFixPt x, y;
|
|
254 |
|
|
255 |
svgplex.GetNextPoint( com, x, y );
|
|
256 |
svgplex.Cleanup();
|
|
257 |
|
|
258 |
iOrgFromFloatX = iFromFloatX = x;
|
|
259 |
iOrgFromFloatY = iFromFloatY = y;
|
|
260 |
iMotionPath->MoveToL( x, y, ETrue ); // 'from' -> MoveTo
|
|
261 |
}
|
|
262 |
|
|
263 |
if(iReqAttrFlag == KAtrSVGAmo)
|
|
264 |
{
|
|
265 |
iReqAttrFlag = KAtrToBy;
|
|
266 |
}
|
|
267 |
else
|
|
268 |
{
|
|
269 |
iReqAttrFlag = 0;
|
|
270 |
}
|
|
271 |
}
|
|
272 |
else if ( aName == KTmpBy )
|
|
273 |
{
|
|
274 |
if ( !iHaveTo )
|
|
275 |
{
|
|
276 |
iHaveBy = ETrue;
|
|
277 |
if(iReqAttrFlag == KAtrSVGAmo || iReqAttrFlag == KAtrToBy)
|
|
278 |
{
|
|
279 |
iReqAttrFlag = 0;
|
|
280 |
}
|
|
281 |
if ( !iHaveValues )
|
|
282 |
{
|
|
283 |
TSvgPointLexer svgplex ( aValue );
|
|
284 |
TChar com;
|
|
285 |
TFloatFixPt x, y;
|
|
286 |
|
|
287 |
svgplex.GetNextPoint( com, x, y );
|
|
288 |
svgplex.Cleanup();
|
|
289 |
|
|
290 |
if ( iNoFrom )
|
|
291 |
{
|
|
292 |
iToFloatX = x;
|
|
293 |
iToFloatY = y;
|
|
294 |
iNoFrom = EFalse;
|
|
295 |
// this is taken from animate transforms.
|
|
296 |
iAdditive = KAdditiveSum;
|
|
297 |
iAdditiveOrg = KAdditiveSum;
|
|
298 |
}
|
|
299 |
else
|
|
300 |
{
|
|
301 |
iToFloatX = iFromFloatX + x;
|
|
302 |
iToFloatY = iFromFloatY + y;
|
|
303 |
}
|
|
304 |
|
|
305 |
CGfxPathIterator* itr;
|
|
306 |
iMotionPath->GetPathIteratorL( &iIdentTransform, itr );
|
|
307 |
CleanupStack::PushL( itr );
|
|
308 |
|
|
309 |
if ( itr->IsDone() )
|
|
310 |
{
|
|
311 |
TFloatFixPt lZero;
|
|
312 |
// If the animation path is empty, fill with default value.
|
|
313 |
iMotionPath->MoveToL( lZero, lZero, ETrue );
|
|
314 |
}
|
|
315 |
CleanupStack::PopAndDestroy( 1 ); // itr
|
|
316 |
iMotionPath->LineToL( x, y, ETrue ); // 'by' -> LineTo
|
|
317 |
}
|
|
318 |
}
|
|
319 |
|
|
320 |
if(iReqAttrFlag == KAtrSVGAmo && (iMotionPath->PointTypeArray())->Count() != 0 )
|
|
321 |
{
|
|
322 |
iReqAttrFlag = 0;
|
|
323 |
}
|
|
324 |
}
|
|
325 |
else if ( aName == KTmpTo )
|
|
326 |
{
|
|
327 |
if ( !iHaveValues )
|
|
328 |
{
|
|
329 |
|
|
330 |
// this is taken from animate transforms.
|
|
331 |
if ( iNoFrom )
|
|
332 |
{
|
|
333 |
iAdditive = KAdditiveSum;
|
|
334 |
iAdditiveOrg = KAdditiveSum;
|
|
335 |
}
|
|
336 |
TSvgPointLexer svgplex ( aValue );
|
|
337 |
TChar com;
|
|
338 |
TFloatFixPt x, y;
|
|
339 |
iHaveTo = ETrue;
|
|
340 |
svgplex.GetNextPoint( com, x, y );
|
|
341 |
svgplex.Cleanup();
|
|
342 |
|
|
343 |
iToFloatX = x;
|
|
344 |
iToFloatY = y;
|
|
345 |
CGfxPathIterator* itr;
|
|
346 |
iMotionPath->GetPathIteratorL( &iIdentTransform, itr );
|
|
347 |
CleanupStack::PushL( itr );
|
|
348 |
if ( itr->IsDone() )
|
|
349 |
{
|
|
350 |
TFloatFixPt lZero;
|
|
351 |
// If the animation path is empty, fill with default value.
|
|
352 |
// should this default be zero or object position
|
|
353 |
iMotionPath->MoveToL( lZero, lZero, ETrue );
|
|
354 |
}
|
|
355 |
CleanupStack::PopAndDestroy( 1 ); // itr
|
|
356 |
iMotionPath->LineToL( x, y, ETrue ); // 'to' -> LineTo
|
|
357 |
}
|
|
358 |
|
|
359 |
if(iReqAttrFlag == KAtrSVGAmo || iReqAttrFlag == KAtrToBy)
|
|
360 |
{
|
|
361 |
iReqAttrFlag = 0;
|
|
362 |
}
|
|
363 |
}
|
|
364 |
else if ( aName == KTmpValues )
|
|
365 |
{
|
|
366 |
// Process only if Path values have not been seen
|
|
367 |
if ( !iPathSeen )
|
|
368 |
{
|
|
369 |
TStringTokenizer tkn ( aValue, SEMICOLON );
|
|
370 |
TBool first = ETrue;
|
|
371 |
iHaveValues = ETrue;
|
|
372 |
iNoFrom = EFalse; //.
|
|
373 |
iMotionPath->Reset();
|
|
374 |
while ( tkn.HasMoreTokens() ) // 'values' is a set of coordinates
|
|
375 |
{
|
|
376 |
TSvgPointLexer svgplex ( tkn.NextToken() );
|
|
377 |
TChar com;
|
|
378 |
TFloatFixPt x, y;
|
|
379 |
svgplex.GetNextPoint( com, x, y );
|
|
380 |
svgplex.Cleanup();
|
|
381 |
|
|
382 |
if ( first )
|
|
383 |
{
|
|
384 |
iMotionPath->MoveToL( x, y, ETrue );
|
|
385 |
iOrgFromFloatX = iFromFloatX = x; //.
|
|
386 |
iOrgFromFloatY = iFromFloatY = y;
|
|
387 |
first = EFalse;
|
|
388 |
}
|
|
389 |
else
|
|
390 |
{
|
|
391 |
iMotionPath->LineToL( x, y, ETrue );
|
|
392 |
}
|
|
393 |
iToFloatX = x; //.
|
|
394 |
iToFloatY = y;
|
|
395 |
}
|
|
396 |
|
|
397 |
if(iReqAttrFlag == KAtrSVGAmo || iReqAttrFlag == KAtrToBy)
|
|
398 |
{
|
|
399 |
iReqAttrFlag = 0;
|
|
400 |
}
|
|
401 |
}
|
|
402 |
}
|
|
403 |
else
|
|
404 |
{
|
|
405 |
return CSvgAnimationBase::SetAttributeL( aName, aValue );
|
|
406 |
}
|
|
407 |
|
|
408 |
return KErrNone;
|
|
409 |
}
|
|
410 |
|
|
411 |
// ---------------------------------------------------------------------------
|
|
412 |
// From MSvgEventReceiver
|
|
413 |
// ---------------------------------------------------------------------------
|
|
414 |
TBool CSvgAnimateMotionElementImpl::ReceiveEventL( MSvgEvent* aEvent )
|
|
415 |
{
|
|
416 |
return CSvgAnimationBase::ReceiveEventProcL( aEvent, this );
|
|
417 |
}
|
|
418 |
|
|
419 |
// ---------------------------------------------------------------------------
|
|
420 |
// From CSvgAnimationBase
|
|
421 |
// ---------------------------------------------------------------------------
|
|
422 |
//
|
|
423 |
TBool CSvgAnimateMotionElementImpl::AnimProcL( MSvgTimerEvent* aEvent )
|
|
424 |
|
|
425 |
{
|
|
426 |
|
|
427 |
|
|
428 |
if((iAnimStatus != KAnimActive) || iDoFreeze)
|
|
429 |
{
|
|
430 |
if(iFill== KAnimFillFreeze && !iDoFreeze && iAnimStatus == KAnimFinished)
|
|
431 |
{
|
|
432 |
// calculate the freeze value.
|
|
433 |
}
|
|
434 |
else
|
|
435 |
{
|
|
436 |
CSvgAnimationBase::CheckForEndTimesAndFreezeL(this);
|
|
437 |
return EFalse;
|
|
438 |
}
|
|
439 |
}
|
|
440 |
if ( ( iPathIterator == NULL ) || ( iPathIterator->IsDone() ) )
|
|
441 |
{
|
|
442 |
return EFalse; // Already end of path. Nothing to do any more.
|
|
443 |
}
|
|
444 |
|
|
445 |
TFloatFixPt nextPos, diff;
|
|
446 |
TFloatFixPt zero ( 0 );
|
|
447 |
|
|
448 |
// Get next position in [0..255] range
|
|
449 |
TInt32 animatetime; // Not used...
|
|
450 |
TInt32 valix, subanimtime;
|
|
451 |
iAnimTime->GetAnimTime( (aEvent->Time()-iNegativeBeginTime), animatetime, valix, subanimtime );
|
|
452 |
|
|
453 |
// Get next position in actual length
|
|
454 |
TFloatFixPt v2;
|
|
455 |
if ( valix >= iValuesFloat->Count() - 1 )
|
|
456 |
{
|
|
457 |
valix= iValuesFloat->Count() - 1;
|
|
458 |
v2 = ( *iValuesFloat )[valix];
|
|
459 |
}
|
|
460 |
else
|
|
461 |
{
|
|
462 |
v2 = ( *iValuesFloat )[valix + 1];
|
|
463 |
}
|
|
464 |
nextPos = CSvgAnimationBase::BlendFloat( subanimtime,
|
|
465 |
( *iValuesFloat )[valix],
|
|
466 |
v2 );
|
|
467 |
|
|
468 |
diff = nextPos - iCurrentPos;
|
|
469 |
TGfxSegType SegType;
|
|
470 |
|
|
471 |
while ( iSubPos + diff > iSubLength && !iPathIterator->IsDone() )
|
|
472 |
{
|
|
473 |
if ( iSubLength < zero )
|
|
474 |
{
|
|
475 |
iSubLength = zero;
|
|
476 |
}
|
|
477 |
TFloatFixPt tmpcoords[6];
|
|
478 |
diff -= iSubLength - iSubPos;
|
|
479 |
iPathIterator->NextL();
|
|
480 |
SegType = iPathIterator->CurrentSegment( tmpcoords );
|
|
481 |
iCurrentSeg.iX1 = iCurrentSeg.iX2;
|
|
482 |
iCurrentSeg.iY1 = iCurrentSeg.iY2;
|
|
483 |
iCurrentSeg.iX2 = tmpcoords[0];
|
|
484 |
iCurrentSeg.iY2 = tmpcoords[1];
|
|
485 |
|
|
486 |
if ( SegType == EGfxSegMoveTo )
|
|
487 |
{
|
|
488 |
iSubLength = zero;
|
|
489 |
}
|
|
490 |
else
|
|
491 |
{
|
|
492 |
iSubLength = iCurrentSeg.Length();
|
|
493 |
}
|
|
494 |
|
|
495 |
iSubPos = zero;
|
|
496 |
}
|
|
497 |
iSubPos += diff;
|
|
498 |
|
|
499 |
// Calcualate or set rotation
|
|
500 |
TReal32 rot = 0.0f;
|
|
501 |
if ( iAnimMotionRotate < 0 )
|
|
502 |
{
|
|
503 |
TFloatFixPt dx = iCurrentSeg.iX1 - iCurrentSeg.iX2;
|
|
504 |
if ( dx == zero )
|
|
505 |
{
|
|
506 |
|
|
507 |
if( iAnimMotionRotate == KAnimMotionRotateAuto )
|
|
508 |
{
|
|
509 |
if(iPrevRotate == 0 || iPrevRotate >= 3.1415926f)
|
|
510 |
rot = 3.1415926f + 1.5707963f;
|
|
511 |
else
|
|
512 |
rot = 1.5707963f; // pi/2
|
|
513 |
}
|
|
514 |
else // AutoReverse
|
|
515 |
{
|
|
516 |
if(iPrevRotate >= 0 )
|
|
517 |
rot = 1.5707963f;
|
|
518 |
else
|
|
519 |
rot = -1.5707963f;
|
|
520 |
|
|
521 |
}
|
|
522 |
}
|
|
523 |
else
|
|
524 |
{
|
|
525 |
TReal atan;
|
|
526 |
Math::ATan( atan, ( TReal32 )( iCurrentSeg.iY1 - iCurrentSeg.iY2 ), ( TReal32 )dx );
|
|
527 |
rot = ( TReal32 ) atan;
|
|
528 |
if ( iAnimMotionRotate == KAnimMotionRotateAuto )
|
|
529 |
{
|
|
530 |
rot += 3.1415926f;
|
|
531 |
}
|
|
532 |
|
|
533 |
}
|
|
534 |
iPrevRotate = rot;
|
|
535 |
}
|
|
536 |
else
|
|
537 |
{
|
|
538 |
rot = iAnimMotionRotate * 3.1415926f / 180.0f;
|
|
539 |
}
|
|
540 |
|
|
541 |
// Create transform
|
|
542 |
MSvgTransformList* trList;
|
|
543 |
TInt32 matrixIndex;
|
|
544 |
iTargetElement->GetTransform( trList );
|
|
545 |
iTargetElement->GetAttributeIntL( KAtrAnimMotionMatrixIndex, matrixIndex );
|
|
546 |
// new position
|
|
547 |
TInt32 subalpha;
|
|
548 |
if ( iSubLength == zero )
|
|
549 |
{
|
|
550 |
subalpha = 0;
|
|
551 |
}
|
|
552 |
else
|
|
553 |
{
|
|
554 |
subalpha = ( TInt32 ) ( iSubPos / iSubLength * TFloatFixPt( 255 ) ); // need to make sure value does not exceed 0x7fff
|
|
555 |
}
|
|
556 |
if ( subalpha > 0xff )
|
|
557 |
{
|
|
558 |
subalpha = 0xff;
|
|
559 |
}
|
|
560 |
if ( subalpha < 0 )
|
|
561 |
{
|
|
562 |
subalpha = 0;
|
|
563 |
}
|
|
564 |
|
|
565 |
TFloatFixPt trnsx, trnsy;
|
|
566 |
trnsx = CSvgAnimationBase::BlendFloat( subalpha,
|
|
567 |
iCurrentSeg.iX1,
|
|
568 |
iCurrentSeg.iX2 );
|
|
569 |
trnsy = CSvgAnimationBase::BlendFloat( subalpha,
|
|
570 |
iCurrentSeg.iY1,
|
|
571 |
iCurrentSeg.iY2 );
|
|
572 |
|
|
573 |
TGfxAffineTransform deltaTr = TGfxAffineTransform::GetTranslateInstance( trnsx,
|
|
574 |
trnsy );
|
|
575 |
if ( rot != 0.0f )
|
|
576 |
{
|
|
577 |
deltaTr.Rotate( rot );
|
|
578 |
}
|
|
579 |
|
|
580 |
// Set transform
|
|
581 |
|
|
582 |
if ( iAccumulate == KAccumSum ) //.
|
|
583 |
{
|
|
584 |
TGfxAffineTransform accumulateDeltaTr = TGfxAffineTransform::GetTranslateInstance( iFromFloatX - iOrgFromFloatX, iFromFloatY - iOrgFromFloatY);
|
|
585 |
deltaTr.Concatenate( accumulateDeltaTr );
|
|
586 |
}
|
|
587 |
|
|
588 |
if ( iAdditive == KAdditiveSum ) //.
|
|
589 |
{
|
|
590 |
TGfxAffineTransform curMatrix = trList->GetItem( matrixIndex );
|
|
591 |
curMatrix.Concatenate( deltaTr );
|
|
592 |
trList->ReplaceItem( curMatrix, matrixIndex );
|
|
593 |
}
|
|
594 |
else
|
|
595 |
{
|
|
596 |
trList->ReplaceItem( deltaTr, matrixIndex );
|
|
597 |
|
|
598 |
}
|
|
599 |
if(iFill== KAnimFillFreeze)
|
|
600 |
{
|
|
601 |
iEndMatrix = deltaTr;
|
|
602 |
}
|
|
603 |
// update current position
|
|
604 |
iCurrentPos = nextPos;
|
|
605 |
|
|
606 |
CSvgAnimationBase::CheckForEndTimesAndFreezeL(this);
|
|
607 |
return ETrue;
|
|
608 |
}
|
|
609 |
|
|
610 |
|
|
611 |
//
|
|
612 |
// ---------------------------------------------------------------------------
|
|
613 |
//
|
|
614 |
// ---------------------------------------------------------------------------
|
|
615 |
void CSvgAnimateMotionElementImpl::ResetAnimationL()
|
|
616 |
{
|
|
617 |
TFloatFixPt tmpcoords[6];
|
|
618 |
|
|
619 |
// Path iterator
|
|
620 |
if ( iPathIterator )
|
|
621 |
{
|
|
622 |
delete iPathIterator;
|
|
623 |
iPathIterator = NULL;
|
|
624 |
}
|
|
625 |
|
|
626 |
iPathIterator = CGfxFlatteningPathIterator::NewL( iMotionPath,
|
|
627 |
&iIdentTransform,
|
|
628 |
3 );
|
|
629 |
|
|
630 |
|
|
631 |
// path length
|
|
632 |
iPathIterator->CurrentSegment( tmpcoords );
|
|
633 |
iCurrentSeg.iX1 = tmpcoords[0];
|
|
634 |
iCurrentSeg.iY1 = tmpcoords[1];
|
|
635 |
iCurrentSeg.iX2 = tmpcoords[0];
|
|
636 |
iCurrentSeg.iY2 = tmpcoords[1];
|
|
637 |
|
|
638 |
iSubLength = -1;
|
|
639 |
iCurrentPos = 0;
|
|
640 |
iSubPos = 0;
|
|
641 |
}
|
|
642 |
|
|
643 |
// ---------------------------------------------------------------------------
|
|
644 |
//
|
|
645 |
// ---------------------------------------------------------------------------
|
|
646 |
void CSvgAnimateMotionElementImpl::InitAnimationL()
|
|
647 |
{
|
|
648 |
if(!iTargetElement)
|
|
649 |
{
|
|
650 |
// if target element is not found then remove it.
|
|
651 |
((CSvgDocumentImpl*)iOwnerDocument)->RemoveFromEventReceiverList(this);
|
|
652 |
((CSvgDocumentImpl*)iOwnerDocument)->Engine()->UpdatePresentation(1);
|
|
653 |
return;
|
|
654 |
}
|
|
655 |
|
|
656 |
TFloatFixPt len;
|
|
657 |
TFloatFixPt lx, ly;
|
|
658 |
TFloatFixPt dx, dy, int0x7f( KMAXFLOATFIX );
|
|
659 |
// Create values of distance from start point on motion path
|
|
660 |
TFloatFixPt tmpcoords[6];
|
|
661 |
{
|
|
662 |
CGfxGeneralPath* path = CGfxGeneralPath::NewLC();
|
|
663 |
CGfxPathIterator* itr;
|
|
664 |
iMotionPath->GetPathIteratorL( &iIdentTransform, itr );
|
|
665 |
|
|
666 |
CleanupStack::PushL( itr );
|
|
667 |
TFloatFixPt length;
|
|
668 |
iValuesFloat->Reset();
|
|
669 |
while ( !itr->IsDone() )
|
|
670 |
{
|
|
671 |
switch ( itr->CurrentSegment( tmpcoords ) )
|
|
672 |
{
|
|
673 |
case EGfxSegMoveTo:
|
|
674 |
path->MoveToL( tmpcoords[0], tmpcoords[1], ETrue );
|
|
675 |
lx = tmpcoords[0];
|
|
676 |
ly = tmpcoords[1];
|
|
677 |
len = TSvgPathDataParser::PathLengthL( path );
|
|
678 |
break;
|
|
679 |
case EGfxSegLineTo:
|
|
680 |
path->LineToL( tmpcoords[0], tmpcoords[1], ETrue );
|
|
681 |
dx = lx - tmpcoords[0];
|
|
682 |
dy = ly - tmpcoords[1];
|
|
683 |
if ( dx > int0x7f || dy > int0x7f )
|
|
684 |
{
|
|
685 |
// calculate as integer
|
|
686 |
TInt32 tmplen, tx, ty;
|
|
687 |
tx = ( TInt32 ) dx;
|
|
688 |
ty = ( TInt32 ) dy;
|
|
689 |
#ifdef SVG_FLOAT_BUILD
|
|
690 |
tmplen = TFloatFixPt::Sqrt(tx * tx + ty * ty);
|
|
691 |
#else
|
|
692 |
tmplen = TFloatFixPt::FixedSqrtGeneral( tx * tx + ty * ty, 0 );
|
|
693 |
#endif
|
|
694 |
len += TFloatFixPt( tmplen );
|
|
695 |
}
|
|
696 |
else
|
|
697 |
{
|
|
698 |
// calculate as TFixPt
|
|
699 |
|
|
700 |
len += TFloatFixPt::Sqrt( dx * dx + dy * dy );
|
|
701 |
}
|
|
702 |
lx = tmpcoords[0];
|
|
703 |
ly = tmpcoords[1];
|
|
704 |
|
|
705 |
break;
|
|
706 |
case EGfxSegQuadTo:
|
|
707 |
path->QuadToL( tmpcoords[0],
|
|
708 |
tmpcoords[1],
|
|
709 |
tmpcoords[2],
|
|
710 |
tmpcoords[3],
|
|
711 |
ETrue );
|
|
712 |
len = TSvgPathDataParser::PathLengthL( path );
|
|
713 |
break;
|
|
714 |
case EGfxSegCubicTo:
|
|
715 |
path->CubicToL( tmpcoords[0],
|
|
716 |
tmpcoords[1],
|
|
717 |
tmpcoords[2],
|
|
718 |
tmpcoords[3],
|
|
719 |
tmpcoords[4],
|
|
720 |
tmpcoords[5],
|
|
721 |
ETrue );
|
|
722 |
len = TSvgPathDataParser::PathLengthL( path );
|
|
723 |
break;
|
|
724 |
case EGfxSegClose:
|
|
725 |
path->LineToL( tmpcoords[0], tmpcoords[1], ETrue );
|
|
726 |
len = TSvgPathDataParser::PathLengthL( path );
|
|
727 |
break;
|
|
728 |
}
|
|
729 |
|
|
730 |
length = len;
|
|
731 |
//length = TSvgPathDataParser::PathLengthL( path );
|
|
732 |
iValuesFloat->AppendL( length );
|
|
733 |
itr->NextL();
|
|
734 |
}
|
|
735 |
CleanupStack::PopAndDestroy( 2 ); // path, itr
|
|
736 |
}
|
|
737 |
|
|
738 |
CSvgAnimationBase::InitAnimationL();
|
|
739 |
if(!iKeyTimesPresent)
|
|
740 |
iAnimTime->CreateKeyTime( iMotionPath->PointTypeArray()->Count() );
|
|
741 |
iAnimTime->PrepareTimeL( iValuesFloat );
|
|
742 |
SetFillValueL();
|
|
743 |
this->ResetAnimationL();
|
|
744 |
}
|
|
745 |
|
|
746 |
|
|
747 |
// ---------------------------------------------------------------------------
|
|
748 |
//
|
|
749 |
// ---------------------------------------------------------------------------
|
|
750 |
void CSvgAnimateMotionElementImpl::SetFillValueL()
|
|
751 |
{
|
|
752 |
iPrevRotate = 0;
|
|
753 |
MSvgTransformList* trList = NULL;
|
|
754 |
if ( iTargetElement )
|
|
755 |
{
|
|
756 |
((CSvgElementImpl*)iTargetElement)->GetTransform( trList );
|
|
757 |
TInt32 matrixIndex = -1;
|
|
758 |
iTargetElement->GetAttributeIntL( KAtrAnimMotionMatrixIndex, matrixIndex );
|
|
759 |
((CSvgElementImpl*)iTargetElement)->GetTransform( trList );
|
|
760 |
if ( trList && matrixIndex != -1 )
|
|
761 |
{
|
|
762 |
iFillMatrix = trList->GetItem(matrixIndex);
|
|
763 |
}
|
|
764 |
}
|
|
765 |
}
|
|
766 |
|
|
767 |
// ---------------------------------------------------------------------------
|
|
768 |
//
|
|
769 |
// ---------------------------------------------------------------------------
|
|
770 |
void CSvgAnimateMotionElementImpl::SetToOriginalL()
|
|
771 |
{
|
|
772 |
MSvgTransformList* trList;
|
|
773 |
TInt32 matrixIndex;
|
|
774 |
if (iTargetElement == NULL)
|
|
775 |
{
|
|
776 |
return;
|
|
777 |
}
|
|
778 |
iTargetElement->GetAttributeIntL( KAtrAnimMotionMatrixIndex, matrixIndex );
|
|
779 |
( ( CSvgElementImpl * ) iTargetElement )->GetTransform( trList );
|
|
780 |
|
|
781 |
|
|
782 |
trList->ReplaceItem( iFillMatrix, matrixIndex );
|
|
783 |
|
|
784 |
|
|
785 |
}
|
|
786 |
|
|
787 |
// ---------------------------------------------------------------------------
|
|
788 |
//
|
|
789 |
// ---------------------------------------------------------------------------
|
|
790 |
void CSvgAnimateMotionElementImpl::SetToInitialValueL()
|
|
791 |
{
|
|
792 |
MSvgTransformList* trList;
|
|
793 |
TInt32 matrixIndex;
|
|
794 |
iTargetElement->GetAttributeIntL( KAtrAnimMotionMatrixIndex, matrixIndex );
|
|
795 |
( ( CSvgElementImpl * ) iTargetElement )->GetTransform( trList );
|
|
796 |
|
|
797 |
if( iAdditive == KAdditiveSum)
|
|
798 |
{
|
|
799 |
TGfxAffineTransform curMatrix = trList->GetItem( matrixIndex );
|
|
800 |
curMatrix.Concatenate(iFillMatrix);
|
|
801 |
trList->ReplaceItem( curMatrix, matrixIndex );
|
|
802 |
}
|
|
803 |
else
|
|
804 |
{
|
|
805 |
trList->ReplaceItem( iFillMatrix, matrixIndex );
|
|
806 |
}
|
|
807 |
}
|
|
808 |
|
|
809 |
// ---------------------------------------------------------------------------
|
|
810 |
//
|
|
811 |
// ---------------------------------------------------------------------------
|
|
812 |
void CSvgAnimateMotionElementImpl::SetToEndValueL()
|
|
813 |
{
|
|
814 |
MSvgTransformList* trList;
|
|
815 |
TInt32 matrixIndex;
|
|
816 |
iTargetElement->GetAttributeIntL( KAtrAnimMotionMatrixIndex, matrixIndex );
|
|
817 |
( ( CSvgElementImpl * ) iTargetElement )->GetTransform( trList );
|
|
818 |
|
|
819 |
if( iAdditive == KAdditiveSum)
|
|
820 |
{
|
|
821 |
TGfxAffineTransform curMatrix = trList->GetItem( matrixIndex );
|
|
822 |
curMatrix.Concatenate(iEndMatrix);
|
|
823 |
trList->ReplaceItem( curMatrix, matrixIndex );
|
|
824 |
}
|
|
825 |
else
|
|
826 |
{
|
|
827 |
trList->ReplaceItem( iEndMatrix, matrixIndex );
|
|
828 |
}
|
|
829 |
}
|
|
830 |
|
|
831 |
// ---------------------------------------------------------------------------
|
|
832 |
//
|
|
833 |
// ---------------------------------------------------------------------------
|
|
834 |
void CSvgAnimateMotionElementImpl::SetAccumulateValues()
|
|
835 |
{
|
|
836 |
TFloatFixPt lDelta;
|
|
837 |
if(iHaveBy)
|
|
838 |
{
|
|
839 |
|
|
840 |
lDelta = iToFloatX - iFromFloatX;
|
|
841 |
iToFloatX = iToFloatX + lDelta;
|
|
842 |
iFromFloatX = iFromFloatX + lDelta;
|
|
843 |
|
|
844 |
lDelta = iToFloatY - iFromFloatY;
|
|
845 |
iToFloatY = iToFloatY + lDelta;
|
|
846 |
iFromFloatY = iFromFloatY + lDelta;
|
|
847 |
|
|
848 |
}
|
|
849 |
else
|
|
850 |
{
|
|
851 |
lDelta = iToFloatX - iFromFloatX;
|
|
852 |
iFromFloatX = iToFloatX + iOrgFromFloatX;
|
|
853 |
iToFloatX = iFromFloatX + lDelta;
|
|
854 |
|
|
855 |
lDelta = iToFloatY - iFromFloatY;
|
|
856 |
iFromFloatY = iToFloatY + iOrgFromFloatY;
|
|
857 |
iToFloatY = iFromFloatY + lDelta;
|
|
858 |
}
|
|
859 |
}
|
|
860 |
|
|
861 |
// ---------------------------------------------------------------------------
|
|
862 |
// From MXmlElementOpt
|
|
863 |
// ---------------------------------------------------------------------------
|
|
864 |
TInt CSvgAnimateMotionElementImpl::GetAttributePath( const TInt /* aNameId */,
|
|
865 |
CGfxGeneralPath*& /* aValue */ )
|
|
866 |
{
|
|
867 |
return KErrNoAttribute;
|
|
868 |
}
|
|
869 |
|
|
870 |
// ---------------------------------------------------------------------------
|
|
871 |
//
|
|
872 |
// ---------------------------------------------------------------------------
|
|
873 |
TInt CSvgAnimateMotionElementImpl::SetAttributePathL( const TInt aNameId,
|
|
874 |
CGfxGeneralPath* aValue )
|
|
875 |
{
|
|
876 |
if ( aNameId == KAtrData )
|
|
877 |
{
|
|
878 |
iMotionPath->Reset();
|
|
879 |
CGfxPathIterator* lIter = NULL;
|
|
880 |
aValue->GetPathIteratorL( &iIdentTransform, lIter );
|
|
881 |
CleanupStack::PushL( lIter );
|
|
882 |
iMotionPath->AppendL( lIter );
|
|
883 |
CleanupStack::PopAndDestroy( 1 ); //lIter
|
|
884 |
}
|
|
885 |
|
|
886 |
return KErrNone;
|
|
887 |
}
|
|
888 |
|
|
889 |
|
|
890 |
// ---------------------------------------------------------------------------
|
|
891 |
// Functions used by Decoder
|
|
892 |
// ---------------------------------------------------------------------------
|
|
893 |
TInt CSvgAnimateMotionElementImpl::SetAttributePathRef( const TInt aNameId,
|
|
894 |
CGfxGeneralPath*& aValue )
|
|
895 |
{
|
|
896 |
iIsMotionPath= EFalse;
|
|
897 |
if ( aNameId == KAtrAnimateMotion )
|
|
898 |
{
|
|
899 |
if(iMotionPath)
|
|
900 |
{
|
|
901 |
delete iMotionPath;
|
|
902 |
iMotionPath= NULL;
|
|
903 |
}
|
|
904 |
iMotionPath= aValue;
|
|
905 |
|
|
906 |
if((iMotionPath->PointTypeArray())->Count() != 0 )
|
|
907 |
{
|
|
908 |
CGfxPathIterator* itr = NULL;
|
|
909 |
TFloatFixPt tmpcoords[6];
|
|
910 |
TRAPD( error,iMotionPath->GetPathIteratorL( &iIdentTransform, itr ) );
|
|
911 |
if (error!= KErrNone)
|
|
912 |
{
|
|
913 |
return error;
|
|
914 |
}
|
|
915 |
|
|
916 |
|
|
917 |
|
|
918 |
while ( !itr->IsDone() )
|
|
919 |
{
|
|
920 |
switch ( itr->CurrentSegment( tmpcoords ) )
|
|
921 |
{
|
|
922 |
case EGfxSegMoveTo:
|
|
923 |
iToFloatX = tmpcoords[0];
|
|
924 |
iToFloatY = tmpcoords[1];
|
|
925 |
break;
|
|
926 |
case EGfxSegLineTo:
|
|
927 |
iToFloatX = tmpcoords[0];
|
|
928 |
iToFloatY = tmpcoords[1];
|
|
929 |
break;
|
|
930 |
case EGfxSegQuadTo:
|
|
931 |
iToFloatX = tmpcoords[2];
|
|
932 |
iToFloatY = tmpcoords[3];
|
|
933 |
break;
|
|
934 |
case EGfxSegCubicTo:
|
|
935 |
iToFloatX = tmpcoords[4];
|
|
936 |
iToFloatY = tmpcoords[5];
|
|
937 |
break;
|
|
938 |
case EGfxSegClose:
|
|
939 |
iToFloatX = tmpcoords[0];
|
|
940 |
iToFloatY = tmpcoords[1];
|
|
941 |
}
|
|
942 |
|
|
943 |
TRAPD( error, itr->NextL() );
|
|
944 |
if ( error != KErrNone )
|
|
945 |
{
|
|
946 |
delete itr;
|
|
947 |
return KErrNone;
|
|
948 |
}
|
|
949 |
}
|
|
950 |
|
|
951 |
delete itr;
|
|
952 |
itr= NULL;
|
|
953 |
|
|
954 |
|
|
955 |
RArray<TFloatFixPt>* lArrayFix;
|
|
956 |
lArrayFix= iMotionPath->PointCoordsArrayAll();
|
|
957 |
if (lArrayFix)
|
|
958 |
{
|
|
959 |
iOrgFromFloatX = iFromFloatX = lArrayFix->operator[](0);
|
|
960 |
iOrgFromFloatY = iFromFloatY = lArrayFix->operator[](1);
|
|
961 |
}
|
|
962 |
|
|
963 |
}
|
|
964 |
}
|
|
965 |
|
|
966 |
else
|
|
967 |
{
|
|
968 |
return KErrNoAttribute;
|
|
969 |
}
|
|
970 |
|
|
971 |
return KErrNone;
|
|
972 |
}
|
|
973 |
// ---------------------------------------------------------------------------
|
|
974 |
// Functions used by Decoder
|
|
975 |
// ---------------------------------------------------------------------------
|
|
976 |
void CSvgAnimateMotionElementImpl::SetAnimRotate(TInt16 aRotate)
|
|
977 |
{
|
|
978 |
iAnimMotionRotate= aRotate;
|
|
979 |
}
|
|
980 |
// ---------------------------------------------------------------------------
|
|
981 |
// Functions used by Decoder
|
|
982 |
// ---------------------------------------------------------------------------
|
|
983 |
TInt CSvgAnimateMotionElementImpl::SetAttributeIntL( const TInt aNameId, const TInt32 aValue)
|
|
984 |
{
|
|
985 |
if(aNameId == KAtrRotate)
|
|
986 |
{
|
|
987 |
iAnimMotionRotate = (TInt16)aValue;
|
|
988 |
return KErrNone;
|
|
989 |
}
|
|
990 |
return CSvgAnimationBase::SetAttributeIntL(aNameId,aValue);
|
|
991 |
}
|
|
992 |
// ---------------------------------------------------------------------------
|
|
993 |
// Functions used by Decoder
|
|
994 |
// ---------------------------------------------------------------------------
|
|
995 |
TInt CSvgAnimateMotionElementImpl::GetAttributeIntL( const TInt aNameId, TInt32& aValue )
|
|
996 |
{
|
|
997 |
if(aNameId == KAtrRotate)
|
|
998 |
{
|
|
999 |
aValue = (TInt)(iAnimMotionRotate);
|
|
1000 |
return KErrNone;
|
|
1001 |
}
|
|
1002 |
return CSvgAnimationBase::GetAttributeIntL(aNameId,aValue);
|
|
1003 |
}
|
|
1004 |
// ---------------------------------------------------------------------------
|
|
1005 |
// Functions used by Decoder
|
|
1006 |
// ---------------------------------------------------------------------------
|
|
1007 |
TInt CSvgAnimateMotionElementImpl::SetAttributeFloatL(const TInt aNameId, TFloatFixPt aValue )
|
|
1008 |
{
|
|
1009 |
return CSvgAnimationBase::SetAttributeFloatL(aNameId,aValue);
|
|
1010 |
}
|
|
1011 |
// ---------------------------------------------------------------------------
|
|
1012 |
// Functions used by Decoder
|
|
1013 |
// ---------------------------------------------------------------------------
|
|
1014 |
TInt CSvgAnimateMotionElementImpl::GetAttributeFloat(const TInt aNameId, TFloatFixPt& aValue )
|
|
1015 |
{
|
|
1016 |
return CSvgAnimationBase::GetAttributeFloat(aNameId,aValue);
|
|
1017 |
}
|
|
1018 |
// ---------------------------------------------------------------------------
|
|
1019 |
// Functions used by Decoder
|
|
1020 |
// ---------------------------------------------------------------------------
|
|
1021 |
void CSvgAnimateMotionElementImpl::ReInitializeAnimation()
|
|
1022 |
{
|
|
1023 |
|
|
1024 |
if ( iAttrId == 0xffff )
|
|
1025 |
return;
|
|
1026 |
|
|
1027 |
if( iCurrentRepeatCount > 0 && iAccumulate == KAccumSum )
|
|
1028 |
{
|
|
1029 |
iFromFloatX= iOrgFromFloatX;
|
|
1030 |
iFromFloatY= iOrgFromFloatY;
|
|
1031 |
iToFloatX= iOrgToFloatX;
|
|
1032 |
iToFloatY= iOrgToFloatY;
|
|
1033 |
}
|
|
1034 |
|
|
1035 |
CSvgAnimationBase::ReInitializeAnimation();
|
|
1036 |
|
|
1037 |
iCurrentSeg.iX1 = (TFloatFixPt) 0;
|
|
1038 |
iCurrentSeg.iX2 = (TFloatFixPt) 0;
|
|
1039 |
iCurrentSeg.iY1 = (TFloatFixPt) 0;
|
|
1040 |
iCurrentSeg.iY2 = (TFloatFixPt) 0;
|
|
1041 |
MSvgTransformList* trList;
|
|
1042 |
TInt32 matrixIndex = 0;
|
|
1043 |
|
|
1044 |
if (iTargetElement)
|
|
1045 |
{
|
|
1046 |
TRAPD(error ,iTargetElement->GetAttributeIntL( KAtrAnimMotionMatrixIndex, matrixIndex ));
|
|
1047 |
if ( error != KErrNone )
|
|
1048 |
{
|
|
1049 |
// ignore trap error
|
|
1050 |
}
|
|
1051 |
( ( CSvgElementImpl * ) iTargetElement )->GetTransform( trList );
|
|
1052 |
if( trList && (trList->NumberOfItems() > matrixIndex) )
|
|
1053 |
{
|
|
1054 |
trList->ReplaceItem( TGfxAffineTransform(), matrixIndex );
|
|
1055 |
|
|
1056 |
trList->SetAdditive( iAdditive, matrixIndex );
|
|
1057 |
}
|
|
1058 |
}
|
|
1059 |
iFillMatrix= TGfxAffineTransform();
|
|
1060 |
}
|
|
1061 |
|
|
1062 |
// ---------------------------------------------------------------------------
|
|
1063 |
//
|
|
1064 |
// ---------------------------------------------------------------------------
|
|
1065 |
void CSvgAnimateMotionElementImpl::SetOriginalValues_DOMReuse()
|
|
1066 |
{
|
|
1067 |
iOrgToFloatX= iToFloatX;
|
|
1068 |
iOrgToFloatY= iToFloatY;
|
|
1069 |
// calling base class function.
|
|
1070 |
CSvgAnimationBase::SetOriginalValues_DOMReuse();
|
|
1071 |
}
|
|
1072 |
// ---------------------------------------------------------------------------
|
|
1073 |
// Functions used by Decoder
|
|
1074 |
// ---------------------------------------------------------------------------
|
|
1075 |
CGfxGeneralPath* CSvgAnimateMotionElementImpl::GetPathAttribute(TInt aAttributeId)
|
|
1076 |
{
|
|
1077 |
if(aAttributeId == KAtrPath)
|
|
1078 |
{
|
|
1079 |
return iMotionPath;
|
|
1080 |
}
|
|
1081 |
else
|
|
1082 |
{
|
|
1083 |
return CSvgAnimationBase::GetPathAttribute(aAttributeId);
|
|
1084 |
}
|
|
1085 |
}
|
|
1086 |
|
|
1087 |
// ---------------------------------------------------------------------------
|
|
1088 |
//
|
|
1089 |
// ---------------------------------------------------------------------------
|
|
1090 |
void CSvgAnimateMotionElementImpl::SetPathAttribute(TInt aAttributeId, CGfxGeneralPath* aPathHandle)
|
|
1091 |
{
|
|
1092 |
|
|
1093 |
if(aAttributeId == KAtrPath)
|
|
1094 |
{
|
|
1095 |
if(iMotionPath == aPathHandle)
|
|
1096 |
{
|
|
1097 |
return;
|
|
1098 |
}
|
|
1099 |
delete iMotionPath;
|
|
1100 |
iMotionPath = aPathHandle;
|
|
1101 |
|
|
1102 |
CGfxPathIterator* itr = NULL;
|
|
1103 |
TFloatFixPt tmpcoords[6];
|
|
1104 |
TRAPD(error ,iMotionPath->GetPathIteratorL( &iIdentTransform, itr ));
|
|
1105 |
if ( error != KErrNone )
|
|
1106 |
{
|
|
1107 |
// ignore trap error
|
|
1108 |
}
|
|
1109 |
|
|
1110 |
if(itr)
|
|
1111 |
{
|
|
1112 |
while ( !itr->IsDone() )
|
|
1113 |
{
|
|
1114 |
switch ( itr->CurrentSegment( tmpcoords ) )
|
|
1115 |
{
|
|
1116 |
case EGfxSegMoveTo:
|
|
1117 |
iToFloatX = tmpcoords[0];
|
|
1118 |
iToFloatY = tmpcoords[1];
|
|
1119 |
break;
|
|
1120 |
case EGfxSegLineTo:
|
|
1121 |
iToFloatX = tmpcoords[0];
|
|
1122 |
iToFloatY = tmpcoords[1];
|
|
1123 |
break;
|
|
1124 |
case EGfxSegQuadTo:
|
|
1125 |
iToFloatX = tmpcoords[2];
|
|
1126 |
iToFloatY = tmpcoords[3];
|
|
1127 |
break;
|
|
1128 |
case EGfxSegCubicTo:
|
|
1129 |
iToFloatX = tmpcoords[4];
|
|
1130 |
iToFloatY = tmpcoords[5];
|
|
1131 |
break;
|
|
1132 |
case EGfxSegClose:
|
|
1133 |
iToFloatX = tmpcoords[0]; //.
|
|
1134 |
iToFloatY = tmpcoords[1];
|
|
1135 |
}
|
|
1136 |
TRAPD( error, itr->NextL() );
|
|
1137 |
if ( error != KErrNone )
|
|
1138 |
{
|
|
1139 |
delete itr;
|
|
1140 |
return;
|
|
1141 |
}
|
|
1142 |
}
|
|
1143 |
|
|
1144 |
delete itr;
|
|
1145 |
}
|
|
1146 |
|
|
1147 |
RArray<TFloatFixPt>* lArrayFix;
|
|
1148 |
lArrayFix= iMotionPath->PointCoordsArrayAll();
|
|
1149 |
if (lArrayFix)
|
|
1150 |
{
|
|
1151 |
iOrgFromFloatX = iFromFloatX = lArrayFix->operator[](0);
|
|
1152 |
iOrgFromFloatY = iFromFloatY = lArrayFix->operator[](1);
|
|
1153 |
}
|
|
1154 |
|
|
1155 |
}
|
|
1156 |
else
|
|
1157 |
{
|
|
1158 |
CSvgAnimationBase::SetPathAttribute(aAttributeId, aPathHandle);
|
|
1159 |
}
|
|
1160 |
}
|
|
1161 |
|
|
1162 |
// ---------------------------------------------------------------------------
|
|
1163 |
//
|
|
1164 |
// ---------------------------------------------------------------------------
|
|
1165 |
void CSvgAnimateMotionElementImpl::Reset(MSvgEvent* aEvent)
|
|
1166 |
{
|
|
1167 |
iIsUserSeek = ETrue;
|
|
1168 |
// first call the animation base function.
|
|
1169 |
TSvgTimerEvent* timerEvent = ( TSvgTimerEvent* ) aEvent;
|
|
1170 |
if((TInt32)timerEvent->Time() < iAbsoluteBeginTime)
|
|
1171 |
{
|
|
1172 |
// let it come to initial position.
|
|
1173 |
((CSvgDocumentImpl*)iOwnerDocument)->iInitialDrawFlag = ETrue;
|
|
1174 |
ReInitializeAnimation();
|
|
1175 |
return;
|
|
1176 |
}
|
|
1177 |
TRAPD(error,CSvgAnimationBase::ResetL( aEvent, this));
|
|
1178 |
|
|
1179 |
if (error != KErrNone)
|
|
1180 |
{
|
|
1181 |
// error processing not processed
|
|
1182 |
return;
|
|
1183 |
}
|
|
1184 |
}
|
|
1185 |
|
|
1186 |
|
|
1187 |
/////////////////////////////////////////////
|
|
1188 |
MXmlElement* CSvgAnimateMotionElementImpl::CloneL(MXmlElement*
|
|
1189 |
aParentElement)
|
|
1190 |
{
|
|
1191 |
CSvgAnimateMotionElementImpl* newElement = CSvgAnimateMotionElementImpl::NewL( this->ElemID(),
|
|
1192 |
((CSvgDocumentImpl*)iOwnerDocument) );
|
|
1193 |
CleanupStack::PushL( newElement );
|
|
1194 |
newElement->iParentNode = aParentElement;
|
|
1195 |
// copy the data
|
|
1196 |
// end copying data from this class.
|
|
1197 |
// this will get cloned setting the parent element to aParentElement;
|
|
1198 |
newElement->iOwnerDocument = this->iOwnerDocument;
|
|
1199 |
// set the target element this needs to be modified.
|
|
1200 |
newElement->iTargetElement = (CSvgElementImpl*)aParentElement;
|
|
1201 |
this->CopyL(newElement);
|
|
1202 |
CleanupStack::Pop();
|
|
1203 |
return newElement;
|
|
1204 |
}
|
|
1205 |
|
|
1206 |
// ---------------------------------------------------------------------------
|
|
1207 |
//
|
|
1208 |
// ---------------------------------------------------------------------------
|
|
1209 |
void CSvgAnimateMotionElementImpl::CopyL(CSvgAnimateMotionElementImpl* aDestElement )
|
|
1210 |
{
|
|
1211 |
if(aDestElement)
|
|
1212 |
{
|
|
1213 |
|
|
1214 |
|
|
1215 |
// copy stuff from superclass
|
|
1216 |
this->CSvgAnimationBase::CopyL(aDestElement);
|
|
1217 |
|
|
1218 |
// copy the reference to idoc (CSvgDocumentImpl)
|
|
1219 |
aDestElement->iOwnerDocument = this->iOwnerDocument;
|
|
1220 |
|
|
1221 |
/*Need to check Test whether Copying is proper*/
|
|
1222 |
|
|
1223 |
aDestElement->iFillMatrix = this->iFillMatrix;
|
|
1224 |
if(this->iMotionPath)
|
|
1225 |
{
|
|
1226 |
/*Motion Path and iPathIterator assignment needs to be checked.*/
|
|
1227 |
aDestElement->iMotionPath->Reset();
|
|
1228 |
aDestElement->iMotionPath->SetPointCoordsArrayL(this->iMotionPath->PointCoordsArrayAll());
|
|
1229 |
aDestElement->iMotionPath->SetPointTypeArrayL(this->iMotionPath->PointTypeArray());
|
|
1230 |
}
|
|
1231 |
aDestElement->iIdentTransform = this->iIdentTransform;
|
|
1232 |
aDestElement->iSubLength = this->iSubLength;
|
|
1233 |
aDestElement->iCurrentPos = this->iCurrentPos;
|
|
1234 |
aDestElement->iSubPos = this->iSubPos;
|
|
1235 |
aDestElement->iCurrentSeg = this->iCurrentSeg;
|
|
1236 |
aDestElement->iAnimMotionRotate = this->iAnimMotionRotate;
|
|
1237 |
aDestElement->iEndMatrix = this->iEndMatrix;
|
|
1238 |
//aDestElement->iIsValues = this->iIsValues;
|
|
1239 |
aDestElement->iToFloatX = this->iToFloatX;
|
|
1240 |
aDestElement->iToFloatY = this->iToFloatY;
|
|
1241 |
aDestElement->iFromFloatX = this->iFromFloatX;
|
|
1242 |
aDestElement->iFromFloatY = this->iFromFloatY;
|
|
1243 |
aDestElement->iOrgFromFloatX = this->iOrgFromFloatX;
|
|
1244 |
aDestElement->iOrgFromFloatY = this->iOrgFromFloatY;
|
|
1245 |
// for DOM Reuse
|
|
1246 |
aDestElement->iOrgToFloatX = this->iOrgToFloatX;
|
|
1247 |
aDestElement->iOrgToFloatY = this->iOrgToFloatY;
|
|
1248 |
aDestElement->iIsMotionPath = this->iIsMotionPath;
|
|
1249 |
|
|
1250 |
if(this->iPathIterator)
|
|
1251 |
{
|
|
1252 |
aDestElement->ResetAnimationL();
|
|
1253 |
}
|
|
1254 |
}
|
|
1255 |
}
|
|
1256 |
|
|
1257 |
// ---------------------------------------------------------------------------
|
|
1258 |
//
|
|
1259 |
// ---------------------------------------------------------------------------
|
|
1260 |
void CSvgAnimateMotionElementImpl::DeactivateAnimation()
|
|
1261 |
{
|
|
1262 |
CSvgAnimationBase::DeactivateAnimation(this);
|
|
1263 |
}
|
|
1264 |
|
|
1265 |
// ---------------------------------------------------------------------------
|
|
1266 |
//
|
|
1267 |
// ---------------------------------------------------------------------------
|
|
1268 |
TBool CSvgAnimateMotionElementImpl::DoAnimProcL(MSvgEvent* aEvent)
|
|
1269 |
{
|
|
1270 |
return this->AnimProcL((MSvgTimerEvent*)aEvent);
|
|
1271 |
}
|
|
1272 |
|
|
1273 |
// ---------------------------------------------------------------------------
|
|
1274 |
//
|
|
1275 |
// ---------------------------------------------------------------------------
|
|
1276 |
void CSvgAnimateMotionElementImpl::SetAccumulateValuesForSetMediaTime()
|
|
1277 |
{
|
|
1278 |
if(iAccumulate == KAccumSum )
|
|
1279 |
{
|
|
1280 |
iFromFloatX= iOrgFromFloatX;
|
|
1281 |
iFromFloatY= iOrgFromFloatY;
|
|
1282 |
iToFloatX= iOrgToFloatX;
|
|
1283 |
iToFloatY= iOrgToFloatY;
|
|
1284 |
|
|
1285 |
TInt i=0;
|
|
1286 |
while(i < iCurrentRepeatCount )
|
|
1287 |
{
|
|
1288 |
SetAccumulateValues();
|
|
1289 |
i++;
|
|
1290 |
}
|
|
1291 |
}
|
|
1292 |
}
|
|
1293 |
|
|
1294 |
// ---------------------------------------------------------------------------
|
|
1295 |
//
|
|
1296 |
// ---------------------------------------------------------------------------
|
|
1297 |
void CSvgAnimateMotionElementImpl::Print( TBool aIsEncodeOn )
|
|
1298 |
{
|
|
1299 |
if (!aIsEncodeOn)
|
|
1300 |
{
|
|
1301 |
#ifdef _DEBUG
|
|
1302 |
RDebug::Printf("<animateMotion calcMode=\"hmm\" xlink:href=\"hmm\" path=\"hmm\" keyPoints=\"hmm\" rotate=\"%d\"/>",
|
|
1303 |
/*Href(),*/ (int)iAnimMotionRotate);
|
|
1304 |
#endif
|
|
1305 |
}
|
|
1306 |
}
|
|
1307 |
|
|
1308 |
|