summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-images.js
blob: 5fba5ad7610875c8a21ea3933cf6fa5345ee563b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(function() {

BouncingCanvasImage = Utilities.createSubclass(BouncingCanvasParticle,
    function(stage)
    {
        BouncingCanvasParticle.call(this, stage, "image");
        this._imageElement = stage.imageElement;
    }, {

    _draw: function()
    {
        this.context.save();
            this.applyRotation();
            this.context.drawImage(this._imageElement, 0, 0, this.size.x, this.size.y);
        this.context.restore();
    }
});

BouncingCanvasImagesStage = Utilities.createSubclass(BouncingCanvasParticlesStage,
    function()
    {
        BouncingCanvasParticlesStage.call(this);
    }, {

    initialize: function(benchmark, options)
    {
        BouncingCanvasParticlesStage.prototype.initialize.call(this, benchmark, options);
        var imageSrc = options["imageSrc"] || "resources/yin-yang.svg";
        this.imageElement = document.querySelector(".hidden[src=\"" + imageSrc + "\"]");
    },

    createParticle: function()
    {
        return new BouncingCanvasImage(this);
    }
});

BouncingCanvasImagesBenchmark = Utilities.createSubclass(Benchmark,
    function(options)
    {
        Benchmark.call(this, new BouncingCanvasImagesStage(), options);
    }
);

window.benchmarkClass = BouncingCanvasImagesBenchmark;

})();