| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 | |
| 7 #include "WebAnimationImpl.h" | |
| 8 | |
| 9 #include "WebFloatAnimationCurveImpl.h" | |
| 10 #include "WebTransformAnimationCurveImpl.h" | |
| 11 #include "cc/active_animation.h" | |
| 12 #include "cc/animation_curve.h" | |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimation.h" | |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimationCurve.h
" | |
| 15 | |
| 16 using cc::CCActiveAnimation; | |
| 17 | |
| 18 namespace WebKit { | |
| 19 | |
| 20 WebAnimation* WebAnimation::create(const WebAnimationCurve& curve, TargetPropert
y targetProperty, int animationId) | |
| 21 { | |
| 22 return new WebAnimationImpl(curve, targetProperty, animationId, 0); | |
| 23 } | |
| 24 | |
| 25 WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& webCurve, TargetProp
erty targetProperty, int animationId, int groupId) | |
| 26 { | |
| 27 static int nextAnimationId = 1; | |
| 28 static int nextGroupId = 1; | |
| 29 if (!animationId) | |
| 30 animationId = nextAnimationId++; | |
| 31 if (!groupId) | |
| 32 groupId = nextGroupId++; | |
| 33 | |
| 34 WebAnimationCurve::AnimationCurveType curveType = webCurve.type(); | |
| 35 scoped_ptr<cc::CCAnimationCurve> curve; | |
| 36 switch (curveType) { | |
| 37 case WebAnimationCurve::AnimationCurveTypeFloat: { | |
| 38 const WebFloatAnimationCurveImpl* floatCurveImpl = static_cast<const Web
FloatAnimationCurveImpl*>(&webCurve); | |
| 39 curve = floatCurveImpl->cloneToCCAnimationCurve(); | |
| 40 break; | |
| 41 } | |
| 42 case WebAnimationCurve::AnimationCurveTypeTransform: { | |
| 43 const WebTransformAnimationCurveImpl* transformCurveImpl = static_cast<c
onst WebTransformAnimationCurveImpl*>(&webCurve); | |
| 44 curve = transformCurveImpl->cloneToCCAnimationCurve(); | |
| 45 break; | |
| 46 } | |
| 47 } | |
| 48 m_animation = CCActiveAnimation::create(curve.Pass(), animationId, groupId,
static_cast<cc::CCActiveAnimation::TargetProperty>(targetProperty)); | |
| 49 } | |
| 50 | |
| 51 WebAnimationImpl::~WebAnimationImpl() | |
| 52 { | |
| 53 } | |
| 54 | |
| 55 int WebAnimationImpl::id() | |
| 56 { | |
| 57 return m_animation->id(); | |
| 58 } | |
| 59 | |
| 60 WebAnimation::TargetProperty WebAnimationImpl::targetProperty() const | |
| 61 { | |
| 62 return static_cast<WebAnimationImpl::TargetProperty>(m_animation->targetProp
erty()); | |
| 63 } | |
| 64 | |
| 65 int WebAnimationImpl::iterations() const | |
| 66 { | |
| 67 return m_animation->iterations(); | |
| 68 } | |
| 69 | |
| 70 void WebAnimationImpl::setIterations(int n) | |
| 71 { | |
| 72 m_animation->setIterations(n); | |
| 73 } | |
| 74 | |
| 75 double WebAnimationImpl::startTime() const | |
| 76 { | |
| 77 return m_animation->startTime(); | |
| 78 } | |
| 79 | |
| 80 void WebAnimationImpl::setStartTime(double monotonicTime) | |
| 81 { | |
| 82 m_animation->setStartTime(monotonicTime); | |
| 83 } | |
| 84 | |
| 85 double WebAnimationImpl::timeOffset() const | |
| 86 { | |
| 87 return m_animation->timeOffset(); | |
| 88 } | |
| 89 | |
| 90 void WebAnimationImpl::setTimeOffset(double monotonicTime) | |
| 91 { | |
| 92 m_animation->setTimeOffset(monotonicTime); | |
| 93 } | |
| 94 | |
| 95 bool WebAnimationImpl::alternatesDirection() const | |
| 96 { | |
| 97 return m_animation->alternatesDirection(); | |
| 98 } | |
| 99 | |
| 100 void WebAnimationImpl::setAlternatesDirection(bool alternates) | |
| 101 { | |
| 102 m_animation->setAlternatesDirection(alternates); | |
| 103 } | |
| 104 | |
| 105 scoped_ptr<cc::CCActiveAnimation> WebAnimationImpl::cloneToCCAnimation() | |
| 106 { | |
| 107 scoped_ptr<cc::CCActiveAnimation> toReturn(m_animation->clone(cc::CCActiveAn
imation::NonControllingInstance)); | |
| 108 toReturn->setNeedsSynchronizedStartTime(true); | |
| 109 return toReturn.Pass(); | |
| 110 } | |
| 111 | |
| 112 } // namespace WebKit | |
| OLD | NEW |