OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) Research In Motion Limited 2011, 2012. All rights reserved. | |
3 * | |
4 * This library is free software; you can redistribute it and/or | |
5 * modify it under the terms of the GNU Library General Public | |
6 * License as published by the Free Software Foundation; either | |
7 * version 2 of the License, or (at your option) any later version. | |
8 * | |
9 * This library is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 * Library General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU Library General Public License | |
15 * along with this library; see the file COPYING.LIB. If not, write to | |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
17 * Boston, MA 02110-1301, USA. | |
18 */ | |
19 | |
20 #include "config.h" | |
21 | |
22 #include "core/svg/SVGAnimatedPointList.h" | |
23 | |
24 #include "core/svg/SVGAnimateElement.h" | |
25 #include "core/svg/SVGParserUtilities.h" | |
26 | |
27 namespace WebCore { | |
28 | |
29 SVGAnimatedPointListAnimator::SVGAnimatedPointListAnimator(SVGAnimationElement*
animationElement, SVGElement* contextElement) | |
30 : SVGAnimatedTypeAnimator(AnimatedPoints, animationElement, contextElement) | |
31 { | |
32 } | |
33 | |
34 PassOwnPtr<SVGAnimatedType> SVGAnimatedPointListAnimator::constructFromString(co
nst String& string) | |
35 { | |
36 OwnPtr<SVGAnimatedType> animtedType = SVGAnimatedType::createPointList(new S
VGPointList); | |
37 pointsListFromSVGData(animtedType->pointList(), string); | |
38 return animtedType.release(); | |
39 } | |
40 | |
41 PassOwnPtr<SVGAnimatedType> SVGAnimatedPointListAnimator::startAnimValAnimation(
const SVGElementAnimatedPropertyList& animatedTypes) | |
42 { | |
43 return SVGAnimatedType::createPointList(constructFromBaseValue<SVGAnimatedPo
intList>(animatedTypes)); | |
44 } | |
45 | |
46 void SVGAnimatedPointListAnimator::stopAnimValAnimation(const SVGElementAnimated
PropertyList& animatedTypes) | |
47 { | |
48 stopAnimValAnimationForType<SVGAnimatedPointList>(animatedTypes); | |
49 } | |
50 | |
51 void SVGAnimatedPointListAnimator::resetAnimValToBaseVal(const SVGElementAnimate
dPropertyList& animatedTypes, SVGAnimatedType* type) | |
52 { | |
53 resetFromBaseValue<SVGAnimatedPointList>(animatedTypes, type, &SVGAnimatedTy
pe::pointList); | |
54 } | |
55 | |
56 void SVGAnimatedPointListAnimator::animValWillChange(const SVGElementAnimatedPro
pertyList& animatedTypes) | |
57 { | |
58 animValWillChangeForType<SVGAnimatedPointList>(animatedTypes); | |
59 } | |
60 | |
61 void SVGAnimatedPointListAnimator::animValDidChange(const SVGElementAnimatedProp
ertyList& animatedTypes) | |
62 { | |
63 animValDidChangeForType<SVGAnimatedPointList>(animatedTypes); | |
64 } | |
65 | |
66 void SVGAnimatedPointListAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAn
imatedType* to) | |
67 { | |
68 ASSERT(from->type() == AnimatedPoints); | |
69 ASSERT(from->type() == to->type()); | |
70 | |
71 const SVGPointList& fromPointList = from->pointList(); | |
72 SVGPointList& toPointList = to->pointList(); | |
73 | |
74 unsigned fromPointListSize = fromPointList.size(); | |
75 if (!fromPointListSize || fromPointListSize != toPointList.size()) | |
76 return; | |
77 | |
78 for (unsigned i = 0; i < fromPointListSize; ++i) | |
79 toPointList[i] += fromPointList[i]; | |
80 } | |
81 | |
82 void SVGAnimatedPointListAnimator::calculateAnimatedValue(float percentage, unsi
gned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* t
oAtEndOfDuration, SVGAnimatedType* animated) | |
83 { | |
84 ASSERT(m_animationElement); | |
85 | |
86 const SVGPointList& fromPointList = m_animationElement->animationMode() == T
oAnimation ? animated->pointList() : from->pointList(); | |
87 const SVGPointList& toPointList = to->pointList(); | |
88 const SVGPointList& toAtEndOfDurationPointList = toAtEndOfDuration->pointLis
t(); | |
89 SVGPointList& animatedPointList = animated->pointList(); | |
90 if (!m_animationElement->adjustFromToListValues<SVGPointList>(fromPointList,
toPointList, animatedPointList, percentage)) | |
91 return; | |
92 | |
93 unsigned fromPointListSize = fromPointList.size(); | |
94 unsigned toPointListSize = toPointList.size(); | |
95 unsigned toAtEndOfDurationSize = toAtEndOfDurationPointList.size(); | |
96 | |
97 for (unsigned i = 0; i < toPointListSize; ++i) { | |
98 FloatPoint effectiveFrom; | |
99 if (fromPointListSize) | |
100 effectiveFrom = fromPointList[i]; | |
101 FloatPoint effectiveToAtEnd = i < toAtEndOfDurationSize ? toAtEndOfDurat
ionPointList[i] : FloatPoint(); | |
102 | |
103 float animatedX = animatedPointList[i].x(); | |
104 float animatedY = animatedPointList[i].y(); | |
105 m_animationElement->animateAdditiveNumber(percentage, repeatCount, effec
tiveFrom.x(), toPointList[i].x(), effectiveToAtEnd.x(), animatedX); | |
106 m_animationElement->animateAdditiveNumber(percentage, repeatCount, effec
tiveFrom.y(), toPointList[i].y(), effectiveToAtEnd.y(), animatedY); | |
107 animatedPointList[i] = FloatPoint(animatedX, animatedY); | |
108 } | |
109 } | |
110 | |
111 float SVGAnimatedPointListAnimator::calculateDistance(const String&, const Strin
g&) | |
112 { | |
113 // FIXME: Distance calculation is not possible for SVGPointList right now. W
e need the distance of for every single value. | |
114 return -1; | |
115 } | |
116 | |
117 } | |
OLD | NEW |