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