| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "WebAnimationImpl.h" | 7 #include "WebAnimationImpl.h" |
| 8 | 8 |
| 9 #include "CCActiveAnimation.h" | 9 #include "CCActiveAnimation.h" |
| 10 #include "CCAnimationCurve.h" | 10 #include "CCAnimationCurve.h" |
| 11 #include "WebFloatAnimationCurveImpl.h" | 11 #include "WebFloatAnimationCurveImpl.h" |
| 12 #include "WebTransformAnimationCurveImpl.h" | 12 #include "WebTransformAnimationCurveImpl.h" |
| 13 #include <public/WebAnimation.h> | 13 #include <public/WebAnimation.h> |
| 14 #include <public/WebAnimationCurve.h> | 14 #include <public/WebAnimationCurve.h> |
| 15 #include <wtf/OwnPtr.h> | 15 #include <wtf/OwnPtr.h> |
| 16 #include <wtf/PassOwnPtr.h> | |
| 17 | 16 |
| 18 using cc::CCActiveAnimation; | 17 using cc::CCActiveAnimation; |
| 19 | 18 |
| 20 namespace WebKit { | 19 namespace WebKit { |
| 21 | 20 |
| 22 WebAnimation* WebAnimation::create(const WebAnimationCurve& curve, TargetPropert
y targetProperty, int animationId) | 21 WebAnimation* WebAnimation::create(const WebAnimationCurve& curve, TargetPropert
y targetProperty, int animationId) |
| 23 { | 22 { |
| 24 return new WebAnimationImpl(curve, targetProperty, animationId, 0); | 23 return new WebAnimationImpl(curve, targetProperty, animationId, 0); |
| 25 } | 24 } |
| 26 | 25 |
| 27 WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& webCurve, TargetProp
erty targetProperty, int animationId, int groupId) | 26 WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& webCurve, TargetProp
erty targetProperty, int animationId, int groupId) |
| 28 { | 27 { |
| 29 static int nextAnimationId = 1; | 28 static int nextAnimationId = 1; |
| 30 static int nextGroupId = 1; | 29 static int nextGroupId = 1; |
| 31 if (!animationId) | 30 if (!animationId) |
| 32 animationId = nextAnimationId++; | 31 animationId = nextAnimationId++; |
| 33 if (!groupId) | 32 if (!groupId) |
| 34 groupId = nextGroupId++; | 33 groupId = nextGroupId++; |
| 35 | 34 |
| 36 WebAnimationCurve::AnimationCurveType curveType = webCurve.type(); | 35 WebAnimationCurve::AnimationCurveType curveType = webCurve.type(); |
| 37 OwnPtr<cc::CCAnimationCurve> curve; | 36 scoped_ptr<cc::CCAnimationCurve> curve; |
| 38 switch (curveType) { | 37 switch (curveType) { |
| 39 case WebAnimationCurve::AnimationCurveTypeFloat: { | 38 case WebAnimationCurve::AnimationCurveTypeFloat: { |
| 40 const WebFloatAnimationCurveImpl* floatCurveImpl = static_cast<const Web
FloatAnimationCurveImpl*>(&webCurve); | 39 const WebFloatAnimationCurveImpl* floatCurveImpl = static_cast<const Web
FloatAnimationCurveImpl*>(&webCurve); |
| 41 curve = floatCurveImpl->cloneToCCAnimationCurve(); | 40 curve = floatCurveImpl->cloneToCCAnimationCurve(); |
| 42 break; | 41 break; |
| 43 } | 42 } |
| 44 case WebAnimationCurve::AnimationCurveTypeTransform: { | 43 case WebAnimationCurve::AnimationCurveTypeTransform: { |
| 45 const WebTransformAnimationCurveImpl* transformCurveImpl = static_cast<c
onst WebTransformAnimationCurveImpl*>(&webCurve); | 44 const WebTransformAnimationCurveImpl* transformCurveImpl = static_cast<c
onst WebTransformAnimationCurveImpl*>(&webCurve); |
| 46 curve = transformCurveImpl->cloneToCCAnimationCurve(); | 45 curve = transformCurveImpl->cloneToCCAnimationCurve(); |
| 47 break; | 46 break; |
| 48 } | 47 } |
| 49 } | 48 } |
| 50 m_animation = CCActiveAnimation::create(curve.release(), animationId, groupI
d, static_cast<cc::CCActiveAnimation::TargetProperty>(targetProperty)); | 49 m_animation = CCActiveAnimation::create(curve.Pass(), animationId, groupId,
static_cast<cc::CCActiveAnimation::TargetProperty>(targetProperty)); |
| 51 } | 50 } |
| 52 | 51 |
| 53 WebAnimationImpl::~WebAnimationImpl() | 52 WebAnimationImpl::~WebAnimationImpl() |
| 54 { | 53 { |
| 55 } | 54 } |
| 56 | 55 |
| 57 int WebAnimationImpl::id() | 56 int WebAnimationImpl::id() |
| 58 { | 57 { |
| 59 return m_animation->id(); | 58 return m_animation->id(); |
| 60 } | 59 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 bool WebAnimationImpl::alternatesDirection() const | 96 bool WebAnimationImpl::alternatesDirection() const |
| 98 { | 97 { |
| 99 return m_animation->alternatesDirection(); | 98 return m_animation->alternatesDirection(); |
| 100 } | 99 } |
| 101 | 100 |
| 102 void WebAnimationImpl::setAlternatesDirection(bool alternates) | 101 void WebAnimationImpl::setAlternatesDirection(bool alternates) |
| 103 { | 102 { |
| 104 m_animation->setAlternatesDirection(alternates); | 103 m_animation->setAlternatesDirection(alternates); |
| 105 } | 104 } |
| 106 | 105 |
| 107 PassOwnPtr<cc::CCActiveAnimation> WebAnimationImpl::cloneToCCAnimation() | 106 scoped_ptr<cc::CCActiveAnimation> WebAnimationImpl::cloneToCCAnimation() |
| 108 { | 107 { |
| 109 OwnPtr<cc::CCActiveAnimation> toReturn(m_animation->clone(cc::CCActiveAnimat
ion::NonControllingInstance)); | 108 scoped_ptr<cc::CCActiveAnimation> toReturn(m_animation->clone(cc::CCActiveAn
imation::NonControllingInstance)); |
| 110 toReturn->setNeedsSynchronizedStartTime(true); | 109 toReturn->setNeedsSynchronizedStartTime(true); |
| 111 return toReturn.release(); | 110 return toReturn.Pass(); |
| 112 } | 111 } |
| 113 | 112 |
| 114 } // namespace WebKit | 113 } // namespace WebKit |
| OLD | NEW |