2011-02-20 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Feb 2011 03:26:11 +0000 (03:26 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Feb 2011 03:26:11 +0000 (03:26 +0000)
        Reviewed by Dirk Schulze.

        REGRESSION (r73369-r73405): transform animation interpolates incorrectly
        https://bugs.webkit.org/show_bug.cgi?id=54793

        After the refactoring in r73380, the ending state for some types of
        accelerated animations was computed incorrectly, because the TransformationMatrix
        wasn't reset to identity before the ending value transformations were applied.

        Fix by cleaning up the code to use explicit, separate values for
        starting and ending values. Only matrix-type animations had this
        issue, but cleaned up other clauses similarly.

        Test: animations/3d/matrix-transform-type-animation.html

        * platform/graphics/ca/GraphicsLayerCA.cpp:
        (WebCore::GraphicsLayerCA::setTransformAnimationEndpoints):

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

LayoutTests/ChangeLog
LayoutTests/animations/3d/matrix-transform-type-animation.html [new file with mode: 0644]
LayoutTests/platform/mac/animations/3d/matrix-transform-type-animation-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/animations/3d/matrix-transform-type-animation-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/animations/3d/matrix-transform-type-animation-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

index 7cde934..a958bc4 100644 (file)
@@ -1,3 +1,17 @@
+2011-02-20  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Dirk Schulze.
+
+        REGRESSION (r73369-r73405): transform animation interpolates incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=54793
+        
+        Testcase for a matrix animation.
+
+        * animations/3d/matrix-transform-type-animation.html: Added.
+        * platform/mac/animations/3d/matrix-transform-type-animation-expected.checksum: Added.
+        * platform/mac/animations/3d/matrix-transform-type-animation-expected.png: Added.
+        * platform/mac/animations/3d/matrix-transform-type-animation-expected.txt: Added.
+
 2011-02-20  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Maciej Stachowiak.
diff --git a/LayoutTests/animations/3d/matrix-transform-type-animation.html b/LayoutTests/animations/3d/matrix-transform-type-animation.html
new file mode 100644 (file)
index 0000000..660fc0b
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style type="text/css">
+    .container {
+      position: relative;
+      height: 100px;
+    }
+    .box {
+      position: absolute;
+      left: 0;
+      top: 0;
+      height: 100px;
+      width: 100px;
+      background-color: green;
+    }
+    
+    #indicator {
+      position: absolute;
+      top: 0;
+      left: 50px;
+      background-color: red;
+    }
+    
+    #box {
+      -webkit-animation: anim 2s linear;
+    }
+    
+    @-webkit-keyframes anim {
+        from { -webkit-transform: matrix(1, 0, 0, 1, 100, 0); }
+        to   { -webkit-transform: matrix(1, 0, 0, 1, 0, 0); }
+    }
+  </style>
+  <script src="../animation-test-helpers.js" type="text/javascript"></script>
+  <script type="text/javascript">
+    const expectedValues = [
+      // [animation, time, element-id, property, expected-value, tolerance]
+      ["anim", 1, "box",  "webkitTransform.4", 50, 2],
+    ];
+    
+    var pixelTest = true;
+    var disablePauseAPI = false;
+    runAnimationTest(expectedValues, null, null, disablePauseAPI, pixelTest);
+  </script>
+</head>
+<body>
+
+<!-- In the pixel result, the green box should obscure the red box. -->
+<div class="container">
+  <div id="indicator" class="box"></div>
+  <div class="box" id="box"></div>
+</div>
+
+<div id="result"></div>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/animations/3d/matrix-transform-type-animation-expected.checksum b/LayoutTests/platform/mac/animations/3d/matrix-transform-type-animation-expected.checksum
new file mode 100644 (file)
index 0000000..23b12a9
--- /dev/null
@@ -0,0 +1 @@
+164f57179e802788c35892cf6b5a1f41
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/animations/3d/matrix-transform-type-animation-expected.png b/LayoutTests/platform/mac/animations/3d/matrix-transform-type-animation-expected.png
new file mode 100644 (file)
index 0000000..e7f99f7
Binary files /dev/null and b/LayoutTests/platform/mac/animations/3d/matrix-transform-type-animation-expected.png differ
diff --git a/LayoutTests/platform/mac/animations/3d/matrix-transform-type-animation-expected.txt b/LayoutTests/platform/mac/animations/3d/matrix-transform-type-animation-expected.txt
new file mode 100644 (file)
index 0000000..2b415b1
--- /dev/null
@@ -0,0 +1,15 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x134
+  RenderBlock {HTML} at (0,0) size 800x134
+    RenderBody {BODY} at (8,8) size 784x118
+      RenderBlock {DIV} at (0,100) size 784x18
+        RenderText {#text} at (0,0) size 568x18
+          text run at (0,0) width 568: "PASS - \"webkitTransform.4\" property for \"box\" element at 1s saw something close to: 50"
+        RenderBR {BR} at (568,0) size 0x18
+layer at (8,8) size 784x100
+  RenderBlock (relative positioned) {DIV} at (0,0) size 784x100
+layer at (58,8) size 100x100
+  RenderBlock (positioned) {DIV} at (50,0) size 100x100 [bgcolor=#FF0000]
+layer at (8,8) size 100x100
+  RenderBlock (positioned) {DIV} at (0,0) size 100x100 [bgcolor=#008000]
index 8be6864..5f9b40f 100644 (file)
@@ -1,3 +1,23 @@
+2011-02-20  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Dirk Schulze.
+
+        REGRESSION (r73369-r73405): transform animation interpolates incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=54793
+        
+        After the refactoring in r73380, the ending state for some types of
+        accelerated animations was computed incorrectly, because the TransformationMatrix
+        wasn't reset to identity before the ending value transformations were applied.
+        
+        Fix by cleaning up the code to use explicit, separate values for
+        starting and ending values. Only matrix-type animations had this
+        issue, but cleaned up other clauses similarly.
+
+        Test: animations/3d/matrix-transform-type-animation.html
+
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::setTransformAnimationEndpoints):
+
 2011-02-20  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Maciej Stachowiak.
index 2b4a39e..59f7203 100644 (file)
@@ -1759,23 +1759,29 @@ bool GraphicsLayerCA::setTransformAnimationEndpoints(const KeyframeValueList& va
         basicAnim->setToValue(toTransform);
     } else {
         if (isTransformTypeNumber(transformOpType)) {
-            float value;
-            getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, value);
-            basicAnim->setFromValue(value);
-            getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, value);
-            basicAnim->setToValue(value);
+            float fromValue;
+            getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, fromValue);
+            basicAnim->setFromValue(fromValue);
+            
+            float toValue;
+            getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, toValue);
+            basicAnim->setToValue(toValue);
         } else if (isTransformTypeFloatPoint3D(transformOpType)) {
-            FloatPoint3D value;
-            getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, value);
-            basicAnim->setFromValue(value);
-            getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, value);
-            basicAnim->setToValue(value);
+            FloatPoint3D fromValue;
+            getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, fromValue);
+            basicAnim->setFromValue(fromValue);
+            
+            FloatPoint3D toValue;
+            getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, toValue);
+            basicAnim->setToValue(toValue);
         } else {
-            TransformationMatrix value;
-            getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, value);
-            basicAnim->setFromValue(value);
-            getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, value);
-            basicAnim->setToValue(value);
+            TransformationMatrix fromValue;
+            getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, fromValue);
+            basicAnim->setFromValue(fromValue);
+
+            TransformationMatrix toValue;
+            getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, toValue);
+            basicAnim->setToValue(toValue);
         }
     }