Changeset 108727 in webkit
- Timestamp:
- Feb 23, 2012 9:31:12 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r108726 r108727 1 2012-02-23 Ian Vollick <vollick@chromium.org> 2 3 [chromium] Implement keyframed animations for the cc thread. 4 https://bugs.webkit.org/show_bug.cgi?id=77229 5 6 Reviewed by James Robinson. 7 8 * WebCore.gypi: 9 * platform/graphics/chromium/LayerChromium.cpp: 10 (WebCore::LayerChromium::hasActiveAnimation): 11 (WebCore): 12 * platform/graphics/chromium/LayerChromium.h: 13 (LayerChromium): 14 * platform/graphics/chromium/cc/CCActiveAnimation.cpp: 15 (WebCore::CCActiveAnimation::CCActiveAnimation): 16 (WebCore::CCActiveAnimation::isFinishedAt): 17 (WebCore::CCActiveAnimation::trimTimeToCurrentIteration): 18 (WebCore::CCActiveAnimation::cloneForImplThread): 19 * platform/graphics/chromium/cc/CCActiveAnimation.h: 20 (WebCore::CCActiveAnimation::curve): 21 (CCActiveAnimation): 22 * platform/graphics/chromium/cc/CCKeyframedAnimationCurve.cpp: Added. 23 (WebCore::CCKeyframedFloatAnimationCurve::create): 24 (WebCore): 25 (WebCore::CCKeyframedFloatAnimationCurve::CCKeyframedFloatAnimationCurve): 26 (WebCore::CCKeyframedFloatAnimationCurve::~CCKeyframedFloatAnimationCurve): 27 (WebCore::CCKeyframedFloatAnimationCurve::duration): 28 (WebCore::CCKeyframedFloatAnimationCurve::clone): 29 (WebCore::CCKeyframedFloatAnimationCurve::getValue): 30 (WebCore::CCKeyframedTransformAnimationCurve::create): 31 (WebCore::CCKeyframedTransformAnimationCurve::CCKeyframedTransformAnimationCurve): 32 (WebCore::CCKeyframedTransformAnimationCurve::~CCKeyframedTransformAnimationCurve): 33 (WebCore::CCKeyframedTransformAnimationCurve::duration): 34 (WebCore::CCKeyframedTransformAnimationCurve::clone): 35 (WebCore::CCKeyframedTransformAnimationCurve::getValue): 36 * platform/graphics/chromium/cc/CCKeyframedAnimationCurve.h: Added. 37 (WebCore): 38 (WebCore::CCFloatKeyframe::CCFloatKeyframe): 39 (CCFloatKeyframe): 40 (WebCore::CCTransformKeyframe::CCTransformKeyframe): 41 (CCTransformKeyframe): 42 (CCKeyframedFloatAnimationCurve): 43 (CCKeyframedTransformAnimationCurve): 44 * platform/graphics/chromium/cc/CCLayerAnimationController.cpp: 45 (WebCore::CCLayerAnimationController::addAnimation): 46 * platform/graphics/chromium/cc/CCLayerAnimationController.h: 47 (WebCore::CCLayerAnimationController::hasActiveAnimation): 48 (CCLayerAnimationController): 49 * platform/graphics/chromium/cc/CCLayerAnimationControllerImpl.cpp: 50 (WebCore::CCLayerAnimationControllerImpl::tickAnimations): 51 1 52 2012-02-23 Raymond Toy <rtoy@google.com> 2 53 -
trunk/Source/WebCore/WebCore.gypi
r108710 r108727 3269 3269 'platform/graphics/chromium/cc/CCHeadsUpDisplay.h', 3270 3270 'platform/graphics/chromium/cc/CCInputHandler.h', 3271 'platform/graphics/chromium/cc/CCKeyframedAnimationCurve.cpp', 3272 'platform/graphics/chromium/cc/CCKeyframedAnimationCurve.h', 3271 3273 'platform/graphics/chromium/cc/CCLayerAnimationController.h', 3272 3274 'platform/graphics/chromium/cc/CCLayerAnimationController.cpp', -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
r108698 r108727 137 137 } 138 138 139 bool LayerChromium::hasActiveAnimation() const 140 { 141 return m_layerAnimationController->hasActiveAnimation(); 142 } 143 139 144 void LayerChromium::setIsNonCompositedContent(bool isNonCompositedContent) 140 145 { -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h
r108698 r108727 225 225 CCLayerAnimationController* layerAnimationController() { return m_layerAnimationController.get(); } 226 226 void setLayerAnimationController(PassOwnPtr<CCLayerAnimationController>); 227 bool hasActiveAnimation() const; 227 228 228 229 protected: -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.cpp
r108581 r108727 39 39 40 40 CCActiveAnimation::CCActiveAnimation(PassOwnPtr<CCAnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty) 41 : m_ animationCurve(curve)41 : m_curve(curve) 42 42 , m_id(animationId) 43 43 , m_group(groupId) … … 71 71 return m_runState == Running 72 72 && m_iterations >= 0 73 && m_iterations * m_ animationCurve->duration() <= time - startTime() - m_totalPausedTime;73 && m_iterations * m_curve->duration() <= time - startTime() - m_totalPausedTime; 74 74 } 75 75 … … 110 110 111 111 // If less than an iteration duration, just return trimmed. 112 if (trimmed < m_ animationCurve->duration())112 if (trimmed < m_curve->duration()) 113 113 return trimmed; 114 114 115 115 // If greater than or equal to the total duration, return iteration duration. 116 if (m_iterations >= 0 && trimmed >= m_ animationCurve->duration() * m_iterations)117 return m_ animationCurve->duration();116 if (m_iterations >= 0 && trimmed >= m_curve->duration() * m_iterations) 117 return m_curve->duration(); 118 118 119 119 // Finally, return x where trimmed = x + n * m_animation->duration() for some positive integer n. 120 return fmod(trimmed, m_ animationCurve->duration());120 return fmod(trimmed, m_curve->duration()); 121 121 } 122 122 123 123 PassOwnPtr<CCActiveAnimation> CCActiveAnimation::cloneForImplThread() const 124 124 { 125 OwnPtr<CCActiveAnimation> toReturn(adoptPtr(new CCActiveAnimation(m_ animationCurve->clone(), m_id, m_group, m_targetProperty)));125 OwnPtr<CCActiveAnimation> toReturn(adoptPtr(new CCActiveAnimation(m_curve->clone(), m_id, m_group, m_targetProperty))); 126 126 toReturn->m_runState = m_runState; 127 127 toReturn->m_iterations = m_iterations; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCActiveAnimation.h
r108581 r108727 98 98 bool isRunningOrHasRun() const; 99 99 100 CCAnimationCurve* animationCurve() { return m_animationCurve.get(); }101 const CCAnimationCurve* animationCurve() const { return m_animationCurve.get(); }100 CCAnimationCurve* curve() { return m_curve.get(); } 101 const CCAnimationCurve* curve() const { return m_curve.get(); } 102 102 103 103 // Takes the given absolute time, and using the start time and the number … … 114 114 CCActiveAnimation(PassOwnPtr<CCAnimationCurve>, int animationId, int groupId, TargetProperty); 115 115 116 OwnPtr<CCAnimationCurve> m_ animationCurve;116 OwnPtr<CCAnimationCurve> m_curve; 117 117 118 118 // IDs are not necessarily unique. -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp
r108581 r108727 29 29 #include "GraphicsLayer.h" // for KeyframeValueList 30 30 #include "cc/CCActiveAnimation.h" 31 #include "cc/CCKeyframedAnimationCurve.h" 31 32 #include "cc/CCLayerAnimationControllerImpl.h" 33 #include <wtf/CurrentTime.h> 32 34 #include <wtf/HashMap.h> 33 35 34 36 namespace WebCore { 35 37 38 namespace { 39 40 template <typename Keyframe, typename Value> 41 void appendKeyframe(Vector<Keyframe>& keyframes, double keyTime, const Value* value) 42 { 43 keyframes.append(Keyframe(keyTime, value->value())); 44 } 45 46 template <> 47 void appendKeyframe<CCTransformKeyframe, TransformAnimationValue>(Vector<CCTransformKeyframe>& keyframes, double keyTime, const TransformAnimationValue* value) 48 { 49 keyframes.append(CCTransformKeyframe(keyTime, *value->value())); 50 } 51 52 template <class Value, class Keyframe, class Curve> 53 PassOwnPtr<CCActiveAnimation> createActiveAnimation(const KeyframeValueList& valueList, const Animation* animation, size_t animationId, size_t groupId, double timeOffset, CCActiveAnimation::TargetProperty targetProperty) 54 { 55 // FIXME: add support for different directions. 56 if (animation && animation->isDirectionSet() && animation->direction() == Animation::AnimationDirectionAlternate) 57 return nullptr; 58 59 // FIXME: add support for delay 60 if (animation && animation->isDelaySet() && animation->delay() > 0) 61 return nullptr; 62 63 // FIXME: add support for fills forwards and fills backwards 64 if (animation && animation->isFillModeSet() && (animation->fillsForwards() || animation->fillsBackwards())) 65 return nullptr; 66 67 Vector<Keyframe> keyframes; 68 69 for (size_t i = 0; i < valueList.size(); i++) { 70 const Value* originalValue = static_cast<const Value*>(valueList.at(i)); 71 72 // FIXME: add support for timing functions. 73 if (originalValue->timingFunction() && originalValue->timingFunction()->type() != TimingFunction::LinearFunction) 74 return nullptr; 75 76 double duration = (animation && animation->isDurationSet()) ? animation->duration() : 1; 77 appendKeyframe(keyframes, originalValue->keyTime() * duration, originalValue); 78 } 79 80 OwnPtr<Curve> curve = Curve::create(keyframes); 81 82 OwnPtr<CCActiveAnimation> anim = CCActiveAnimation::create(curve.release(), animationId, groupId, targetProperty); 83 84 ASSERT(anim.get()); 85 86 if (anim.get()) { 87 int iterations = (animation && animation->isIterationCountSet()) ? animation->iterationCount() : 1; 88 anim->setIterations(iterations); 89 } 90 91 return anim.release(); 92 } 93 94 } // namepace 95 36 96 CCLayerAnimationController::CCLayerAnimationController() 37 97 { … … 47 107 } 48 108 49 bool CCLayerAnimationController::addAnimation(const KeyframeValueList& valueList, 50 const IntSize&, 51 const Animation* animation, 52 int animationId, 53 int groupId, 54 double timeOffset) 55 { 109 bool CCLayerAnimationController::addAnimation(const KeyframeValueList& valueList, const IntSize&, const Animation* animation, int animationId, int groupId, double timeOffset) 110 { 111 if (!animation) 112 return false; 113 114 OwnPtr<CCActiveAnimation> toAdd; 115 if (valueList.property() == AnimatedPropertyWebkitTransform) 116 toAdd = createActiveAnimation<TransformAnimationValue, CCTransformKeyframe, CCKeyframedTransformAnimationCurve>(valueList, animation, animationId, groupId, timeOffset, CCActiveAnimation::Transform); 117 else if (valueList.property() == AnimatedPropertyOpacity) 118 toAdd = createActiveAnimation<FloatAnimationValue, CCFloatKeyframe, CCKeyframedFloatAnimationCurve>(valueList, animation, animationId, groupId, timeOffset, CCActiveAnimation::Opacity); 119 120 if (toAdd.get()) { 121 m_activeAnimations.append(toAdd.release()); 122 return true; 123 } 124 56 125 return false; 57 126 } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.h
r108593 r108727 57 57 virtual void synchronizeAnimations(CCLayerAnimationControllerImpl*); 58 58 59 // This is for testing purposes only.60 Vector<OwnPtr<CCActiveAnimation> >& activeAnimations() { return m_activeAnimations; }59 bool hasActiveAnimation() const { return m_activeAnimations.size(); } 60 CCActiveAnimation* getActiveAnimation(int groupId, CCActiveAnimation::TargetProperty); 61 61 62 62 protected: … … 69 69 void pushAnimationProperties(CCLayerAnimationControllerImpl*); 70 70 71 CCActiveAnimation* getActiveAnimation(int groupId, CCActiveAnimation::TargetProperty);72 71 void remove(int groupId, CCActiveAnimation::TargetProperty); 73 72 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationControllerImpl.cpp
r108581 r108727 202 202 203 203 case CCActiveAnimation::Transform: { 204 const CCTransformAnimationCurve* transformAnimationCurve = m_activeAnimations[i]-> animationCurve()->toTransformAnimationCurve();204 const CCTransformAnimationCurve* transformAnimationCurve = m_activeAnimations[i]->curve()->toTransformAnimationCurve(); 205 205 const TransformationMatrix matrix = transformAnimationCurve->getValue(trimmed, m_client->bounds()); 206 206 if (m_activeAnimations[i]->isFinishedAt(now)) … … 212 212 213 213 case CCActiveAnimation::Opacity: { 214 const CCFloatAnimationCurve* floatAnimationCurve = m_activeAnimations[i]-> animationCurve()->toFloatAnimationCurve();214 const CCFloatAnimationCurve* floatAnimationCurve = m_activeAnimations[i]->curve()->toFloatAnimationCurve(); 215 215 const float opacity = floatAnimationCurve->getValue(trimmed); 216 216 if (m_activeAnimations[i]->isFinishedAt(now)) -
trunk/Source/WebKit/chromium/ChangeLog
r108706 r108727 1 2012-02-23 Ian Vollick <vollick@chromium.org> 2 3 [chromium] Implement keyframed animations for the cc thread. 4 https://bugs.webkit.org/show_bug.cgi?id=77229 5 6 Reviewed by James Robinson. 7 8 * WebKit.gypi: 9 * tests/CCAnimationTestCommon.cpp: 10 (WebCore): 11 (WebCore::addOpacityTransition): 12 (WebKitTests::addOpacityTransitionToController): 13 (WebKitTests::addOpacityTransitionToLayer): 14 * tests/CCAnimationTestCommon.h: 15 (WebCore): 16 (WebKitTests): 17 * tests/CCKeyframedAnimationCurveTest.cpp: Added. 18 (WebCore): 19 (WebCore::expectTranslateX): 20 (WebCore::TEST): 21 * tests/CCLayerAnimationControllerTest.cpp: 22 (WebKitTests::expectTranslateX): 23 (WebKitTests): 24 (WebKitTests::TEST): 25 * tests/CCLayerTreeHostTest.cpp: 26 (WTF::CCLayerTreeHostTest::dispatchAddAnimation): 27 (WTF::CCLayerTreeHostTest::doBeginTest): 28 1 29 2012-02-23 James Robinson <jamesr@chromium.org> 2 30 -
trunk/Source/WebKit/chromium/WebKit.gypi
r108581 r108727 67 67 'tests/CCDelayBasedTimeSourceTest.cpp', 68 68 'tests/CCFrameRateControllerTest.cpp', 69 'tests/CCKeyframedAnimationCurveTest.cpp', 69 70 'tests/CCLayerAnimationControllerImplTest.cpp', 70 71 'tests/CCLayerAnimationControllerTest.cpp', -
trunk/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp
r108581 r108727 29 29 #include "GraphicsLayer.h" 30 30 #include "LayerChromium.h" 31 #include "cc/CCLayerAnimationController.h" 31 32 32 33 using namespace WebCore; 34 35 namespace { 36 37 template <class Target> 38 void addOpacityTransition(Target& target, double duration, float startOpacity, float endOpacity) 39 { 40 WebCore::KeyframeValueList values(AnimatedPropertyOpacity); 41 if (duration > 0) 42 values.insert(new FloatAnimationValue(0, startOpacity)); 43 values.insert(new FloatAnimationValue(duration, endOpacity)); 44 45 RefPtr<Animation> animation = Animation::create(); 46 animation->setDuration(duration); 47 48 IntSize boxSize; 49 50 target.addAnimation(values, boxSize, animation.get(), 0, 0, 0); 51 } 52 53 } // namespace 33 54 34 55 namespace WebKitTests { … … 100 121 } 101 122 102 void addOpacityTransition (WebCore::LayerChromium& layer, double duration, float startOpacity, float endOpacity)123 void addOpacityTransitionToController(WebCore::CCLayerAnimationController& controller, double duration, float startOpacity, float endOpacity) 103 124 { 104 WebCore::KeyframeValueList values(AnimatedPropertyOpacity); 105 if (duration > 0) 106 values.insert(new FloatAnimationValue(0, startOpacity)); 107 values.insert(new FloatAnimationValue(duration, endOpacity)); 125 addOpacityTransition(controller, duration, startOpacity, endOpacity); 126 } 108 127 109 RefPtr<Animation> animation = Animation::create(); 110 animation->setDuration(1); 111 112 IntSize boxSize; 113 114 layer.addAnimation(values, boxSize, animation.get(), 0, 0, 0); 128 void addOpacityTransitionToLayer(WebCore::LayerChromium& layer, double duration, float startOpacity, float endOpacity) 129 { 130 addOpacityTransition(layer, duration, startOpacity, endOpacity); 115 131 } 116 132 -
trunk/Source/WebKit/chromium/tests/CCAnimationTestCommon.h
r108581 r108727 32 32 33 33 namespace WebCore { 34 class CCLayerAnimationController; 34 35 class LayerChromium; 35 36 } … … 95 96 }; 96 97 97 void addOpacityTransition(WebCore::LayerChromium&, double duration, float startOpacity, float endOpacity); 98 void addOpacityTransitionToController(WebCore::CCLayerAnimationController&, double duration, float startOpacity, float endOpacity); 99 100 void addOpacityTransitionToLayer(WebCore::LayerChromium&, double duration, float startOpacity, float endOpacity); 98 101 99 102 } // namespace WebKitTests -
trunk/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
r108581 r108727 28 28 29 29 #include "CCAnimationTestCommon.h" 30 #include "GraphicsLayer.h" 31 #include "Length.h" 32 #include "TranslateTransformOperation.h" 33 #include "cc/CCActiveAnimation.h" 34 #include "cc/CCAnimationCurve.h" 35 30 36 #include <gmock/gmock.h> 31 37 #include <gtest/gtest.h> … … 37 43 namespace { 38 44 45 void expectTranslateX(double translateX, const TransformationMatrix& matrix) 46 { 47 TransformationMatrix::DecomposedType decomposedType; 48 matrix.decompose(decomposedType); 49 EXPECT_FLOAT_EQ(translateX, decomposedType.translateX); 50 } 51 39 52 PassOwnPtr<CCActiveAnimation> createActiveAnimation(PassOwnPtr<CCAnimationCurve> curve, int id, CCActiveAnimation::TargetProperty property) 40 53 { … … 42 55 } 43 56 57 TEST(CCLayerAnimationControllerTest, createOpacityAnimation) 58 { 59 OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); 60 const double duration = 1; 61 WebCore::KeyframeValueList values(AnimatedPropertyOpacity); 62 values.insert(new FloatAnimationValue(0, 0)); 63 values.insert(new FloatAnimationValue(duration, 1)); 64 65 RefPtr<Animation> animation = Animation::create(); 66 animation->setDuration(duration); 67 68 IntSize boxSize; 69 controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0); 70 71 EXPECT_TRUE(controller->hasActiveAnimation()); 72 73 CCActiveAnimation* activeAnimation = controller->getActiveAnimation(0, CCActiveAnimation::Opacity); 74 EXPECT_TRUE(activeAnimation); 75 76 EXPECT_EQ(1, activeAnimation->iterations()); 77 EXPECT_EQ(CCActiveAnimation::Opacity, activeAnimation->targetProperty()); 78 79 EXPECT_EQ(CCAnimationCurve::Float, activeAnimation->curve()->type()); 80 81 const CCFloatAnimationCurve* curve = activeAnimation->curve()->toFloatAnimationCurve(); 82 EXPECT_TRUE(curve); 83 84 EXPECT_EQ(0, curve->getValue(0)); 85 EXPECT_EQ(1, curve->getValue(duration)); 86 } 87 88 TEST(CCLayerAnimationControllerTest, createTransformAnimation) 89 { 90 OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); 91 const double duration = 1; 92 WebCore::KeyframeValueList values(AnimatedPropertyWebkitTransform); 93 94 TransformOperations operations1; 95 operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); 96 values.insert(new TransformAnimationValue(0, &operations1)); 97 98 TransformOperations operations2; 99 operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); 100 values.insert(new TransformAnimationValue(duration, &operations2)); 101 102 RefPtr<Animation> animation = Animation::create(); 103 animation->setDuration(duration); 104 105 IntSize boxSize; 106 controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0); 107 108 EXPECT_TRUE(controller->hasActiveAnimation()); 109 110 CCActiveAnimation* activeAnimation = controller->getActiveAnimation(0, CCActiveAnimation::Transform); 111 EXPECT_TRUE(activeAnimation); 112 113 EXPECT_EQ(1, activeAnimation->iterations()); 114 EXPECT_EQ(CCActiveAnimation::Transform, activeAnimation->targetProperty()); 115 116 EXPECT_EQ(CCAnimationCurve::Transform, activeAnimation->curve()->type()); 117 118 const CCTransformAnimationCurve* curve = activeAnimation->curve()->toTransformAnimationCurve(); 119 EXPECT_TRUE(curve); 120 121 expectTranslateX(2, curve->getValue(0, boxSize)); 122 expectTranslateX(4, curve->getValue(duration, boxSize)); 123 } 124 44 125 TEST(CCLayerAnimationControllerTest, syncNewAnimation) 45 126 { 46 127 FakeLayerAnimationControllerImplClient dummy; 47 OwnPtr<CCLayerAnimationControllerImpl> controllerImpl( 48 CCLayerAnimationControllerImpl::create(&dummy)); 49 OwnPtr<CCLayerAnimationController> controller( 50 CCLayerAnimationController::create()); 51 52 EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); 53 54 controller->activeAnimations().append(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimationCurve()), 0, 0, CCActiveAnimation::Opacity)); 128 OwnPtr<CCLayerAnimationControllerImpl> controllerImpl(CCLayerAnimationControllerImpl::create(&dummy)); 129 OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); 130 131 EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); 132 133 addOpacityTransitionToController(*controller, 1, 0, 1); 55 134 56 135 controller->synchronizeAnimations(controllerImpl.get()); … … 63 142 { 64 143 FakeLayerAnimationControllerImplClient dummy; 65 OwnPtr<CCLayerAnimationControllerImpl> controllerImpl( 66 CCLayerAnimationControllerImpl::create(&dummy)); 67 OwnPtr<CCLayerAnimationController> controller( 68 CCLayerAnimationController::create()); 69 70 EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); 71 72 controller->activeAnimations().append(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimationCurve()), 0, 0, CCActiveAnimation::Opacity)); 144 OwnPtr<CCLayerAnimationControllerImpl> controllerImpl(CCLayerAnimationControllerImpl::create(&dummy)); 145 OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); 146 147 EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); 148 149 addOpacityTransitionToController(*controller, 1, 0, 1); 73 150 74 151 controller->synchronizeAnimations(controllerImpl.get()); … … 88 165 { 89 166 FakeLayerAnimationControllerImplClient dummy; 90 OwnPtr<CCLayerAnimationControllerImpl> controllerImpl( 91 CCLayerAnimationControllerImpl::create(&dummy)); 92 OwnPtr<CCLayerAnimationController> controller( 93 CCLayerAnimationController::create()); 94 95 EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); 96 97 controller->activeAnimations().append(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimationCurve()), 0, 0, CCActiveAnimation::Opacity)); 167 OwnPtr<CCLayerAnimationControllerImpl> controllerImpl(CCLayerAnimationControllerImpl::create(&dummy)); 168 OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); 169 170 EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); 171 172 addOpacityTransitionToController(*controller, 1, 0, 1); 98 173 99 174 controller->synchronizeAnimations(controllerImpl.get()); … … 113 188 { 114 189 FakeLayerAnimationControllerImplClient dummy; 115 OwnPtr<CCLayerAnimationControllerImpl> controllerImpl( 116 CCLayerAnimationControllerImpl::create(&dummy)); 117 OwnPtr<CCLayerAnimationController> controller( 118 CCLayerAnimationController::create()); 119 120 EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); 121 122 controller->activeAnimations().append(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimationCurve()), 0, 0, CCActiveAnimation::Opacity)); 190 OwnPtr<CCLayerAnimationControllerImpl> controllerImpl(CCLayerAnimationControllerImpl::create(&dummy)); 191 OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); 192 193 EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); 194 195 addOpacityTransitionToController(*controller, 1, 0, 1); 123 196 124 197 controller->synchronizeAnimations(controllerImpl.get()); … … 133 206 134 207 EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); 135 EXPECT_ EQ(size_t(1), controller->activeAnimations().size());136 137 controller->synchronizeAnimations(controllerImpl.get()); 138 139 EXPECT_ EQ(size_t(0), controller->activeAnimations().size());208 EXPECT_TRUE(controller->hasActiveAnimation()); 209 210 controller->synchronizeAnimations(controllerImpl.get()); 211 212 EXPECT_FALSE(controller->hasActiveAnimation()); 140 213 } 141 214 -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
r108706 r108727 152 152 }; 153 153 154 // Adapts CCLayerAnimationController for test. Adds a dummy implementation of addAnimation that inserts a float animation.155 // FIXME: once CCLayerAnimationController::addAnimation is implemented, that function should be called directly and this156 // class can be removed.157 class MockLayerAnimationController : public CCLayerAnimationController {158 public:159 static PassOwnPtr<MockLayerAnimationController> create()160 {161 return adoptPtr(new MockLayerAnimationController);162 }163 164 private:165 virtual bool addAnimation(const KeyframeValueList&, const IntSize& boxSize, const Animation*, int animationId, int groupId, double timeOffset)166 {167 double duration = 0;168 activeAnimations().append(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(duration, 1, 0)), animationId, groupId, CCActiveAnimation::Opacity));169 return true;170 }171 };172 173 154 class CompositorFakeWebGraphicsContext3DWithTextureTracking : public CompositorFakeWebGraphicsContext3D { 174 155 public: … … 362 343 ASSERT(test); 363 344 if (test->m_layerTreeHost && test->m_layerTreeHost->rootLayer()) 364 test->m_layerTreeHost->rootLayer()->addAnimation(KeyframeValueList(AnimatedPropertyOpacity), IntSize(), 0, 0, 0, 0.0);345 addOpacityTransitionToLayer(*test->m_layerTreeHost->rootLayer(), 0, 0, 1); 365 346 } 366 347 … … 515 496 ASSERT_TRUE(m_layerTreeHost); 516 497 rootLayer->setLayerTreeHost(m_layerTreeHost.get()); 517 rootLayer->setLayerAnimationController(MockLayerAnimationController::create());518 498 519 499 m_beginning = true;
Note: See TracChangeset
for help on using the changeset viewer.