Add developer Animometer test that bounces P3-tagged images
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Mar 2016 22:46:58 +0000 (22:46 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Mar 2016 22:46:58 +0000 (22:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155511

Reviewed by Tim Horton.

Add a test for rendering performance of tagged images. The 5 images are tagged
with the Display P3 colorspace.

* Animometer/resources/debug-runner/tests.js:
* Animometer/tests/bouncing-particles/bouncing-tagged-images.html: Added.
* Animometer/tests/bouncing-particles/resources/bouncing-tagged-images.js: Added.
* Animometer/tests/bouncing-particles/resources/image1.jpg: Added.
* Animometer/tests/bouncing-particles/resources/image2.jpg: Added.
* Animometer/tests/bouncing-particles/resources/image3.jpg: Added.
* Animometer/tests/bouncing-particles/resources/image4.jpg: Added.
* Animometer/tests/bouncing-particles/resources/image5.jpg: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198236 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/Animometer/resources/debug-runner/tests.js
PerformanceTests/Animometer/tests/bouncing-particles/bouncing-tagged-images.html [new file with mode: 0644]
PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-tagged-images.js [new file with mode: 0644]
PerformanceTests/Animometer/tests/bouncing-particles/resources/image1.jpg [new file with mode: 0644]
PerformanceTests/Animometer/tests/bouncing-particles/resources/image2.jpg [new file with mode: 0644]
PerformanceTests/Animometer/tests/bouncing-particles/resources/image3.jpg [new file with mode: 0644]
PerformanceTests/Animometer/tests/bouncing-particles/resources/image4.jpg [new file with mode: 0644]
PerformanceTests/Animometer/tests/bouncing-particles/resources/image5.jpg [new file with mode: 0644]
PerformanceTests/ChangeLog

index 2ef5bb4..859c32d 100644 (file)
@@ -160,6 +160,10 @@ Suites.push(new Suite("HTML suite",
         {
             url: "bouncing-particles/bouncing-css-images.html?particleWidth=80&particleHeight=80&imageSrc=../resources/yin-yang.svg",
             name: "CSS bouncing SVG images"
+        },
+        {
+            url: "bouncing-particles/bouncing-tagged-images.html?particleWidth=100&particleHeight=100",
+            name: "CSS bouncing tagged images"
         }
     ]
 ));
diff --git a/PerformanceTests/Animometer/tests/bouncing-particles/bouncing-tagged-images.html b/PerformanceTests/Animometer/tests/bouncing-particles/bouncing-tagged-images.html
new file mode 100644 (file)
index 0000000..f67f14a
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        img {
+            position: absolute;
+        }
+    </style>
+    <link rel="stylesheet" type="text/css" href="../resources/stage.css">
+
+    <script src="../../resources/strings.js"></script>
+    <script src="../../resources/extensions.js"></script>
+    <script src="../../resources/statistics.js"></script>
+    <script src="../resources/math.js"></script>
+    <script src="../resources/main.js"></script>
+    <script src="resources/bouncing-particles.js"></script>
+    <script src="resources/bouncing-tagged-images.js"></script>
+</head>
+<body>
+    <div id="stage"></div>
+</body>
+</html>
diff --git a/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-tagged-images.js b/PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-tagged-images.js
new file mode 100644 (file)
index 0000000..ad33e2d
--- /dev/null
@@ -0,0 +1,106 @@
+(function() {
+
+BouncingTaggedImage = Utilities.createSubclass(BouncingParticle,
+    function(stage)
+    {
+        BouncingParticle.call(this, stage);
+
+        this.element = document.createElement("img");
+        this.element.style.width = this.size.x + "px";
+        this.element.style.height = this.size.y + "px";
+        this.element.setAttribute("src", stage.images[Stage.randomInt(0, stage.images.length - 1)].src);
+
+        stage.element.appendChild(this.element);
+        this._move();
+    }, {
+
+    _move: function()
+    {
+        this.element.style.transform = "translate(" + this.position.x + "px," + this.position.y + "px) " + this.rotater.rotateZ();
+    },
+
+    animate: function(timeDelta)
+    {
+        BouncingParticle.prototype.animate.call(this, timeDelta);
+        this._move();
+    }
+});
+
+BouncingTaggedImagesStage = Utilities.createSubclass(BouncingParticlesStage,
+
+    function()
+    {
+        BouncingParticlesStage.call(this);
+    }, {
+
+    imageSrcs: [
+        "image1",
+        "image2",
+        "image3",
+        "image4",
+        "image5",
+    ],
+    images: [],
+
+    initialize: function(benchmark, options)
+    {
+        BouncingParticlesStage.prototype.initialize.call(this, benchmark, options);
+
+        var lastPromise;
+        var images = this.images;
+        this.imageSrcs.forEach(function(imageSrc) {
+            var promise = this._loadImage("resources/" + imageSrc + ".jpg");
+            if (!lastPromise)
+                lastPromise = promise;
+            else {
+                lastPromise = lastPromise.then(function(img) {
+                    images.push(img);
+                    return promise;
+                });
+            }
+        }, this);
+
+        lastPromise.then(function(img) {
+            images.push(img);
+            benchmark.readyPromise.resolve();
+        });
+    },
+
+    _loadImage: function(src) {
+        var img = new Image;
+        var promise = new SimplePromise;
+
+        img.onload = function(e) {
+            promise.resolve(e.target);
+        };
+
+        img.src = src;
+        return promise;
+    },
+
+    createParticle: function()
+    {
+        return new BouncingTaggedImage(this);
+    },
+
+    particleWillBeRemoved: function(particle)
+    {
+        particle.element.remove();
+    }
+});
+
+BouncingTaggedImagesBenchmark = Utilities.createSubclass(Benchmark,
+    function(options)
+    {
+        Benchmark.call(this, new BouncingTaggedImagesStage(), options);
+    }, {
+
+    waitUntilReady: function() {
+        this.readyPromise = new SimplePromise;
+        return this.readyPromise;
+    }
+});
+
+window.benchmarkClass = BouncingTaggedImagesBenchmark;
+
+})();
diff --git a/PerformanceTests/Animometer/tests/bouncing-particles/resources/image1.jpg b/PerformanceTests/Animometer/tests/bouncing-particles/resources/image1.jpg
new file mode 100644 (file)
index 0000000..ea7a4c1
Binary files /dev/null and b/PerformanceTests/Animometer/tests/bouncing-particles/resources/image1.jpg differ
diff --git a/PerformanceTests/Animometer/tests/bouncing-particles/resources/image2.jpg b/PerformanceTests/Animometer/tests/bouncing-particles/resources/image2.jpg
new file mode 100644 (file)
index 0000000..697272d
Binary files /dev/null and b/PerformanceTests/Animometer/tests/bouncing-particles/resources/image2.jpg differ
diff --git a/PerformanceTests/Animometer/tests/bouncing-particles/resources/image3.jpg b/PerformanceTests/Animometer/tests/bouncing-particles/resources/image3.jpg
new file mode 100644 (file)
index 0000000..6e5964e
Binary files /dev/null and b/PerformanceTests/Animometer/tests/bouncing-particles/resources/image3.jpg differ
diff --git a/PerformanceTests/Animometer/tests/bouncing-particles/resources/image4.jpg b/PerformanceTests/Animometer/tests/bouncing-particles/resources/image4.jpg
new file mode 100644 (file)
index 0000000..806f548
Binary files /dev/null and b/PerformanceTests/Animometer/tests/bouncing-particles/resources/image4.jpg differ
diff --git a/PerformanceTests/Animometer/tests/bouncing-particles/resources/image5.jpg b/PerformanceTests/Animometer/tests/bouncing-particles/resources/image5.jpg
new file mode 100644 (file)
index 0000000..d7971f6
Binary files /dev/null and b/PerformanceTests/Animometer/tests/bouncing-particles/resources/image5.jpg differ
index aa54e46..eee4f44 100644 (file)
@@ -1,3 +1,22 @@
+2016-03-15  Simon Fraser  <simon.fraser@apple.com>
+
+        Add developer Animometer test that bounces P3-tagged images
+        https://bugs.webkit.org/show_bug.cgi?id=155511
+
+        Reviewed by Tim Horton.
+        
+        Add a test for rendering performance of tagged images. The 5 images are tagged
+        with the Display P3 colorspace.
+
+        * Animometer/resources/debug-runner/tests.js:
+        * Animometer/tests/bouncing-particles/bouncing-tagged-images.html: Added.
+        * Animometer/tests/bouncing-particles/resources/bouncing-tagged-images.js: Added.
+        * Animometer/tests/bouncing-particles/resources/image1.jpg: Added.
+        * Animometer/tests/bouncing-particles/resources/image2.jpg: Added.
+        * Animometer/tests/bouncing-particles/resources/image3.jpg: Added.
+        * Animometer/tests/bouncing-particles/resources/image4.jpg: Added.
+        * Animometer/tests/bouncing-particles/resources/image5.jpg: Added.
+
 2016-03-09  Jon Lee  <jonlee@apple.com>
 
         Enhance existing Animometer tests