Add a basic compositing Animometer test
[WebKit-https.git] / PerformanceTests / Animometer / tests / misc / resources / compositing-transforms.js
1 function BouncingCompositedImage(stage)
2 {
3     BouncingParticle.call(this, stage);
4
5     this.element = document.createElement("img");
6     this.element.style.width = this._size.x + "px";
7     this.element.style.height = this._size.y + "px";
8     this.element.setAttribute("src", stage.imageSrc);
9     
10     if (stage.useFilters)
11         this.element.style.filter = "hue-rotate(" + stage.randomAngle() + "rad)";
12     
13     stage.element.appendChild(this.element);
14     this._move();
15 }
16
17 BouncingCompositedImage.prototype = Object.create(BouncingParticle.prototype);
18 BouncingCompositedImage.prototype.constructor = BouncingCompositedImage;
19
20 BouncingCompositedImage.prototype._move = function()
21 {
22     this.element.style.transform = "translate3d(" + this._position.x + "px," + this._position.y + "px, 0) " + this._rotater.rotateZ();
23 }
24     
25 BouncingCompositedImage.prototype.animate = function(timeDelta)
26 {
27     BouncingParticle.prototype.animate.call(this, timeDelta);
28     this._move();
29 }
30
31 function CompositingTransformsStage(element, options)
32 {
33     BouncingParticlesStage.call(this, element, options);
34     this.imageSrc = options["imageSrc"] || "../resources/yin-yang.svg";
35     this.useFilters = options["filters"] == "yes";
36 }
37
38 CompositingTransformsStage.prototype = Object.create(BouncingParticlesStage.prototype);
39 CompositingTransformsStage.prototype.constructor = CompositingTransformsStage;
40
41 CompositingTransformsStage.prototype.createParticle = function()
42 {
43     return new BouncingCompositedImage(this);
44 }
45
46 CompositingTransformsStage.prototype.particleWillBeRemoved = function(particle)
47 {
48     particle.element.remove();
49 }
50
51 function CompositedTransformsBenchmark(suite, test, options, recordTable, progressBar)
52 {
53     BouncingParticlesBenchmark.call(this, suite, test, options, recordTable, progressBar);
54 }
55
56 CompositedTransformsBenchmark.prototype = Object.create(BouncingParticlesBenchmark.prototype);
57 CompositedTransformsBenchmark.prototype.constructor = CompositedTransformsBenchmark;
58
59 CompositedTransformsBenchmark.prototype.createStage = function(element)
60 {
61     return new CompositingTransformsStage(element, this._options);
62 }
63
64 window.benchmarkClient.create = function(suite, test, options, recordTable, progressBar)
65 {
66     return new CompositedTransformsBenchmark(suite, test, options, recordTable, progressBar);
67 }