| 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 "webkit/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 "third_party/WebKit/public/platform/WebAnimation.h" | 10 #include "third_party/WebKit/public/platform/WebAnimation.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 double WebAnimationImpl::timeOffset() const { | 90 double WebAnimationImpl::timeOffset() const { |
| 91 return animation_->time_offset(); | 91 return animation_->time_offset(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void WebAnimationImpl::setTimeOffset(double monotonic_time) { | 94 void WebAnimationImpl::setTimeOffset(double monotonic_time) { |
| 95 animation_->set_time_offset(monotonic_time); | 95 animation_->set_time_offset(monotonic_time); |
| 96 } | 96 } |
| 97 | 97 |
| 98 #if WEB_ANIMATION_SUPPORTS_FULL_DIRECTION | |
| 99 blink::WebAnimation::Direction WebAnimationImpl::direction() const { | |
| 100 switch (animation_->direction()) { | |
| 101 case cc::Animation::Normal: | |
| 102 return DirectionNormal; | |
| 103 case cc::Animation::Reverse: | |
| 104 return DirectionReverse; | |
| 105 case cc::Animation::Alternate: | |
| 106 return DirectionAlternate; | |
| 107 case cc::Animation::AlternateReverse: | |
| 108 return DirectionAlternateReverse; | |
| 109 default: | |
| 110 NOTREACHED(); | |
| 111 } | |
| 112 return DirectionNormal; | |
| 113 } | |
| 114 | |
| 115 void WebAnimationImpl::setDirection(Direction direction) { | |
| 116 switch (direction) { | |
| 117 case DirectionNormal: | |
| 118 animation_->set_direction(cc::Animation::Normal); | |
| 119 break; | |
| 120 case DirectionReverse: | |
| 121 animation_->set_direction(cc::Animation::Reverse); | |
| 122 break; | |
| 123 case DirectionAlternate: | |
| 124 animation_->set_direction(cc::Animation::Alternate); | |
| 125 break; | |
| 126 case DirectionAlternateReverse: | |
| 127 animation_->set_direction(cc::Animation::AlternateReverse); | |
| 128 break; | |
| 129 } | |
| 130 } | |
| 131 #else | |
| 132 bool WebAnimationImpl::alternatesDirection() const { | 98 bool WebAnimationImpl::alternatesDirection() const { |
| 133 return animation_->direction() == cc::Animation::Alternate; | 99 return animation_->alternates_direction(); |
| 134 } | 100 } |
| 135 | 101 |
| 136 void WebAnimationImpl::setAlternatesDirection(bool alternates) { | 102 void WebAnimationImpl::setAlternatesDirection(bool alternates) { |
| 137 return animation_->set_direction(cc::Animation::Alternate); | 103 animation_->set_alternates_direction(alternates); |
| 138 } | 104 } |
| 139 #endif | |
| 140 | 105 |
| 141 scoped_ptr<cc::Animation> WebAnimationImpl::PassAnimation() { | 106 scoped_ptr<cc::Animation> WebAnimationImpl::PassAnimation() { |
| 142 animation_->set_needs_synchronized_start_time(true); | 107 animation_->set_needs_synchronized_start_time(true); |
| 143 return animation_.Pass(); | 108 return animation_.Pass(); |
| 144 } | 109 } |
| 145 | 110 |
| 146 #define COMPILE_ASSERT_MATCHING_ENUMS(webkit_name, cc_name) \ | 111 #define COMPILE_ASSERT_MATCHING_ENUMS(webkit_name, cc_name) \ |
| 147 COMPILE_ASSERT(static_cast<int>(webkit_name) == static_cast<int>(cc_name), \ | 112 COMPILE_ASSERT(static_cast<int>(webkit_name) == static_cast<int>(cc_name), \ |
| 148 mismatching_enums) | 113 mismatching_enums) |
| 149 | 114 |
| 150 COMPILE_ASSERT_MATCHING_ENUMS( | 115 COMPILE_ASSERT_MATCHING_ENUMS( |
| 151 WebAnimation::TargetPropertyTransform, Animation::Transform); | 116 WebAnimation::TargetPropertyTransform, Animation::Transform); |
| 152 COMPILE_ASSERT_MATCHING_ENUMS( | 117 COMPILE_ASSERT_MATCHING_ENUMS( |
| 153 WebAnimation::TargetPropertyOpacity, Animation::Opacity); | 118 WebAnimation::TargetPropertyOpacity, Animation::Opacity); |
| 154 COMPILE_ASSERT_MATCHING_ENUMS( | 119 COMPILE_ASSERT_MATCHING_ENUMS( |
| 155 WebAnimation::TargetPropertyFilter, Animation::Filter); | 120 WebAnimation::TargetPropertyFilter, Animation::Filter); |
| 156 #if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED | 121 #if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED |
| 157 COMPILE_ASSERT_MATCHING_ENUMS( | 122 COMPILE_ASSERT_MATCHING_ENUMS( |
| 158 WebAnimation::TargetPropertyScrollOffset, Animation::ScrollOffset); | 123 WebAnimation::TargetPropertyScrollOffset, Animation::ScrollOffset); |
| 159 #endif | 124 #endif |
| 160 | 125 |
| 161 } // namespace webkit | 126 } // namespace webkit |
| OLD | NEW |