| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/animation/CompositorAnimation.h" | 5 #include "platform/animation/CompositorAnimation.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 "platform/animation/CompositorAnimationCurve.h" | 10 #include "platform/animation/CompositorAnimationCurve.h" |
| 11 #include "platform/animation/CompositorFilterAnimationCurve.h" | 11 #include "platform/animation/CompositorFilterAnimationCurve.h" |
| 12 #include "platform/animation/CompositorFloatAnimationCurve.h" | 12 #include "platform/animation/CompositorFloatAnimationCurve.h" |
| 13 #include "platform/animation/CompositorScrollOffsetAnimationCurve.h" | 13 #include "platform/animation/CompositorScrollOffsetAnimationCurve.h" |
| 14 #include "platform/animation/CompositorTransformAnimationCurve.h" | 14 #include "platform/animation/CompositorTransformAnimationCurve.h" |
| 15 | 15 |
| 16 using cc::Animation; | 16 using cc::Animation; |
| 17 using cc::AnimationIdProvider; | 17 using cc::AnimationIdProvider; |
| 18 | 18 |
| 19 using blink::CompositorAnimation; | 19 using blink::CompositorAnimation; |
| 20 using blink::CompositorAnimationCurve; | 20 using blink::CompositorAnimationCurve; |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 | 23 |
| 24 #define STATIC_ASSERT_ENUM(a, b) \ | 24 CompositorAnimation::CompositorAnimation(const CompositorAnimationCurve& webCurv
e, CompositorTargetProperty::Type targetProperty, int animationId, int groupId) |
| 25 static_assert(static_cast<int>(a) == static_cast<int>(b), \ | |
| 26 "mismatching enums: " #a) | |
| 27 | |
| 28 // TargetProperty | |
| 29 STATIC_ASSERT_ENUM(CompositorAnimation::TargetPropertyTransform, cc::Animation::
TRANSFORM); | |
| 30 STATIC_ASSERT_ENUM(CompositorAnimation::TargetPropertyOpacity, cc::Animation::OP
ACITY); | |
| 31 STATIC_ASSERT_ENUM(CompositorAnimation::TargetPropertyFilter, cc::Animation::FIL
TER); | |
| 32 STATIC_ASSERT_ENUM(CompositorAnimation::TargetPropertyScrollOffset, cc::Animatio
n::SCROLL_OFFSET); | |
| 33 | |
| 34 CompositorAnimation::CompositorAnimation(const CompositorAnimationCurve& webCurv
e, TargetProperty targetProperty, int animationId, int groupId) | |
| 35 { | 25 { |
| 36 if (!animationId) | 26 if (!animationId) |
| 37 animationId = AnimationIdProvider::NextAnimationId(); | 27 animationId = AnimationIdProvider::NextAnimationId(); |
| 38 if (!groupId) | 28 if (!groupId) |
| 39 groupId = AnimationIdProvider::NextGroupId(); | 29 groupId = AnimationIdProvider::NextGroupId(); |
| 40 | 30 |
| 41 CompositorAnimationCurve::AnimationCurveType curveType = webCurve.type(); | 31 CompositorAnimationCurve::AnimationCurveType curveType = webCurve.type(); |
| 42 scoped_ptr<cc::AnimationCurve> curve; | 32 scoped_ptr<cc::AnimationCurve> curve; |
| 43 switch (curveType) { | 33 switch (curveType) { |
| 44 case CompositorAnimationCurve::AnimationCurveTypeFloat: { | 34 case CompositorAnimationCurve::AnimationCurveTypeFloat: { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 55 const blink::CompositorFilterAnimationCurve* filterCurve = static_cast<c
onst blink::CompositorFilterAnimationCurve*>(&webCurve); | 45 const blink::CompositorFilterAnimationCurve* filterCurve = static_cast<c
onst blink::CompositorFilterAnimationCurve*>(&webCurve); |
| 56 curve = filterCurve->cloneToAnimationCurve(); | 46 curve = filterCurve->cloneToAnimationCurve(); |
| 57 break; | 47 break; |
| 58 } | 48 } |
| 59 case CompositorAnimationCurve::AnimationCurveTypeScrollOffset: { | 49 case CompositorAnimationCurve::AnimationCurveTypeScrollOffset: { |
| 60 const blink::CompositorScrollOffsetAnimationCurve* scrollCurve = static_
cast<const blink::CompositorScrollOffsetAnimationCurve*>(&webCurve); | 50 const blink::CompositorScrollOffsetAnimationCurve* scrollCurve = static_
cast<const blink::CompositorScrollOffsetAnimationCurve*>(&webCurve); |
| 61 curve = scrollCurve->cloneToAnimationCurve(); | 51 curve = scrollCurve->cloneToAnimationCurve(); |
| 62 break; | 52 break; |
| 63 } | 53 } |
| 64 } | 54 } |
| 65 m_animation = Animation::Create( | 55 m_animation = Animation::Create(std::move(curve), animationId, groupId, targ
etProperty); |
| 66 std::move(curve), animationId, groupId, | |
| 67 static_cast<cc::Animation::TargetProperty>(targetProperty)); | |
| 68 } | 56 } |
| 69 | 57 |
| 70 CompositorAnimation::CompositorAnimation() {} | 58 CompositorAnimation::CompositorAnimation() {} |
| 71 | 59 |
| 72 CompositorAnimation::~CompositorAnimation() {} | 60 CompositorAnimation::~CompositorAnimation() {} |
| 73 | 61 |
| 74 int CompositorAnimation::id() | 62 int CompositorAnimation::id() |
| 75 { | 63 { |
| 76 return m_animation->id(); | 64 return m_animation->id(); |
| 77 } | 65 } |
| 78 | 66 |
| 79 int CompositorAnimation::group() | 67 int CompositorAnimation::group() |
| 80 { | 68 { |
| 81 return m_animation->group(); | 69 return m_animation->group(); |
| 82 } | 70 } |
| 83 | 71 |
| 84 blink::CompositorAnimation::TargetProperty CompositorAnimation::targetProperty()
const | 72 CompositorTargetProperty::Type CompositorAnimation::targetProperty() const |
| 85 { | 73 { |
| 86 return static_cast<CompositorAnimation::TargetProperty>(m_animation->target_
property()); | 74 return m_animation->target_property(); |
| 87 } | 75 } |
| 88 | 76 |
| 89 double CompositorAnimation::iterations() const | 77 double CompositorAnimation::iterations() const |
| 90 { | 78 { |
| 91 return m_animation->iterations(); | 79 return m_animation->iterations(); |
| 92 } | 80 } |
| 93 | 81 |
| 94 void CompositorAnimation::setIterations(double n) | 82 void CompositorAnimation::setIterations(double n) |
| 95 { | 83 { |
| 96 m_animation->set_iterations(n); | 84 m_animation->set_iterations(n); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return std::move(m_animation); | 201 return std::move(m_animation); |
| 214 } | 202 } |
| 215 | 203 |
| 216 cc::Animation* CompositorAnimation::releaseCCAnimation() | 204 cc::Animation* CompositorAnimation::releaseCCAnimation() |
| 217 { | 205 { |
| 218 m_animation->set_needs_synchronized_start_time(true); | 206 m_animation->set_needs_synchronized_start_time(true); |
| 219 return m_animation.release(); | 207 return m_animation.release(); |
| 220 } | 208 } |
| 221 | 209 |
| 222 } // namespace blink | 210 } // namespace blink |
| OLD | NEW |