Title: [116786] trunk
Revision
116786
Author
[email protected]
Date
2012-05-11 11:04:15 -0700 (Fri, 11 May 2012)

Log Message

[chromium] Ensure that animations continue to run when transform-style is changed
https://bugs.webkit.org/show_bug.cgi?id=83283

Source/WebCore:

Make sure that we transfer animations when changing layers due to a transform-style change.
Unit tested in GraphicsLayerChromiumTest.updateLayerPreserves3DWithAnimations

Patch by Ian Vollick <[email protected]> on 2012-05-11
Reviewed by James Robinson.

Test: animations/change-transform-style-during-animation.html

* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::GraphicsLayerChromium::updateLayerPreserves3D):
* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::setLayerAnimationController):
(WebCore::LayerChromium::releaseLayerAnimationController):
(WebCore):
(WebCore::LayerChromium::notifyAnimationStarted):
* platform/graphics/chromium/LayerChromium.h:
(LayerChromium):
* platform/graphics/chromium/cc/CCLayerAnimationController.cpp:
(WebCore::CCLayerAnimationController::CCLayerAnimationController):
(WebCore::CCLayerAnimationController::pushAnimationUpdatesTo):
(WebCore::CCLayerAnimationController::notifyAnimationStarted):
(WebCore::CCLayerAnimationController::setClient):
(WebCore):
(WebCore::CCLayerAnimationController::pushNewAnimationsToImplThread):
(WebCore::CCLayerAnimationController::replaceImplThreadAnimations):
* platform/graphics/chromium/cc/CCLayerAnimationController.h:
(CCLayerAnimationController):
(WebCore::CCLayerAnimationController::setForceSync):

Source/WebKit/chromium:

Patch by Ian Vollick <[email protected]> on 2012-05-11
Reviewed by James Robinson.

* WebKit.gypi:
* tests/GraphicsLayerChromiumTest.cpp: Added.
(WebKitTests):
(MockGraphicsLayerClient):
(WebKitTests::MockGraphicsLayerClient::notifyAnimationStarted):
(WebKitTests::MockGraphicsLayerClient::notifySyncRequired):
(WebKitTests::MockGraphicsLayerClient::paintContents):
(WebKitTests::MockGraphicsLayerClient::showDebugBorders):
(WebKitTests::MockGraphicsLayerClient::showRepaintCounter):
(WebKitTests::TEST):

LayoutTests:

Patch by Ian Vollick <[email protected]> on 2012-05-11
Reviewed by James Robinson.

* animations/change-transform-style-during-animation-expected.png: Added.
* animations/change-transform-style-during-animation-expected.txt: Added.
* animations/change-transform-style-during-animation.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (116785 => 116786)


--- trunk/LayoutTests/ChangeLog	2012-05-11 17:57:17 UTC (rev 116785)
+++ trunk/LayoutTests/ChangeLog	2012-05-11 18:04:15 UTC (rev 116786)
@@ -1,3 +1,14 @@
+2012-05-11  Ian Vollick  <[email protected]>
+
+        [chromium] Ensure that animations continue to run when transform-style is changed
+        https://bugs.webkit.org/show_bug.cgi?id=83283
+
+        Reviewed by James Robinson.
+
+        * animations/change-transform-style-during-animation-expected.png: Added.
+        * animations/change-transform-style-during-animation-expected.txt: Added.
+        * animations/change-transform-style-during-animation.html: Added.
+
 2012-05-11  Dave Tharp  <[email protected]>
 
         [Qt]ietestcenter/css3/flexbox tests fail on 32 bit

Added: trunk/LayoutTests/animations/change-transform-style-during-animation-expected.png (0 => 116786)


--- trunk/LayoutTests/animations/change-transform-style-during-animation-expected.png	                        (rev 0)
+++ trunk/LayoutTests/animations/change-transform-style-during-animation-expected.png	2012-05-11 18:04:15 UTC (rev 116786)
@@ -0,0 +1,7 @@
+\x89PNG
+
+
+IHDR X')tEXtchecksum1ecf3b281e6e08bcec99c07b70fac274Z\xB6\xA4\xA3
+\xC0IDATx\x9C\xED\xDC\xC1	\xC4@\xC1\xDB\xC3yG.'Ѱx\xA9\x8A`\x9E\x8DZ3\xF3\xA0\xF3\xDF=\xE04 &\xB0b &\xB0b &\xB0b\xD7\xEE'X\xCF\xDA=\xE13\xE6\xF6w
+\x80\xF3\xB9`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4\xD6\xCC\xEC\xDEp,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\xD8\xB3G
+\xAB\xD4BIEND\xAEB`\x82
\ No newline at end of file

Added: trunk/LayoutTests/animations/change-transform-style-during-animation-expected.txt (0 => 116786)


--- trunk/LayoutTests/animations/change-transform-style-during-animation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/animations/change-transform-style-during-animation-expected.txt	2012-05-11 18:04:15 UTC (rev 116786)
@@ -0,0 +1 @@
+PASS - Computed final position is correct.

Added: trunk/LayoutTests/animations/change-transform-style-during-animation.html (0 => 116786)


--- trunk/LayoutTests/animations/change-transform-style-during-animation.html	                        (rev 0)
+++ trunk/LayoutTests/animations/change-transform-style-during-animation.html	2012-05-11 18:04:15 UTC (rev 116786)
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style>
+    #container {
+      -webkit-transform: translateZ(0px);
+      -webkit-perspective: 400;
+    }
+
+    #revealed {
+      position: absolute;
+      left: 100px;
+      height: 100px;
+      width: 100px;
+      background-color: green;
+    }
+
+    #animated {
+      position: absolute;
+      left: 100px;
+      height: 100px;
+      width: 100px;
+      background-color: red;
+      -webkit-transform: translateZ(10px);
+      -webkit-transform-style: preserve-3d;
+      -webkit-animation-duration: 100ms;
+      -webkit-animation-fill-mode: both;
+      -webkit-animation-timing-function: linear;
+      -webkit-animation-iteration-count: 1;
+    }
+
+    @-webkit-keyframes anim {
+      from { -webkit-transform: translateZ(0px) translateX(0px); }
+      to { -webkit-transform: translateZ(200px) translateX(-200px); }
+    }
+   </style>
+
+   <script src=""
+   <script>
+     if (window.layoutTestController) {
+       layoutTestController.dumpAsText();
+       layoutTestController.waitUntilDone();
+     }
+
+     function animationDone()
+     {
+       var animated = document.getElementById('animated');
+       var result;
+       var expected = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -200, 0, 200, 1];
+       var computed = getPropertyValue("webkitTransform", "animated");
+       if (comparePropertyValue("webkitTransform", computed, expected, 0.002)) {
+         result = "PASS - Computed final position is correct.";
+       } else {
+         result = "FAIL - Computed final position is incorrect. Expected " + expected + ", got " + computed;
+       }
+       document.getElementById('result').innerHTML = result;
+       layoutTestController.notifyDone();
+     }
+
+     function animationStarted()
+     {
+       var animated = document.getElementById('animated');
+       animated.style.webkitTransformStyle = 'flat';
+     }
+
+     function startTest()
+     {
+       var animated = document.getElementById('animated');
+       animated.style.webkitAnimationName = "anim";
+       animated.addEventListener('webkitAnimationEnd', animationDone);
+       waitForAnimationToStart(animated, animationStarted);
+     }
+   </script>
+</head>
+<body _onload_="startTest()">
+  <!-- Test for DRT pauseAnimationAtTimeOnElementWithId() API on animations with multiple keyframes -->
+  <div id="container">
+    <div id="revealed"></div>
+    <div id="animated"></div>
+  </div>
+  <div id="result"></div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (116785 => 116786)


--- trunk/Source/WebCore/ChangeLog	2012-05-11 17:57:17 UTC (rev 116785)
+++ trunk/Source/WebCore/ChangeLog	2012-05-11 18:04:15 UTC (rev 116786)
@@ -1,3 +1,36 @@
+2012-05-11  Ian Vollick  <[email protected]>
+
+        [chromium] Ensure that animations continue to run when transform-style is changed
+        https://bugs.webkit.org/show_bug.cgi?id=83283
+
+        Make sure that we transfer animations when changing layers due to a transform-style change.
+        Unit tested in GraphicsLayerChromiumTest.updateLayerPreserves3DWithAnimations
+
+        Reviewed by James Robinson.
+
+        Test: animations/change-transform-style-during-animation.html
+
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayerChromium::updateLayerPreserves3D):
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::setLayerAnimationController):
+        (WebCore::LayerChromium::releaseLayerAnimationController):
+        (WebCore):
+        (WebCore::LayerChromium::notifyAnimationStarted):
+        * platform/graphics/chromium/LayerChromium.h:
+        (LayerChromium):
+        * platform/graphics/chromium/cc/CCLayerAnimationController.cpp:
+        (WebCore::CCLayerAnimationController::CCLayerAnimationController):
+        (WebCore::CCLayerAnimationController::pushAnimationUpdatesTo):
+        (WebCore::CCLayerAnimationController::notifyAnimationStarted):
+        (WebCore::CCLayerAnimationController::setClient):
+        (WebCore):
+        (WebCore::CCLayerAnimationController::pushNewAnimationsToImplThread):
+        (WebCore::CCLayerAnimationController::replaceImplThreadAnimations):
+        * platform/graphics/chromium/cc/CCLayerAnimationController.h:
+        (CCLayerAnimationController):
+        (WebCore::CCLayerAnimationController::setForceSync):
+
 2012-05-11  Tommy Widenflycht  <[email protected]>
 
         MediaStream API: Fix a reference counting issue in UserMediaRequest

Modified: trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp (116785 => 116786)


--- trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2012-05-11 17:57:17 UTC (rev 116785)
+++ trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2012-05-11 18:04:15 UTC (rev 116786)
@@ -607,6 +607,7 @@
         m_transformLayer = LayerChromium::create();
         m_transformLayer->setPreserves3D(true);
         m_transformLayer->setLayerAnimationDelegate(this);
+        m_transformLayer->setLayerAnimationController(m_layer->releaseLayerAnimationController());
 
         // Copy the position from this layer.
         updateLayerPosition();
@@ -638,6 +639,9 @@
         if (m_transformLayer->parent())
             m_transformLayer->parent()->replaceChild(m_transformLayer.get(), m_layer.get());
 
+        m_layer->setLayerAnimationDelegate(this);
+        m_layer->setLayerAnimationController(m_transformLayer->releaseLayerAnimationController());
+
         // Release the transform layer.
         m_transformLayer->setLayerAnimationDelegate(0);
         m_transformLayer = 0;

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp (116785 => 116786)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp	2012-05-11 17:57:17 UTC (rev 116785)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp	2012-05-11 18:04:15 UTC (rev 116786)
@@ -632,9 +632,20 @@
 void LayerChromium::setLayerAnimationController(PassOwnPtr<CCLayerAnimationController> layerAnimationController)
 {
     m_layerAnimationController = layerAnimationController;
+    if (m_layerAnimationController) {
+        m_layerAnimationController->setClient(this);
+        m_layerAnimationController->setForceSync();
+    }
     setNeedsCommit();
 }
 
+PassOwnPtr<CCLayerAnimationController> LayerChromium::releaseLayerAnimationController()
+{
+    OwnPtr<CCLayerAnimationController> toReturn = m_layerAnimationController.release();
+    m_layerAnimationController = CCLayerAnimationController::create(this);
+    return toReturn.release();
+}
+
 bool LayerChromium::hasActiveAnimation() const
 {
     return m_layerAnimationController->hasActiveAnimation();
@@ -643,7 +654,8 @@
 void LayerChromium::notifyAnimationStarted(const CCAnimationEvent& event, double wallClockTime)
 {
     m_layerAnimationController->notifyAnimationStarted(event);
-    m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime);
+    if (m_layerAnimationDelegate)
+        m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime);
 }
 
 void LayerChromium::notifyAnimationFinished(double wallClockTime)

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h (116785 => 116786)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h	2012-05-11 17:57:17 UTC (rev 116785)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h	2012-05-11 18:04:15 UTC (rev 116786)
@@ -240,6 +240,7 @@
 
     CCLayerAnimationController* layerAnimationController() { return m_layerAnimationController.get(); }
     void setLayerAnimationController(PassOwnPtr<CCLayerAnimationController>);
+    PassOwnPtr<CCLayerAnimationController> releaseLayerAnimationController();
 
     void setLayerAnimationDelegate(CCLayerAnimationDelegate* layerAnimationDelegate) { m_layerAnimationDelegate = layerAnimationDelegate; }
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp (116785 => 116786)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp	2012-05-11 17:57:17 UTC (rev 116785)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp	2012-05-11 18:04:15 UTC (rev 116786)
@@ -124,7 +124,8 @@
 } // namepace
 
 CCLayerAnimationController::CCLayerAnimationController(CCLayerAnimationControllerClient* client)
-    : m_client(client)
+    : m_forceSync(false)
+    , m_client(client)
 {
 }
 
@@ -203,9 +204,14 @@
 // are kept in sync.
 void CCLayerAnimationController::pushAnimationUpdatesTo(CCLayerAnimationController* controllerImpl)
 {
-    pushNewAnimationsToImplThread(controllerImpl);
-    removeAnimationsCompletedOnMainThread(controllerImpl);
-    pushPropertiesToImplThread(controllerImpl);
+    if (m_forceSync) {
+        replaceImplThreadAnimations(controllerImpl);
+        m_forceSync = false;
+    } else {
+        pushNewAnimationsToImplThread(controllerImpl);
+        removeAnimationsCompletedOnMainThread(controllerImpl);
+        pushPropertiesToImplThread(controllerImpl);
+    }
 }
 
 void CCLayerAnimationController::animate(double monotonicTime, CCAnimationEventsVector* events)
@@ -253,8 +259,7 @@
 void CCLayerAnimationController::notifyAnimationStarted(const CCAnimationEvent& event)
 {
     for (size_t i = 0; i < m_activeAnimations.size(); ++i) {
-        if (m_activeAnimations[i]->group() == event.groupId && m_activeAnimations[i]->targetProperty() == event.targetProperty) {
-            ASSERT(m_activeAnimations[i]->needsSynchronizedStartTime());
+        if (m_activeAnimations[i]->group() == event.groupId && m_activeAnimations[i]->targetProperty() == event.targetProperty && m_activeAnimations[i]->needsSynchronizedStartTime()) {
             m_activeAnimations[i]->setNeedsSynchronizedStartTime(false);
             m_activeAnimations[i]->setStartTime(event.monotonicTime);
             return;
@@ -262,6 +267,11 @@
     }
 }
 
+void CCLayerAnimationController::setClient(CCLayerAnimationControllerClient* client)
+{
+    m_client = client;
+}
+
 void CCLayerAnimationController::pushNewAnimationsToImplThread(CCLayerAnimationController* controllerImpl) const
 {
     // Any new animations owned by the main thread's controller are cloned and adde to the impl thread's controller.
@@ -281,6 +291,7 @@
         ASSERT(!toAdd->needsSynchronizedStartTime());
         // The new animation should be set to run as soon as possible.
         toAdd->setRunState(CCActiveAnimation::WaitingForTargetAvailability, 0);
+        toAdd->setStartTime(0);
         controllerImpl->add(toAdd.release());
     }
 }
@@ -437,6 +448,13 @@
     }
 }
 
+void CCLayerAnimationController::replaceImplThreadAnimations(CCLayerAnimationController* controllerImpl) const
+{
+    controllerImpl->m_activeAnimations.clear();
+    for (size_t i = 0; i < m_activeAnimations.size(); ++i)
+        controllerImpl->add(m_activeAnimations[i]->cloneForImplThread());
+}
+
 void CCLayerAnimationController::tickAnimations(double monotonicTime)
 {
     for (size_t i = 0; i < m_activeAnimations.size(); ++i) {

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.h (116785 => 116786)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.h	2012-05-11 17:57:17 UTC (rev 116785)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.h	2012-05-11 18:04:15 UTC (rev 116786)
@@ -90,6 +90,12 @@
     // function updates the corresponding main thread animation's start time.
     void notifyAnimationStarted(const CCAnimationEvent&);
 
+    // If a sync is forced, then the next time animation updates are pushed to the impl
+    // thread, all animations will be transferred.
+    void setForceSync() { m_forceSync = true; }
+
+    void setClient(CCLayerAnimationControllerClient*);
+
 protected:
     explicit CCLayerAnimationController(CCLayerAnimationControllerClient*);
 
@@ -99,6 +105,7 @@
     void pushNewAnimationsToImplThread(CCLayerAnimationController*) const;
     void removeAnimationsCompletedOnMainThread(CCLayerAnimationController*) const;
     void pushPropertiesToImplThread(CCLayerAnimationController*) const;
+    void replaceImplThreadAnimations(CCLayerAnimationController*) const;
 
     void startAnimationsWaitingForNextTick(double monotonicTime, CCAnimationEventsVector*);
     void startAnimationsWaitingForStartTime(double monotonicTime, CCAnimationEventsVector*);
@@ -108,6 +115,9 @@
 
     void tickAnimations(double monotonicTime);
 
+    // If this is true, we force a sync to the impl thread.
+    bool m_forceSync;
+
     CCLayerAnimationControllerClient* m_client;
     Vector<OwnPtr<CCActiveAnimation> > m_activeAnimations;
 };

Modified: trunk/Source/WebKit/chromium/ChangeLog (116785 => 116786)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-11 17:57:17 UTC (rev 116785)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-11 18:04:15 UTC (rev 116786)
@@ -1,3 +1,21 @@
+2012-05-11  Ian Vollick  <[email protected]>
+
+        [chromium] Ensure that animations continue to run when transform-style is changed
+        https://bugs.webkit.org/show_bug.cgi?id=83283
+
+        Reviewed by James Robinson.
+
+        * WebKit.gypi:
+        * tests/GraphicsLayerChromiumTest.cpp: Added.
+        (WebKitTests):
+        (MockGraphicsLayerClient):
+        (WebKitTests::MockGraphicsLayerClient::notifyAnimationStarted):
+        (WebKitTests::MockGraphicsLayerClient::notifySyncRequired):
+        (WebKitTests::MockGraphicsLayerClient::paintContents):
+        (WebKitTests::MockGraphicsLayerClient::showDebugBorders):
+        (WebKitTests::MockGraphicsLayerClient::showRepaintCounter):
+        (WebKitTests::TEST):
+
 2012-05-11  Min Qin  <[email protected]>
 
         split MediaPlayer::enterFullscreen into 2 seperate functions

Modified: trunk/Source/WebKit/chromium/WebKit.gypi (116785 => 116786)


--- trunk/Source/WebKit/chromium/WebKit.gypi	2012-05-11 17:57:17 UTC (rev 116785)
+++ trunk/Source/WebKit/chromium/WebKit.gypi	2012-05-11 18:04:15 UTC (rev 116786)
@@ -105,6 +105,7 @@
             'tests/FrameLoaderClientImplTest.cpp',
             'tests/FrameTestHelpers.cpp',
             'tests/FrameTestHelpers.h',
+            'tests/GraphicsLayerChromiumTest.cpp',
             'tests/IDBBindingUtilitiesTest.cpp',
             'tests/IDBKeyPathTest.cpp',
             'tests/IDBLevelDBCodingTest.cpp',

Added: trunk/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp (0 => 116786)


--- trunk/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp	2012-05-11 18:04:15 UTC (rev 116786)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "GraphicsLayerChromium.h"
+
+#include "CCAnimationTestCommon.h"
+#include "GraphicsLayer.h"
+#include <gtest/gtest.h>
+#include <wtf/PassOwnPtr.h>
+
+using namespace WebCore;
+using namespace WebKitTests;
+
+namespace {
+
+class MockGraphicsLayerClient : public GraphicsLayerClient {
+  public:
+    virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { }
+    virtual void notifySyncRequired(const GraphicsLayer*) { }
+    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) { }
+    virtual bool showDebugBorders(const GraphicsLayer*) const { return false; }
+    virtual bool showRepaintCounter(const GraphicsLayer*) const { return false; }
+};
+
+TEST(GraphicsLayerChromiumTest, updateLayerPreserves3DWithAnimations)
+{
+    MockGraphicsLayerClient client;
+    OwnPtr<GraphicsLayerChromium> graphicsLayer = static_pointer_cast<GraphicsLayerChromium>(GraphicsLayer::create(&client));
+    ASSERT_TRUE(graphicsLayer.get());
+
+    LayerChromium* platformLayer = static_cast<LayerChromium*>(graphicsLayer->platformLayer());
+    ASSERT_TRUE(platformLayer);
+
+    ASSERT_FALSE(platformLayer->hasActiveAnimation());
+
+    OwnPtr<CCActiveAnimation> floatAnimation(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimationCurve), 0, 1, CCActiveAnimation::Opacity));
+    platformLayer->layerAnimationController()->add(floatAnimation.release());
+
+    ASSERT_TRUE(platformLayer->hasActiveAnimation());
+
+    graphicsLayer->setPreserves3D(true);
+
+    platformLayer = static_cast<LayerChromium*>(graphicsLayer->platformLayer());
+    ASSERT_TRUE(platformLayer);
+
+    ASSERT_TRUE(platformLayer->hasActiveAnimation());
+    platformLayer->removeAnimation(0);
+    ASSERT_FALSE(platformLayer->hasActiveAnimation());
+
+    graphicsLayer->setPreserves3D(false);
+
+    platformLayer = static_cast<LayerChromium*>(graphicsLayer->platformLayer());
+    ASSERT_TRUE(platformLayer);
+
+    ASSERT_FALSE(platformLayer->hasActiveAnimation());
+}
+
+} // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to