Title: [132795] trunk
Revision
132795
Author
[email protected]
Date
2012-10-29 07:10:05 -0700 (Mon, 29 Oct 2012)

Log Message

[CSS Shaders] Implement CustomFilterArrayParameter::blend
https://bugs.webkit.org/show_bug.cgi?id=96437

Reviewed by Dean Jackson.

Source/WebCore:

This patch adds the missing code to blend values within
an array() when using Custom Filters.

Test: css3/filters/custom/custom-filter-array-blending.html

* platform/graphics/filters/CustomFilterArrayParameter.h:
(WebCore::CustomFilterArrayParameter::blend):

LayoutTests:

New tests to asses the correctness of CustomFilterArrayParameter::blend.

* animations/resources/animation-test-helpers.js:
(customFilterParameterMatch): A check for functions' parameters length has been added.
* css3/filters/custom/custom-filter-array-blending-expected.txt: Added.
* css3/filters/custom/custom-filter-array-blending.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (132794 => 132795)


--- trunk/LayoutTests/ChangeLog	2012-10-29 13:52:23 UTC (rev 132794)
+++ trunk/LayoutTests/ChangeLog	2012-10-29 14:10:05 UTC (rev 132795)
@@ -1,3 +1,17 @@
+2012-10-29  Michelangelo De Simone  <[email protected]>
+
+        [CSS Shaders] Implement CustomFilterArrayParameter::blend
+        https://bugs.webkit.org/show_bug.cgi?id=96437
+
+        Reviewed by Dean Jackson.
+
+        New tests to asses the correctness of CustomFilterArrayParameter::blend.
+        
+        * animations/resources/animation-test-helpers.js:
+        (customFilterParameterMatch): A check for functions' parameters length has been added.
+        * css3/filters/custom/custom-filter-array-blending-expected.txt: Added.
+        * css3/filters/custom/custom-filter-array-blending.html: Added.
+
 2012-10-29  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r132782.

Modified: trunk/LayoutTests/animations/resources/animation-test-helpers.js (132794 => 132795)


--- trunk/LayoutTests/animations/resources/animation-test-helpers.js	2012-10-29 13:52:23 UTC (rev 132794)
+++ trunk/LayoutTests/animations/resources/animation-test-helpers.js	2012-10-29 14:10:05 UTC (rev 132795)
@@ -103,6 +103,10 @@
         case "function":
             if (val1.name != val2.name)
                 return false;
+            if (val1.arguments.length != val2.arguments.length) {
+                console.error("Arguments length mismatch: ", val1.arguments.length, "/", val2.arguments.length);
+                return false;
+            }
             for (var t = 0; t < val1.arguments.length; ++t) {
                 if (val1.arguments[t].type != "number" || val2.arguments[t].type != "number")
                     return false;

Added: trunk/LayoutTests/css3/filters/custom/custom-filter-array-blending-expected.txt (0 => 132795)


--- trunk/LayoutTests/css3/filters/custom/custom-filter-array-blending-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/custom/custom-filter-array-blending-expected.txt	2012-10-29 14:10:05 UTC (rev 132795)
@@ -0,0 +1,9 @@
+     
+PASS - "webkitFilter" property for "custom-blend-from-none-box" element at 1s saw something close to: custom(url(no-shader-needed.vs) none, 1 1 filter-box, arrayFromNoneAnim array(10, 20))
+PASS - "webkitFilter" property for "custom-blend-to-none-box" element at 1s saw something close to: custom(url(no-shader-needed.vs) none, 1 1 filter-box, arrayToNoneAnim array(10, 20))
+PASS - "webkitFilter" property for "custom-blend-single-element-box" element at 1s saw something close to: custom(url(no-shader-needed.vs) none, 1 1 filter-box, singleElementArray array(5))
+PASS - "webkitFilter" property for "custom-blend-two-floats-box" element at 1s saw something close to: custom(url(no-shader-needed.vs) none, 1 1 filter-box, twoFloatsArray array(2, 6.4))
+PASS - "webkitFilter" property for "custom-blend-multiple-elements-box" element at 1s saw something close to: custom(url(no-shader-needed.vs) none, 1 1 filter-box, multipleElementsArray array(5, 10, 5, 10, 5, 10, 5, 10, 5))
+PASS - "webkitFilter" property for "custom-blend-first-longer-box" element at 1s saw something close to: custom(url(no-shader-needed.vs) none, 1 1 filter-box, firstLonger array(10, 10, 10, 10))
+PASS - "webkitFilter" property for "custom-blend-second-longer-box" element at 1s saw something close to: custom(url(no-shader-needed.vs) none, 1 1 filter-box, secondLonger array(10, 10, 10, 10, 10))
+

Added: trunk/LayoutTests/css3/filters/custom/custom-filter-array-blending.html (0 => 132795)


--- trunk/LayoutTests/css3/filters/custom/custom-filter-array-blending.html	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/custom/custom-filter-array-blending.html	2012-10-29 14:10:05 UTC (rev 132795)
@@ -0,0 +1,115 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <script>
+        if (window.testRunner) {
+            window.testRunner.overridePreference("WebKitCSSCustomFilterEnabled", "1");
+            window.testRunner.overridePreference("WebKitWebGLEnabled", "1");
+        }
+    </script>
+    <style>
+        .box {
+            height: 100px;
+            width: 100px;
+            margin: 10px;
+            background-color: blue;
+            display: inline-block;
+        }
+
+        #custom-blend-from-none-box {
+            -webkit-animation: custom-blend-from-none-anim 2s linear;
+        }
+
+        #custom-blend-to-none-box {
+            -webkit-animation: custom-blend-to-none-anim 2s linear;
+        }
+
+        #custom-blend-single-element-box {
+            -webkit-animation: custom-blend-single-element-anim 2s linear;
+        }
+
+        #custom-blend-two-floats-box {
+            -webkit-animation: custom-blend-two-floats-anim 2s linear;
+        }
+
+        #custom-blend-multiple-elements-box {
+            -webkit-animation: custom-blend-multiple-elements-anim 2s linear;
+        }
+
+        #custom-blend-first-longer-box {
+            -webkit-animation: custom-blend-first-longer-anim 2s linear;
+        }
+
+        #custom-blend-second-longer-box {
+            -webkit-animation: custom-blend-second-longer-anim 2s linear;
+        }
+
+        @-webkit-keyframes custom-blend-from-none-anim {
+            from { -webkit-filter: custom(url(no-shader-needed.vs)); }
+            to   { -webkit-filter: custom(url(no-shader-needed.vs), arrayFromNoneAnim array(10.0, 20.0)); }
+        }
+
+        @-webkit-keyframes custom-blend-to-none-anim {
+            from { -webkit-filter: custom(url(no-shader-needed.vs), arrayToNoneAnim array(10.0, 20.0)); }
+            to   { -webkit-filter: custom(url(no-shader-needed.vs)); }
+        }
+    
+        @-webkit-keyframes custom-blend-single-element-anim {
+            from { -webkit-filter: custom(url(no-shader-needed.vs), singleElementArray array(0)); }
+            to   { -webkit-filter: custom(url(no-shader-needed.vs), singleElementArray array(10)); }
+        }
+
+        @-webkit-keyframes custom-blend-two-floats-anim {
+            from { -webkit-filter: custom(url(no-shader-needed.vs), twoFloatsArray array(1.01, 3.14)); }
+            to   { -webkit-filter: custom(url(no-shader-needed.vs), twoFloatsArray array(3.03, 9.42)); }
+        }
+
+
+        @-webkit-keyframes custom-blend-multiple-elements-anim {
+            from { -webkit-filter: custom(url(no-shader-needed.vs), multipleElementsArray array(0, 0, 0, 0, 0, 0, 0, 0, 0)); }
+            to   { -webkit-filter: custom(url(no-shader-needed.vs), multipleElementsArray array(10, 20, 10, 20, 10, 20, 10, 20, 10)); }
+        }
+
+        @-webkit-keyframes custom-blend-first-longer-anim {
+            from { -webkit-filter: custom(url(no-shader-needed.vs), firstLonger array(10, 10, 10, 10, 10)); }
+            to   { -webkit-filter: custom(url(no-shader-needed.vs), firstLonger array(10, 10, 10, 10)); }
+        }
+
+        @-webkit-keyframes custom-blend-second-longer-anim {
+            from { -webkit-filter: custom(url(no-shader-needed.vs), secondLonger array(10, 10, 10, 10)); }
+            to   { -webkit-filter: custom(url(no-shader-needed.vs), secondLonger array(10, 10, 10, 10, 10)); }
+        }
+    </style>
+    <script src=""
+    <script src=""
+    <script type="text/_javascript_">
+        const expectedValues = [
+            // [animation-name, time, element-id, property, expected-value, tolerance]
+            ["custom-blend-from-none-anim",  1, "custom-blend-from-none-box", "webkitFilter", 'custom(url(no-shader-needed.vs) none, 1 1 filter-box, arrayFromNoneAnim array(10, 20))', 2],
+            ["custom-blend-to-none-anim",  1, "custom-blend-to-none-box", "webkitFilter", 'custom(url(no-shader-needed.vs) none, 1 1 filter-box, arrayToNoneAnim array(10, 20))', 2],
+
+            ["custom-blend-single-element-anim", 1, "custom-blend-single-element-box", "webkitFilter", 'custom(url(no-shader-needed.vs) none, 1 1 filter-box, singleElementArray array(5))', 2],
+
+            ["custom-blend-two-floats-anim", 1, "custom-blend-two-floats-box", "webkitFilter", 'custom(url(no-shader-needed.vs) none, 1 1 filter-box, twoFloatsArray array(2, 6.4))', 2],
+
+            ["custom-blend-multiple-elements-anim", 1, "custom-blend-multiple-elements-box", "webkitFilter", 'custom(url(no-shader-needed.vs) none, 1 1 filter-box, multipleElementsArray array(5, 10, 5, 10, 5, 10, 5, 10, 5))', 4],
+
+            ["custom-blend-first-longer-anim", 1, "custom-blend-first-longer-box", "webkitFilter", 'custom(url(no-shader-needed.vs) none, 1 1 filter-box, firstLonger array(10, 10, 10, 10))', 2],
+
+            ["custom-blend-second-longer-anim", 1, "custom-blend-second-longer-box", "webkitFilter", 'custom(url(no-shader-needed.vs) none, 1 1 filter-box, secondLonger array(10, 10, 10, 10, 10))', 2]];
+        runAnimationTest(expectedValues);
+    </script>
+</head>
+<body>
+    <div class="box" id="custom-blend-from-none-box"></div>
+    <div class="box" id="custom-blend-to-none-box"></div>
+    <div class="box" id="custom-blend-single-element-box"></div>
+    <div class="box" id="custom-blend-two-floats-box"></div>
+    <div class="box" id="custom-blend-multiple-elements-box"></div>
+    <div class="box" id="custom-blend-first-longer-box"></div>
+    <div class="box" id="custom-blend-second-longer-box"></div>
+    <div id="result">
+    </div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (132794 => 132795)


--- trunk/Source/WebCore/ChangeLog	2012-10-29 13:52:23 UTC (rev 132794)
+++ trunk/Source/WebCore/ChangeLog	2012-10-29 14:10:05 UTC (rev 132795)
@@ -1,3 +1,18 @@
+2012-10-29  Michelangelo De Simone  <[email protected]>
+
+        [CSS Shaders] Implement CustomFilterArrayParameter::blend
+        https://bugs.webkit.org/show_bug.cgi?id=96437
+
+        Reviewed by Dean Jackson.
+
+        This patch adds the missing code to blend values within
+        an array() when using Custom Filters.
+
+        Test: css3/filters/custom/custom-filter-array-blending.html
+
+        * platform/graphics/filters/CustomFilterArrayParameter.h:
+        (WebCore::CustomFilterArrayParameter::blend):
+
 2012-10-29  Alexander Pavlov  <[email protected]>
 
         Web Inspector: Drag and drop a URL in inspector is not working as expected

Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterArrayParameter.h (132794 => 132795)


--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterArrayParameter.h	2012-10-29 13:52:23 UTC (rev 132794)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterArrayParameter.h	2012-10-29 14:10:05 UTC (rev 132795)
@@ -50,11 +50,19 @@
 
     virtual PassRefPtr<CustomFilterParameter> blend(const CustomFilterParameter* from, double progress, const LayoutSize&)
     {
-        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=96437
-        UNUSED_PARAM(from);
-        UNUSED_PARAM(progress);
+        if (!from || !isSameType(*from))
+            return this;
 
-        return this;
+        const CustomFilterArrayParameter* fromArray = static_cast<const CustomFilterArrayParameter*>(from);
+
+        if (size() != fromArray->size())
+            return this;
+
+        RefPtr<CustomFilterArrayParameter> result = CustomFilterArrayParameter::create(name());
+        for (size_t i = 0; i < size(); ++i)
+            result->addValue(WebCore::blend(fromArray->valueAt(i), valueAt(i), progress));
+
+        return result.release();
     }
 
     virtual bool operator==(const CustomFilterParameter& o) const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to