Changeset 196381 in webkit


Ignore:
Timestamp:
Feb 10, 2016 12:45:01 PM (8 years ago)
Author:
Said Abou-Hallawa
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.

Location:
trunk/PerformanceTests
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/PerformanceTests/Animometer/resources/debug-runner/tests.js

    r196372 r196381  
    131131        },
    132132        {
     133            url: "bouncing-particles/bouncing-css-shapes.html?particleWidth=80&particleHeight=80&shape=circle&blend",
     134            name: "CSS bouncing blend circles"
     135        },
     136        {
     137            url: "bouncing-particles/bouncing-css-shapes.html?particleWidth=80&particleHeight=80&shape=circle&filter",
     138            name: "CSS bouncing filter circles"
     139        },
     140        {
    133141            url: "bouncing-particles/bouncing-css-images.html?particleWidth=80&particleHeight=80&imageSrc=../resources/yin-yang.svg",
    134142            name: "CSS bouncing SVG images"
  • trunk/PerformanceTests/Animometer/resources/extensions.js

    r196288 r196381  
    8383        parentElement.appendChild(element);
    8484        return element;
     85    },
     86   
     87    browserPrefix: function()
     88    {
     89        // Get the HTML element's CSSStyleDeclaration
     90        var styles = window.getComputedStyle(document.documentElement, '');
     91       
     92        // Convert the styles list to an array
     93        var stylesArray = Array.prototype.slice.call(styles);
     94       
     95        // Concatenate all the styles in one big string
     96        var stylesString = stylesArray.join('');
     97
     98        // Search the styles string for a known prefix type, settle on Opera if none is found.
     99        var prefixes = stylesString.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']);
     100       
     101        // prefixes has two elements; e.g. for webkit it has ['-webkit-', 'webkit'];
     102        var prefix = prefixes[1];
     103
     104        // Have 'O' before 'Moz' in the string so it is matched first.
     105        var dom = ('WebKit|O|Moz|MS').match(new RegExp(prefix, 'i'))[0];
     106
     107        // Return all the required prefixes.
     108        return {
     109            dom: dom,
     110            lowercase: prefix,
     111            css: '-' + prefix + '-',
     112            js: prefix[0].toUpperCase() + prefix.substr(1)
     113        };
     114    },
     115   
     116    setElementPrefixedProperty: function(element, property, value)
     117    {
     118        element.style[property] = element.style[this.browserPrefix().js + property[0].toUpperCase() + property.substr(1)] = value;
    85119    }
    86120};
  • trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-css-shapes.js

    r196289 r196381  
    1818            break;
    1919        }
     20
     21        if (stage.blend)
     22            this.element.style.mixBlendMode = Stage.randomStyleMixBlendMode();
     23       
     24        // Some browsers have not un-prefixed the css filter yet.
     25        if (stage.filter)
     26            Utilities.setElementPrefixedProperty(this.element, "filter", Stage.randomStyleFilter());
    2027
    2128        this._move();
  • trunk/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-particles.js

    r196294 r196381  
    8585        this.fill = options["fill"] || "solid";
    8686        this.clip = options["clip"] || "";
     87        this.blend = options["blend"] || false;
     88        this.filter = options["filter"] || false;
    8789    },
    8890
  • trunk/PerformanceTests/Animometer/tests/resources/main.js

    r196372 r196381  
    767767    },
    768768
     769    randomStyleMixBlendMode: function()
     770    {
     771        var mixBlendModeList = [
     772          'normal',
     773          'multiply',
     774          'screen',
     775          'overlay',
     776          'darken',
     777          'lighten',
     778          'color-dodge',
     779          'color-burn',
     780          'hard-light',
     781          'soft-light',
     782          'difference',
     783          'exclusion',
     784          'hue',
     785          'saturation',
     786          'color',
     787          'luminosity'
     788        ];
     789       
     790        return mixBlendModeList[this.randomInt(0, mixBlendModeList.length)];
     791    },
     792
     793    randomStyleFilter: function()
     794    {
     795        var filterList = [
     796            'grayscale(50%)',
     797            'sepia(50%)',
     798            'saturate(50%)',
     799            'hue-rotate(180)',
     800            'invert(50%)',
     801            'opacity(50%)',
     802            'brightness(50%)',
     803            'contrast(50%)',
     804            'blur(10px)',
     805            'drop-shadow(10px 10px 10px gray)'
     806        ];
     807       
     808        return filterList[this.randomInt(0, filterList.length)];
     809    },
     810
    769811    rotatingColor: function(cycleLengthMs, saturation, lightness)
    770812    {
  • trunk/PerformanceTests/ChangeLog

    r196372 r196381  
     12016-02-09  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Add internal benchmark tests for CSS mix-blend-modes and filters
     4        https://bugs.webkit.org/show_bug.cgi?id=154058
     5
     6        Provisionally reviewed by Jon Lee.
     7
     8        * Animometer/resources/debug-runner/tests.js: Include the new tests in the
     9        "HTML suite" of the debug runner.
     10       
     11        * Animometer/resources/extensions.js:
     12        (Utilities.browserPrefix):
     13        (Utilities.setElementPrefixedProperty): Utility functions to allow setting
     14        prefixed style properties.
     15       
     16        * Animometer/tests/bouncing-particles/resources/bouncing-css-shapes.js:
     17        Set the mix-blend-mode and the filter to some random values if the options
     18        of the test requested that.
     19       
     20        * Animometer/tests/bouncing-particles/resources/bouncing-particles.js:
     21        (parseShapeParameters): Parse the url options "blend" and "filter" and set
     22        the corresponding flags.
     23       
     24        * Animometer/tests/resources/main.js:
     25        (randomStyleMixBlendMode):
     26        (randomStyleFilter): Return random mix-blend-mode and filter.
     27
    1282016-02-08  Jon Lee  <jonlee@apple.com>
    229
Note: See TracChangeset for help on using the changeset viewer.