| 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/compositor_bindings/web_animation_impl.h" | 5 #include "webkit/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 "third_party/WebKit/Source/Platform/chromium/public/WebAnimation.h" | 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimation.h" |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimationCurve.h
" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimationCurve.h
" |
| 12 #include "webkit/compositor_bindings/web_float_animation_curve_impl.h" | 12 #include "webkit/compositor_bindings/web_float_animation_curve_impl.h" |
| 13 #include "webkit/compositor_bindings/web_transform_animation_curve_impl.h" | 13 #include "webkit/compositor_bindings/web_transform_animation_curve_impl.h" |
| 14 | 14 |
| 15 using cc::Animation; | 15 using cc::Animation; |
| 16 using cc::AnimationIdProvider; | 16 using cc::AnimationIdProvider; |
| 17 | 17 |
| 18 namespace WebKit { | 18 using WebKit::WebAnimationCurve; |
| 19 |
| 20 namespace webkit { |
| 19 | 21 |
| 20 WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& web_curve, | 22 WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& web_curve, |
| 21 TargetProperty target_property, | 23 TargetProperty target_property, |
| 22 int animation_id, | 24 int animation_id, |
| 23 int group_id) { | 25 int group_id) { |
| 24 if (!animation_id) | 26 if (!animation_id) |
| 25 animation_id = AnimationIdProvider::NextAnimationId(); | 27 animation_id = AnimationIdProvider::NextAnimationId(); |
| 26 if (!group_id) | 28 if (!group_id) |
| 27 group_id = AnimationIdProvider::NextGroupId(); | 29 group_id = AnimationIdProvider::NextGroupId(); |
| 28 | 30 |
| 29 WebAnimationCurve::AnimationCurveType curve_type = web_curve.type(); | 31 WebAnimationCurve::AnimationCurveType curve_type = web_curve.type(); |
| 30 scoped_ptr<cc::AnimationCurve> curve; | 32 scoped_ptr<cc::AnimationCurve> curve; |
| 31 switch (curve_type) { | 33 switch (curve_type) { |
| 32 case WebAnimationCurve::AnimationCurveTypeFloat: { | 34 case WebAnimationCurve::AnimationCurveTypeFloat: { |
| 33 const WebFloatAnimationCurveImpl* float_curve_impl = | 35 const WebFloatAnimationCurveImpl* float_curve_impl = |
| 34 static_cast<const WebFloatAnimationCurveImpl*>(&web_curve); | 36 static_cast<const WebFloatAnimationCurveImpl*>(&web_curve); |
| 35 curve = float_curve_impl->cloneToAnimationCurve(); | 37 curve = float_curve_impl->CloneToAnimationCurve(); |
| 36 break; | 38 break; |
| 37 } | 39 } |
| 38 case WebAnimationCurve::AnimationCurveTypeTransform: { | 40 case WebAnimationCurve::AnimationCurveTypeTransform: { |
| 39 const WebTransformAnimationCurveImpl* transform_curve_impl = | 41 const WebTransformAnimationCurveImpl* transform_curve_impl = |
| 40 static_cast<const WebTransformAnimationCurveImpl*>(&web_curve); | 42 static_cast<const WebTransformAnimationCurveImpl*>(&web_curve); |
| 41 curve = transform_curve_impl->cloneToAnimationCurve(); | 43 curve = transform_curve_impl->CloneToAnimationCurve(); |
| 42 break; | 44 break; |
| 43 } | 45 } |
| 44 } | 46 } |
| 45 animation_ = Animation::Create( | 47 animation_ = Animation::Create( |
| 46 curve.Pass(), | 48 curve.Pass(), |
| 47 animation_id, | 49 animation_id, |
| 48 group_id, | 50 group_id, |
| 49 static_cast<cc::Animation::TargetProperty>(target_property)); | 51 static_cast<cc::Animation::TargetProperty>(target_property)); |
| 50 } | 52 } |
| 51 | 53 |
| 52 WebAnimationImpl::~WebAnimationImpl() {} | 54 WebAnimationImpl::~WebAnimationImpl() {} |
| 53 | 55 |
| 54 int WebAnimationImpl::id() { return animation_->id(); } | 56 int WebAnimationImpl::id() { return animation_->id(); } |
| 55 | 57 |
| 56 WebAnimation::TargetProperty WebAnimationImpl::targetProperty() const { | 58 WebKit::WebAnimation::TargetProperty WebAnimationImpl::targetProperty() const { |
| 57 return static_cast<WebAnimationImpl::TargetProperty>( | 59 return static_cast<WebAnimationImpl::TargetProperty>( |
| 58 animation_->target_property()); | 60 animation_->target_property()); |
| 59 } | 61 } |
| 60 | 62 |
| 61 int WebAnimationImpl::iterations() const { return animation_->iterations(); } | 63 int WebAnimationImpl::iterations() const { return animation_->iterations(); } |
| 62 | 64 |
| 63 void WebAnimationImpl::setIterations(int n) { animation_->set_iterations(n); } | 65 void WebAnimationImpl::setIterations(int n) { animation_->set_iterations(n); } |
| 64 | 66 |
| 65 double WebAnimationImpl::startTime() const { return animation_->start_time(); } | 67 double WebAnimationImpl::startTime() const { return animation_->start_time(); } |
| 66 | 68 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 77 } | 79 } |
| 78 | 80 |
| 79 bool WebAnimationImpl::alternatesDirection() const { | 81 bool WebAnimationImpl::alternatesDirection() const { |
| 80 return animation_->alternates_direction(); | 82 return animation_->alternates_direction(); |
| 81 } | 83 } |
| 82 | 84 |
| 83 void WebAnimationImpl::setAlternatesDirection(bool alternates) { | 85 void WebAnimationImpl::setAlternatesDirection(bool alternates) { |
| 84 animation_->set_alternates_direction(alternates); | 86 animation_->set_alternates_direction(alternates); |
| 85 } | 87 } |
| 86 | 88 |
| 87 scoped_ptr<cc::Animation> WebAnimationImpl::cloneToAnimation() { | 89 scoped_ptr<cc::Animation> WebAnimationImpl::CloneToAnimation() { |
| 88 scoped_ptr<cc::Animation> to_return( | 90 scoped_ptr<cc::Animation> to_return( |
| 89 animation_->Clone(cc::Animation::NonControllingInstance)); | 91 animation_->Clone(cc::Animation::NonControllingInstance)); |
| 90 to_return->set_needs_synchronized_start_time(true); | 92 to_return->set_needs_synchronized_start_time(true); |
| 91 return to_return.Pass(); | 93 return to_return.Pass(); |
| 92 } | 94 } |
| 93 | 95 |
| 94 } // namespace WebKit | 96 } // namespace webkit |
| OLD | NEW |