[chromium] timing functions are getting incorrectly applied for accelerated css trans...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Mar 2012 12:22:30 +0000 (12:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Mar 2012 12:22:30 +0000 (12:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81692

Patch by Ian Vollick <vollick@chromium.org> on 2012-03-21
Reviewed by Adrienne Walker.

Source/WebCore:

Tested in CCLayerTreeHostTestAddAnimationWithTimingFunction

* platform/graphics/chromium/cc/CCLayerAnimationController.cpp:

Source/WebKit/chromium:

* tests/CCAnimationTestCommon.cpp:
(WebCore::addOpacityTransition):
(WebKitTests::addOpacityTransitionToController):
(WebKitTests::addOpacityTransitionToLayer):
* tests/CCAnimationTestCommon.h:
(WebKitTests):
* tests/CCLayerAnimationControllerTest.cpp:
(WebKitTests::TEST):
* tests/CCLayerTreeHostTest.cpp:
(WTF::CCLayerTreeHostTest::dispatchAddInstantAnimation):
(WTF::CCLayerTreeHostTest::dispatchAddAnimation):
(WTF::TEST_F):
(WTF):
(CCLayerTreeHostTestAddAnimationWithTimingFunction):
(WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::CCLayerTreeHostTestAddAnimationWithTimingFunction):
(WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::beginTest):
(WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::animateLayers):
(WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::afterTest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111527 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp
Source/WebKit/chromium/tests/CCAnimationTestCommon.h
Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

index 49f1b3bafbe28e75f6c552c3c22be549615163c2..26b01ff48ad78d216dd8e9d0b85383f842ff62c1 100644 (file)
@@ -1,3 +1,14 @@
+2012-03-21  Ian Vollick  <vollick@chromium.org>
+
+        [chromium] timing functions are getting incorrectly applied for accelerated css transitions
+        https://bugs.webkit.org/show_bug.cgi?id=81692
+
+        Reviewed by Adrienne Walker.
+
+        Tested in CCLayerTreeHostTestAddAnimationWithTimingFunction
+
+        * platform/graphics/chromium/cc/CCLayerAnimationController.cpp:
+
 2012-03-21  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
 
         [Qt] Cookie Jar blocks on fsync in SQLITE
index 39f9b1699619a60b4d97c2549ab532ceee24af14..372a0e08e8f3b27c745eb45b15235394e72026cb 100644 (file)
@@ -67,8 +67,15 @@ PassOwnPtr<CCActiveAnimation> createActiveAnimation(const KeyframeValueList& val
         const Value* originalValue = static_cast<const Value*>(valueList.at(i));
 
         OwnPtr<CCTimingFunction> timingFunction;
-        if (originalValue->timingFunction()) {
-            switch (originalValue->timingFunction()->type()) {
+        const TimingFunction* originalTimingFunction = originalValue->timingFunction();
+
+        // If there hasn't been a timing function associated with this keyframe, use the
+        // animation's timing function, if we have one.
+        if (!originalTimingFunction && animation->isTimingFunctionSet())
+            originalTimingFunction = animation->timingFunction().get();
+
+        if (originalTimingFunction) {
+            switch (originalTimingFunction->type()) {
             case TimingFunction::StepsFunction:
                 // FIXME: add support for steps timing function.
                 return nullptr;
@@ -76,8 +83,8 @@ PassOwnPtr<CCActiveAnimation> createActiveAnimation(const KeyframeValueList& val
                 // Don't set the timing function. Keyframes are interpolated linearly if there is no timing function.
                 break;
             case TimingFunction::CubicBezierFunction:
-                const CubicBezierTimingFunction* originalTimingFunction = static_cast<const CubicBezierTimingFunction*>(originalValue->timingFunction());
-                timingFunction = CCCubicBezierTimingFunction::create(originalTimingFunction->x1(), originalTimingFunction->y1(), originalTimingFunction->x2(), originalTimingFunction->y2());
+                const CubicBezierTimingFunction* originalBezierTimingFunction = static_cast<const CubicBezierTimingFunction*>(originalTimingFunction);
+                timingFunction = CCCubicBezierTimingFunction::create(originalBezierTimingFunction->x1(), originalBezierTimingFunction->y1(), originalBezierTimingFunction->x2(), originalBezierTimingFunction->y2());
                 break;
             } // switch
         } else
index 6c3b8453e6e4163fe87cc81b52f41b489c650522..ee0583cc3cb5694112e353ce8f077abff255958d 100644 (file)
@@ -1,3 +1,29 @@
+2012-03-21  Ian Vollick  <vollick@chromium.org>
+
+        [chromium] timing functions are getting incorrectly applied for accelerated css transitions
+        https://bugs.webkit.org/show_bug.cgi?id=81692
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCAnimationTestCommon.cpp:
+        (WebCore::addOpacityTransition):
+        (WebKitTests::addOpacityTransitionToController):
+        (WebKitTests::addOpacityTransitionToLayer):
+        * tests/CCAnimationTestCommon.h:
+        (WebKitTests):
+        * tests/CCLayerAnimationControllerTest.cpp:
+        (WebKitTests::TEST):
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::CCLayerTreeHostTest::dispatchAddInstantAnimation):
+        (WTF::CCLayerTreeHostTest::dispatchAddAnimation):
+        (WTF::TEST_F):
+        (WTF):
+        (CCLayerTreeHostTestAddAnimationWithTimingFunction):
+        (WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::CCLayerTreeHostTestAddAnimationWithTimingFunction):
+        (WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::beginTest):
+        (WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::animateLayers):
+        (WTF::CCLayerTreeHostTestAddAnimationWithTimingFunction::afterTest):
+
 2012-03-21  Ian Vollick  <vollick@chromium.org>
 
         [chromium] Animation events should only be used for synchronizing animation start times
index c22e4322b91784f821acc22d7d61636de565a89f..a1d97a51bb47314d0ba95c5491d7760052f7793d 100644 (file)
@@ -35,7 +35,7 @@ using namespace WebCore;
 namespace {
 
 template <class Target>
-void addOpacityTransition(Target& target, double duration, float startOpacity, float endOpacity)
+void addOpacityTransition(Target& target, double duration, float startOpacity, float endOpacity, bool useTimingFunction)
 {
     WebCore::KeyframeValueList values(AnimatedPropertyOpacity);
     if (duration > 0)
@@ -45,6 +45,9 @@ void addOpacityTransition(Target& target, double duration, float startOpacity, f
     RefPtr<Animation> animation = Animation::create();
     animation->setDuration(duration);
 
+    if (useTimingFunction)
+        animation->setTimingFunction(LinearTimingFunction::create());
+
     IntSize boxSize;
 
     target.addAnimation(values, boxSize, animation.get(), 0, 0, 0);
@@ -120,14 +123,14 @@ PassOwnPtr<WebCore::CCAnimationCurve> FakeFloatTransition::clone() const
     return adoptPtr(new FakeFloatTransition(*this));
 }
 
-void addOpacityTransitionToController(WebCore::CCLayerAnimationController& controller, double duration, float startOpacity, float endOpacity)
+void addOpacityTransitionToController(WebCore::CCLayerAnimationController& controller, double duration, float startOpacity, float endOpacity, bool useTimingFunction)
 {
-    addOpacityTransition(controller, duration, startOpacity, endOpacity);
+    addOpacityTransition(controller, duration, startOpacity, endOpacity, useTimingFunction);
 }
 
-void addOpacityTransitionToLayer(WebCore::LayerChromium& layer, double duration, float startOpacity, float endOpacity)
+void addOpacityTransitionToLayer(WebCore::LayerChromium& layer, double duration, float startOpacity, float endOpacity, bool useTimingFunction)
 {
-    addOpacityTransition(layer, duration, startOpacity, endOpacity);
+    addOpacityTransition(layer, duration, startOpacity, endOpacity, useTimingFunction);
 }
 
 } // namespace WebKitTests
index 146414e301ba48716fa47084e3e142a18be4e63d..11a76b8acb07cf8aba79952fe814603406e39da4 100644 (file)
@@ -95,9 +95,9 @@ private:
     WebCore::IntSize m_bounds;
 };
 
-void addOpacityTransitionToController(WebCore::CCLayerAnimationController&, double duration, float startOpacity, float endOpacity);
+void addOpacityTransitionToController(WebCore::CCLayerAnimationController&, double duration, float startOpacity, float endOpacity, bool useTimingFunction);
 
-void addOpacityTransitionToLayer(WebCore::LayerChromium&, double duration, float startOpacity, float endOpacity);
+void addOpacityTransitionToLayer(WebCore::LayerChromium&, double duration, float startOpacity, float endOpacity, bool useTimingFunction);
 
 } // namespace WebKitTests
 
index cb400b936aef6921f987fee3804243e1123411ab..25199b3432f24452605f6046d2d591b81c622cd9 100644 (file)
@@ -133,7 +133,7 @@ TEST(CCLayerAnimationControllerTest, syncNewAnimation)
 
     EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity));
 
-    addOpacityTransitionToController(*controller, 1, 0, 1);
+    addOpacityTransitionToController(*controller, 1, 0, 1, false);
 
     controller->pushAnimationUpdatesTo(controllerImpl.get());
 
index 533ad545facafa47a300703f931c0c696b7eb36e..cdac3295a0b6b79a666627a25c74233c6aeb4e21 100644 (file)
@@ -356,7 +356,7 @@ protected:
         CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self);
         ASSERT(test);
         if (test->m_layerTreeHost && test->m_layerTreeHost->rootLayer())
-            addOpacityTransitionToLayer(*test->m_layerTreeHost->rootLayer(), 0, 0, 0.5);
+            addOpacityTransitionToLayer(*test->m_layerTreeHost->rootLayer(), 0, 0, 0.5, false);
     }
 
     static void dispatchAddAnimation(void* self)
@@ -365,7 +365,7 @@ protected:
         CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self);
         ASSERT(test);
         if (test->m_layerTreeHost && test->m_layerTreeHost->rootLayer())
-            addOpacityTransitionToLayer(*test->m_layerTreeHost->rootLayer(), 10, 0, 0.5);
+            addOpacityTransitionToLayer(*test->m_layerTreeHost->rootLayer(), 10, 0, 0.5, true);
     }
 
     static void dispatchSetNeedsAnimateAndCommit(void* self)
@@ -977,6 +977,44 @@ TEST_F(CCLayerTreeHostTestTickAnimationWhileBackgrounded, runMultiThread)
     runTestThreaded();
 }
 
+// Ensures that animations continue to be ticked when we are backgrounded.
+class CCLayerTreeHostTestAddAnimationWithTimingFunction : public CCLayerTreeHostTestThreadOnly {
+public:
+    CCLayerTreeHostTestAddAnimationWithTimingFunction()
+    {
+    }
+
+    virtual void beginTest()
+    {
+        postAddAnimationToMainThread();
+    }
+
+    virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double monotonicTime)
+    {
+        const CCFloatAnimationCurve* curve = m_layerTreeHost->rootLayer()->layerAnimationController()->getActiveAnimation(0, CCActiveAnimation::Opacity)->curve()->toFloatAnimationCurve();
+        float startOpacity = curve->getValue(0);
+        float endOpacity = curve->getValue(curve->duration());
+        float linearlyInterpolatedOpacity = 0.25 * endOpacity + 0.75 * startOpacity;
+        double time = curve->duration() * 0.25;
+        // If the linear timing function associated with this animation was not picked up,
+        // then the linearly interpolated opacity would be different because of the
+        // default ease timing function.
+        EXPECT_FLOAT_EQ(linearlyInterpolatedOpacity, curve->getValue(time));
+        endTest();
+    }
+
+    virtual void afterTest()
+    {
+    }
+
+private:
+};
+
+TEST_F(CCLayerTreeHostTestAddAnimationWithTimingFunction, runMultiThread)
+{
+    runTestThreaded();
+}
+
 // Ensures that when opacity is being animated, this value does not cause the subtree to be skipped.
 class CCLayerTreeHostTestDoNotSkipLayersWithAnimatedOpacity : public CCLayerTreeHostTestThreadOnly {
 public: