[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

simon.fraser at apple.com simon.fraser at apple.com
Thu Feb 4 21:33:26 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit e72e003891913e0aba298fece08f49acb2da68ee
Author: simon.fraser at apple.com <simon.fraser at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Jan 31 03:21:44 2010 +0000

    2010-01-30  Simon Fraser  <simon.fraser at apple.com>
    
            Reviewed by Adele Peterson.
    
            Do color animations on premultiplied colors
            https://bugs.webkit.org/show_bug.cgi?id=34383
    
            Convert colors to premultiplied alpha before interpolating them,
            then convert the result back to non-premultiplied. This gives better
            results when animating from transparent colors.
    
            Test: transitions/color-transition-premultiplied.html
    
            * page/animation/AnimationBase.cpp:
            (WebCore::blendFunc):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54106 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 205583a..14a29c6 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1 +1,13 @@
+2010-01-30  Simon Fraser  <simon.fraser at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        Do color animations on premultiplied colors
+        https://bugs.webkit.org/show_bug.cgi?id=34383
+        
+        Testcase for animating from transparent colors.
+
+        * transitions/color-transition-premultiplied-expected.txt: Added.
+        * transitions/color-transition-premultiplied.html: Added.
+
 == Rolled over to ChangeLog-2010-01-29 ==
diff --git a/LayoutTests/transitions/color-transition-premultiplied-expected.txt b/LayoutTests/transitions/color-transition-premultiplied-expected.txt
new file mode 100644
index 0000000..59fca89
--- /dev/null
+++ b/LayoutTests/transitions/color-transition-premultiplied-expected.txt
@@ -0,0 +1,3 @@
+PASS - "background-color" property for "one" element at 0.5s saw something close to: 0,127,0
+PASS - "background-color" property for "two" element at 0.5s saw something close to: 0,0,255
+
diff --git a/LayoutTests/transitions/color-transition-premultiplied.html b/LayoutTests/transitions/color-transition-premultiplied.html
new file mode 100644
index 0000000..d725a16
--- /dev/null
+++ b/LayoutTests/transitions/color-transition-premultiplied.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <style type="text/css" media="screen">
+  
+    .box {
+      width: 100px;
+      height: 100px;
+      margin: 10px;
+      border: 1px solid black;
+      -webkit-transition: background-color 1s linear;
+      -moz-transition: background-color 1s linear;
+    }
+    
+    #one {
+      background-color: transparent;
+    }
+    
+    #one.changed {
+      background-color: green;
+    }
+    
+    #two {
+      background-color: rgba(0, 255, 0, 0);
+    }
+
+    #two.changed {
+      background-color: rgba(0, 0, 255, 1);
+    }
+  </style>
+  <script src="transition-test-helpers.js" type="text/javascript" charset="utf-8"></script>
+  <script type="text/javascript" charset="utf-8">
+    const expectedValues = [
+      // [time, element-id, property, expected-value, tolerance]
+      [0.5, 'one', 'background-color', [0, 127, 0], 2],
+      [0.5, 'two', 'background-color', [0, 0, 255], 2]
+    ];
+
+    function setupTest()
+    {
+      document.getElementById('one').className = 'box changed';
+      document.getElementById('two').className = 'box changed';
+    }
+
+    runTransitionTest(expectedValues, setupTest, true);
+  </script>
+</head>
+<body>
+
+  <div class="box" id="one">
+  </div>
+
+  <div class="box" id="two">
+  </div>
+  
+  <div id="result">
+  </div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 825e14e..aef12e8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2010-01-30  Simon Fraser  <simon.fraser at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        Do color animations on premultiplied colors
+        https://bugs.webkit.org/show_bug.cgi?id=34383
+        
+        Convert colors to premultiplied alpha before interpolating them,
+        then convert the result back to non-premultiplied. This gives better
+        results when animating from transparent colors.
+
+        Test: transitions/color-transition-premultiplied.html
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::blendFunc):
+
 2010-01-30  Gustavo Noronha Silva  <gns at gnome.org>
 
         Build fixes needed for make distcheck.
diff --git a/WebCore/page/animation/AnimationBase.cpp b/WebCore/page/animation/AnimationBase.cpp
index 135365c..2a2ab4b 100644
--- a/WebCore/page/animation/AnimationBase.cpp
+++ b/WebCore/page/animation/AnimationBase.cpp
@@ -92,10 +92,17 @@ static inline Color blendFunc(const AnimationBase* anim, const Color& from, cons
     if (progress == 1 && !to.isValid())
         return Color();
 
-    return Color(blendFunc(anim, from.red(), to.red(), progress),
-                 blendFunc(anim, from.green(), to.green(), progress),
-                 blendFunc(anim, from.blue(), to.blue(), progress),
-                 blendFunc(anim, from.alpha(), to.alpha(), progress));
+    // Contrary to the name, RGBA32 actually stores ARGB, so we can initialize Color directly from premultipliedARGBFromColor().
+    // Also, premultipliedARGBFromColor() bails on zero alpha, so special-case that.
+    Color premultFrom = from.alpha() ? premultipliedARGBFromColor(from) : 0;
+    Color premultTo = to.alpha() ? premultipliedARGBFromColor(to) : 0;
+
+    Color premultBlended(blendFunc(anim, premultFrom.red(), premultTo.red(), progress),
+                 blendFunc(anim, premultFrom.green(), premultTo.green(), progress),
+                 blendFunc(anim, premultFrom.blue(), premultTo.blue(), progress),
+                 blendFunc(anim, premultFrom.alpha(), premultTo.alpha(), progress));
+
+    return Color(colorFromPremultipliedARGB(premultBlended.rgb()));
 }
 
 static inline Length blendFunc(const AnimationBase*, const Length& from, const Length& to, double progress)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list