summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/MotionMark/tests/simple/resources/simple-canvas.js
blob: 483d535d755e72689b301d32251b85fc4ca9c992 (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
Utilities.extendObject(SimpleCanvasStage.prototype, {
    tune: function(count)
    {
        if (count == 0)
            return;

        if (count < 0) {
            this.offsetIndex = Math.max(this.offsetIndex + count, 0);
            return;
        }

        this.offsetIndex = this.offsetIndex + count;
        if (this.offsetIndex > this.objects.length) {
            // For some tests, it may be easier to see how well the test is going
            // by limiting the range of coordinates in which new objects can reside
            var coordinateMaximumFactor = Math.min(this.objects.length, Math.min(this.size.x, this.size.y)) / Math.min(this.size.x, this.size.y);
            var newIndex = this.offsetIndex - this.objects.length;
            for (var i = 0; i < newIndex; ++i)
                this.objects.push(new this._canvasObject(this, coordinateMaximumFactor));
        }
    },

    animate: function()
    {
        var context = this.context;
        context.clearRect(0, 0, this.size.x, this.size.y);
        for (var i = 0, length = this.offsetIndex; i < length; ++i)
            this.objects[i].draw(context);
    },

    complexity: function()
    {
        return this.offsetIndex;
    }
});