Title: [196381] trunk/PerformanceTests
Revision
196381
Author
s...@apple.com
Date
2016-02-10 12:45:01 -0800 (Wed, 10 Feb 2016)

Log Message

Add internal benchmark tests for CSS mix-blend-modes and filters
https://bugs.webkit.org/show_bug.cgi?id=154058

Provisionally reviewed by Jon Lee.

* Animometer/resources/debug-runner/tests.js: Include the new tests in the
"HTML suite" of the debug runner.
        
* Animometer/resources/extensions.js:
(Utilities.browserPrefix):
(Utilities.setElementPrefixedProperty): Utility functions to allow setting
prefixed style properties.
        
* Animometer/tests/bouncing-particles/resources/bouncing-css-shapes.js:
Set the mix-blend-mode and the filter to some random values if the options
of the test requested that.
        
* Animometer/tests/bouncing-particles/resources/bouncing-particles.js:
(parseShapeParameters): Parse the url options "blend" and "filter" and set
the corresponding flags.
        
* Animometer/tests/resources/main.js:
(randomStyleMixBlendMode):
(randomStyleFilter): Return random mix-blend-mode and filter.

Modified Paths

Diff

Modified: trunk/PerformanceTests/Animometer/resources/debug-runner/tests.js (196380 => 196381)


--- trunk/PerformanceTests/Animometer/resources/debug-runner/tests.js	2016-02-10 20:33:20 UTC (rev 196380)
+++ trunk/PerformanceTests/Animometer/resources/debug-runner/tests.js	2016-02-10 20:45:01 UTC (rev 196381)
@@ -130,6 +130,14 @@
             name: "CSS bouncing gradient circles"
         },
         {
+            url: "bouncing-particles/bouncing-css-shapes.html?particleWidth=80&particleHeight=80&shape=circle&blend",
+            name: "CSS bouncing blend circles"
+        },
+        {
+            url: "bouncing-particles/bouncing-css-shapes.html?particleWidth=80&particleHeight=80&shape=circle&filter",
+            name: "CSS bouncing filter circles"
+        },
+        {
             url: "bouncing-particles/bouncing-css-images.html?particleWidth=80&particleHeight=80&imageSrc=../resources/yin-yang.svg",
             name: "CSS bouncing SVG images"
         },

Modified: trunk/PerformanceTests/Animometer/resources/extensions.js (196380 => 196381)


--- trunk/PerformanceTests/Animometer/resources/extensions.js	2016-02-10 20:33:20 UTC (rev 196380)
+++ trunk/PerformanceTests/Animometer/resources/extensions.js	2016-02-10 20:45:01 UTC (rev 196381)
@@ -82,6 +82,40 @@
 
         parentElement.appendChild(element);
         return element;
+    },
+    
+    browserPrefix: function()
+    {
+        // Get the HTML element's CSSStyleDeclaration
+        var styles = window.getComputedStyle(document.documentElement, '');
+        
+        // Convert the styles list to an array
+        var stylesArray = Array.prototype.slice.call(styles);
+        
+        // Concatenate all the styles in one big string
+        var stylesString = stylesArray.join('');
+
+        // Search the styles string for a known prefix type, settle on Opera if none is found.
+        var prefixes = stylesString.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']);
+        
+        // prefixes has two elements; e.g. for webkit it has ['-webkit-', 'webkit'];
+        var prefix = prefixes[1];
+
+        // Have 'O' before 'Moz' in the string so it is matched first.
+        var dom = ('WebKit|O|Moz|MS').match(new RegExp(prefix, 'i'))[0];
+
+        // Return all the required prefixes.
+        return {
+            dom: dom,
+            lowercase: prefix,
+            css: '-' + prefix + '-',
+            js: prefix[0].toUpperCase() + prefix.substr(1)
+        };
+    },
+    
+    setElementPrefixedProperty: function(element, property, value)
+    {
+        element.style[property] = element.style[this.browserPrefix().js + property[0].toUpperCase() + property.substr(1)] = value;
     }
 };
 

Modified: trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-css-shapes.js (196380 => 196381)


--- trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-css-shapes.js	2016-02-10 20:33:20 UTC (rev 196380)
+++ trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-css-shapes.js	2016-02-10 20:45:01 UTC (rev 196381)
@@ -18,6 +18,13 @@
             break;
         }
 
+        if (stage.blend)
+            this.element.style.mixBlendMode = Stage.randomStyleMixBlendMode();
+        
+        // Some browsers have not un-prefixed the css filter yet.
+        if (stage.filter)
+            Utilities.setElementPrefixedProperty(this.element, "filter", Stage.randomStyleFilter());
+
         this._move();
     }, {
 

Modified: trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-particles.js (196380 => 196381)


--- trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-particles.js	2016-02-10 20:33:20 UTC (rev 196380)
+++ trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-particles.js	2016-02-10 20:45:01 UTC (rev 196381)
@@ -84,6 +84,8 @@
         this.shape = options["shape"] || "circle";
         this.fill = options["fill"] || "solid";
         this.clip = options["clip"] || "";
+        this.blend = options["blend"] || false;
+        this.filter = options["filter"] || false;
     },
 
     animate: function(timeDelta)

Modified: trunk/PerformanceTests/Animometer/tests/resources/main.js (196380 => 196381)


--- trunk/PerformanceTests/Animometer/tests/resources/main.js	2016-02-10 20:33:20 UTC (rev 196380)
+++ trunk/PerformanceTests/Animometer/tests/resources/main.js	2016-02-10 20:45:01 UTC (rev 196381)
@@ -766,6 +766,48 @@
             + this.randomInt(min, max).toString(16);
     },
 
+    randomStyleMixBlendMode: function()
+    {
+        var mixBlendModeList = [
+          'normal',
+          'multiply',
+          'screen',
+          'overlay',
+          'darken',
+          'lighten',
+          'color-dodge',
+          'color-burn',
+          'hard-light',
+          'soft-light',
+          'difference',
+          'exclusion',
+          'hue',
+          'saturation',
+          'color',
+          'luminosity'
+        ];
+        
+        return mixBlendModeList[this.randomInt(0, mixBlendModeList.length)];
+    },
+
+    randomStyleFilter: function()
+    {
+        var filterList = [
+            'grayscale(50%)',
+            'sepia(50%)',
+            'saturate(50%)',
+            'hue-rotate(180)',
+            'invert(50%)',
+            'opacity(50%)',
+            'brightness(50%)',
+            'contrast(50%)',
+            'blur(10px)',
+            'drop-shadow(10px 10px 10px gray)'
+        ];
+        
+        return filterList[this.randomInt(0, filterList.length)];
+    },
+
     rotatingColor: function(cycleLengthMs, saturation, lightness)
     {
         return "hsl("

Modified: trunk/PerformanceTests/ChangeLog (196380 => 196381)


--- trunk/PerformanceTests/ChangeLog	2016-02-10 20:33:20 UTC (rev 196380)
+++ trunk/PerformanceTests/ChangeLog	2016-02-10 20:45:01 UTC (rev 196381)
@@ -1,3 +1,30 @@
+2016-02-09  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        Add internal benchmark tests for CSS mix-blend-modes and filters
+        https://bugs.webkit.org/show_bug.cgi?id=154058
+
+        Provisionally reviewed by Jon Lee.
+
+        * Animometer/resources/debug-runner/tests.js: Include the new tests in the
+        "HTML suite" of the debug runner.
+        
+        * Animometer/resources/extensions.js:
+        (Utilities.browserPrefix):
+        (Utilities.setElementPrefixedProperty): Utility functions to allow setting
+        prefixed style properties.
+        
+        * Animometer/tests/bouncing-particles/resources/bouncing-css-shapes.js:
+        Set the mix-blend-mode and the filter to some random values if the options
+        of the test requested that.
+        
+        * Animometer/tests/bouncing-particles/resources/bouncing-particles.js:
+        (parseShapeParameters): Parse the url options "blend" and "filter" and set
+        the corresponding flags.
+        
+        * Animometer/tests/resources/main.js:
+        (randomStyleMixBlendMode):
+        (randomStyleFilter): Return random mix-blend-mode and filter.
+
 2016-02-08  Jon Lee  <jon...@apple.com>
 
         Add a ramp controller
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to