OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/renderer/compositor_bindings/web_animation_impl.h" | 5 #include "content/renderer/compositor_bindings/web_animation_impl.h" |
6 | 6 |
7 #include "cc/animation/animation.h" | 7 #include "cc/animation/animation.h" |
8 #include "cc/animation/animation_curve.h" | 8 #include "cc/animation/animation_curve.h" |
9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "content/renderer/compositor_bindings/web_filter_animation_curve_impl.h
" |
| 11 #include "content/renderer/compositor_bindings/web_float_animation_curve_impl.h" |
| 12 #include "content/renderer/compositor_bindings/web_scroll_offset_animation_curve
_impl.h" |
| 13 #include "content/renderer/compositor_bindings/web_transform_animation_curve_imp
l.h" |
10 #include "third_party/WebKit/public/platform/WebAnimation.h" | 14 #include "third_party/WebKit/public/platform/WebAnimation.h" |
11 #include "third_party/WebKit/public/platform/WebAnimationCurve.h" | 15 #include "third_party/WebKit/public/platform/WebAnimationCurve.h" |
12 #include "webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h" | |
13 #include "webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h" | |
14 #include "webkit/renderer/compositor_bindings/web_scroll_offset_animation_curve_
impl.h" | |
15 #include "webkit/renderer/compositor_bindings/web_transform_animation_curve_impl
.h" | |
16 | 16 |
17 using cc::Animation; | 17 using cc::Animation; |
18 using cc::AnimationIdProvider; | 18 using cc::AnimationIdProvider; |
19 | 19 |
20 using blink::WebAnimation; | 20 using blink::WebAnimation; |
21 using blink::WebAnimationCurve; | 21 using blink::WebAnimationCurve; |
22 | 22 |
23 namespace webkit { | 23 namespace content { |
24 | 24 |
25 WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& web_curve, | 25 WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& web_curve, |
26 TargetProperty target_property, | 26 TargetProperty target_property, |
27 int animation_id, | 27 int animation_id, |
28 int group_id) { | 28 int group_id) { |
29 if (!animation_id) | 29 if (!animation_id) |
30 animation_id = AnimationIdProvider::NextAnimationId(); | 30 animation_id = AnimationIdProvider::NextAnimationId(); |
31 if (!group_id) | 31 if (!group_id) |
32 group_id = AnimationIdProvider::NextGroupId(); | 32 group_id = AnimationIdProvider::NextGroupId(); |
33 | 33 |
(...skipping 27 matching lines...) Expand all Loading... |
61 } | 61 } |
62 #endif | 62 #endif |
63 } | 63 } |
64 animation_ = Animation::Create( | 64 animation_ = Animation::Create( |
65 curve.Pass(), | 65 curve.Pass(), |
66 animation_id, | 66 animation_id, |
67 group_id, | 67 group_id, |
68 static_cast<cc::Animation::TargetProperty>(target_property)); | 68 static_cast<cc::Animation::TargetProperty>(target_property)); |
69 } | 69 } |
70 | 70 |
71 WebAnimationImpl::~WebAnimationImpl() {} | 71 WebAnimationImpl::~WebAnimationImpl() { |
| 72 } |
72 | 73 |
73 int WebAnimationImpl::id() { return animation_->id(); } | 74 int WebAnimationImpl::id() { |
| 75 return animation_->id(); |
| 76 } |
74 | 77 |
75 blink::WebAnimation::TargetProperty WebAnimationImpl::targetProperty() const { | 78 blink::WebAnimation::TargetProperty WebAnimationImpl::targetProperty() const { |
76 return static_cast<WebAnimationImpl::TargetProperty>( | 79 return static_cast<WebAnimationImpl::TargetProperty>( |
77 animation_->target_property()); | 80 animation_->target_property()); |
78 } | 81 } |
79 | 82 |
80 int WebAnimationImpl::iterations() const { return animation_->iterations(); } | 83 int WebAnimationImpl::iterations() const { |
| 84 return animation_->iterations(); |
| 85 } |
81 | 86 |
82 void WebAnimationImpl::setIterations(int n) { animation_->set_iterations(n); } | 87 void WebAnimationImpl::setIterations(int n) { |
| 88 animation_->set_iterations(n); |
| 89 } |
83 | 90 |
84 double WebAnimationImpl::startTime() const { | 91 double WebAnimationImpl::startTime() const { |
85 return (animation_->start_time() - base::TimeTicks()).InSecondsF(); | 92 return (animation_->start_time() - base::TimeTicks()).InSecondsF(); |
86 } | 93 } |
87 | 94 |
88 void WebAnimationImpl::setStartTime(double monotonic_time) { | 95 void WebAnimationImpl::setStartTime(double monotonic_time) { |
89 animation_->set_start_time(base::TimeTicks::FromInternalValue( | 96 animation_->set_start_time(base::TimeTicks::FromInternalValue( |
90 monotonic_time * base::Time::kMicrosecondsPerSecond)); | 97 monotonic_time * base::Time::kMicrosecondsPerSecond)); |
91 } | 98 } |
92 | 99 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 else | 149 else |
143 animation_->set_direction(cc::Animation::Normal); | 150 animation_->set_direction(cc::Animation::Normal); |
144 } | 151 } |
145 #endif | 152 #endif |
146 | 153 |
147 scoped_ptr<cc::Animation> WebAnimationImpl::PassAnimation() { | 154 scoped_ptr<cc::Animation> WebAnimationImpl::PassAnimation() { |
148 animation_->set_needs_synchronized_start_time(true); | 155 animation_->set_needs_synchronized_start_time(true); |
149 return animation_.Pass(); | 156 return animation_.Pass(); |
150 } | 157 } |
151 | 158 |
152 #define COMPILE_ASSERT_MATCHING_ENUMS(webkit_name, cc_name) \ | 159 } // namespace content |
153 COMPILE_ASSERT(static_cast<int>(webkit_name) == static_cast<int>(cc_name), \ | |
154 mismatching_enums) | |
155 | 160 |
156 COMPILE_ASSERT_MATCHING_ENUMS( | |
157 WebAnimation::TargetPropertyTransform, Animation::Transform); | |
158 COMPILE_ASSERT_MATCHING_ENUMS( | |
159 WebAnimation::TargetPropertyOpacity, Animation::Opacity); | |
160 COMPILE_ASSERT_MATCHING_ENUMS( | |
161 WebAnimation::TargetPropertyFilter, Animation::Filter); | |
162 #if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED | |
163 COMPILE_ASSERT_MATCHING_ENUMS( | |
164 WebAnimation::TargetPropertyScrollOffset, Animation::ScrollOffset); | |
165 #endif | |
166 | |
167 } // namespace webkit | |
OLD | NEW |