Title: [197499] trunk/PerformanceTests
Revision
197499
Author
[email protected]
Date
2016-03-03 00:22:32 -0800 (Thu, 03 Mar 2016)

Log Message

Add some new controllers, and refine tests
https://bugs.webkit.org/show_bug.cgi?id=154914

Reviewed by Simon Fraser.

Improve tests.

* Animometer/tests/master/focus.html: Move each particle into a layer. Put the particle
in a container element. Expand the container element by the max blur radius, and clip
overflow. This way, when the blur is applied, it avoids causing layer resizes.
* Animometer/tests/master/resources/focus.js:
(FocusElement.Utilities.createClass): Create a container element, and put the particle
inside.
(hide): Set display:none.
(show): Set display:block.
(animate): Apply filters to the container element.
(FocusStage.call.initialize): Instead of inserting and removing elements from the DOM,
keep them in the stage, but set the display style instead. Use this._offsetIndex to
keep track of which elements are displayed.
(FocusStage.call.animate): Move some calculations around to avoid doing unneeded math.
(FocusStage.call.getBlurValue): Make sure elements are always blurred.
(FocusStage.call.getOpacityValue): Make sure elements have some opacity.
* Animometer/tests/master/resources/multiply.js: Have the particles on the edge of the
stage appear less black when the complexity gets large enough.
(tune): Have this._distanceFactor calculate the factor. Avoid calculating square root each
frame.

Modified Paths

Diff

Modified: trunk/PerformanceTests/Animometer/tests/master/focus.html (197498 => 197499)


--- trunk/PerformanceTests/Animometer/tests/master/focus.html	2016-03-03 08:15:35 UTC (rev 197498)
+++ trunk/PerformanceTests/Animometer/tests/master/focus.html	2016-03-03 08:22:32 UTC (rev 197499)
@@ -10,8 +10,12 @@
         z-index: -10000;
     }
 
-    #stage div {
+    #stage > div {
         position: absolute;
+        overflow: hidden;
+    }
+    #stage div div {
+        position: absolute;
         background-color: #DEDADD;
         border-radius: 50%;
     }
@@ -23,14 +27,14 @@
         position: absolute;
         top: 50%;
         left: 50%;
-        transform: translateX(-50%) translateY(-50%);
+        transform: translate3d(-50%, -50%, 0);
     }
 
     </style>
 </head>
 <body>
     <div id="stage">
-        <div id="center-text"><span>focus</span></div>
+        <div id="center-text"><div><span>focus</span></div></div>
     </div>
     <script src=""
     <script src=""

Modified: trunk/PerformanceTests/Animometer/tests/master/resources/focus.js (197498 => 197499)


--- trunk/PerformanceTests/Animometer/tests/master/resources/focus.js	2016-03-03 08:15:35 UTC (rev 197498)
+++ trunk/PerformanceTests/Animometer/tests/master/resources/focus.js	2016-03-03 08:22:32 UTC (rev 197499)
@@ -1,14 +1,15 @@
 (function() {
 
 var maxVerticalOffset = 50;
-var radius = 20;
+var radius = 10;
+var centerDiameter = 100;
 var sizeVariance = 80;
 var travelDistance = 70;
 
 var minObjectDepth = 0.2;
 var maxObjectDepth = 1.0;
 
-var opacityMultiplier = 40;
+var opacityMultiplier = 30;
 
 var FocusElement = Utilities.createClass(
     function(stage)
@@ -22,27 +23,41 @@
         var distance = Utilities.lerp(this._depth, 1, sizeVariance);
         var size = 2 * radius + sizeVariance - distance;
 
-        this.element = document.createElement('div');
-        this.element.style.width = size + "px";
-        this.element.style.height = size + "px";
-        this.element.style.top = top + "px";
-        this.element.style.left = left + "px";
-        this.element.style.zIndex = Math.round((1 - this._depth) * 10);
+        this.container = document.createElement('div');
+        this.container.style.width = (size + stage.maxBlurValue * 2) + "px";
+        this.container.style.height = (size + stage.maxBlurValue * 2) + "px";
+        this.container.style.top = top + "px";
+        this.container.style.left = left + "px";
+        this.container.style.zIndex = Math.round((1 - this._depth) * 10);
 
-        Utilities.setElementPrefixedProperty(this.element, "filter", "blur(" + stage.getBlurValue(this._depth) + "px) opacity(" + stage.getOpacityValue(this._depth) + "%)");
+        var particle = Utilities.createElement("div", {}, this.container);
+        particle.style.width = size + "px";
+        particle.style.height = size + "px";
+        particle.style.top = stage.maxBlurValue + "px";
+        particle.style.left = stage.maxBlurValue + "px";
 
         var depthMultiplier = Utilities.lerp(1 - this._depth, 0.8, 1);
         this._sinMultiplier = Pseudo.random() * Stage.randomSign() * depthMultiplier;
         this._cosMultiplier = Pseudo.random() * Stage.randomSign() * depthMultiplier;
     }, {
 
-    animate: function(stage, sinTime, cosTime)
+    hide: function()
     {
-        var top = sinTime * this._sinMultiplier * travelDistance;
-        var left = cosTime * this._cosMultiplier * travelDistance;
+        this.container.style.display = "none";
+    },
 
-        Utilities.setElementPrefixedProperty(this.element, "filter", "blur(" + stage.getBlurValue(this._depth) + "px) opacity(" + stage.getOpacityValue(this._depth) + "%)");
-        this.element.style.transform = "translateX(" + left + "%) translateY(" + top + "%)";
+    show: function()
+    {
+        this.container.style.display = "block";
+    },
+
+    animate: function(stage, sinFactor, cosFactor)
+    {
+        var top = sinFactor * this._sinMultiplier;
+        var left = cosFactor * this._cosMultiplier;
+
+        Utilities.setElementPrefixedProperty(this.container, "filter", "blur(" + stage.getBlurValue(this._depth) + "px) opacity(" + stage.getOpacityValue(this._depth) + "%)");
+        this.container.style.transform = "translate3d(" + left + "%, " + top + "%, 0)";
     }
 });
 
@@ -67,19 +82,26 @@
 
         this._testElements = [];
         this._focalPoint = 0.5;
+        this._offsetIndex = 0;
 
         this._centerElement = document.getElementById("center-text");
-        this._centerElement.style.width = (radius * 5) + 'px';
-        this._centerElement.style.height = (radius * 5) + 'px';
+        this._centerElement.style.width = (centerDiameter + this.maxCenterObjectBlurValue * 2) + "px";
+        this._centerElement.style.height = (centerDiameter + this.maxCenterObjectBlurValue * 2) + "px";
         this._centerElement.style.zIndex = Math.round(10 * this.centerObjectDepth);
 
-        var blur = this.getBlurValue(this.centerObjectDepth);
+        var particle = document.querySelector("#center-text div");
+        particle.style.width = centerDiameter + "px";
+        particle.style.height = centerDiameter + "px";
+        particle.style.top = this.maxCenterObjectBlurValue + "px";
+        particle.style.left = this.maxCenterObjectBlurValue + "px";
+
+        var blur = this.getBlurValue(this.centerObjectDepth, true);
         Utilities.setElementPrefixedProperty(this._centerElement, "filter", "blur(" + blur + "px)");
     },
 
     complexity: function()
     {
-        return 1 + this._testElements.length;
+        return 1 + this._offsetIndex;
     },
 
     tune: function(count)
@@ -87,55 +109,51 @@
         if (count == 0)
             return;
 
-        if (count > 0) {
-            for (var i = 0; i < count; ++i) {
-                var obj = new FocusElement(this);
-                this._testElements.push(obj);
-                this.element.appendChild(obj.element);
-            }
+        if (count < 0) {
+            this._offsetIndex = Math.max(0, this._offsetIndex + count);
+            for (var i = this._offsetIndex; i < this._testElements.length; ++i)
+                this._testElements[i].hide();
             return;
         }
 
-        while (count < 0) {
-            var obj = this._testElements.shift();
-            if (!obj)
-                return;
-
-            this.element.removeChild(obj.element);
-            count++;
+        var newIndex = this._offsetIndex + count;
+        for (var i = this._testElements.length; i < newIndex; ++i) {
+            var obj = new FocusElement(this);
+            this._testElements.push(obj);
+            this.element.appendChild(obj.container);
         }
+        for (var i = this._offsetIndex; i < newIndex; ++i)
+            this._testElements[i].show();
+        this._offsetIndex = newIndex;
     },
 
     animate: function()
     {
         var time = this._benchmark.timestamp;
-        var sinTime = Math.sin(time / this.movementDuration);
-        var cosTime = Math.cos(time / this.movementDuration);
+        var sinFactor = Math.sin(time / this.movementDuration) * travelDistance;
+        var cosFactor = Math.cos(time / this.movementDuration) * travelDistance;
 
-        var focusProgress = Utilities.progressValue(Math.sin(time / this.focusDuration), -1, 1);
+        var focusProgress = 0.5 + 0.5 * Math.sin(time / this.focusDuration);
         this._focalPoint = focusProgress;
 
         // update center element before loop
         Utilities.setElementPrefixedProperty(this._centerElement, "filter", "blur(" + this.getBlurValue(this.centerObjectDepth, true) + "px)");
 
-        this._testElements.forEach(function(element) {
-            element.animate(this, sinTime, cosTime);
-        }, this);
+        for (var i = 0; i < this._offsetIndex; ++i)
+            this._testElements[i].animate(this, sinFactor, cosFactor);
     },
 
     getBlurValue: function(depth, isCenter)
     {
-        var value = Math.abs(depth - this._focalPoint);
-
         if (isCenter)
-            return this.maxCenterObjectBlurValue * value;
+            return 1 + Math.abs(depth - this._focalPoint) * (this.maxCenterObjectBlurValue - 1);
 
-        return Utilities.lerp(value, this.minBlurValue, this.maxBlurValue);
+        return Utilities.lerp(Math.abs(depth - this._focalPoint), this.minBlurValue, this.maxBlurValue);
     },
 
     getOpacityValue: function(depth)
     {
-        return opacityMultiplier * (1 - Math.abs(depth - this._focalPoint));
+        return Math.max(1, opacityMultiplier * (1 - Math.abs(depth - this._focalPoint)));
     },
 });
 

Modified: trunk/PerformanceTests/Animometer/tests/master/resources/multiply.js (197498 => 197499)


--- trunk/PerformanceTests/Animometer/tests/master/resources/multiply.js	2016-03-03 08:15:35 UTC (rev 197498)
+++ trunk/PerformanceTests/Animometer/tests/master/resources/multiply.js	2016-03-03 08:22:32 UTC (rev 197499)
@@ -21,8 +21,8 @@
         var spiralCounter = 2;
         var nextIndex = 1;
         var maxSide = Math.floor(y / tileStride) * 2 + 1;
-        var centerSpiralCount = maxSide * maxSide;
-        for (var i = 0; i < centerSpiralCount; ++i) {
+        this._centerSpiralCount = maxSide * maxSide;
+        for (var i = 0; i < this._centerSpiralCount; ++i) {
             this._addTile(x, y, tileSize, i % 360);
 
             if (i == nextIndex) {
@@ -40,8 +40,8 @@
                 y += tileStride;
         }
 
-        centerSpiralCount = maxSide * Math.floor((this.size.width - x) / tileStride) * 2;
-        for (var i = 0; i < centerSpiralCount; ++i) {
+        this._sidePanelCount = maxSide * Math.floor((this.size.width - x) / tileStride) * 2;
+        for (var i = 0; i < this._sidePanelCount; ++i) {
             var sideX = x + Math.floor(Math.floor(i / maxSide) / 2) * tileStride;
             var sideY = y - tileStride * (i % maxSide);
 
@@ -61,7 +61,7 @@
         tile.style.height = tileSize + 'px';
         tile.style.visibility = "hidden";
 
-        var distance = 1.3 / tileSize * this.size.multiply(0.5).subtract(new Point(x + halfTileSize, y + halfTileSize)).length();
+        var distance = 1 / tileSize * this.size.multiply(0.5).subtract(new Point(x + halfTileSize, y + halfTileSize)).length();
 
         this.tiles.push({
             element: tile,
@@ -80,12 +80,11 @@
     tune: function(count)
     {
         this._offsetIndex = Math.max(0, Math.min(this._offsetIndex + count, this.tiles.length));
+        this._distanceFactor = 1.5 * (1 - 0.5 * Math.max(this._offsetIndex - this._centerSpiralCount, 0) / this._sidePanelCount) / Math.sqrt(this._offsetIndex);
     },
 
     animate: function()
     {
-        var distanceFactor = 1 / Math.sqrt(this._offsetIndex);
-
         var progress = this._benchmark.timestamp % 10000 / 10000;
         var bounceProgress = Math.sin(2 * Math.abs( 0.5 - progress));
         var l = Utilities.lerp(bounceProgress, 20, 50);
@@ -98,7 +97,7 @@
             tile.rotate += tile.step;
             tile.element.style.transform = "rotate(" + tile.rotate + "deg)";
 
-            var influence = 1 - (tile.distance * distanceFactor);
+            var influence = 1 - (tile.distance * this._distanceFactor);
             tile.element.style.backgroundColor = hslPrefix + l * Math.tan(influence / 1.25) + "%," + influence + ")";
         }
 

Modified: trunk/PerformanceTests/ChangeLog (197498 => 197499)


--- trunk/PerformanceTests/ChangeLog	2016-03-03 08:15:35 UTC (rev 197498)
+++ trunk/PerformanceTests/ChangeLog	2016-03-03 08:22:32 UTC (rev 197499)
@@ -5,6 +5,35 @@
 
         Reviewed by Simon Fraser.
 
+        Improve tests.
+
+        * Animometer/tests/master/focus.html: Move each particle into a layer. Put the particle
+        in a container element. Expand the container element by the max blur radius, and clip
+        overflow. This way, when the blur is applied, it avoids causing layer resizes.
+        * Animometer/tests/master/resources/focus.js:
+        (FocusElement.Utilities.createClass): Create a container element, and put the particle
+        inside.
+        (hide): Set display:none.
+        (show): Set display:block.
+        (animate): Apply filters to the container element.
+        (FocusStage.call.initialize): Instead of inserting and removing elements from the DOM,
+        keep them in the stage, but set the display style instead. Use this._offsetIndex to
+        keep track of which elements are displayed.
+        (FocusStage.call.animate): Move some calculations around to avoid doing unneeded math.
+        (FocusStage.call.getBlurValue): Make sure elements are always blurred.
+        (FocusStage.call.getOpacityValue): Make sure elements have some opacity.
+        * Animometer/tests/master/resources/multiply.js: Have the particles on the edge of the
+        stage appear less black when the complexity gets large enough.
+        (tune): Have this._distanceFactor calculate the factor. Avoid calculating square root each
+        frame.
+
+2016-03-02  Jon Lee  <[email protected]>
+
+        Add some new controllers, and refine tests
+        https://bugs.webkit.org/show_bug.cgi?id=154914
+
+        Reviewed by Simon Fraser.
+
         Add a controller that centers around 30 fps instead of 60 fps.
 
         * Animometer/developer.html: Add a new option.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to