2 function SimpleCanvasStage(element, options, canvasObject)
4 Stage.call(this, element, options);
5 this.context = this.element.getContext("2d");
6 this.canvasObject = canvasObject;
9 SimpleCanvasStage.prototype = Object.create(Stage.prototype);
10 SimpleCanvasStage.prototype.constructor = SimpleCanvasStage;
11 SimpleCanvasStage.prototype.tune = function(count)
14 return this._objects.length;
17 // For path-based tests, use the object length as a maximum coordinate value
18 // to make it easier to see what the test is doing
19 var coordinateMaximum = Math.max(this._objects.length, 200);
20 for (var i = 0; i < count; ++i) {
21 this._objects.push(new this.canvasObject(this, coordinateMaximum));
23 return this._objects.length;
26 count = Math.min(-count, this._objects.length);
27 this._objects.splice(-count, count);
29 return this._objects.length;
31 SimpleCanvasStage.prototype.animate = function()
33 var context = this.context;
34 this._objects.forEach(function(object) {
39 function SimpleCanvasAnimator(benchmark)
41 StageAnimator.call(this, benchmark);
42 this._context = benchmark._stage.context;
45 SimpleCanvasAnimator.prototype = Object.create(StageAnimator.prototype);
46 SimpleCanvasAnimator.prototype.constructor = SimpleCanvasAnimator;
47 SimpleCanvasAnimator.prototype.animate = function()
49 this._context.clearRect(0, 0, this._benchmark._stage.size.x, this._benchmark._stage.size.y);
50 return StageAnimator.prototype.animate.call(this);
54 function SimpleCanvasBenchmark(suite, test, options, recordTable, progressBar) {
56 options["addLimit"] = 100;
57 options["removeLimit"] = 1000;
58 StageBenchmark.call(this, suite, test, options, recordTable, progressBar);
60 SimpleCanvasBenchmark.prototype = Object.create(StageBenchmark.prototype);
61 SimpleCanvasBenchmark.prototype.constructor = SimpleCanvasBenchmark;
62 SimpleCanvasBenchmark.prototype.createAnimator = function() {
63 return new SimpleCanvasAnimator(this);