28a78115497b12e94f198ccc87a3c9e7258c33af
[WebKit-https.git] / PerformanceTests / Animometer / tests / bouncing-particles / resources / bouncing-canvas-images.js
1 function BouncingCanvasImage(stage)
2 {
3     BouncingCanvasParticle.call(this, stage);
4     this._imageElement = stage.imageElement;
5     this._shape = "image";
6 }
7
8 BouncingCanvasImage.prototype = Object.create(BouncingCanvasParticle.prototype);
9 BouncingCanvasImage.prototype.constructor = BouncingCanvasImage;
10
11 BouncingCanvasImage.prototype._draw = function()
12 {
13     this._context.save();
14         this._applyRotation();
15         this._context.drawImage(this._imageElement, 0, 0, this._size.x, this._size.y);
16     this._context.restore();
17 }
18
19 function BouncingCanvasImagesStage(element, options)
20 {
21     BouncingCanvasParticlesStage.call(this, element, options);
22
23     var imageSrc = options["imageSrc"] || "resources/yin-yang.svg";
24     this.imageElement = document.querySelector(".hidden[src=\"" + imageSrc + "\"]");
25 }
26
27 BouncingCanvasImagesStage.prototype = Object.create(BouncingCanvasParticlesStage.prototype);
28 BouncingCanvasImagesStage.prototype.constructor = BouncingCanvasImagesStage;
29
30 BouncingCanvasImagesStage.prototype.createParticle = function()
31 {
32     return new BouncingCanvasImage(this);
33 }
34
35 function BouncingCanvasImagesBenchmark(suite, test, options, progressBar)
36 {
37     BouncingCanvasParticlesBenchmark.call(this, suite, test, options, progressBar);
38 }
39
40 BouncingCanvasImagesBenchmark.prototype = Object.create(BouncingCanvasParticlesBenchmark.prototype);
41 BouncingCanvasImagesBenchmark.prototype.constructor = BouncingCanvasImagesBenchmark;
42
43 BouncingCanvasImagesBenchmark.prototype.createStage = function(element)
44 {
45     return new BouncingCanvasImagesStage(element, this._options);
46 }
47
48 window.benchmarkClient.create = function(suite, test, options, progressBar)
49 {
50     return new BouncingCanvasImagesBenchmark(suite, test, options, progressBar);
51 }