OLD | NEW |
| (Empty) |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 | |
7 #include "WebAnimationImpl.h" | |
8 | |
9 #include "CCActiveAnimation.h" | |
10 #include "CCAnimationCurve.h" | |
11 #include "WebFloatAnimationCurveImpl.h" | |
12 #include "WebTransformAnimationCurveImpl.h" | |
13 #include <public/WebAnimation.h> | |
14 #include <public/WebAnimationCurve.h> | |
15 #include <wtf/OwnPtr.h> | |
16 #include <wtf/PassOwnPtr.h> | |
17 | |
18 using WebCore::CCActiveAnimation; | |
19 | |
20 namespace WebKit { | |
21 | |
22 WebAnimation* WebAnimation::create(const WebAnimationCurve& curve, TargetPropert
y targetProperty, int animationId) | |
23 { | |
24 return new WebAnimationImpl(curve, targetProperty, animationId, 0); | |
25 } | |
26 | |
27 WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& webCurve, TargetProp
erty targetProperty, int animationId, int groupId) | |
28 { | |
29 static int nextAnimationId = 1; | |
30 static int nextGroupId = 1; | |
31 if (!animationId) | |
32 animationId = nextAnimationId++; | |
33 if (!groupId) | |
34 groupId = nextGroupId++; | |
35 | |
36 WebAnimationCurve::AnimationCurveType curveType = webCurve.type(); | |
37 OwnPtr<WebCore::CCAnimationCurve> curve; | |
38 switch (curveType) { | |
39 case WebAnimationCurve::AnimationCurveTypeFloat: { | |
40 const WebFloatAnimationCurveImpl* floatCurveImpl = static_cast<const Web
FloatAnimationCurveImpl*>(&webCurve); | |
41 curve = floatCurveImpl->cloneToCCAnimationCurve(); | |
42 break; | |
43 } | |
44 case WebAnimationCurve::AnimationCurveTypeTransform: { | |
45 const WebTransformAnimationCurveImpl* transformCurveImpl = static_cast<c
onst WebTransformAnimationCurveImpl*>(&webCurve); | |
46 curve = transformCurveImpl->cloneToCCAnimationCurve(); | |
47 break; | |
48 } | |
49 } | |
50 m_animation = CCActiveAnimation::create(curve.release(), animationId, groupI
d, static_cast<WebCore::CCActiveAnimation::TargetProperty>(targetProperty)); | |
51 } | |
52 | |
53 WebAnimationImpl::~WebAnimationImpl() | |
54 { | |
55 } | |
56 | |
57 int WebAnimationImpl::id() | |
58 { | |
59 return m_animation->id(); | |
60 } | |
61 | |
62 WebAnimation::TargetProperty WebAnimationImpl::targetProperty() const | |
63 { | |
64 return static_cast<WebAnimationImpl::TargetProperty>(m_animation->targetProp
erty()); | |
65 } | |
66 | |
67 int WebAnimationImpl::iterations() const | |
68 { | |
69 return m_animation->iterations(); | |
70 } | |
71 | |
72 void WebAnimationImpl::setIterations(int n) | |
73 { | |
74 m_animation->setIterations(n); | |
75 } | |
76 | |
77 double WebAnimationImpl::startTime() const | |
78 { | |
79 return m_animation->startTime(); | |
80 } | |
81 | |
82 void WebAnimationImpl::setStartTime(double monotonicTime) | |
83 { | |
84 m_animation->setStartTime(monotonicTime); | |
85 } | |
86 | |
87 double WebAnimationImpl::timeOffset() const | |
88 { | |
89 return m_animation->timeOffset(); | |
90 } | |
91 | |
92 void WebAnimationImpl::setTimeOffset(double monotonicTime) | |
93 { | |
94 m_animation->setTimeOffset(monotonicTime); | |
95 } | |
96 | |
97 bool WebAnimationImpl::alternatesDirection() const | |
98 { | |
99 return m_animation->alternatesDirection(); | |
100 } | |
101 | |
102 void WebAnimationImpl::setAlternatesDirection(bool alternates) | |
103 { | |
104 m_animation->setAlternatesDirection(alternates); | |
105 } | |
106 | |
107 PassOwnPtr<WebCore::CCActiveAnimation> WebAnimationImpl::cloneToCCAnimation() | |
108 { | |
109 OwnPtr<WebCore::CCActiveAnimation> toReturn(m_animation->clone(WebCore::CCAc
tiveAnimation::NonControllingInstance)); | |
110 toReturn->setNeedsSynchronizedStartTime(true); | |
111 return toReturn.release(); | |
112 } | |
113 | |
114 } // namespace WebKit | |
OLD | NEW |